54 |
* Fixed bugs: for a large namber of events is not possible to have vectors, so I have subsituted graphs with histograms |
* 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. |
* 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 |
|
|
90 |
|
|
91 |
//------------------- Variables initilization -------------------------// |
//------------------- Variables initilization -------------------------// |
92 |
Long64_t nevents=0; |
Long64_t nevents=0; |
93 |
ULong_t lastime, firstime;// offset, lastoffset, firstoffset; |
ULong_t lastime, firstime, primotempo, ultimotempo, primoffset=500000000, ultimoffset=100000000; |
94 |
double obmin=0.; |
double obmin=0.; |
95 |
double obmax=0.; |
double obmax=0.; |
96 |
stringstream oss, oss1, oss2, oss3, noentries; |
stringstream oss, oss1, oss2, oss3, noentries, stringa; |
97 |
//------- load root file -------------- |
//------- load root file -------------- |
98 |
TFile *file = new TFile(base.Data()); |
TFile *file = new TFile(base.Data()); |
99 |
if (!file){ |
if (!file){ |
161 |
} |
} |
162 |
|
|
163 |
//------------------------ First histogram -----------------------------------// |
//------------------------ First histogram -----------------------------------// |
164 |
|
|
165 |
obmin=firstime; |
obmin=firstime; |
166 |
obmax=lastime; |
obmax=lastime; |
167 |
|
|
168 |
oss1.str(""); |
oss1.str(""); |
169 |
oss1 <<"File name= "<< filename.Data() <<". Start time= " << obmin << ", end time= "<< obmax <<" ms"<<". Physics Packet per minute"; |
oss1 << filename.Data() <<": Physics Packet per minute. Start time = " << obmin << ", End time = "<< obmax <<" ms"; |
170 |
Int_t nbin = (lastime-firstime)/60000; |
Int_t nbin = (lastime-firstime)/60000; |
171 |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
TH1F *h1 = new TH1F ("histo1", oss1.str().c_str(), nbin, obmin, obmax); |
|
|
|
|
//------------- Graph PscuCounter vs FileOffset --------------------------------- |
|
|
const Int_t size = 10000; |
|
|
Int_t ev=0; |
|
|
Double_t PscuCounter[size], FileOffset[size], tempo[size], PcktLenght[size]; |
|
|
Int_t m=0; |
|
|
Int_t pag= (nevents/10000)+1; |
|
|
|
|
|
TMultiGraph *mg1 = new TMultiGraph(); |
|
|
oss1.str(""); |
|
|
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
|
|
mg1->SetTitle(oss1.str().c_str()); |
|
|
|
|
|
TMultiGraph *mg2 = new TMultiGraph(); |
|
|
oss1.str(""); |
|
|
oss1 << filename.Data() <<": OBT vs FileOffset."; |
|
|
mg2->SetTitle(oss1.str().c_str()); |
|
172 |
|
|
|
TMultiGraph *mg3 = new TMultiGraph(); |
|
173 |
oss2.str(""); |
oss2.str(""); |
174 |
oss2 << filename.Data() <<": Lenght of Physic packets"; |
oss2 << filename.Data() <<": Lenght of Physic packets"; |
175 |
mg3->SetTitle(oss2.str().c_str()); |
Int_t nbin2 =(lastime-firstime); |
176 |
|
TH1F *packetLength = new TH1F ("packetLength", oss2.str().c_str(), nbin2, obmin, obmax); |
177 |
|
|
|
TMultiGraph *mg4 = new TMultiGraph(); |
|
178 |
oss3.str(""); |
oss3.str(""); |
179 |
oss3 << filename.Data() <<": Physics Counter"; |
oss3 << filename.Data() <<": Physics Counter"; |
180 |
mg4->SetTitle(oss3.str().c_str()); |
TH1F *packeCounter = new TH1F ("packeCounter", oss3.str().c_str(), nbin2, obmin, obmax); |
181 |
|
//---------------------------------------------------- |
182 |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1150); |
183 |
finalCanv1->Divide(1,3); |
finalCanv1->Divide(1,3); |
184 |
finalCanv1->SetFillColor(10); |
finalCanv1->SetFillColor(10); |
185 |
|
TPad *all2= new TPad ("","", 0, 0, 1, 1); |
186 |
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
all2->SetFillColor(10); |
187 |
|
TPad *all3= new TPad ("","", 0, 0, 1, 1); |
188 |
|
all3->SetFillColor(10); |
189 |
|
TPad *all4= new TPad ("","", 0, 0, 1, 1); |
190 |
|
all4->SetFillColor(10); |
191 |
|
//---------------------------------------------------- |
192 |
|
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1150); |
193 |
finalCanv2->Divide(1,2); |
finalCanv2->Divide(1,2); |
194 |
finalCanv2->SetFillColor(10); |
finalCanv2->SetFillColor(10); |
195 |
|
|
196 |
/////ciclo sulle pagine//////////////////// |
TMultiGraph *mg1 = new TMultiGraph(); |
197 |
for (Int_t interval=0; interval<pag; interval++){ |
oss1.str(""); |
198 |
|
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
199 |
|
mg1->SetTitle(oss1.str().c_str()); |
200 |
|
|
201 |
|
TMultiGraph *mg2 = new TMultiGraph(); |
202 |
|
|
203 |
for (Int_t l = 0; l < size; l++){ //ciclo su un sottogruppo |
TPad *all= new TPad ("","", 0, 0, 1, 1); |
204 |
headBr->GetEntry(ev+l); |
all->SetFillColor(10); |
205 |
|
TPad *all1= new TPad ("","", 0, 0, 1, 1); |
206 |
|
all1->SetFillColor(10); |
207 |
|
TPad *pad = new TPad("pad","pad", .80,.50,.90,.80); |
208 |
|
pad->SetFillColor(10); |
209 |
|
//-------------------------------------------------------------------------- |
210 |
|
for (Int_t l = 0; l < nevents; l++){ |
211 |
|
headBr->GetEntry(l); |
212 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
213 |
PscuCounter[l]= ph->GetCounter(); // = PcktCounter[l] |
h1->Fill(ph->GetOrbitalTime()); |
214 |
FileOffset[l]=ph->GetFileOffset(); |
packetLength->Fill(ph->GetOrbitalTime(),ph->GetPacketLenght()); |
215 |
tempo[l]=ph->GetOrbitalTime(); |
packeCounter->Fill(ph->GetOrbitalTime(),ph->GetCounter()); |
|
PcktLenght[l]=ph->GetPacketLenght(); |
|
|
h1->Fill(ph->GetOrbitalTime()); |
|
|
m=l; |
|
216 |
} |
} |
217 |
|
|
|
TGraph *graph1= new TGraph(m, tempo, PcktLenght); |
|
|
graph1->SetMarkerColor(2); |
|
|
graph1->SetMarkerSize(.5); |
|
|
graph1->SetMarkerStyle(21); |
|
|
mg3->Add(graph1); |
|
|
|
|
|
TGraph *graph2= new TGraph(m, tempo, PscuCounter); |
|
|
graph2->SetMarkerColor(4); |
|
|
graph2->SetMarkerSize(.5); |
|
|
graph2->SetMarkerStyle(21); |
|
|
mg4->Add(graph2); |
|
|
|
|
|
TGraph *graph3= new TGraph(m, FileOffset, PscuCounter); |
|
|
graph3->SetMarkerColor(3); |
|
|
graph3->SetMarkerSize(.5); |
|
|
graph3->SetMarkerStyle(21); |
|
|
mg1->Add(graph3); |
|
|
|
|
|
TGraph *graph4= new TGraph(m, FileOffset, tempo); |
|
|
graph4->SetMarkerColor(kBlue); |
|
|
graph4->SetMarkerSize(.5); |
|
|
graph4->SetMarkerStyle(21); |
|
|
mg2->Add(graph4); |
|
|
|
|
|
ev=ev+10000; |
|
|
} |
|
218 |
//------------ First Canvas ---------------------// |
//------------ First Canvas ---------------------// |
219 |
|
|
220 |
finalCanv1->cd(1); |
finalCanv1->cd(1); |
221 |
|
all2->Draw(); |
222 |
|
all2->cd(); |
223 |
h1->SetStats(kFALSE); |
h1->SetStats(kFALSE); |
224 |
h1->GetXaxis()->SetTitle("OBT (ms)"); |
h1->GetXaxis()->SetTitle("OBT (ms)"); |
225 |
h1->GetXaxis()->CenterTitle(); |
h1->GetXaxis()->CenterTitle(); |
230 |
h1->GetYaxis()->SetTitleOffset(0.8); |
h1->GetYaxis()->SetTitleOffset(0.8); |
231 |
h1->Draw(); |
h1->Draw(); |
232 |
|
|
|
finalCanv1->cd(2); |
|
|
mg3->Draw("AP"); |
|
|
mg3->GetXaxis()->SetTitle("OBT (ms)"); |
|
|
mg3->GetXaxis()->CenterTitle(); |
|
|
mg3->GetXaxis()->SetLabelSize(0.04); |
|
|
mg3->GetYaxis()->SetTitle("Lenght (byte)"); |
|
|
mg3->GetYaxis()->CenterTitle(); |
|
|
mg3->GetYaxis()->SetLabelSize(0.04); |
|
|
mg3->GetYaxis()->SetTitleSize(0.06); |
|
|
mg3->GetYaxis()->SetTitleOffset(0.8); |
|
233 |
|
|
234 |
|
finalCanv1->cd(2); |
235 |
|
all3->Draw(); |
236 |
|
all3->cd(); |
237 |
|
packetLength->SetStats(kFALSE); |
238 |
|
packetLength->SetMarkerColor(2); |
239 |
|
packetLength->SetMarkerSize(.5); |
240 |
|
packetLength->SetMarkerStyle(21); |
241 |
|
packetLength->GetXaxis()->SetTitle("OBT (ms)"); |
242 |
|
packetLength->GetXaxis()->CenterTitle(); |
243 |
|
packetLength->GetXaxis()->SetLabelSize(0.04); |
244 |
|
packetLength->GetYaxis()->SetTitle("Lenght (byte)"); |
245 |
|
packetLength->GetYaxis()->CenterTitle(); |
246 |
|
packetLength->GetYaxis()->SetLabelSize(0.04); |
247 |
|
packetLength->GetYaxis()->SetTitleSize(0.06); |
248 |
|
packetLength->GetYaxis()->SetTitleOffset(0.8); |
249 |
|
packetLength->Draw("9p"); |
250 |
|
|
251 |
finalCanv1->cd(3); |
finalCanv1->cd(3); |
252 |
mg4->Draw("AP"); |
all4->Draw(); |
253 |
mg4->GetXaxis()->SetTitle("OBT (ms)"); |
all4->cd(); |
254 |
mg4->GetXaxis()->SetTitleSize(0.05); |
packeCounter->SetStats(kFALSE); |
255 |
mg4->GetXaxis()->CenterTitle(); |
packeCounter->SetMarkerColor(4); |
256 |
mg4->GetXaxis()->SetLabelSize(0.04); |
packeCounter->SetMarkerSize(.5); |
257 |
mg4->GetYaxis()->SetTitle("Counter"); |
packeCounter->SetMarkerStyle(21); |
258 |
mg4->GetYaxis()->SetTitleSize(0.05); |
packeCounter->GetXaxis()->SetTitle("OBT (ms)"); |
259 |
mg4->GetYaxis()->CenterTitle(); |
packeCounter->GetXaxis()->SetTitleSize(0.05); |
260 |
mg4->GetYaxis()->SetLabelSize(0.04); |
packeCounter->GetXaxis()->CenterTitle(); |
261 |
mg4->GetYaxis()->SetTitleSize(0.06); |
packeCounter->GetXaxis()->SetLabelSize(0.04); |
262 |
mg4->GetYaxis()->SetTitleOffset(0.8); |
packeCounter->GetYaxis()->SetTitle("Counter"); |
263 |
|
packeCounter->GetYaxis()->SetTitleSize(0.05); |
264 |
finalCanv1->Update(); |
packeCounter->GetYaxis()->CenterTitle(); |
265 |
|
packeCounter->GetYaxis()->SetLabelSize(0.04); |
266 |
|
packeCounter->GetYaxis()->SetTitleSize(0.06); |
267 |
|
packeCounter->GetYaxis()->SetTitleOffset(0.8); |
268 |
|
Double_t min = 500000000.; |
269 |
|
for (Int_t l = 0; l < nevents; l++){ |
270 |
|
if((packeCounter->GetBinContent(l))<= min && (packeCounter->GetBinContent(l))!= 0) min = packeCounter->GetBinContent(l); |
271 |
|
} |
272 |
|
packeCounter->SetMinimum(min); |
273 |
|
packeCounter->Draw("9p"); |
274 |
|
|
275 |
oss.str(""); |
oss.str(""); |
276 |
oss << outDir.Data() << filename.Data(); |
oss << outDir.Data() << filename.Data(); |
277 |
oss << "_HeaderScan_1." << format.Data(); |
oss << "_HeaderScan_1." << format.Data(); |
278 |
finalCanv1->SaveAs(oss.str().c_str()); |
finalCanv1->SaveAs(oss.str().c_str()); |
279 |
|
|
280 |
|
//------------------------------------------------- |
281 |
|
TList *list = new TList; |
282 |
|
Int_t numkey; |
283 |
|
TObject *key = new TObject; |
284 |
|
const char *name; |
285 |
|
TTree* tr = new TTree; |
286 |
|
Long64_t nevntskey=0; |
287 |
|
list = file->GetListOfKeys(); |
288 |
|
numkey = file->GetNkeys(); |
289 |
|
|
290 |
|
const Int_t size1 = 10000; |
291 |
|
Int_t ev1=0; |
292 |
|
Double_t PscuCounter1[size1], FileOffset1[size1], tempo1[size1], salto[size1]; |
293 |
|
Int_t pag1=0; |
294 |
|
Int_t m1=0; |
295 |
|
Int_t ll=0; |
296 |
|
|
297 |
|
for (Int_t i=0; i<numkey; i++){ |
298 |
|
key = list->At(i); |
299 |
|
name=(char *)(key->GetName()); |
300 |
|
tr = (TTree*)file->Get(name); |
301 |
|
if (tr->IsZombie()) continue; |
302 |
|
tr->SetBranchAddress("Header", &eh); |
303 |
|
TBranch *Br = tr->GetBranch("Header"); |
304 |
|
nevntskey = tr->GetEntries(); |
305 |
|
m1=0; |
306 |
|
pag1= (nevntskey/10000)+1; |
307 |
|
/////ciclo sulle pagine//////////////////// |
308 |
|
for (Int_t interval1=0; interval1<pag1; interval1++){ |
309 |
|
|
310 |
|
for (Int_t l = 0; l < size1; l++){ //ciclo su un sottogruppo |
311 |
|
Br->GetEntry(ev1+l); |
312 |
|
ph = eh->GetPscuHeader(); |
313 |
|
PscuCounter1[l]= ph->GetCounter(); // = PcktCounter[l] |
314 |
|
FileOffset1[l]=ph->GetFileOffset(); |
315 |
|
tempo1[l]=ph->GetOrbitalTime(); |
316 |
|
if(ph->GetFileOffset()<= primoffset){ |
317 |
|
primoffset =ph->GetFileOffset(); |
318 |
|
primotempo=ph->GetOrbitalTime(); |
319 |
|
} |
320 |
|
if(ph->GetFileOffset()>= ultimoffset){ |
321 |
|
ultimoffset = ph->GetFileOffset(); |
322 |
|
ultimotempo = ph->GetOrbitalTime(); |
323 |
|
} |
324 |
|
if(l>0){ |
325 |
|
if(tempo1[l] < tempo1[l-1]){ |
326 |
|
salto[ll]= ph->GetOrbitalTime(); |
327 |
|
ll=ll+1; |
328 |
|
} |
329 |
|
} |
330 |
|
|
331 |
|
m1=l; |
332 |
|
} |
333 |
|
|
334 |
|
TGraph *graph3= new TGraph(m1, FileOffset1, PscuCounter1); |
335 |
|
graph3->SetMarkerColor(3); |
336 |
|
graph3->SetMarkerSize(.5); |
337 |
|
graph3->SetMarkerStyle(21); |
338 |
|
mg1->Add(graph3); |
339 |
|
|
340 |
|
TGraph *graph4= new TGraph(m1, FileOffset1, tempo1); |
341 |
|
graph4->SetMarkerColor(kBlue); |
342 |
|
graph4->SetMarkerSize(.5); |
343 |
|
graph4->SetMarkerStyle(21); |
344 |
|
mg2->Add(graph4); |
345 |
|
|
346 |
|
ev1=ev1+10000; |
347 |
|
} |
348 |
|
} |
349 |
|
|
350 |
|
|
351 |
|
TLatex *lat = new TLatex(); |
352 |
|
lat->SetTextAlign(12); |
353 |
|
lat->SetTextSize(0.15); |
354 |
|
lat->SetTextColor(kBlue); |
355 |
|
|
356 |
|
|
357 |
//------------ Second Canvas ---------------------// |
//------------ Second Canvas ---------------------// |
358 |
finalCanv2->cd(1); |
finalCanv2->cd(1); |
359 |
|
all1->Draw(); |
360 |
|
all1->cd(); |
361 |
mg1->Draw("AP"); |
mg1->Draw("AP"); |
362 |
mg1->GetXaxis()->SetTitle("File Offset"); |
mg1->GetXaxis()->SetTitle("File Offset"); |
363 |
mg1->GetXaxis()->CenterTitle(); |
mg1->GetXaxis()->CenterTitle(); |
366 |
mg1->GetYaxis()->SetTitle("Counter"); |
mg1->GetYaxis()->SetTitle("Counter"); |
367 |
mg1->GetYaxis()->CenterTitle(); |
mg1->GetYaxis()->CenterTitle(); |
368 |
mg1->GetYaxis()->SetTitleSize(0.05); |
mg1->GetYaxis()->SetTitleSize(0.05); |
369 |
mg1->GetYaxis()->SetLabelSize(0.04); |
mg1->GetYaxis()->SetLabelSize(0.03); |
370 |
|
|
371 |
finalCanv2->cd(2); |
finalCanv2->cd(2); |
372 |
|
all->Draw(); |
373 |
|
all->cd(); |
374 |
|
|
375 |
|
oss3.str(""); |
376 |
|
oss3 << filename.Data() <<" OBT vs FileOffset. First packet = "<<primotempo <<" ms, Last packet = "<<ultimotempo<<" ms."; |
377 |
|
mg2->SetTitle(oss3.str().c_str()); |
378 |
mg2->Draw("AP"); |
mg2->Draw("AP"); |
379 |
mg2->GetXaxis()->SetTitle("File Offset"); |
mg2->GetXaxis()->SetTitle("File Offset"); |
380 |
mg2->GetXaxis()->CenterTitle(); |
mg2->GetXaxis()->CenterTitle(); |
383 |
mg2->GetYaxis()->SetTitle("OBT"); |
mg2->GetYaxis()->SetTitle("OBT"); |
384 |
mg2->GetYaxis()->CenterTitle(); |
mg2->GetYaxis()->CenterTitle(); |
385 |
mg2->GetYaxis()->SetTitleSize(0.05); |
mg2->GetYaxis()->SetTitleSize(0.05); |
386 |
mg2->GetYaxis()->SetLabelSize(0.04); |
mg2->GetYaxis()->SetLabelSize(0.03); |
387 |
|
double min2 = 0.8; |
388 |
|
if(ll-1 > 0){ |
389 |
|
pad->Draw(); |
390 |
|
pad->cd(); |
391 |
|
stringa.str(""); |
392 |
|
stringa << "jump back at:"; |
393 |
|
lat->DrawLatex(0.08, min2, stringa.str().c_str()); |
394 |
|
for(Int_t kk=0; kk <(ll-1); kk++){ |
395 |
|
stringa.str(""); |
396 |
|
stringa << salto[kk]; |
397 |
|
min2=min2-0.1; |
398 |
|
lat->DrawLatex(0.08, min2,stringa.str().c_str()); |
399 |
|
//cout<<salto[kk]<<";\n"; |
400 |
|
} |
401 |
|
} |
402 |
|
|
403 |
finalCanv2->Update(); |
finalCanv2->Update(); |
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
oss1.str(""); |
oss1.str(""); |
410 |
oss1 << outDir.Data() << filename.Data(); |
oss1 << outDir.Data() << filename.Data(); |
411 |
oss1 << "_HeaderScan_2"<<"." << format.Data(); |
oss1 << "_HeaderScan_2"<<"." << format.Data(); |