| 1 |
/** |
/** |
| 2 |
* FTrkQLook_BASIC.cpp |
* FTrkQLook_BASIC.cxx |
| 3 |
* |
* |
| 4 |
* autor: D.Fedele |
* autor: D.Fedele |
| 5 |
* version 3.0 |
* version v1r12 |
| 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 |
|
#include <TAxis.h> |
| 24 |
|
#include <TROOT.h> |
| 25 |
|
#include <cstdlib> |
| 26 |
|
#include <sys/stat.h> |
| 27 |
// |
// |
| 28 |
#include <physics/tracker/TrackerEvent.h> |
#include <physics/tracker/TrackerEvent.h> |
| 29 |
#include <PscuHeader.h> |
#include <PscuHeader.h> |
| 34 |
// |
// |
| 35 |
#define MAXSTORAGE 50000 |
#define MAXSTORAGE 50000 |
| 36 |
|
|
|
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); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
| 37 |
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) |
| 38 |
{ |
{ |
| 39 |
// |
// |
| 40 |
// obtain information about the data file and select the output dir |
// obtain information about the data file and select the output dir |
| 41 |
const string filepath=file.Data(); |
Int_t dwpos = file.Last('/'); |
| 42 |
Int_t dwpos = filepath.rfind("/"); |
Int_t dwpos1 = file.Last('.'); |
|
Int_t dwpos1 = filepath.find(".root"); |
|
|
TString fpath=(filepath.c_str()); |
|
| 43 |
TString base,ffile ; |
TString base,ffile ; |
| 44 |
stringcopy(ffile,fpath,dwpos+1,dwpos1); |
ffile=file(dwpos+1,dwpos1-(dwpos+1)); |
| 45 |
stringcopy(base,fpath,0,dwpos); |
if(dwpos>0) base=file(0,dwpos); |
|
if(dwpos>0) base+="/"; |
|
| 46 |
|
|
| 47 |
TString out; |
TString out; |
| 48 |
if(outdir.Length()==0){ |
if(outdir.Length()==0){ |
| 50 |
}else{ |
}else{ |
| 51 |
out = outdir; |
out = outdir; |
| 52 |
} |
} |
| 53 |
|
if(out.Last('/')+1<out.Length()) out+="/"; |
| 54 |
|
|
| 55 |
// |
// |
| 56 |
// inizialise the variables and open the file |
// inizialise the variables and open the file |
| 107 |
} else if (toevent > nevent) { |
} else if (toevent > nevent) { |
| 108 |
maxevent = nevent; |
maxevent = nevent; |
| 109 |
} else { |
} else { |
| 110 |
maxevent = toevent+1; |
maxevent = nevent; |
| 111 |
} |
} |
| 112 |
nevent=maxevent-minevent ; |
nevent=maxevent-minevent ; |
| 113 |
} |
} |
| 117 |
stringstream oss,fromfile,isfile; |
stringstream oss,fromfile,isfile; |
| 118 |
// |
// |
| 119 |
// information about the RunHeader |
// information about the RunHeader |
| 120 |
Int_t HOBT[neventH]; |
ULong_t HOBT[neventH]; |
| 121 |
Int_t trk_cal_us[neventH]; |
Int_t trk_cal_us[neventH]; |
| 122 |
for (Int_t vi=0; vi<neventH;vi++){ |
for (Int_t vi=0; vi<neventH;vi++){ |
| 123 |
HOBT[vi]=0; |
HOBT[vi]=0; |
| 135 |
if((HOBT[ev]<HOBT[ev-1]) && ev>0) |
if((HOBT[ev]<HOBT[ev-1]) && ev>0) |
| 136 |
countnboot+=1; |
countnboot+=1; |
| 137 |
} |
} |
| 138 |
countnboot+=2*(Int_t)nevent/MAXSTORAGE; |
countnboot+=(Int_t)(2*nevent/MAXSTORAGE); |
| 139 |
// printf("\ncountnboot=%d\n",countnboot); |
// printf("\ncountnboot=%d\n",countnboot); |
| 140 |
|
|
| 141 |
// |
// |
| 142 |
// information about calibration OBT |
// information about calibration OBT |
| 143 |
Int_t COBT[neventC]; |
ULong_t COBT[neventC]; |
| 144 |
for (Int_t vi=0; vi<neventC;vi++){ |
for (Int_t vi=0; vi<neventC;vi++){ |
| 145 |
COBT[vi]=0; |
COBT[vi]=0; |
| 146 |
} |
} |
| 264 |
t2->SetTextSize(0.08); |
t2->SetTextSize(0.08); |
| 265 |
|
|
| 266 |
Int_t i=0; |
Int_t i=0; |
| 267 |
Float_t x[MAXSTORAGE], xb[MAXSTORAGE]; |
ULong_t x[MAXSTORAGE], xb[MAXSTORAGE]; |
| 268 |
Float_t yyd[MAXSTORAGE][12],yyb[MAXSTORAGE][12]; |
Float_t yyd[MAXSTORAGE][12],yyb[MAXSTORAGE][12]; |
| 269 |
Int_t countbad[12]; |
Int_t countbad[12]; |
| 270 |
Float_t perc=0,xMIN=0.,xMAX=0.; |
Float_t perc=0; |
| 271 |
|
Double_t xMIN=0.,xMAX=0.; |
| 272 |
for (Int_t n=0; n<12 ; n++) |
for (Int_t n=0; n<12 ; n++) |
| 273 |
countbad[n]=0; |
countbad[n]=0; |
| 274 |
|
|
| 291 |
|
|
| 292 |
if(ev==maxevent-1) maxev=maxevent-1; |
if(ev==maxevent-1) maxev=maxevent-1; |
| 293 |
|
|
| 294 |
if((ph->GetOrbitalTime()<x[ev-minev-1] && ev-minev!=0) || ev-minev==MAXSTORAGE){ |
if(((ULong_t)ph->GetOrbitalTime()<x[ev-minev-1] && ev-minev!=0) || ev-minev==MAXSTORAGE){ |
| 295 |
maxev=ev; |
maxev=ev; |
| 296 |
break; |
break; |
| 297 |
} |
} |
| 301 |
x[(ev-minev)]= ph->GetOrbitalTime(); |
x[(ev-minev)]= ph->GetOrbitalTime(); |
| 302 |
i=0; |
i=0; |
| 303 |
|
|
| 304 |
for (Int_t n=0; n<12 ; n++){ |
for (Int_t n=0; n<12 ; n++){ |
| 305 |
yyb[countbad[n]][i]=0; |
i=te->DSPnumber[n]-1; |
| 306 |
xb[countbad[n]]= 0; |
if(i>=0){ |
| 307 |
|
if(i<12){ |
| 308 |
i=te->DSPnumber[n]-1; |
yyb[countbad[i]][i]=0; |
| 309 |
|
xb[countbad[i]]= 0; |
| 310 |
yyd[(ev-minev)][i]=te->DATAlength[n]; |
|
| 311 |
if(i==6){ |
yyd[(ev-minev)][i]=te->DATAlength[n]; |
| 312 |
if(yyd[(ev-minev)][i]>1500){ |
if(i==6){ |
| 313 |
if(yyd[(ev-minev)][i]<3075){ |
if(yyd[(ev-minev)][i]>1500){ |
| 314 |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
if(yyd[(ev-minev)][i]<3075){ |
| 315 |
xb[countbad[i]]= x[(ev-minev)]; |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
| 316 |
countbad[i]+=1; |
xb[countbad[i]]= x[(ev-minev)]; |
| 317 |
|
countbad[i]+=1; |
| 318 |
|
} |
| 319 |
|
} |
| 320 |
} |
} |
| 321 |
} |
else{ |
| 322 |
} |
if(yyd[(ev-minev)][i]>750){ |
| 323 |
else{ |
if(yyd[(ev-minev)][i]<3075){ |
| 324 |
if(yyd[(ev-minev)][i]>750){ |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
| 325 |
if(yyd[(ev-minev)][i]<3075){ |
xb[countbad[i]]= x[(ev-minev)]; |
| 326 |
yyb[countbad[i]][i]= yyd[(ev-minev)][i]; |
countbad[i]+=1; |
| 327 |
xb[countbad[i]]= x[(ev-minev)]; |
} |
| 328 |
countbad[i]+=1; |
} |
| 329 |
} |
} |
| 330 |
} |
} |
| 331 |
} |
} |
| 332 |
} |
} |
| 333 |
} |
} |
| 334 |
} |
} |
| 335 |
|
|
| 338 |
|
|
| 339 |
xMAX=x[maxev-minev-1]+(x[maxev-minev-1]-x[0])/10; |
xMAX=x[maxev-minev-1]+(x[maxev-minev-1]-x[0])/10; |
| 340 |
if(xMAX>1000000) xMIN=x[0]-(x[maxev-minev-1]-x[0])/10; |
if(xMAX>1000000) xMIN=x[0]-(x[maxev-minev-1]-x[0])/10; |
| 341 |
if(xMAX<1000000 || xMIN<0) xMIN=0.; |
if(xMAX<1000000 || xMIN<0) xMIN=0.; |
| 342 |
|
if(xMIN==xMAX) xMIN=x[0] * x[0]/xMAX; |
| 343 |
|
|
| 344 |
|
|
| 345 |
// |
// |
| 346 |
// Draw Histos |
// Draw Histos |
| 347 |
for (Int_t i=0; i<12 ; i++){ |
for (Int_t n=0; n<12 ; n++){ |
| 348 |
|
|
| 349 |
Float_t y[maxev-minev],yb[maxev-minev]; |
Double_t yd[maxev-minev],ybd[maxev-minev]; |
| 350 |
|
Double_t xd[maxev-minev],xbd[maxev-minev]; |
| 351 |
|
|
| 352 |
for(Int_t v=0;v<maxev-minev;v++){ |
for(Int_t v=0;v<maxev-minev;v++){ |
| 353 |
y[v]=yyd[v][i]; |
yd[v]=(Double_t)yyd[v][n]; |
| 354 |
yb[v]=yyb[v][i]; |
ybd[v]=(Double_t)yyb[v][n]; |
| 355 |
|
xd[v]=(Double_t)x[v]; |
| 356 |
|
xbd[v]=(Double_t)xb[v]; |
| 357 |
} |
} |
| 358 |
|
|
| 359 |
if(xMAX<1000000){ |
if(xMAX<1000000){ |
| 360 |
x[maxev-minev-1]=0.; |
xd[maxev-minev-1]=0; |
| 361 |
y[maxev-minev-1]=0.; |
yd[maxev-minev-1]=0.; |
| 362 |
} |
} |
| 363 |
|
|
| 364 |
if((maxev-minev)>1000){ |
if((maxev-minev)>1000){ |
| 365 |
perc=(countbad[i]*100)/(maxev-minev); |
perc=(countbad[n]*100)/(maxev-minev); |
| 366 |
if(perc>10) pad[i][ii]->SetFillColor(2); |
if(perc>10) pad[n][ii]->SetFillColor(2); |
| 367 |
else pad[i][ii]->SetFillColor(10); |
else pad[n][ii]->SetFillColor(10); |
| 368 |
|
|
| 369 |
} |
} |
| 370 |
else{ |
else{ |
| 371 |
if(countbad[i]>=100) pad[i][ii]->SetFillColor(2); |
if(countbad[n]>=100) pad[n][ii]->SetFillColor(2); |
| 372 |
else pad[i][ii]->SetFillColor(10); |
else pad[n][ii]->SetFillColor(10); |
| 373 |
} |
} |
| 374 |
|
|
| 375 |
oss<<"DSP "<<i+1; |
oss<<"DSP "<<n+1; |
| 376 |
DataTimeCanv[ii]->cd(); |
DataTimeCanv[ii]->cd(); |
| 377 |
pad[i][ii]->SetFrameFillColor(10); |
pad[n][ii]->SetFrameFillColor(10); |
| 378 |
pad[i][ii]->Draw(); |
pad[n][ii]->Draw(); |
| 379 |
pad[i][ii]->cd(); |
pad[n][ii]->cd(); |
| 380 |
dataletime[i][ii]= new TGraph((maxev-minev),x,y); |
dataletime[n][ii]= new TGraph((maxev-minev),xd,yd); |
| 381 |
dataletime[i][ii]->SetTitle(oss.str().c_str()); |
if(maxev-minev==1) dataletime[n][ii]->GetXaxis()->SetNdivisions(-501); |
| 382 |
dataletime[i][ii]->GetXaxis()->SetTitle("OBT (ms)"); |
dataletime[n][ii]->SetTitle(oss.str().c_str()); |
| 383 |
dataletime[i][ii]->GetXaxis()->CenterTitle(); |
dataletime[n][ii]->GetXaxis()->SetTitle("OBT (ms)"); |
| 384 |
dataletime[i][ii]->GetXaxis()->SetRangeUser(xMIN,xMAX); |
dataletime[n][ii]->GetXaxis()->CenterTitle(); |
| 385 |
dataletime[i][ii]->GetYaxis()->SetTitle("datalength (Word 13 bit)"); |
dataletime[n][ii]->GetXaxis()->SetRangeUser(xMIN,xMAX); |
| 386 |
dataletime[i][ii]->GetYaxis()->CenterTitle(); |
dataletime[n][ii]->GetYaxis()->SetTitle("datalength (Word 13 bit)"); |
| 387 |
if(i==6) dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4500); |
dataletime[n][ii]->GetYaxis()->CenterTitle(); |
| 388 |
else dataletime[i][ii]->GetYaxis()->SetRangeUser(0,4000); |
if(i==6) dataletime[n][ii]->GetYaxis()->SetRangeUser(0,4500); |
| 389 |
dataletime[i][ii]->SetMarkerStyle(21); |
else dataletime[n][ii]->GetYaxis()->SetRangeUser(0,4000); |
| 390 |
if((maxev-minev)<50) dataletime[i][ii]->SetMarkerSize(0.5); |
dataletime[n][ii]->SetMarkerStyle(21); |
| 391 |
else dataletime[i][ii]->SetMarkerSize(0.3); |
if((maxev-minev)<50) dataletime[n][ii]->SetMarkerSize(0.5); |
| 392 |
dataletime[i][ii]->SetMarkerColor(4); |
else dataletime[n][ii]->SetMarkerSize(0.1); |
| 393 |
dataletime[i][ii]->Draw("ap"); |
dataletime[n][ii]->SetMarkerColor(4); |
| 394 |
|
dataletime[n][ii]->Draw("ap"); |
| 395 |
|
|
| 396 |
|
|
| 397 |
if((maxev-minev)>1000 && perc>10){ |
if((maxev-minev)>1000 && perc>10){ |
| 398 |
dataletime1[i][ii]= new TGraph(countbad[i],xb,yb); |
dataletime1[n][ii]= new TGraph(countbad[n],xbd,ybd); |
| 399 |
dataletime1[i][ii]->SetMarkerStyle(21); |
dataletime1[n][ii]->SetMarkerStyle(21); |
| 400 |
if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); |
dataletime1[n][ii]->SetMarkerSize(0.1); |
| 401 |
else dataletime1[i][ii]->SetMarkerSize(0.3); |
dataletime1[n][ii]->SetMarkerColor(2); |
| 402 |
dataletime1[i][ii]->SetMarkerColor(2); |
dataletime1[n][ii]->Draw("psame"); |
| 403 |
dataletime1[i][ii]->Draw("psame"); |
} |
| 404 |
} |
else if((maxev-minev)<1000 && countbad[n]>=100){ |
| 405 |
else if((maxev-minev)<1000 && countbad[i]>=100){ |
dataletime1[n][ii]= new TGraph(countbad[n],xbd,ybd); |
| 406 |
dataletime1[i][ii]= new TGraph(countbad[i],xb,yb); |
dataletime1[n][ii]->SetMarkerStyle(21); |
| 407 |
dataletime1[i][ii]->SetMarkerStyle(21); |
if((maxev-minev)<50) dataletime1[n][ii]->SetMarkerSize(0.5); |
| 408 |
if((maxev-minev)<50) dataletime1[i][ii]->SetMarkerSize(0.5); |
else dataletime1[n][ii]->SetMarkerSize(0.1); |
| 409 |
else dataletime1[i][ii]->SetMarkerSize(0.3); |
dataletime1[n][ii]->SetMarkerColor(2); |
| 410 |
dataletime1[i][ii]->SetMarkerColor(2); |
dataletime1[n][ii]->Draw("psame"); |
|
dataletime1[i][ii]->Draw("psame"); |
|
| 411 |
} |
} |
| 412 |
li.SetLineColor(1); |
li.SetLineColor(1); |
| 413 |
li.SetLineStyle(1); |
li.SetLineStyle(1); |