1 |
/** |
/** |
2 |
* Header Scan |
* Header_Scan |
3 |
* Author Nagni |
* Author Nagni |
4 |
* version 1.0 |
* version 1.0 |
5 |
* |
* |
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,obt, 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){ |
149 |
} |
} |
150 |
|
|
151 |
//-------------- to know the max and min OBT ----------------------------// |
//-------------- to know the max and min OBT ----------------------------// |
152 |
for (Int_t i = 0; i < nevents; i++){ |
headBr->GetEntry(0); |
153 |
|
ph = eh->GetPscuHeader(); |
154 |
|
firstime = ph->GetOrbitalTime(); |
155 |
|
|
156 |
|
for (Int_t i = 0; i < nevents; i++){ |
157 |
headBr->GetEntry(i); |
headBr->GetEntry(i); |
158 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
159 |
obt = ph->GetOrbitalTime(); |
if((ph->GetOrbitalTime()) <= firstime) firstime=ph->GetOrbitalTime(); |
160 |
offset=ph->GetFileOffset(); |
if((ph->GetOrbitalTime()) >= lastime) lastime=ph->GetOrbitalTime(); |
|
if(obt <= firstime) firstime=obt; |
|
|
if(obt >= lastime) lastime=obt; |
|
161 |
} |
} |
162 |
|
|
|
//*************************** Histograms ************************************************************// |
|
163 |
//------------------------ First histogram -----------------------------------// |
//------------------------ First histogram -----------------------------------// |
164 |
obmin=firstime; |
|
165 |
obmax=lastime; |
obmin=firstime; |
166 |
|
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); |
172 |
|
|
|
//------------------------ Second histogram -----------------------------------// |
|
173 |
oss2.str(""); |
oss2.str(""); |
174 |
oss2 << " Lenght of Physic packets;"; |
oss2 << filename.Data() <<": Lenght of Physic packets"; |
175 |
Int_t nint = (lastime-firstime); |
Int_t nbin2 =(lastime-firstime); |
176 |
TH1F *PcktLenght = new TH1F ("histo2", oss2.str().c_str(), nint, obmin, obmax); |
TH1F *packetLength = new TH1F ("packetLength", oss2.str().c_str(), nbin2, obmin, obmax); |
177 |
|
|
|
//------------------------ Third histogram -----------------------------------// |
|
178 |
oss3.str(""); |
oss3.str(""); |
179 |
oss3 << " Physics Counter"; |
oss3 << filename.Data() <<": Physics Counter"; |
180 |
TH1F *PcktCounter = new TH1F ("histo3", oss3.str().c_str(), nint, obmin, obmax); |
TH1F *packeCounter = new TH1F ("packeCounter", oss3.str().c_str(), nbin2, obmin, obmax); |
181 |
|
//---------------------------------------------------- |
182 |
|
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1150); |
183 |
|
finalCanv1->Divide(1,3); |
184 |
|
finalCanv1->SetFillColor(10); |
185 |
|
TPad *all2= new TPad ("","", 0, 0, 1, 1); |
186 |
|
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); |
194 |
|
finalCanv2->SetFillColor(10); |
195 |
|
|
196 |
//**************************************************************************************************// |
TMultiGraph *mg1 = new TMultiGraph(); |
197 |
//------- fill histograms ---------// |
oss1.str(""); |
198 |
Int_t l=0; |
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
199 |
for (Int_t i = 0; i < nevents; i++){ |
mg1->SetTitle(oss1.str().c_str()); |
200 |
headBr->GetEntry(i); |
|
201 |
|
TMultiGraph *mg2 = new TMultiGraph(); |
202 |
|
|
203 |
|
TPad *all= new TPad ("","", 0, 0, 1, 1); |
204 |
|
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 |
h1->Fill(ph->GetOrbitalTime()); |
h1->Fill(ph->GetOrbitalTime()); |
214 |
PcktLenght->Fill(ph->GetOrbitalTime(),ph->GetPacketLenght()); |
packetLength->Fill(ph->GetOrbitalTime(),ph->GetPacketLenght()); |
215 |
PcktCounter->Fill(ph->GetOrbitalTime(),ph->GetCounter()); |
packeCounter->Fill(ph->GetOrbitalTime(),ph->GetCounter()); |
216 |
} |
} |
217 |
|
|
218 |
//****************************** Canvases *******************************// |
//------------ First Canvas ---------------------// |
|
//TGaxis::SetMaxDigits(4); |
|
|
//------------------- First Canvas --------------------------------// |
|
|
TCanvas *finalCanv1 = new TCanvas("Header_1", base, 1280, 1024); |
|
|
finalCanv1->Divide(1,3); |
|
|
finalCanv1->SetFillColor(10); |
|
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 |
|
|
233 |
|
|
234 |
finalCanv1->cd(2); |
finalCanv1->cd(2); |
235 |
PcktLenght->SetStats(kFALSE); |
all3->Draw(); |
236 |
PcktLenght->GetXaxis()->SetTitle("OBT (ms)"); |
all3->cd(); |
237 |
PcktLenght->GetXaxis()->CenterTitle(); |
packetLength->SetStats(kFALSE); |
238 |
PcktLenght->GetXaxis()->SetLabelSize(0.04); |
packetLength->SetMarkerColor(2); |
239 |
PcktLenght->GetYaxis()->SetTitle("Lenght (byte)"); |
packetLength->SetMarkerSize(.5); |
240 |
PcktLenght->GetYaxis()->CenterTitle(); |
packetLength->SetMarkerStyle(21); |
241 |
PcktLenght->GetYaxis()->SetLabelSize(0.04); |
packetLength->GetXaxis()->SetTitle("OBT (ms)"); |
242 |
PcktLenght->GetYaxis()->SetTitleSize(0.06); |
packetLength->GetXaxis()->CenterTitle(); |
243 |
PcktLenght->GetYaxis()->SetTitleOffset(0.8); |
packetLength->GetXaxis()->SetLabelSize(0.04); |
244 |
PcktLenght->SetMarkerColor(2); |
packetLength->GetYaxis()->SetTitle("Lenght (byte)"); |
245 |
PcktLenght->SetMarkerSize(.5); |
packetLength->GetYaxis()->CenterTitle(); |
246 |
PcktLenght->SetMarkerStyle(21); |
packetLength->GetYaxis()->SetLabelSize(0.04); |
247 |
PcktLenght->Draw("9p"); |
packetLength->GetYaxis()->SetTitleSize(0.06); |
248 |
|
packetLength->GetYaxis()->SetTitleOffset(0.8); |
249 |
|
packetLength->Draw("9p"); |
250 |
|
|
251 |
finalCanv1->cd(3); |
finalCanv1->cd(3); |
252 |
PcktCounter->SetStats(kFALSE); |
all4->Draw(); |
253 |
PcktCounter->GetXaxis()->SetTitle("OBT (ms)"); |
all4->cd(); |
254 |
PcktCounter->GetXaxis()->SetTitleSize(0.05); |
packeCounter->SetStats(kFALSE); |
255 |
PcktCounter->GetXaxis()->CenterTitle(); |
packeCounter->SetMarkerColor(4); |
256 |
PcktCounter->GetXaxis()->SetLabelSize(0.04); |
packeCounter->SetMarkerSize(.5); |
257 |
PcktCounter->GetYaxis()->SetTitle("Counter"); |
packeCounter->SetMarkerStyle(21); |
258 |
PcktCounter->GetYaxis()->SetTitleSize(0.05); |
packeCounter->GetXaxis()->SetTitle("OBT (ms)"); |
259 |
PcktCounter->GetYaxis()->CenterTitle(); |
packeCounter->GetXaxis()->SetTitleSize(0.05); |
260 |
PcktCounter->GetYaxis()->SetLabelSize(0.04); |
packeCounter->GetXaxis()->CenterTitle(); |
261 |
PcktCounter->GetYaxis()->SetTitleSize(0.06); |
packeCounter->GetXaxis()->SetLabelSize(0.04); |
262 |
PcktCounter->GetYaxis()->SetTitleOffset(0.8); |
packeCounter->GetYaxis()->SetTitle("Counter"); |
263 |
PcktCounter->SetMarkerColor(4); |
packeCounter->GetYaxis()->SetTitleSize(0.05); |
264 |
PcktCounter->SetMarkerSize(.5); |
packeCounter->GetYaxis()->CenterTitle(); |
265 |
PcktCounter->SetMarkerStyle(21); |
packeCounter->GetYaxis()->SetLabelSize(0.04); |
266 |
PcktCounter->Draw("9p"); |
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 |
//------------- Graph PscuCounter vs FileOffset --------------------------------- |
//------------------------------------------------- |
281 |
const Int_t size = 100000; |
TList *list = new TList; |
282 |
Int_t ev=0; |
Int_t numkey; |
283 |
Double_t PscuCounter[size], FileOffset[size]; |
TObject *key = new TObject; |
284 |
Int_t m=0; |
const char *name; |
285 |
Int_t pag= (nevents/100000)+1; |
TTree* tr = new TTree; |
286 |
|
Long64_t nevntskey=0; |
287 |
TMultiGraph *mg1 = new TMultiGraph(); |
list = file->GetListOfKeys(); |
288 |
oss1.str(""); |
numkey = file->GetNkeys(); |
289 |
oss1 << filename.Data() <<": PscuCounter vs FileOffset."; |
|
290 |
mg1->SetTitle(oss1.str().c_str()); |
const Int_t size1 = 10000; |
291 |
|
Int_t ev1=0; |
292 |
TCanvas *finalCanv2 = new TCanvas("Header_2", base, 1280, 1024); |
Double_t PscuCounter1[size1], FileOffset1[size1], tempo1[size1], salto[size1]; |
293 |
finalCanv2->SetFillColor(10); |
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//////////////////// |
/////ciclo sulle pagine//////////////////// |
308 |
for (Int_t interval=0; interval<pag; interval++){ |
for (Int_t interval1=0; interval1<pag1; interval1++){ |
309 |
|
|
310 |
for (Int_t l = 0; l < size; l++){ //ciclo su un sottogruppo |
for (Int_t l = 0; l < size1; l++){ //ciclo su un sottogruppo |
311 |
headBr->GetEntry(ev+l); |
Br->GetEntry(ev1+l); |
312 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
313 |
PscuCounter[l]= ph->GetCounter(); |
PscuCounter1[l]= ph->GetCounter(); // = PcktCounter[l] |
314 |
FileOffset[l]=ph->GetFileOffset(); |
FileOffset1[l]=ph->GetFileOffset(); |
315 |
m=l; |
tempo1[l]=ph->GetOrbitalTime(); |
316 |
} |
if(ph->GetFileOffset()<= primoffset){ |
317 |
|
primoffset =ph->GetFileOffset(); |
318 |
TGraph *graph= new TGraph(m, FileOffset, PscuCounter); |
primotempo=ph->GetOrbitalTime(); |
319 |
graph->SetMarkerColor(3); |
} |
320 |
graph->SetMarkerSize(.5); |
if(ph->GetFileOffset()>= ultimoffset){ |
321 |
graph->SetMarkerStyle(21); |
ultimoffset = ph->GetFileOffset(); |
322 |
mg1->Add(graph); |
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 |
ev=ev+100000; |
ev1=ev1+10000; |
347 |
|
} |
348 |
} |
} |
349 |
finalCanv2->cd(); |
|
350 |
|
|
351 |
|
TLatex *lat = new TLatex(); |
352 |
|
lat->SetTextAlign(12); |
353 |
|
lat->SetTextSize(0.15); |
354 |
|
lat->SetTextColor(kBlue); |
355 |
|
|
356 |
|
|
357 |
|
//------------ Second Canvas ---------------------// |
358 |
|
finalCanv2->cd(1); |
359 |
|
all1->Draw(); |
360 |
|
all1->cd(); |
361 |
mg1->Draw("AP"); |
mg1->Draw("AP"); |
|
mg1->SetTitle(oss1.str().c_str()); |
|
362 |
mg1->GetXaxis()->SetTitle("File Offset"); |
mg1->GetXaxis()->SetTitle("File Offset"); |
363 |
mg1->GetXaxis()->CenterTitle(); |
mg1->GetXaxis()->CenterTitle(); |
364 |
mg1->GetXaxis()->SetTitleSize(0.04); |
mg1->GetXaxis()->SetTitleSize(0.05); |
365 |
mg1->GetXaxis()->SetLabelSize(0.02); |
mg1->GetXaxis()->SetLabelSize(0.04); |
366 |
mg1->GetYaxis()->SetTitle("Counter"); |
mg1->GetYaxis()->SetTitle("Counter"); |
367 |
mg1->GetYaxis()->CenterTitle(); |
mg1->GetYaxis()->CenterTitle(); |
368 |
mg1->GetYaxis()->SetTitleSize(0.04); |
mg1->GetYaxis()->SetTitleSize(0.05); |
369 |
mg1->GetYaxis()->SetLabelSize(0.02); |
mg1->GetYaxis()->SetLabelSize(0.03); |
370 |
|
|
371 |
|
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"); |
379 |
|
mg2->GetXaxis()->SetTitle("File Offset"); |
380 |
|
mg2->GetXaxis()->CenterTitle(); |
381 |
|
mg2->GetXaxis()->SetTitleSize(0.05); |
382 |
|
mg2->GetXaxis()->SetLabelSize(0.04); |
383 |
|
mg2->GetYaxis()->SetTitle("OBT"); |
384 |
|
mg2->GetYaxis()->CenterTitle(); |
385 |
|
mg2->GetYaxis()->SetTitleSize(0.05); |
386 |
|
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(); |
412 |
|
|
413 |
finalCanv2->SaveAs(oss1.str().c_str()); |
finalCanv2->SaveAs(oss1.str().c_str()); |
414 |
|
|
415 |
file->Close(); |
file->Close(); |
416 |
|
|
417 |
} |
} |