1 |
/** |
/** |
2 |
* FTrkQLook_BASIC.cpp |
* FTrkQLook_BASIC.cxx |
3 |
* |
* |
4 |
* autor: D.Fedele |
* autor: D.Fedele |
5 |
* version 3.0 |
* version v1r09 |
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 |
17 |
#include <TCanvas.h> |
#include <TCanvas.h> |
18 |
#include <TGraph.h> |
#include <TGraph.h> |
19 |
#include <TStyle.h> |
#include <TStyle.h> |
20 |
|
#include <TFile.h> |
21 |
#include <TTree.h> |
#include <TTree.h> |
22 |
#include <TArrow.h> |
#include <TArrow.h> |
23 |
// |
// |
30 |
// |
// |
31 |
#define MAXSTORAGE 50000 |
#define MAXSTORAGE 50000 |
32 |
|
|
|
void stringcopy(TString& s1, const TString& s2, Int_t from=0, Int_t to=0){ |
|
|
if ( to == 0 ){ |
|
|
Int_t t2length = s2.Length(); |
|
|
s1 = ""; |
|
|
to = t2length; |
|
|
}; |
|
|
for (Int_t i = from; i<to; i++){ |
|
|
s1.Append(s2[i],1); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
33 |
void FTrkQLook_BASIC(TString file,Int_t fromevent,Int_t toevent, TString outdir,TString outfile) |
void FTrkQLook_BASIC(TString file,Int_t fromevent,Int_t toevent, TString outdir,TString outfile) |
34 |
{ |
{ |
35 |
// |
// |
36 |
// obtain information about the data file and select the output dir |
// obtain information about the data file and select the output dir |
37 |
const string filepath=file.Data(); |
Int_t dwpos = file.Last('/'); |
38 |
Int_t dwpos = filepath.rfind("/"); |
Int_t dwpos1 = file.Last('.'); |
|
Int_t dwpos1 = filepath.find(".root"); |
|
|
TString fpath=(filepath.c_str()); |
|
39 |
TString base,ffile ; |
TString base,ffile ; |
40 |
stringcopy(ffile,fpath,dwpos+1,dwpos1); |
ffile=file(dwpos+1,dwpos1-(dwpos+1)); |
41 |
stringcopy(base,fpath,0,dwpos); |
if(dwpos>0) base=file(0,dwpos); |
|
if(dwpos>0) base+="/"; |
|
42 |
|
|
43 |
TString out; |
TString out; |
44 |
if(outdir.Length()==0){ |
if(outdir.Length()==0){ |
46 |
}else{ |
}else{ |
47 |
out = outdir; |
out = outdir; |
48 |
} |
} |
49 |
|
if(out.Last('/')+1<out.Length()) out+="/"; |
50 |
|
|
51 |
// |
// |
52 |
// inizialise the variables and open the file |
// inizialise the variables and open the file |
103 |
} else if (toevent > nevent) { |
} else if (toevent > nevent) { |
104 |
maxevent = nevent; |
maxevent = nevent; |
105 |
} else { |
} else { |
106 |
maxevent = toevent+1; |
maxevent = nevent; |
107 |
} |
} |
108 |
nevent=maxevent-minevent ; |
nevent=maxevent-minevent ; |
109 |
} |
} |
113 |
stringstream oss,fromfile,isfile; |
stringstream oss,fromfile,isfile; |
114 |
// |
// |
115 |
// information about the RunHeader |
// information about the RunHeader |
116 |
Int_t HOBT[neventH]; |
ULong64_t HOBT[neventH]; |
117 |
Int_t trk_cal_us[neventH]; |
Int_t trk_cal_us[neventH]; |
118 |
for (Int_t vi=0; vi<neventH;vi++){ |
for (Int_t vi=0; vi<neventH;vi++){ |
119 |
HOBT[vi]=0; |
HOBT[vi]=0; |
131 |
if((HOBT[ev]<HOBT[ev-1]) && ev>0) |
if((HOBT[ev]<HOBT[ev-1]) && ev>0) |
132 |
countnboot+=1; |
countnboot+=1; |
133 |
} |
} |
134 |
countnboot+=2*(Int_t)nevent/MAXSTORAGE; |
countnboot+=(Int_t)(2*nevent/MAXSTORAGE); |
135 |
// printf("\ncountnboot=%d\n",countnboot); |
// printf("\ncountnboot=%d\n",countnboot); |
136 |
|
|
137 |
// |
// |
138 |
// information about calibration OBT |
// information about calibration OBT |
139 |
Int_t COBT[neventC]; |
ULong64_t COBT[neventC]; |
140 |
for (Int_t vi=0; vi<neventC;vi++){ |
for (Int_t vi=0; vi<neventC;vi++){ |
141 |
COBT[vi]=0; |
COBT[vi]=0; |
142 |
} |
} |
260 |
t2->SetTextSize(0.08); |
t2->SetTextSize(0.08); |
261 |
|
|
262 |
Int_t i=0; |
Int_t i=0; |
263 |
Float_t x[MAXSTORAGE], xb[MAXSTORAGE]; |
Long64_t x[MAXSTORAGE], xb[MAXSTORAGE]; |
264 |
Float_t yyd[MAXSTORAGE][12],yyb[MAXSTORAGE][12]; |
Float_t yyd[MAXSTORAGE][12],yyb[MAXSTORAGE][12]; |
265 |
Int_t countbad[12]; |
Int_t countbad[12]; |
266 |
Float_t perc=0,xMIN=0.,xMAX=0.; |
Float_t perc=0,xMIN=0.,xMAX=0.; |
296 |
x[(ev-minev)]= ph->GetOrbitalTime(); |
x[(ev-minev)]= ph->GetOrbitalTime(); |
297 |
i=0; |
i=0; |
298 |
|
|
299 |
for (Int_t n=0; n<12 ; n++){ |
for (Int_t n=0; n<12 ; n++){ |
300 |
yyb[countbad[n]][i]=0; |
i=te->DSPnumber[n]-1; |
301 |
xb[countbad[n]]= 0; |
if(i>=0){ |
302 |
|
if(i<12){ |
303 |
i=te->DSPnumber[n]-1; |
yyb[countbad[i]][i]=0; |
304 |
|
xb[countbad[i]]= 0; |
305 |
yyd[(ev-minev)][i]=te->DATAlength[n]; |
|
306 |
if(i==6){ |
yyd[(ev-minev)][i]=te->DATAlength[n]; |
307 |
if(yyd[(ev-minev)][i]>1500){ |
if(i==6){ |
308 |
if(yyd[(ev-minev)][i]<3075){ |
if(yyd[(ev-minev)][i]>1500){ |
309 |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
if(yyd[(ev-minev)][i]<3075){ |
310 |
xb[countbad[i]]= x[(ev-minev)]; |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
311 |
countbad[i]+=1; |
xb[countbad[i]]= x[(ev-minev)]; |
312 |
|
countbad[i]+=1; |
313 |
|
} |
314 |
|
} |
315 |
} |
} |
316 |
} |
else{ |
317 |
} |
if(yyd[(ev-minev)][i]>750){ |
318 |
else{ |
if(yyd[(ev-minev)][i]<3075){ |
319 |
if(yyd[(ev-minev)][i]>750){ |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
320 |
if(yyd[(ev-minev)][i]<3075){ |
xb[countbad[i]]= x[(ev-minev)]; |
321 |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
countbad[i]+=1; |
322 |
xb[countbad[i]]= x[(ev-minev)]; |
} |
323 |
countbad[i]+=1; |
} |
324 |
} |
} |
325 |
} |
} |
326 |
} |
} |
327 |
} |
} |
328 |
} |
} |
329 |
} |
} |
330 |
|
|
338 |
|
|
339 |
// |
// |
340 |
// Draw Histos |
// Draw Histos |
341 |
for (Int_t i=0; i<12 ; i++){ |
for (Int_t n=0; n<12 ; n++){ |
342 |
|
|
343 |
Float_t y[maxev-minev],yb[maxev-minev]; |
Double_t yd[maxev-minev],ybd[maxev-minev]; |
344 |
|
Double_t xd[maxev-minev],xbd[maxev-minev]; |
345 |
|
|
346 |
for(Int_t v=0;v<maxev-minev;v++){ |
for(Int_t v=0;v<maxev-minev;v++){ |
347 |
y[v]=yyd[v][i]; |
yd[v]=(Double_t)yyd[v][n]; |
348 |
yb[v]=yyb[v][i]; |
ybd[v]=(Double_t)yyb[v][n]; |
349 |
|
xd[v]=(Double_t)x[v]; |
350 |
|
xbd[v]=(Double_t)xb[v]; |
351 |
} |
} |
352 |
|
|
353 |
if(xMAX<1000000){ |
if(xMAX<1000000){ |
354 |
x[maxev-minev-1]=0.; |
xd[maxev-minev-1]=0; |
355 |
y[maxev-minev-1]=0.; |
yd[maxev-minev-1]=0.; |
356 |
} |
} |
357 |
|
|
358 |
if((maxev-minev)>1000){ |
if((maxev-minev)>1000){ |
359 |
perc=(countbad[i]*100)/(maxev-minev); |
perc=(countbad[n]*100)/(maxev-minev); |
360 |
if(perc>10) pad[i][ii]->SetFillColor(2); |
if(perc>10) pad[n][ii]->SetFillColor(2); |
361 |
else pad[i][ii]->SetFillColor(10); |
else pad[n][ii]->SetFillColor(10); |
362 |
|
|
363 |
} |
} |
364 |
else{ |
else{ |
365 |
if(countbad[i]>=100) pad[i][ii]->SetFillColor(2); |
if(countbad[n]>=100) pad[n][ii]->SetFillColor(2); |
366 |
else pad[i][ii]->SetFillColor(10); |
else pad[n][ii]->SetFillColor(10); |
367 |
} |
} |
368 |
|
|
369 |
oss<<"DSP "<<i+1; |
oss<<"DSP "<<n+1; |
370 |
DataTimeCanv[ii]->cd(); |
DataTimeCanv[ii]->cd(); |
371 |
pad[i][ii]->SetFrameFillColor(10); |
pad[n][ii]->SetFrameFillColor(10); |
372 |
pad[i][ii]->Draw(); |
pad[n][ii]->Draw(); |
373 |
pad[i][ii]->cd(); |
pad[n][ii]->cd(); |
374 |
dataletime[i][ii]= new TGraph((maxev-minev),x,y); |
dataletime[n][ii]= new TGraph((maxev-minev),xd,yd); |
375 |
dataletime[i][ii]->SetTitle(oss.str().c_str()); |
dataletime[n][ii]->SetTitle(oss.str().c_str()); |
376 |
dataletime[i][ii]->GetXaxis()->SetTitle("OBT (ms)"); |
dataletime[n][ii]->GetXaxis()->SetTitle("OBT (ms)"); |
377 |
dataletime[i][ii]->GetXaxis()->CenterTitle(); |
dataletime[n][ii]->GetXaxis()->CenterTitle(); |
378 |
dataletime[i][ii]->GetXaxis()->SetRangeUser(xMIN,xMAX); |
dataletime[n][ii]->GetXaxis()->SetRangeUser(xMIN,xMAX); |
379 |
dataletime[i][ii]->GetYaxis()->SetTitle("datalength (Word 13 bit)"); |
dataletime[n][ii]->GetYaxis()->SetTitle("datalength (Word 13 bit)"); |
380 |
dataletime[i][ii]->GetYaxis()->CenterTitle(); |
dataletime[n][ii]->GetYaxis()->CenterTitle(); |
381 |
if(i==6) dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4500); |
if(i==6) dataletime[n][ii]->GetYaxis()->SetRangeUser(0,4500); |
382 |
else dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4000); |
else dataletime[n][ii]->GetYaxis()->SetRangeUser(0,4000); |
383 |
dataletime[i][ii]->SetMarkerStyle(21); |
dataletime[n][ii]->SetMarkerStyle(21); |
384 |
if((maxev-minev)<50) dataletime[i][ii]->SetMarkerSize(0.5); |
if((maxev-minev)<50) dataletime[n][ii]->SetMarkerSize(0.5); |
385 |
else dataletime[i][ii]->SetMarkerSize(0.3); |
else dataletime[n][ii]->SetMarkerSize(0.1); |
386 |
dataletime[i][ii]->SetMarkerColor(4); |
dataletime[n][ii]->SetMarkerColor(4); |
387 |
dataletime[i][ii]->Draw("ap"); |
dataletime[n][ii]->Draw("ap"); |
388 |
|
|
389 |
|
|
390 |
if((maxev-minev)>1000 && perc>10){ |
if((maxev-minev)>1000 && perc>10){ |
391 |
dataletime1[i][ii]= new TGraph(countbad[i],xb,yb); |
dataletime1[n][ii]= new TGraph(countbad[n],xbd,ybd); |
392 |
dataletime1[i][ii]->SetMarkerStyle(21); |
dataletime1[n][ii]->SetMarkerStyle(21); |
393 |
if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); |
dataletime1[n][ii]->SetMarkerSize(0.1); |
394 |
else dataletime1[i][ii]->SetMarkerSize(0.3); |
dataletime1[n][ii]->SetMarkerColor(2); |
395 |
dataletime1[i][ii]->SetMarkerColor(2); |
dataletime1[n][ii]->Draw("psame"); |
396 |
dataletime1[i][ii]->Draw("psame"); |
} |
397 |
} |
else if((maxev-minev)<1000 && countbad[n]>=100){ |
398 |
else if((maxev-minev)<1000 && countbad[i]>=100){ |
dataletime1[n][ii]= new TGraph(countbad[n],xbd,ybd); |
399 |
dataletime1[i][ii]= new TGraph(countbad[i],xb,yb); |
dataletime1[n][ii]->SetMarkerStyle(21); |
400 |
dataletime1[i][ii]->SetMarkerStyle(21); |
if((maxev-minev)<50) dataletime1[n][ii]->SetMarkerSize(0.5); |
401 |
if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); |
else dataletime1[n][ii]->SetMarkerSize(0.1); |
402 |
else dataletime1[i][ii]->SetMarkerSize(0.3); |
dataletime1[n][ii]->SetMarkerColor(2); |
403 |
dataletime1[i][ii]->SetMarkerColor(2); |
dataletime1[n][ii]->Draw("psame"); |
|
dataletime1[i][ii]->Draw("psame"); |
|
404 |
} |
} |
405 |
li.SetLineColor(1); |
li.SetLineColor(1); |
406 |
li.SetLineStyle(1); |
li.SetLineStyle(1); |