| 1 |
/** |
/** |
| 2 |
* FTrkCalibQLookExpert.cpp |
* FTrkCalibQLookExpert.cxx |
| 3 |
* |
* |
| 4 |
* autor: D.Fedele |
* autor: D.Fedele |
| 5 |
* version 2.0 |
* version v1r05 |
| 6 |
* Parameters: |
* Parameters: |
| 7 |
* file - the data file to analyze |
* file - the data file to analyze |
| 8 |
* step - select =1 in order to analyze one event at time |
* step - select =1 in order to analyze one event at time |
| 18 |
#include <TPaveText.h> |
#include <TPaveText.h> |
| 19 |
#include <TLatex.h> |
#include <TLatex.h> |
| 20 |
#include <TCanvas.h> |
#include <TCanvas.h> |
| 21 |
|
#include <TFile.h> |
| 22 |
#include <TTree.h> |
#include <TTree.h> |
| 23 |
#include <TGraph.h> |
#include <TGraph.h> |
| 24 |
#include <TStyle.h> |
#include <TStyle.h> |
| 30 |
#include <CalibTrk2Event.h> |
#include <CalibTrk2Event.h> |
| 31 |
// |
// |
| 32 |
|
|
| 33 |
|
typedef struct caltrk_def{ |
|
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); |
|
|
}; |
|
|
}; |
|
|
|
|
|
typedef struct caltrk_def{ |
|
| 34 |
Int_t good0[2]; |
Int_t good0[2]; |
| 35 |
Int_t daqmode[12]; |
Int_t daqmode[12]; |
| 36 |
Int_t dspnum[12]; |
Int_t dspnum[12]; |
| 58 |
{ |
{ |
| 59 |
// |
// |
| 60 |
// obtain information about the data file and select the output dir |
// obtain information about the data file and select the output dir |
| 61 |
const string filepath=file.Data(); |
Int_t dwpos = file.Last('/'); |
| 62 |
Int_t dwpos = filepath.rfind("DW_"); |
Int_t dwpos1 = file.Last('.'); |
| 63 |
Int_t dwpos1 = filepath.find(".root"); |
TString base,ffile ; |
| 64 |
TString fpath=(filepath.c_str()); |
ffile=file(dwpos+1,dwpos1-(dwpos+1)); |
| 65 |
TString base,ffile; |
if(dwpos>0) base=file(0,dwpos); |
|
stringcopy(base,fpath,0,dwpos); |
|
|
stringcopy(ffile,fpath,dwpos,dwpos1); |
|
| 66 |
|
|
| 67 |
TString out; |
TString out; |
| 68 |
if(outdir.Length()==0){ |
if(outdir.Length()==0){ |
| 70 |
}else{ |
}else{ |
| 71 |
out = outdir; |
out = outdir; |
| 72 |
} |
} |
| 73 |
|
if(out.Last('/')+1<out.Length()) out+="/"; |
| 74 |
|
|
| 75 |
// |
// |
| 76 |
// inizialise the variables and open the file |
// inizialise the variables and open the file |
| 294 |
TH1F *histoasig[12]; //histos of sigma |
TH1F *histoasig[12]; //histos of sigma |
| 295 |
TH1F *histoaped[12]; //histos of pedestals |
TH1F *histoaped[12]; //histos of pedestals |
| 296 |
|
|
| 297 |
Double_t posy = 0.95; // up y-coord - top pads |
Float_t posy = 0.95; // up y-coord - top pads |
| 298 |
Double_t hpad = 0.15; // pad height |
Float_t hpad = 0.15; // pad height |
| 299 |
Double_t posx1=0; // left x-coord - pad column |
Float_t posx1=0; // left x-coord - pad column |
| 300 |
Double_t posx2=0; // right x-coord - pad olumn |
Float_t posx2=0; // right x-coord - pad olumn |
| 301 |
Double_t posx0=0; // x-coord - column division |
Float_t posx0=0; // x-coord - column division |
| 302 |
Double_t wrel = 0.6; // relative x size of first sub-column |
Float_t wrel = 0.6; // relative x size of first sub-column |
| 303 |
Double_t marg = 0.004; // margin among pads |
Float_t marg = 0.004; // margin among pads |
| 304 |
stringstream title; |
stringstream title; |
| 305 |
stringstream hid; |
stringstream hid; |
| 306 |
|
|
| 323 |
/* -----------> HISTOGRAMS */ |
/* -----------> HISTOGRAMS */ |
| 324 |
/* calibration parameters */ |
/* calibration parameters */ |
| 325 |
title<<"DSP "<<n+1; |
title<<"DSP "<<n+1; |
| 326 |
hid<<"h"<<n; |
hid<<"h"<<n<<"i"<<i; |
| 327 |
histosig[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5); |
histosig[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5); |
| 328 |
hid.str(""); |
hid.str(""); |
| 329 |
hid<<"hh"<<n; |
hid<<"hh"<<n<<"i"<<i; |
| 330 |
histoped[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5); |
histoped[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3072,0.5,3072.5); |
| 331 |
hid.str(""); |
hid.str(""); |
| 332 |
hid<<"hhh"<<n; |
hid<<"hhh"<<n<<"i"<<i; |
| 333 |
title.str(""); |
title.str(""); |
| 334 |
hid.str(""); |
hid.str(""); |
| 335 |
/* AVERAGE calibration parameters */ |
/* AVERAGE calibration parameters */ |
| 336 |
hid<<"ah"<<n; |
hid<<"ah"<<n<<"i"<<i; |
| 337 |
histoasig[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3,0.5,3072.5); |
histoasig[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3,0.5,3072.5); |
| 338 |
hid.str(""); |
hid.str(""); |
| 339 |
hid<<"ahh"<<n; |
hid<<"ahh"<<n<<"i"<<i; |
| 340 |
histoaped[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3,0.5,3072.5); |
histoaped[n] = new TH1F(hid.str().c_str(),title.str().c_str(),3,0.5,3072.5); |
| 341 |
hid.str(""); |
hid.str(""); |
| 342 |
}; //end loop on views |
}; //end loop on views |
| 441 |
li.SetLineStyle(3); |
li.SetLineStyle(3); |
| 442 |
li.SetLineWidth(2); |
li.SetLineWidth(2); |
| 443 |
|
|
| 444 |
|
Float_t maxhist=0; |
| 445 |
|
TBox b; |
| 446 |
|
b.SetFillColor(6); |
| 447 |
|
b.SetFillStyle(3945); |
| 448 |
/* plot PEDESTAL */ |
/* plot PEDESTAL */ |
| 449 |
c1->cd(); |
c1->cd(); |
| 450 |
trkpadtext[nn]->Draw(); |
trkpadtext[nn]->Draw(); |
| 457 |
histoped[nn]->SetLineWidth(1); |
histoped[nn]->SetLineWidth(1); |
| 458 |
histoped[nn]->GetYaxis()->SetTitle("PED (ADC channels)"); |
histoped[nn]->GetYaxis()->SetTitle("PED (ADC channels)"); |
| 459 |
histoped[nn]->GetYaxis()->CenterTitle(); |
histoped[nn]->GetYaxis()->CenterTitle(); |
| 460 |
if((nn+1)%2==1) histoped[nn]->GetYaxis()->SetRangeUser(2500,3200); |
if((nn+1)%2==1) histoped[nn]->GetYaxis()->SetRangeUser(2200,3200); |
| 461 |
if((nn+1)%2==0) histoped[nn]->GetYaxis()->SetRangeUser(1000,1700); |
if((nn+1)%2==0) histoped[nn]->GetYaxis()->SetRangeUser(700,1700); |
| 462 |
histoaped[nn]->SetLineColor(5); |
histoaped[nn]->SetLineColor(5); |
| 463 |
histoaped[nn]->SetLineWidth(1); |
histoaped[nn]->SetLineWidth(1); |
| 464 |
if(ctrk.good0[0]==1 && ctrk.good0[1]==1) histoped[nn]->Draw("b"); |
if(ctrk.good0[0]==1 && ctrk.good0[1]==1){ |
| 465 |
|
histoped[nn]->Draw("b"); |
| 466 |
|
if(nn==1){ |
| 467 |
|
maxhist=histoped[nn]->GetMaximum(); |
| 468 |
|
b.DrawBox(2816.,700.,3060.,maxhist); |
| 469 |
|
} |
| 470 |
|
else if(nn==6){ |
| 471 |
|
maxhist=histoped[nn]->GetMaximum(); |
| 472 |
|
b.DrawBox(2560.,2200.,2816.,maxhist); |
| 473 |
|
b.DrawBox(512.,2200.,768.,maxhist); |
| 474 |
|
b.DrawBox(1024.,2200.,1792.,maxhist); |
| 475 |
|
} |
| 476 |
|
else if(nn==11){ |
| 477 |
|
maxhist=histoped[nn]->GetMaximum(); |
| 478 |
|
b.DrawBox(768.,700.,1024.,maxhist); |
| 479 |
|
} |
| 480 |
|
} |
| 481 |
else histoped[nn]->Draw("axis"); |
else histoped[nn]->Draw("axis"); |
| 482 |
histoaped[nn]->Draw("same"); |
histoaped[nn]->Draw("same"); |
| 483 |
if((nn+1)%2==1) { |
if((nn+1)%2==1) { |
| 484 |
li.DrawLine(1024.5,2500,1024.5,3200); |
li.DrawLine(1024.5,2200,1024.5,3200); |
| 485 |
li.DrawLine(2048.5,2500,2048.5,3200); |
li.DrawLine(2048.5,2200,2048.5,3200); |
| 486 |
} |
} |
| 487 |
if((nn+1)%2==0) { |
if((nn+1)%2==0) { |
| 488 |
li.DrawLine(1024.5,1000,1024.5,1700); |
li.DrawLine(1024.5,700,1024.5,1700); |
| 489 |
li.DrawLine(2048.5,1000,2048.5,1700); |
li.DrawLine(2048.5,700,2048.5,1700); |
| 490 |
} |
} |
| 491 |
|
|
| 492 |
|
|
| 493 |
|
|
| 494 |
/* plot SIGMA */ |
/* plot SIGMA */ |
| 495 |
Double_t max=500.; |
Float_t max=500.; |
| 496 |
c2->cd(); |
c2->cd(); |
| 497 |
trkpadtext[nn]->Draw(); |
trkpadtext[nn]->Draw(); |
| 498 |
trkpad2[nn]->SetLogy(); |
trkpad2[nn]->SetLogy(); |
| 509 |
histosig[nn]->GetYaxis()->CenterTitle(); |
histosig[nn]->GetYaxis()->CenterTitle(); |
| 510 |
histoasig[nn]->SetLineColor(5); |
histoasig[nn]->SetLineColor(5); |
| 511 |
histoasig[nn]->SetLineWidth(1); |
histoasig[nn]->SetLineWidth(1); |
| 512 |
if(ctrk.good0[0]==1 && ctrk.good0[1]==1) histosig[nn]->Draw("b"); |
if(ctrk.good0[0]==1 && ctrk.good0[1]==1){ |
| 513 |
|
histosig[nn]->Draw("b"); |
| 514 |
|
if(nn==1){ |
| 515 |
|
maxhist=histosig[nn]->GetMaximum(); |
| 516 |
|
b.DrawBox(2816.,0.,3060.,maxhist); |
| 517 |
|
} |
| 518 |
|
else if(nn==6){ |
| 519 |
|
maxhist=histosig[nn]->GetMaximum(); |
| 520 |
|
b.DrawBox(2560.,0.,2816.,maxhist); |
| 521 |
|
b.DrawBox(512.,0.,768.,maxhist); |
| 522 |
|
b.DrawBox(1024.,0.,1792.,maxhist); |
| 523 |
|
} |
| 524 |
|
else if(nn==11){ |
| 525 |
|
maxhist=histosig[nn]->GetMaximum(); |
| 526 |
|
b.DrawBox(768.,0.,1024.,maxhist); |
| 527 |
|
} |
| 528 |
|
} |
| 529 |
else histosig[nn]->Draw("axis"); |
else histosig[nn]->Draw("axis"); |
| 530 |
histoasig[nn]->Draw("same"); |
histoasig[nn]->Draw("same"); |
| 531 |
li.DrawLine(1024.5,0,1024.5,max); |
li.DrawLine(1024.5,0,1024.5,max); |
| 532 |
li.DrawLine(2048.5,0,2048.5,max); |
li.DrawLine(2048.5,0,2048.5,max); |
| 533 |
|
|
| 534 |
|
|
| 535 |
|
|
| 536 |
};//end loop on views |
};//end loop on views |
| 537 |
|
|
| 538 |
c1->Update();//draw pads in canvas |
c1->Update();//draw pads in canvas |