| 1 |
/** |
/** |
| 2 |
* Header Scan |
* Header_Scan |
| 3 |
* Author Nagni |
* Author Nagni |
| 4 |
* version 1.0 |
* version 1.0 |
| 5 |
* |
* |
| 43 |
* There is no default value, without this input the program will not run |
* There is no default value, without this input the program will not run |
| 44 |
* TString outDir - the path where to save the output image (Default = ./) |
* TString outDir - the path where to save the output image (Default = ./) |
| 45 |
* TString format - the format which will be used fo rsave the produced images (Default = "jpg") |
* TString format - the format which will be used fo rsave the produced images (Default = "jpg") |
| 46 |
|
* |
| 47 |
|
* |
| 48 |
|
* Version 1.7 |
| 49 |
|
* Date 16 June 2006 - Malvezzi |
| 50 |
|
* |
| 51 |
|
* Description of changes: |
| 52 |
|
* Implementation of the case: numebr of events <= 0. |
| 53 |
|
* Remove graph "grPcktId1"; see PacketScan for the same information. |
| 54 |
|
* Fixed bugs: for a large namber of events is not possible to have vectors, so I have subsituted graphs with histograms |
| 55 |
|
* or divided the graphs in more than one canvas. |
| 56 |
|
* |
| 57 |
|
* Version 1.8 |
| 58 |
|
* Date 8 August 2006 - Malvezzi |
| 59 |
|
* |
| 60 |
|
* Description: changed the scale in the second and third graph of the first canvas; added a pad of text in the second canvas |
| 61 |
|
* |
| 62 |
*/ |
*/ |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
#include <fstream> |
| 66 |
|
#include <math.h> |
| 67 |
|
#include "TLatex.h" |
| 68 |
|
#include "TF1.h" |
| 69 |
|
#include "TPaveText.h" |
| 70 |
|
#include "TMultiGraph.h" |
| 71 |
#include <sstream> |
#include <sstream> |
| 72 |
#include <iostream> |
#include <iostream> |
| 73 |
#include "TString.h" |
#include "TString.h" |
| 82 |
#include "TGaxis.h" |
#include "TGaxis.h" |
| 83 |
#include "EventHeader.h" |
#include "EventHeader.h" |
| 84 |
#include "PscuHeader.h" |
#include "PscuHeader.h" |
| 85 |
|
#include "RunHeaderEvent.h" |
| 86 |
|
#include "TPaveText.h" |
| 87 |
|
|
| 88 |
using namespace std; |
using namespace std; |
| 89 |
|
|
| 90 |
void HeaderScan(TString base, TString outDir, TString format) |
void HeaderScan(TString base, TString outDir, TString format) |
| 91 |
{ |
{ |
| 92 |
|
|
| 93 |
TList *list = new TList; |
|
| 94 |
Int_t numkey; |
//------------------- Variables initilization -------------------------// |
| 95 |
TObject *key = new TObject; |
Long64_t nevents=0, runnevents; |
| 96 |
const char *name; |
ULong_t lastime, firstime, primotempo, ultimotempo, primoffset=500000000, ultimoffset; |
| 97 |
TTree* tr = new TTree; |
double obmin=0., time=0.; |
| 98 |
Long64_t totevents=0, totphysevents=0; |
double obmax=0.; |
| 99 |
Float_t id; |
stringstream oss, oss1, oss2, oss3, noentries, stringa; |
|
Long64_t nevents=0; |
|
|
|
|
| 100 |
//------- load root file -------------- |
//------- load root file -------------- |
|
|
|
| 101 |
TFile *file = new TFile(base.Data()); |
TFile *file = new TFile(base.Data()); |
|
|
|
| 102 |
if (!file){ |
if (!file){ |
| 103 |
printf("No such file in the directory has been found"); |
printf("No such file in the directory has been found"); |
| 104 |
return; |
return; |
| 105 |
} |
} |
|
if (outDir == "" ) outDir = "."; |
|
|
|
|
|
list = file->GetListOfKeys(); |
|
|
|
|
|
numkey = file->GetNkeys(); |
|
|
|
|
|
pamela::EventHeader *eh=0; |
|
|
pamela::PscuHeader *ph=0; |
|
|
|
|
|
///-----to know the total number f events end of physics events----////// |
|
| 106 |
|
|
| 107 |
for (Int_t i=0; i<numkey; i++){ |
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
| 108 |
key = list->At(i); |
TBranch *headBr = PhysicsTr->GetBranch("Header"); |
|
name=(key->GetName()); |
|
|
//cout<<name<<"\n"; |
|
|
tr = (TTree*)file->Get(name); |
|
|
if (tr->IsZombie()) continue; |
|
|
nevents = tr->GetEntries(); |
|
|
totevents+=nevents; |
|
|
tr->SetBranchAddress("Header", &eh); |
|
|
for (Int_t j = 0; j < nevents; j++){ |
|
|
tr->GetEntry(j); |
|
|
ph = eh->GetPscuHeader(); |
|
|
if(ph->GetPacketId1() == 0x10) ++totphysevents; |
|
|
} |
|
|
|
|
|
} |
|
| 109 |
|
|
| 110 |
const Long64_t totalevents=totevents; |
pamela::EventHeader *eh = 0; |
| 111 |
const Long64_t totalphysevents=totphysevents; |
pamela::PscuHeader *ph = 0; |
| 112 |
|
|
| 113 |
///////////////////////////////////////////////// |
PhysicsTr->SetBranchAddress("Header", &eh); |
| 114 |
|
nevents = headBr->GetEntries(); |
| 115 |
|
|
| 116 |
|
TTree *RunHeadTr = (TTree*)file->Get("RunHeader"); ///run header tree |
| 117 |
|
pamela::EventHeader *eH=0; |
| 118 |
|
pamela::RunHeaderEvent *reh=0; |
| 119 |
|
|
| 120 |
|
RunHeadTr->SetBranchAddress("Header",&eH); |
| 121 |
|
RunHeadTr->SetBranchAddress("RunHeader",&reh); |
| 122 |
|
runnevents = RunHeadTr->GetEntries(); |
| 123 |
|
|
| 124 |
|
|
| 125 |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
| 126 |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
filename = ((TObjString*)filename.Tokenize('.')->First())->GetString(); |
|
stringstream oss; |
|
|
oss.str(""); |
|
|
oss << filename.Data(); |
|
|
|
|
|
Float_t obt[totalevents], pcktId[totalevents], pcktLenght[totalphysevents], pcktCounter[totalphysevents], offset[totalevents], allCounter[totalevents]; |
|
|
Float_t obtphysevents=0; |
|
|
|
|
| 127 |
|
|
| 128 |
totphysevents=0; |
//----------- If nevents < = 0 ---------------------------------/ |
| 129 |
totevents=0; |
if (nevents<=0) { |
| 130 |
for (Int_t i=0; i<numkey; i++){ |
printf("nevents = %i \n", nevents); |
| 131 |
key = list->At(i); |
printf(" \n"); |
| 132 |
name=(char *)(key->GetName()); |
|
| 133 |
tr = (TTree*)file->Get(name); |
TCanvas *canv = new TCanvas("No entries", "No entries ", 400, 200); |
| 134 |
if (tr->IsZombie()) continue; |
canv->SetFillColor(10); |
| 135 |
tr->SetBranchAddress("Header", &eh); |
canv->cd(); |
| 136 |
nevents = tr->GetEntries(); |
|
| 137 |
for (Int_t j = 0; j < nevents; j++){ |
TLatex *l = new TLatex(); |
| 138 |
tr->GetEntry(j); |
l->SetTextAlign(12); |
| 139 |
ph = eh->GetPscuHeader(); |
l->SetTextSize(0.15); |
| 140 |
obt[j+totevents]=ph->GetOrbitalTime() ; |
l->SetTextColor(2); |
| 141 |
pcktId[j+totevents]=ph->GetPacketId1(); |
noentries.str(""); |
| 142 |
offset[j+totevents]=ph->GetFileOffset(); |
noentries<< "HeaderScan_QL:"; |
| 143 |
if(pcktId[j+totevents]==16){ |
l->DrawLatex(0.05, 0.7, noentries.str().c_str()); |
| 144 |
pcktLenght[totphysevents]=ph->GetPacketLenght(); |
noentries.str(""); |
| 145 |
pcktCounter[totphysevents]=ph->GetCounter(); |
noentries<< "No Physics entries for this files"; |
| 146 |
totphysevents=totphysevents+1; |
l->DrawLatex(0.05, 0.5, noentries.str().c_str()); |
| 147 |
} |
|
| 148 |
offset[j+totevents]=ph->GetFileOffset(); |
if (outDir == "./") { |
| 149 |
allCounter[j+totevents]= ph->GetCounter(); |
oss.str(""); |
| 150 |
} |
oss << filename.Data() << "_HeaderScan_QL." << format.Data(); |
| 151 |
totevents=totevents+nevents; |
} else { |
| 152 |
} |
oss.str(""); |
| 153 |
|
oss << outDir.Data() << filename.Data() << "_HeaderScan_QL." << format.Data(); |
| 154 |
|
} |
|
Float_t mintime=obt[0], maxtime=obt[0], minlen=pcktLenght[0], maxlen=pcktLenght[0], mincount=pcktCounter[0], maxcount=pcktCounter[0]; |
|
|
|
|
|
|
|
|
for (Int_t t=0; t<totalevents; t++){ |
|
|
if(obt[t]<mintime) mintime=obt[t]; |
|
|
if(obt[t]>maxtime) maxtime=obt[t]; |
|
|
} |
|
|
for (Int_t t=0; t<totalphysevents; t++){ |
|
|
if(pcktLenght[t]<=minlen) minlen=pcktLenght[t]; |
|
|
if(pcktLenght[t]>=maxlen) maxlen=pcktLenght[t]; |
|
|
if(pcktCounter[t]<=mincount) mincount=pcktCounter[t]; |
|
|
if(pcktCounter[t]>=maxcount) maxcount=pcktCounter[t]; |
|
|
} |
|
|
|
|
|
|
|
|
Float_t nbintime = (maxtime-mintime)/1000; |
|
|
Float_t nbinlen = (maxlen-minlen)/100; |
|
|
Float_t nbincount = (maxcount-mincount)/100; |
|
|
|
|
| 155 |
|
|
| 156 |
///---------------------------TO GRAPH---------------------------------------------/// |
canv->Update(); |
| 157 |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
canv->SaveAs(oss.str().c_str()); |
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
|
|
finalCanv1->Divide(3); |
|
|
finalCanv1->SetFillColor(10); |
|
|
finalCanv2->Divide(2); |
|
|
finalCanv2->SetFillColor(10); |
|
| 158 |
|
|
| 159 |
|
return; |
| 160 |
TGraph *grPcktId1 = new TGraph(totalevents, obt, pcktId); |
} |
|
TGraph *grPcktLenght = new TGraph(totalevents, obt, pcktLenght); |
|
|
TGraph *grPcktCounter = new TGraph(totalevents, obt, pcktCounter); |
|
|
TGraph *grFileOffset = new TGraph(totalevents, offset, allCounter); |
|
|
|
|
|
TGaxis::SetMaxDigits(3); |
|
| 161 |
|
|
| 162 |
//-----canvas 1-------------------------------/// |
//-------------- to know the max and min OBT ----------------------------// |
| 163 |
finalCanv1->cd(1); |
headBr->GetEntry(0); |
| 164 |
|
ph = eh->GetPscuHeader(); |
| 165 |
stringstream oss1; |
firstime = ph->GetOrbitalTime(); |
| 166 |
oss1.str(""); |
|
| 167 |
oss1 << "OBT (ms) with t0 = " << mintime << "ms"; |
int iii =0; |
| 168 |
|
while(iii < nevents){ |
| 169 |
gStyle->SetTitleH(0.06); |
headBr->GetEntry(iii); |
| 170 |
grPcktId1->SetTitle(oss.str().c_str()); |
ph = eh->GetPscuHeader(); |
| 171 |
grPcktId1->GetXaxis()->SetTitle(oss1.str().c_str()); |
if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime(); |
| 172 |
grPcktId1->GetXaxis()->CenterTitle(); |
if((ph->GetOrbitalTime()) >= lastime) lastime=ph->GetOrbitalTime(); |
| 173 |
grPcktId1->GetXaxis()->SetLabelSize(0.03); |
iii++; |
| 174 |
grPcktId1->GetYaxis()->SetTitle("Packet ID"); |
} |
|
grPcktId1->GetYaxis()->CenterTitle(); |
|
|
grPcktId1->SetMarkerSize(4); |
|
|
grPcktId1->Draw("AP"); |
|
| 175 |
|
|
| 176 |
|
//------------------------ First histogram -----------------------------------// |
| 177 |
|
|
| 178 |
|
obmin=firstime; |
| 179 |
|
obmax=lastime; |
| 180 |
|
|
|
finalCanv1->cd(2); |
|
| 181 |
oss1.str(""); |
oss1.str(""); |
| 182 |
oss1 << "OBT (min) with t0 = " << mintime << "ms"; |
oss1 << filename.Data() <<": Physics Packet per minute. Start time = " << obmin << ", End time = "<< obmax <<" ms"; |
| 183 |
|
Int_t nbin = (lastime-firstime)/60000; |
| 184 |
|
//TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
| 185 |
|
TH1F *h1 = new TH1F ("histo1", "" , nbin, obmin, obmax); |
| 186 |
|
|
| 187 |
|
oss2.str(""); |
| 188 |
|
oss2 << filename.Data() <<": Lenght of Physic packets"; |
| 189 |
|
Int_t nbin2 =(lastime-firstime); |
| 190 |
|
//TH1F *packetLength = new TH1F ("packetLength", oss2.str().c_str(), nbin2, obmin, obmax); |
| 191 |
|
TH1F *packetLength = new TH1F ("packetLength", "", nbin2, obmin, obmax); |
| 192 |
|
|
| 193 |
|
oss3.str(""); |
| 194 |
|
oss3 << filename.Data() <<": Physics Counter vs. OBT"; |
| 195 |
|
// TH1F *packeCounter = new TH1F ("packeCounter", oss3.str().c_str(), nbin2, obmin, obmax); |
| 196 |
|
TH1F *packeCounter = new TH1F ("packeCounter", "", nbin2, obmin, obmax); |
| 197 |
|
//---------------------------------------------------- |
| 198 |
|
TCanvas *finalCanv = new TCanvas("Header", base, 1200, 1600); |
| 199 |
|
finalCanv->Divide(1,5); |
| 200 |
|
finalCanv->SetFillColor(10); |
| 201 |
|
|
| 202 |
|
TPad *all2= new TPad ("","", 0, 0, 1, 1); |
| 203 |
|
all2->SetFillColor(10); |
| 204 |
|
TPad *all3= new TPad ("","", 0, 0, 1, 1); |
| 205 |
|
all3->SetFillColor(10); |
| 206 |
|
TPad *all4= new TPad ("","", 0, 0, 1, 1); |
| 207 |
|
all4->SetFillColor(10); |
| 208 |
|
TPad *all= new TPad ("","", 0, 0, 1, 1); |
| 209 |
|
all->SetFillColor(10); |
| 210 |
|
TPad *all1= new TPad ("","", 0, 0, 1, 1); |
| 211 |
|
all1->SetFillColor(10); |
| 212 |
|
TPad *pad = new TPad("pad","pad", .80,.50,.90,.80); |
| 213 |
|
pad->SetFillColor(10); |
| 214 |
|
//---------------------------------------------------- |
| 215 |
|
|
| 216 |
|
TMultiGraph *mg1 = new TMultiGraph(); |
| 217 |
|
|
| 218 |
|
|
| 219 |
|
TMultiGraph *mg2 = new TMultiGraph(); |
| 220 |
|
|
| 221 |
|
|
| 222 |
|
//-------------------------------------------------------------------------- |
| 223 |
|
for (Int_t l = 0; l < nevents; l++){ |
| 224 |
|
headBr->GetEntry(l); |
| 225 |
|
ph = eh->GetPscuHeader(); |
| 226 |
|
h1->Fill(ph->GetOrbitalTime()); |
| 227 |
|
packetLength->Fill(ph->GetOrbitalTime(),ph->GetPacketLenght()); |
| 228 |
|
packeCounter->Fill(ph->GetOrbitalTime(),ph->GetCounter()); |
| 229 |
|
} |
| 230 |
|
|
| 231 |
|
//------------ First Canvas ---------------------// |
| 232 |
|
TLine li; |
| 233 |
|
li.SetLineStyle(4); |
| 234 |
|
li.SetLineWidth(2); |
| 235 |
|
|
| 236 |
|
finalCanv->cd(1); |
| 237 |
|
all2->Draw(); |
| 238 |
|
all2->cd(); |
| 239 |
|
|
| 240 |
|
h1->SetStats(kFALSE); |
| 241 |
|
h1->GetXaxis()->SetTitle("OBT (ms)"); |
| 242 |
|
h1->GetXaxis()->CenterTitle(); |
| 243 |
|
h1->GetXaxis()->SetLabelSize(0.04); |
| 244 |
|
h1->GetYaxis()->SetTitle("Number of events "); |
| 245 |
|
h1->GetYaxis()->CenterTitle(); |
| 246 |
|
h1->GetYaxis()->SetLabelSize(0.06); |
| 247 |
|
h1->GetYaxis()->SetTitleSize(0.06); |
| 248 |
|
h1->GetYaxis()->SetTitleOffset(0.6); |
| 249 |
|
h1->Draw(); |
| 250 |
|
for (Int_t l = 0; l < runnevents; l++){ |
| 251 |
|
RunHeadTr->GetEntry(l); |
| 252 |
|
ph = eH->GetPscuHeader(); |
| 253 |
|
int ws= reh->RM_ACQ_SETTING_MODE; |
| 254 |
|
int id = ph->GetPacketId1(); |
| 255 |
|
Int_t obt = ph->GetOrbitalTime(); |
| 256 |
|
if (ws==1){ |
| 257 |
|
li.SetLineColor(3); |
| 258 |
|
li.DrawLine(obt,0,obt,h1->GetMaximum()); |
| 259 |
|
} |
| 260 |
|
else if (ws==2){ |
| 261 |
|
li.SetLineColor(4); |
| 262 |
|
li.DrawLine(obt,0,obt,h1->GetMaximum()); |
| 263 |
|
} |
| 264 |
|
} |
| 265 |
|
|
| 266 |
|
finalCanv->cd(1); |
| 267 |
|
stringstream ws1, ws2; |
| 268 |
|
ws1.str(""); |
| 269 |
|
ws2.str(""); |
| 270 |
|
ws1<<"ACQ_SETTING_MODE = 1"; |
| 271 |
|
ws2<<"ACQ_SETTING_MODE = 2"; |
| 272 |
|
TPaveText *pt=0; |
| 273 |
|
pt = new TPaveText (.60,.92,.76,.98); |
| 274 |
|
pt->AddText(ws1.str().c_str()); |
| 275 |
|
pt->SetTextColor(3); |
| 276 |
|
pt->SetFillColor(10); |
| 277 |
|
pt->SetBorderSize(0); |
| 278 |
|
pt->Draw(); |
| 279 |
|
TPaveText *pt1=0; |
| 280 |
|
pt1 = new TPaveText (.76,.92,.92,.98); |
| 281 |
|
pt1->AddText(ws2.str().c_str()); |
| 282 |
|
pt1->SetTextColor(4); |
| 283 |
|
pt1->SetFillColor(10); |
| 284 |
|
pt1->SetBorderSize(0); |
| 285 |
|
pt1->Draw(); |
| 286 |
|
// TPaveText *pt1=0; |
| 287 |
|
pt1 = new TPaveText (.05,.91,.6,1); |
| 288 |
|
pt1->AddText(oss1.str().c_str()); |
| 289 |
|
pt1->SetTextColor(1); |
| 290 |
|
pt1->SetFillColor(10); |
| 291 |
|
pt1->SetBorderSize(0); |
| 292 |
|
pt1->Draw(); |
| 293 |
|
|
| 294 |
|
finalCanv->cd(2); |
| 295 |
|
all3->Draw(); |
| 296 |
|
all3->cd(); |
| 297 |
|
packetLength->SetStats(kFALSE); |
| 298 |
|
packetLength->SetMarkerColor(2); |
| 299 |
|
packetLength->SetMarkerSize(.5); |
| 300 |
|
packetLength->SetMarkerStyle(21); |
| 301 |
|
packetLength->GetXaxis()->SetTitle("OBT (ms)"); |
| 302 |
|
packetLength->GetXaxis()->CenterTitle(); |
| 303 |
|
packetLength->GetXaxis()->SetLabelSize(0.05); |
| 304 |
|
packetLength->GetYaxis()->SetTitle("Lenght (byte)"); |
| 305 |
|
packetLength->GetYaxis()->CenterTitle(); |
| 306 |
|
packetLength->GetYaxis()->SetLabelSize(0.05); |
| 307 |
|
packetLength->GetYaxis()->SetTitleSize(0.06); |
| 308 |
|
packetLength->GetYaxis()->SetTitleOffset(0.6); |
| 309 |
|
packetLength->Draw("9p"); |
| 310 |
|
finalCanv->cd(2); |
| 311 |
|
//TPaveText *pt=0; |
| 312 |
|
pt = new TPaveText (.6,.91,.90,1); |
| 313 |
|
pt->AddText(oss2.str().c_str()); |
| 314 |
|
pt->SetTextColor(2); |
| 315 |
|
pt->SetFillColor(10); |
| 316 |
|
pt->SetBorderSize(0); |
| 317 |
|
pt->Draw(); |
| 318 |
|
|
| 319 |
|
finalCanv->cd(3); |
| 320 |
|
all4->Draw(); |
| 321 |
|
all4->cd(); |
| 322 |
|
packeCounter->GetTitle(); |
| 323 |
|
packeCounter->SetStats(kFALSE); |
| 324 |
|
packeCounter->SetMarkerColor(4); |
| 325 |
|
packeCounter->SetMarkerSize(.2); |
| 326 |
|
packeCounter->SetMarkerStyle(21); |
| 327 |
|
packeCounter->GetXaxis()->SetTitle("OBT (ms)"); |
| 328 |
|
packeCounter->GetXaxis()->SetTitleSize(0.05); |
| 329 |
|
packeCounter->GetXaxis()->CenterTitle(); |
| 330 |
|
packeCounter->GetXaxis()->SetLabelSize(0.05); |
| 331 |
|
packeCounter->GetYaxis()->SetTitle("Counter"); |
| 332 |
|
packeCounter->GetYaxis()->SetTitleSize(0.05); |
| 333 |
|
packeCounter->GetYaxis()->CenterTitle(); |
| 334 |
|
packeCounter->GetYaxis()->SetLabelSize(0.05); |
| 335 |
|
packeCounter->GetYaxis()->SetTitleSize(0.06); |
| 336 |
|
packeCounter->GetYaxis()->SetTitleOffset(0.6); |
| 337 |
|
Double_t min = 500000000.; |
| 338 |
|
for (Int_t l = 0; l < nevents; l++){ |
| 339 |
|
if((packeCounter->GetBinContent(l))<= min && (packeCounter->GetBinContent(l))!= 0) min = packeCounter->GetBinContent(l); |
| 340 |
|
} |
| 341 |
|
packeCounter->SetMinimum(min); |
| 342 |
|
packeCounter->Draw("9p"); |
| 343 |
|
finalCanv->cd(3); |
| 344 |
|
TPaveText *pt2=0; |
| 345 |
|
pt2 = new TPaveText (.6,.91,.90,1); |
| 346 |
|
pt2->AddText(oss3.str().c_str()); |
| 347 |
|
pt2->SetTextColor(4); |
| 348 |
|
pt2->SetFillColor(10); |
| 349 |
|
pt2->SetBorderSize(0); |
| 350 |
|
pt2->Draw(); |
| 351 |
|
|
|
TH1F *h1 = new TH1F ("h1", oss.str().c_str(), (int)(nbintime/60), mintime, maxtime); |
|
| 352 |
|
|
| 353 |
|
//------------------------------------------------- |
| 354 |
|
TList *list = new TList; |
| 355 |
|
Int_t numkey; |
| 356 |
|
TObject *key = new TObject; |
| 357 |
|
const char *name; |
| 358 |
|
TTree* tr = new TTree; |
| 359 |
|
Long64_t nevntskey=0; |
| 360 |
|
list = file->GetListOfKeys(); |
| 361 |
|
numkey = file->GetNkeys(); |
| 362 |
|
int ll=0; |
| 363 |
|
int kk=0; |
| 364 |
|
|
| 365 |
for (Int_t i=0; i<numkey; i++){ |
for (Int_t i=0; i<numkey; i++){ |
| 366 |
key = list->At(i); |
key = list->At(i); |
| 367 |
name=(char *)(key->GetName()); |
name=(char *)(key->GetName()); |
| 368 |
tr = (TTree*)file->Get(name); |
tr = (TTree*)file->Get(name); |
| 369 |
if (tr->IsZombie()) continue; |
if (tr->IsZombie()) continue; |
| 370 |
tr->SetBranchAddress("Header", &eh); |
tr->SetBranchAddress("Header", &eh); |
| 371 |
nevents = tr->GetEntries(); |
TBranch *Br = tr->GetBranch("Header"); |
| 372 |
for (Int_t j = 0; j < nevents; j++){ |
nevntskey = tr->GetEntries(); |
| 373 |
tr->GetEntry(j); |
|
| 374 |
ph = eh->GetPscuHeader(); |
if(nevntskey !=0){ |
| 375 |
if((ph->GetPacketId1()) == 16){ |
Int_t size1=nevntskey; |
| 376 |
obtphysevents=ph->GetOrbitalTime(); |
Double_t *PscuCounter1 = new Double_t[size1]; |
| 377 |
h1->Fill(obtphysevents); |
Double_t *FileOffset1 = new Double_t[size1]; |
| 378 |
} |
Double_t *tempo1 = new Double_t[size1]; |
| 379 |
} |
//Double_t *salto= new Double_t[100]; |
| 380 |
|
//Double_t *salto1= new Double_t[100]; |
| 381 |
|
|
| 382 |
|
int l=0; |
| 383 |
|
while(l<nevntskey){ |
| 384 |
|
Br->GetEntry(l); |
| 385 |
|
ph = eh->GetPscuHeader(); |
| 386 |
|
PscuCounter1[l]= ph->GetCounter(); |
| 387 |
|
FileOffset1[l]=ph->GetFileOffset(); |
| 388 |
|
tempo1[l]=ph->GetOrbitalTime(); |
| 389 |
|
if(ph->GetFileOffset()<= primoffset){ |
| 390 |
|
primoffset =ph->GetFileOffset(); |
| 391 |
|
primotempo=ph->GetOrbitalTime(); |
| 392 |
|
} |
| 393 |
|
if(ph->GetFileOffset()>= ultimoffset){ |
| 394 |
|
ultimoffset = ph->GetFileOffset(); |
| 395 |
|
ultimotempo = ph->GetOrbitalTime(); |
| 396 |
|
} |
| 397 |
|
/*if(l>0){ |
| 398 |
|
if(tempo1[l] < tempo1[l-1]){ |
| 399 |
|
salto1[kk] =(const Double_t*)tempo1[l-1]; |
| 400 |
|
salto[ll]= ph->GetOrbitalTime(); |
| 401 |
|
ll=ll+1; |
| 402 |
|
kk=kk+1; |
| 403 |
|
} |
| 404 |
|
}*/ |
| 405 |
|
l++; |
| 406 |
|
} |
| 407 |
|
|
| 408 |
|
TGraph *graph3= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)PscuCounter1); |
| 409 |
|
graph3->SetMarkerColor(3); |
| 410 |
|
graph3->SetMarkerSize(.2); |
| 411 |
|
graph3->SetMarkerStyle(21); |
| 412 |
|
mg1->Add(graph3); |
| 413 |
|
|
| 414 |
|
TGraph *graph4= new TGraph(nevntskey, (const Double_t*)FileOffset1, (const Double_t*)tempo1); |
| 415 |
|
graph4->SetMarkerColor(kBlue); |
| 416 |
|
graph4->SetMarkerSize(.2); |
| 417 |
|
graph4->SetMarkerStyle(21); |
| 418 |
|
mg2->Add(graph4); |
| 419 |
|
} |
| 420 |
} |
} |
| 421 |
|
|
| 422 |
h1->SetMarkerStyle(6); |
kk=kk-1; |
| 423 |
h1->GetXaxis()->SetTitle(oss1.str().c_str()); |
ll=ll-1; |
| 424 |
h1->GetXaxis()->CenterTitle(); |
|
| 425 |
h1->GetXaxis()->SetLabelSize(0.03); |
TLatex *lat = new TLatex(); |
| 426 |
h1->GetYaxis()->SetTitle("number of Physic packets"); |
lat->SetTextAlign(12); |
| 427 |
h1->GetYaxis()->CenterTitle(); |
lat->SetTextSize(0.15); |
| 428 |
h1->Draw(); |
lat->SetTextColor(kBlue); |
| 429 |
|
//------------ Second Canvas ---------------------// |
| 430 |
|
finalCanv->cd(4); |
| 431 |
finalCanv1->cd(3); |
all1->Draw(); |
| 432 |
oss1.str(""); |
all1->cd(); |
| 433 |
oss1 << "OBT (ms) with t0 = " << mintime << "ms"; |
|
| 434 |
|
oss1.str(""); |
| 435 |
grPcktLenght->SetTitle(oss.str().c_str()); |
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
| 436 |
grPcktLenght->GetXaxis()->SetTitle(oss1.str().c_str()); |
//mg1->SetTitle(oss1.str().c_str()); |
| 437 |
grPcktLenght->GetXaxis()->CenterTitle(); |
mg1->Draw("AP"); |
| 438 |
grPcktLenght->GetXaxis()->SetLabelSize(0.03); |
mg1->GetXaxis()->SetTitle("File Offset"); |
| 439 |
grPcktLenght->GetYaxis()->SetTitle("Lenght of Physic packets (byte)"); |
mg1->GetXaxis()->CenterTitle(); |
| 440 |
grPcktLenght->GetYaxis()->CenterTitle(); |
mg1->GetXaxis()->SetTitleSize(0.045); |
| 441 |
grPcktLenght->GetYaxis()->SetLabelSize(0.03); |
mg1->GetXaxis()->SetLabelSize(0.05); |
| 442 |
grPcktLenght->SetMarkerSize(4); |
mg1->GetYaxis()->SetTitle("Counter"); |
| 443 |
grPcktLenght->Draw("AP"); |
mg1->GetYaxis()->CenterTitle(); |
| 444 |
|
mg1->GetYaxis()->SetTitleSize(0.05); |
| 445 |
|
mg1->GetYaxis()->SetLabelSize(0.06); |
| 446 |
finalCanv1->cd(2); |
mg1->GetYaxis()->SetTitleOffset(0.7); |
| 447 |
h1->Draw(); |
finalCanv->cd(4); |
| 448 |
|
TPaveText *pt3=0; |
| 449 |
finalCanv1->Update(); |
pt3 = new TPaveText (.60,.91,.90,1); |
| 450 |
|
pt3->AddText(oss1.str().c_str()); |
| 451 |
|
pt3->SetTextColor(3); |
| 452 |
///---------canvas 2-----------------------------// |
pt3->SetFillColor(10); |
| 453 |
finalCanv2->cd(1); |
pt3->SetBorderSize(0); |
| 454 |
|
pt3->Draw(); |
| 455 |
grPcktCounter->SetTitle(oss.str().c_str()); |
|
| 456 |
grPcktCounter->GetXaxis()->SetTitle(oss1.str().c_str()); |
|
| 457 |
grPcktCounter->GetXaxis()->SetTitleSize(0.04); |
finalCanv->cd(5); |
| 458 |
grPcktCounter->GetXaxis()->CenterTitle(); |
all->Draw(); |
| 459 |
grPcktCounter->GetXaxis()->SetLabelSize(0.03); |
all->cd(); |
|
grPcktCounter->GetYaxis()->SetTitle("PacketCounter of Physic packets"); |
|
|
grPcktCounter->GetYaxis()->SetTitleSize(0.04); |
|
|
grPcktCounter->GetYaxis()->CenterTitle(); |
|
|
grPcktCounter->GetYaxis()->SetLabelSize(0.03); |
|
|
grPcktCounter->SetMarkerSize(4); |
|
|
grPcktCounter->SetMinimum(mincount); |
|
|
grPcktCounter->SetMaximum(maxcount); |
|
|
grPcktCounter->Draw("AP"); |
|
| 460 |
|
|
| 461 |
finalCanv2->cd(2); |
oss3.str(""); |
| 462 |
|
oss3 << filename.Data() <<" OBT vs FileOffset. First packet = "<<primotempo <<" ms, Last packet = "<<ultimotempo<<" ms."; |
| 463 |
grFileOffset->SetTitle(oss.str().c_str()); |
//mg2->SetTitle(oss3.str().c_str()); |
| 464 |
grFileOffset->GetXaxis()->SetTitle("File Offset"); |
mg2->Draw("AP"); |
| 465 |
grFileOffset->GetXaxis()->CenterTitle(); |
mg2->GetXaxis()->SetTitle("File Offset"); |
| 466 |
grFileOffset->GetXaxis()->SetTitleSize(0.04); |
mg2->GetXaxis()->CenterTitle(); |
| 467 |
grFileOffset->GetXaxis()->SetLabelSize(0.03); |
mg2->GetXaxis()->SetTitleSize(0.045); |
| 468 |
grFileOffset->GetYaxis()->SetTitle("Packet counter"); |
mg2->GetXaxis()->SetLabelSize(0.05); |
| 469 |
grFileOffset->GetYaxis()->CenterTitle(); |
mg2->GetYaxis()->SetTitle("OBT"); |
| 470 |
grFileOffset->GetYaxis()->SetTitleSize(0.04); |
mg2->GetYaxis()->CenterTitle(); |
| 471 |
grFileOffset->GetYaxis()->SetLabelSize(0.03); |
mg2->GetYaxis()->SetTitleSize(0.05); |
| 472 |
grFileOffset->SetMarkerSize(4); |
mg2->GetYaxis()->SetLabelSize(0.055); |
| 473 |
grFileOffset->Draw("AP"); |
mg2->GetYaxis()->SetTitleOffset(0.6); |
| 474 |
|
/*pad->Draw(); |
| 475 |
finalCanv1->Update(); |
pad->cd(); |
| 476 |
|
stringa.str(""); |
| 477 |
|
stringa << "new data from "<< primotempo;//<<" to "<< salto1; |
| 478 |
//-------to save---------------------------/// |
lat->DrawLatex(0.08, 0.8, stringa.str().c_str()); |
| 479 |
oss.str(""); |
double min2 = 0.8; |
| 480 |
oss1.str(""); |
if(ll > 0){ |
| 481 |
|
pad->Draw(); |
| 482 |
oss << outDir.Data() << filename.Data(); |
pad->cd(); |
| 483 |
oss1 << outDir.Data() << filename.Data(); |
for(Int_t k=0; k <(kk); k++){ |
| 484 |
|
stringa.str(""); |
| 485 |
|
stringa << "old data from "<< salto[kk]<< " to "<<salto1[kk+1]; |
| 486 |
|
min2=min2-0.1; |
| 487 |
|
lat->DrawLatex(0.08, min2,stringa.str().c_str()); |
| 488 |
|
//cout<<salto[kk]<<";\n"; |
| 489 |
|
} |
| 490 |
|
}*/ |
| 491 |
|
|
| 492 |
|
finalCanv->cd(5); |
| 493 |
|
TPaveText *pt4=0; |
| 494 |
|
pt4 = new TPaveText (.38 ,.91,.92,1); |
| 495 |
|
pt4->AddText(oss3.str().c_str()); |
| 496 |
|
pt4->SetTextColor(kBlue); |
| 497 |
|
pt4->SetFillColor(10); |
| 498 |
|
pt4->SetBorderSize(0); |
| 499 |
|
pt4->Draw(); |
| 500 |
|
|
| 501 |
|
// finalCanv->Draw(); |
| 502 |
|
finalCanv->Update(); |
| 503 |
|
|
| 504 |
|
oss1.str(""); |
| 505 |
|
oss1 << outDir.Data() << filename.Data(); |
| 506 |
|
oss1 << "_HeaderScan"<<"." << format.Data(); |
| 507 |
|
|
| 508 |
|
finalCanv->SaveAs(oss1.str().c_str()); |
| 509 |
|
|
|
oss << "_HeaderScan_1." << format.Data(); |
|
|
oss1 << "_HeaderScan_2." << format.Data(); |
|
|
|
|
|
finalCanv1->SaveAs(oss.str().c_str()); |
|
|
finalCanv2->SaveAs(oss1.str().c_str()); |
|
|
|
|
| 510 |
|
|
| 511 |
file->Close(); |
|
| 512 |
|
file->Close(); |
| 513 |
|
|
| 514 |
} |
} |
| 515 |
|
|
|
|
|
|
|
|
| 516 |
int main(int argc, char* argv[]){ |
int main(int argc, char* argv[]){ |
| 517 |
TString path; |
TString path; |
| 518 |
TString outDir = "./"; |
TString outDir = "./"; |
| 519 |
TString format = "jpg"; |
TString format = "jpg"; |
|
|
|
| 520 |
if (argc < 2){ |
if (argc < 2){ |
| 521 |
printf("You have to insert at least the file to analyze \n"); |
printf("You have to insert at least the file to analyze \n"); |
| 522 |
printf("Try '--help' for more information. \n"); |
printf("Try '--help' for more information. \n"); |
| 523 |
exit(1); |
exit(1); |
| 524 |
} |
} |
|
|
|
| 525 |
if (!strcmp(argv[1], "--help")){ |
if (!strcmp(argv[1], "--help")){ |
| 526 |
printf( "Usage: HeaderScan FILE [OPTION] \n"); |
printf( "Usage: HeaderScan FILE [OPTION] \n"); |
| 527 |
printf( "\t --help Print this help and exit \n"); |
printf( "\t --help Print this help and exit \n"); |
| 529 |
printf( "\t -format[jpg|ps|gif] Format for output files [default 'jpg'] \n"); |
printf( "\t -format[jpg|ps|gif] Format for output files [default 'jpg'] \n"); |
| 530 |
exit(1); |
exit(1); |
| 531 |
} |
} |
|
|
|
|
|
|
| 532 |
path=argv[1]; |
path=argv[1]; |
| 533 |
|
for (int i = 2; i < argc; i++){ |
|
for (int i = 2; i < argc; i++){ |
|
|
|
|
| 534 |
if (!strcmp(argv[i], "-outDir")){ |
if (!strcmp(argv[i], "-outDir")){ |
| 535 |
if (++i >= argc){ |
if (++i >= argc){ |
| 536 |
printf( "-outDir needs arguments. \n"); |
printf( "-outDir needs arguments. \n"); |
| 541 |
outDir = argv[i]; |
outDir = argv[i]; |
| 542 |
continue; |
continue; |
| 543 |
} |
} |
| 544 |
} |
} |
|
|
|
| 545 |
if (!strcmp(argv[i], "-format")){ |
if (!strcmp(argv[i], "-format")){ |
| 546 |
if (++i >= argc){ |
if (++i >= argc){ |
| 547 |
printf( "-format needs arguments. \n"); |
printf( "-format needs arguments. \n"); |
| 553 |
continue; |
continue; |
| 554 |
} |
} |
| 555 |
} |
} |
|
|
|
|
|
|
| 556 |
} |
} |
|
|
|
| 557 |
HeaderScan(argv[1], outDir, format); |
HeaderScan(argv[1], outDir, format); |
|
|
|
| 558 |
} |
} |
| 559 |
|
|