2 |
* FTrkQLook_BASIC.cpp |
* FTrkQLook_BASIC.cpp |
3 |
* |
* |
4 |
* autor: D.Fedele |
* autor: D.Fedele |
5 |
* version 2.0 |
* version 3.0 |
6 |
* Parameters: |
* Parameters: |
7 |
* file - the data file to analyze |
* file - the data file to analyze |
8 |
* fromevent - first event to analyze |
* fromevent - first event to analyze |
28 |
#include <PacketType.h> |
#include <PacketType.h> |
29 |
// |
// |
30 |
#define MAXSTORAGE 50000 |
#define MAXSTORAGE 50000 |
|
#define GAP 10040*4 |
|
31 |
|
|
32 |
void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){ |
void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){ |
33 |
if ( to == 0 ){ |
if ( to == 0 ){ |
124 |
// |
// |
125 |
// other variables definitions |
// other variables definitions |
126 |
stringstream oss,fromfile,isfile; |
stringstream oss,fromfile,isfile; |
127 |
const Int_t sizeH=neventH; |
// |
128 |
const Int_t sizeC=neventC; |
// information about the RunHeader |
129 |
Int_t count=0,trk_cal_us[sizeH],countrun=1; |
Int_t HOBT[neventH]; |
130 |
Float_t perc=0,xMIN=0,xMAX=0; |
Int_t trk_cal_us[neventH]; |
131 |
Int_t HOBT[sizeH],COBT[sizeC]; |
for (Int_t vi=0; vi<neventH;vi++){ |
|
|
|
|
for (Int_t vi=0; vi<sizeH;vi++){ |
|
132 |
HOBT[vi]=0; |
HOBT[vi]=0; |
133 |
trk_cal_us[vi]=0; |
trk_cal_us[vi]=0; |
134 |
} |
} |
135 |
for (Int_t vi=0; vi<sizeC;vi++){ |
|
|
COBT[vi]=0; |
|
|
} |
|
|
|
|
|
//*************************************************************************************** |
|
|
// LOOP on each event |
|
|
//*************************************************************************************** |
|
|
|
|
136 |
// |
// |
137 |
// information about trk_calib_used |
// information about RunHeader |
138 |
|
Int_t countnboot=1; |
139 |
for (Int_t ev=0; ev<neventH; ev++){ |
for (Int_t ev=0; ev<neventH; ev++){ |
140 |
otr->GetEntry(ev); |
otr->GetEntry(ev); |
141 |
pH = eH->GetPscuHeader(); |
pH = eH->GetPscuHeader(); |
142 |
HOBT[ev]= pH->GetOrbitalTime(); |
HOBT[ev]= pH->GetOrbitalTime(); |
143 |
trk_cal_us[ev]=reh->TRK_CALIB_USED; |
trk_cal_us[ev]=reh->TRK_CALIB_USED; |
144 |
if((HOBT[ev]<HOBT[ev-1]) && ev>0) |
if((HOBT[ev]<HOBT[ev-1]) && ev>0) |
145 |
countrun+=1; |
countnboot+=1; |
|
// printf("\n%lld\t\tcountrun=%d\n",HOBT[ev],countrun); |
|
146 |
} |
} |
147 |
countrun+=(Int_t)nevent/30000; |
countnboot+=2*(Int_t)nevent/MAXSTORAGE; |
148 |
// printf("\ncountrun=%d\n",countrun); |
// printf("\ncountnboot=%d\n",countnboot); |
149 |
|
|
150 |
// |
// |
151 |
// information about calibration OBT |
// information about calibration OBT |
152 |
|
Int_t COBT[neventC]; |
153 |
|
for (Int_t vi=0; vi<neventC;vi++){ |
154 |
|
COBT[vi]=0; |
155 |
|
} |
156 |
for (Int_t ev=0; ev<neventC; ev++){ |
for (Int_t ev=0; ev<neventC; ev++){ |
157 |
ctr->GetEntry(ev); |
ctr->GetEntry(ev); |
158 |
pH = ceh->GetPscuHeader(); |
pH = ceh->GetPscuHeader(); |
159 |
COBT[ev]= pH->GetOrbitalTime(); |
COBT[ev]= pH->GetOrbitalTime(); |
160 |
} |
} |
161 |
|
|
162 |
//**************************************************************************************** |
// |
163 |
//Output figure |
// Style options |
|
//**************************************************************************************** |
|
164 |
gStyle->SetLabelSize(0.06,"x"); |
gStyle->SetLabelSize(0.06,"x"); |
165 |
gStyle->SetLabelSize(0.06,"y"); |
gStyle->SetLabelSize(0.06,"y"); |
166 |
gStyle->SetStatFontSize(0.075); |
gStyle->SetStatFontSize(0.075); |
173 |
gStyle->SetTitleSize(0.06,"y"); |
gStyle->SetTitleSize(0.06,"y"); |
174 |
gStyle->SetTitleSize(0.055,"x"); |
gStyle->SetTitleSize(0.055,"x"); |
175 |
|
|
176 |
|
//*************************************************************************************** |
177 |
|
// LOOP on each event |
178 |
|
//*************************************************************************************** |
179 |
|
|
180 |
|
if (fromevent!=0) |
181 |
|
printf("\n Scan of events from %i to %i ... \n",minevent,maxevent-1); |
182 |
|
else |
183 |
|
printf("\n Scan of events from %i to %i ... \n",minevent+1,maxevent); |
184 |
|
|
185 |
|
|
186 |
Int_t minev=minevent,maxev=maxevent,hin=0,hfin=0,cin=0,cfin=0; |
Int_t minev=minevent,maxev=maxevent,hin=0,hfin=0,cin=0,cfin=0; |
187 |
TPad *pad[12][countrun] ; //pad for histos |
TPad *pad[12][countnboot]; |
188 |
TGraph *dataletime[12][countrun],*dataletime1[12][countrun]; |
TGraph *dataletime[12][countnboot],*dataletime1[12][countnboot]; |
189 |
TCanvas *DataTimeCanv[countrun]; |
TCanvas *DataTimeCanv[countnboot]; |
190 |
for(Int_t ii=0; ii<countrun;ii++){ |
for(Int_t ii=0; ii<countnboot;ii++){ |
191 |
fromfile<<"FTrkQLook_BASIC File: "<<ffile; |
fromfile<<"FTrkQLook_BASIC File: "<<ffile; |
192 |
isfile<<"DATALENGTH vs. OBT pag"<<ii+1; |
isfile<<"DATALENGTH vs. OBT pag"<<ii+1; |
193 |
DataTimeCanv[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200); |
DataTimeCanv[ii]=new TCanvas(isfile.str().c_str(),isfile.str().c_str(),900,1200); |
219 |
fromfile.str(""); |
fromfile.str(""); |
220 |
isfile.str(""); |
isfile.str(""); |
221 |
|
|
222 |
fromfile<<"The green arrow (if present) probably points out the time of the online calibration"; |
fromfile<<"The green arrow (if present) points out the time of the online calibration"; |
223 |
t->DrawLatex(7.,96.,fromfile.str().c_str()); |
t->DrawLatex(7.,96.,fromfile.str().c_str()); |
224 |
fromfile.str(""); |
fromfile.str(""); |
225 |
|
|
264 |
|
|
265 |
TArrow ar; |
TArrow ar; |
266 |
ar.SetLineColor(3); |
ar.SetLineColor(3); |
|
//********************************************************************************** |
|
|
// Fill Graphs and Histos |
|
|
//********************************************************************************** |
|
267 |
stringstream calus; |
stringstream calus; |
268 |
|
|
269 |
TLatex *t2=new TLatex(); |
TLatex *t2=new TLatex(); |
275 |
Int_t i=0; |
Int_t i=0; |
276 |
Float_t x[MAXSTORAGE], xb[MAXSTORAGE]; |
Float_t x[MAXSTORAGE], xb[MAXSTORAGE]; |
277 |
Float_t yyd[MAXSTORAGE][12],yyb[MAXSTORAGE][12]; |
Float_t yyd[MAXSTORAGE][12],yyb[MAXSTORAGE][12]; |
278 |
|
Int_t countbad[12]; |
279 |
|
Float_t perc=0,xMIN=0.,xMAX=0.; |
280 |
|
for (Int_t n=0; n<12 ; n++) |
281 |
|
countbad[n]=0; |
282 |
|
|
283 |
|
// |
284 |
|
// obtain values of the datalenght |
285 |
for (Int_t ev=minev; ev<maxevent; ev++){ |
for (Int_t ev=minev; ev<maxevent; ev++){ |
286 |
tr->GetEntry(ev); |
tr->GetEntry(ev); |
287 |
ph = eh->GetPscuHeader(); |
ph = eh->GetPscuHeader(); |
288 |
cod = eh->GetCounter(); |
cod = eh->GetCounter(); |
289 |
|
|
290 |
if(ev==minev){ |
if(ev==minev){ |
291 |
if(cod->Get(pctp->CalibTrk1)>0) |
if(cod->Get(pctp->CalibTrk1)>0) cin=cod->Get(pctp->CalibTrk1)-1; |
292 |
cin=cod->Get(pctp->CalibTrk1)-1; |
else cin=cod->Get(pctp->CalibTrk1); |
293 |
else |
if(cin==cfin-1) cin+=1; |
294 |
cin=cod->Get(pctp->CalibTrk1); |
|
295 |
if(cod->Get(pctp->RunHeader)>0) |
if(cod->Get(pctp->RunHeader)>0) hin=cod->Get(pctp->RunHeader)-1; |
296 |
hin=cod->Get(pctp->RunHeader)-1; |
else hin=cod->Get(pctp->RunHeader); |
297 |
else |
if(hin==hfin-1) hin+=1; |
|
hin=cod->Get(pctp->RunHeader); |
|
298 |
} |
} |
299 |
|
|
300 |
if(ev==maxevent-1) maxev=maxevent-1; |
if(ev==maxevent-1) maxev=maxevent-1; |
310 |
i=0; |
i=0; |
311 |
|
|
312 |
for (Int_t n=0; n<12 ; n++){ |
for (Int_t n=0; n<12 ; n++){ |
313 |
perc=0; |
yyb[countbad[n]][i]=0; |
314 |
count=0; |
xb[countbad[n]]= 0; |
|
yyb[count][i]=0; |
|
|
xb[count]= 0; |
|
315 |
|
|
316 |
i=te->DSPnumber[n]-1; |
i=te->DSPnumber[n]-1; |
317 |
|
|
319 |
if(i==6){ |
if(i==6){ |
320 |
if(yyd[(ev-minev)][i]>1500){ |
if(yyd[(ev-minev)][i]>1500){ |
321 |
if(yyd[(ev-minev)][i]<3075){ |
if(yyd[(ev-minev)][i]<3075){ |
322 |
yyb[count][i]= yyd[(ev-minev)][i]; |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
323 |
xb[count]= x[(ev-minev)]; |
xb[countbad[i]]= x[(ev-minev)]; |
324 |
count++; |
countbad[i]+=1; |
325 |
} |
} |
326 |
} |
} |
327 |
} |
} |
328 |
else{ |
else{ |
329 |
if(yyd[(ev-minev)][i]>750){ |
if(yyd[(ev-minev)][i]>750){ |
330 |
if(yyd[(ev-minev)][i]<3075){ |
if(yyd[(ev-minev)][i]<3075){ |
331 |
yyb[count][i]= yyd[(ev-minev)][i]; |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
332 |
xb[count]= x[(ev-minev)]; |
xb[countbad[i]]= x[(ev-minev)]; |
333 |
count++; |
countbad[i]+=1; |
334 |
} |
} |
335 |
} |
} |
336 |
} |
} |
338 |
} |
} |
339 |
} |
} |
340 |
|
|
341 |
Float_t xmin1=0,xmin2=0; |
// |
342 |
xmin1=x[0]-(x[maxev-minev-1]-x[0])/10; |
// define limit for the Xaxis of the graphs |
343 |
xmin2=x[0]-(x[maxev-minev-1]-COBT[cin])/10; |
|
|
// printf("\n%f\t%f \n",x[0],x[maxev-minev-1]); |
|
|
if(xmin1<xmin2) xMIN=xmin1; |
|
|
else if(xmin2<xmin1) xMIN=xmin2; |
|
344 |
xMAX=x[maxev-minev-1]+(x[maxev-minev-1]-x[0])/10; |
xMAX=x[maxev-minev-1]+(x[maxev-minev-1]-x[0])/10; |
345 |
// printf("\nxMIN=%f\txMAX=%f\n",xMIN,xMAX); |
if(xMAX>1000000) xMIN=x[0]-(x[maxev-minev-1]-x[0])/10; |
346 |
if(xMIN<0) xMIN=0; |
if(xMAX<1000000 || xMIN<0) xMIN=0.; |
347 |
|
|
348 |
|
|
349 |
|
// |
350 |
|
// Draw Histos |
351 |
for (Int_t i=0; i<12 ; i++){ |
for (Int_t i=0; i<12 ; i++){ |
352 |
|
|
353 |
Float_t y[maxev-minev],yb[maxev-minev]; |
Float_t y[maxev-minev],yb[maxev-minev]; |
356 |
yb[v]=yyb[v][i]; |
yb[v]=yyb[v][i]; |
357 |
} |
} |
358 |
|
|
359 |
|
if(xMAX<1000000){ |
360 |
|
x[maxev-minev-1]=0.; |
361 |
|
y[maxev-minev-1]=0.; |
362 |
|
} |
363 |
|
|
364 |
if((maxev-minev)>1000){ |
if((maxev-minev)>1000){ |
365 |
perc=(count*100)/(maxev-minev); |
perc=(countbad[i]*100)/(maxev-minev); |
366 |
if(perc>10) pad[i][ii]->SetFillColor(2); |
if(perc>10) pad[i][ii]->SetFillColor(2); |
367 |
else pad[i][ii]->SetFillColor(10); |
else pad[i][ii]->SetFillColor(10); |
368 |
} |
} |
369 |
else{ |
else{ |
370 |
if(count>=100) pad[i][ii]->SetFillColor(2); |
if(countbad[i]>=100) pad[i][ii]->SetFillColor(2); |
371 |
else pad[i][ii]->SetFillColor(10); |
else pad[i][ii]->SetFillColor(10); |
372 |
} |
} |
373 |
|
|
384 |
dataletime[i][ii]->GetYaxis()->SetTitle("datalength (Word 13 bit)"); |
dataletime[i][ii]->GetYaxis()->SetTitle("datalength (Word 13 bit)"); |
385 |
dataletime[i][ii]->GetYaxis()->CenterTitle(); |
dataletime[i][ii]->GetYaxis()->CenterTitle(); |
386 |
if(i==6) dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4500); |
if(i==6) dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4500); |
387 |
else dataletime[i][ii]->GetYaxis()->SetRangeUser(0,3500); |
else dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4000); |
388 |
dataletime[i][ii]->SetMarkerStyle(21); |
dataletime[i][ii]->SetMarkerStyle(21); |
389 |
if((maxev-minev)<50) dataletime[i][ii]->SetMarkerSize(0.5); |
if((maxev-minev)<50) dataletime[i][ii]->SetMarkerSize(0.5); |
390 |
else dataletime[i][ii]->SetMarkerSize(0.3); |
else dataletime[i][ii]->SetMarkerSize(0.3); |
393 |
|
|
394 |
|
|
395 |
if((maxev-minev)>1000 && perc>10){ |
if((maxev-minev)>1000 && perc>10){ |
396 |
dataletime1[i][ii]= new TGraph(count,xb,yb); |
dataletime1[i][ii]= new TGraph(countbad[i],xb,yb); |
397 |
dataletime1[i][ii]->SetMarkerStyle(21); |
dataletime1[i][ii]->SetMarkerStyle(21); |
398 |
if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); |
if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); |
399 |
else dataletime1[i][ii]->SetMarkerSize(0.3); |
else dataletime1[i][ii]->SetMarkerSize(0.3); |
400 |
dataletime1[i][ii]->SetMarkerColor(2); |
dataletime1[i][ii]->SetMarkerColor(2); |
401 |
dataletime1[i][ii]->Draw("psame"); |
dataletime1[i][ii]->Draw("psame"); |
402 |
} |
} |
403 |
else if((maxev-minev)<1000 && count>=100){ |
else if((maxev-minev)<1000 && countbad[i]>=100){ |
404 |
dataletime1[i][ii]= new TGraph(count,xb,yb); |
dataletime1[i][ii]= new TGraph(countbad[i],xb,yb); |
405 |
dataletime1[i][ii]->SetMarkerStyle(21); |
dataletime1[i][ii]->SetMarkerStyle(21); |
406 |
if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); |
if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); |
407 |
else dataletime1[i][ii]->SetMarkerSize(0.3); |
else dataletime1[i][ii]->SetMarkerSize(0.3); |
420 |
li.SetLineWidth(1); |
li.SetLineWidth(1); |
421 |
for(Int_t j=hin;j<hfin;j++){ |
for(Int_t j=hin;j<hfin;j++){ |
422 |
if(i==6) li.DrawLine(HOBT[j],0.,HOBT[j],4500.); |
if(i==6) li.DrawLine(HOBT[j],0.,HOBT[j],4500.); |
423 |
else li.DrawLine(HOBT[j],0.,HOBT[j],3500.); |
else li.DrawLine(HOBT[j],0.,HOBT[j],4000.); |
424 |
if(trk_cal_us[j]==104){ |
if(trk_cal_us[j]==104){ |
425 |
calus<<"D"; |
calus<<"D"; |
426 |
t2->SetTextColor(6); |
t2->SetTextColor(6); |
427 |
if(i==6) t2->DrawLatex(HOBT[j],4350.,calus.str().c_str()); |
if(i==6) t2->DrawLatex(HOBT[j],4350.,calus.str().c_str()); |
428 |
else t2->DrawLatex(HOBT[j],3350.,calus.str().c_str()); |
else t2->DrawLatex(HOBT[j],3850.,calus.str().c_str()); |
429 |
calus.str(""); |
calus.str(""); |
430 |
} |
} |
431 |
else{ |
else{ |
432 |
calus<<"O"; |
calus<<"O"; |
433 |
t2->SetTextColor(3); |
t2->SetTextColor(3); |
434 |
if(i==6) t2->DrawLatex(HOBT[j],4350.,calus.str().c_str()); |
if(i==6) t2->DrawLatex(HOBT[j],4350.,calus.str().c_str()); |
435 |
else t2->DrawLatex(HOBT[j],3350.,calus.str().c_str()); |
else t2->DrawLatex(HOBT[j],3850.,calus.str().c_str()); |
436 |
calus.str(""); |
calus.str(""); |
437 |
} |
} |
438 |
} |
} |
440 |
if(i==6) ar.DrawArrow(COBT[j],1700.,COBT[j],2700.,0.01,"<"); |
if(i==6) ar.DrawArrow(COBT[j],1700.,COBT[j],2700.,0.01,"<"); |
441 |
else ar.DrawArrow(COBT[j],1000.,COBT[j],2000.,0.01,"<"); |
else ar.DrawArrow(COBT[j],1000.,COBT[j],2000.,0.01,"<"); |
442 |
} |
} |
443 |
|
|
444 |
oss.str(""); |
oss.str(""); |
445 |
DataTimeCanv[ii]->Update(); |
DataTimeCanv[ii]->Update(); |
446 |
} |
} |
447 |
|
|
448 |
minev=maxev; |
minev=maxev; |
|
// printf("\ncountrun=%d\n",ii); |
|
449 |
if(maxev==maxevent-1) { |
if(maxev==maxevent-1) { |
450 |
countrun=ii+1; |
countnboot=ii+1; |
451 |
break; |
break; |
452 |
} |
} |
453 |
} |
} |
454 |
printf("... end of packets. \n"); |
printf("... end of packets. \n"); |
455 |
|
|
456 |
//************************************************************************* |
//************************************************************************* |
457 |
// Save output Files |
// Save output Files |
458 |
//************************************************************************* |
//************************************************************************* |
459 |
stringstream nom1,nom2,nom3; |
stringstream nom1,nom2,nom3; |
460 |
|
|
461 |
for(Int_t fl=0;fl<countrun;fl++){ |
for(Int_t fl=0;fl<countnboot;fl++){ |
462 |
if(countrun==1){ |
if(countnboot==1){ |
463 |
nom1<<ffile<<"_FTrkQLook_BASIC."<<outfile.Data(); |
nom1<<ffile<<"_FTrkQLook_BASIC."<<outfile.Data(); |
464 |
DataTimeCanv[fl]->Print(out+nom1.str().c_str()); |
DataTimeCanv[fl]->Print(out+nom1.str().c_str()); |
465 |
nom1.str(""); |
nom1.str(""); |
466 |
} |
} |
467 |
|
|
468 |
if(countrun>=2){ |
if(countnboot>=2){ |
469 |
if(!strcmp(outfile.Data(),"ps") || !strcmp(outfile.Data(),"pdf")){ |
if(!strcmp(outfile.Data(),"ps") || !strcmp(outfile.Data(),"pdf")){ |
470 |
nom1.str(""); |
nom1.str(""); |
471 |
nom2.str(""); |
nom2.str(""); |
474 |
nom2<<ffile<<"_FTrkQLook_BASIC.ps"; |
nom2<<ffile<<"_FTrkQLook_BASIC.ps"; |
475 |
nom3<<ffile<<"_FTrkQLook_BASIC.ps)"; |
nom3<<ffile<<"_FTrkQLook_BASIC.ps)"; |
476 |
if(fl==0) DataTimeCanv[fl]->Print(out+nom1.str().c_str(),"portrait"); |
if(fl==0) DataTimeCanv[fl]->Print(out+nom1.str().c_str(),"portrait"); |
477 |
else if(fl==countrun-1) DataTimeCanv[fl]->Print(out+nom3.str().c_str(),"portrait"); |
else if(fl==countnboot-1) DataTimeCanv[fl]->Print(out+nom3.str().c_str(),"portrait"); |
478 |
else DataTimeCanv[fl]->Print(out+nom2.str().c_str(),"portrait"); |
else DataTimeCanv[fl]->Print(out+nom2.str().c_str(),"portrait"); |
479 |
|
|
480 |
} |
} |
486 |
} |
} |
487 |
} |
} |
488 |
|
|
489 |
if(!strcmp(outfile.Data(),"pdf") && countrun>=2){ |
// |
490 |
|
// Convert ps to pdf if required |
491 |
|
if(!strcmp(outfile.Data(),"pdf") && countnboot>=2){ |
492 |
stringstream com; |
stringstream com; |
493 |
com<<"ps2pdf13 "<<out<<ffile<<"_FTrkQLook_BASIC.ps "<<out<<ffile<<"_FTrkQLook_BASIC.pdf"; |
com<<"ps2pdf13 "<<out<<ffile<<"_FTrkQLook_BASIC.ps "<<out<<ffile<<"_FTrkQLook_BASIC.pdf"; |
494 |
system(com.str().c_str()); |
system(com.str().c_str()); |