]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/macrosQA/MakeTrendingTOFQA.C
Single-run tree added + trending from tree list
[u/mrichter/AliRoot.git] / TOF / macrosQA / MakeTrendingTOFQA.C
CommitLineData
6c125480 1/*
2fbellini@cern.ch, last update on 09/01/2012
3- added flag for displaying reduced n. of trending plots
4- now producing tree run by run
5- new method to produce trending plots from list of trees
6*/
7
8Int_t MakeTrendingTOFQA(char * runlist, Int_t year=2011, char *period="LHC11h", char* pass="pass1", Int_t trainId=0, Bool_t displayAll=kFALSE){
7cc410ff 9 Int_t filesCounter=0;
3d9550f8 10
7cc410ff 11 if (!runlist) {
12 printf("Invalid list of runs given as input: nothing done\n");
13 return 1;
14 }
15 Int_t runNumber;
16 char infile[300];
17 char postFileName[20];
6c125480 18 char treePostFileName[20];
3d9550f8 19
7cc410ff 20 char trendFileName[100];
21 //Define trending output
22 if (trainId==0){
23 sprintf(trendFileName,"treeTOFQA_%s_%s.root",period,pass);
24 }else{
25 sprintf(trendFileName,"treeTOFQA_QA%i_%s_%s.root",trainId,period,pass);
26 }
27 TFile * trendFile=new TFile(trendFileName,"recreate");
6c125480 28 FILE * files = fopen(runlist, "r") ;
7cc410ff 29
6c125480 30 //create chain of treePostQA
31 Long64_t nentries=100000, firstentry=0;
32 TChain *chainTree = 0;
33 chainTree=new TChain("trendTree");
34
35 while (fscanf(files,"%d",&runNumber)==1 ){
36
37 //get QAtrain output
38 if (trainId==0){
39 sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QAresults.root",year,period,runNumber,pass);
40 } else{
41 sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QA%i/QAresults.root",year,period,runNumber,pass,trainId);
42 }
43 Printf("============== Opening QA file(s) for run %i =======================\n",runNumber);
44
45 //run post-analysis
46 if (RunESDQApostAnalysis(infile,runNumber,kTRUE)==0){
47 filesCounter++;
48 sprintf(postFileName,"postQA_%i.root",runNumber);
49 sprintf(treePostFileName,"treePostQA_%i.root",runNumber);
50
51 if (MakePostQAtree(runNumber, postFileName, treePostFileName)==0){
52 chainTree->Add(treePostFileName);
53 Printf("Tree chain has now %d entries ",(Int_t)chainTree->GetEntries());
54 } else {
55 Printf("Could not get tree with trending quantities for run %i: SKIPPING",runNumber);
56 }
57 } else
58 Printf("Post analysis not run on QA output %s", infile);
59 }
60 return MakeTrendingFromTreeWithErrors(chainTree, trendFileName, displayAll);
61}
62//-----------------------------------------------------------
63Int_t MakeTrendingHistoFromTreeList(char * fileList, Bool_t displayAll=kFALSE){
7cc410ff 64
6c125480 65 Int_t filesCounter=0;
3d9550f8 66
6c125480 67 if (!fileList) {
68 printf("Invalid list of runs given as input: nothing done\n");
69 return 1;
70 }
71 char infile[300];
72 char trendFileName[100];
73 //Define trending output
74 sprintf(trendFileName,"trendingHistoTOFQA_%s.root",fileList);
75 TFile * trendFile=new TFile(trendFileName,"recreate");
76 FILE * files = fopen(fileList, "r") ;
3d9550f8 77
6c125480 78 //create chain of treePostQA
79 Long64_t nentries=100000, firstentry=0;
80 TChain *chainTree =new TChain("trendTree");
3d9550f8 81
6c125480 82 while (fscanf(files,"%s",&infile)==1 ){
83 if (!TFile::Open(infile,"r"))
84 Printf("Error: cannot open file %s", infile);
85 Printf("============== Adding QA tree file %s to the chain",infile);
86 filesCounter++;
87 chainTree->Add(infile);
88 }
89 return MakeTrendingFromTreeWithErrors(chainTree, trendFileName, displayAll);
3d9550f8 90}
91
92//______________________________________________________________________________
6c125480 93Int_t MakeTrendingFromTreeWithErrors(TChain * fin,char* trendFileName=NULL, Bool_t displayAll=kFALSE){
3d9550f8 94
7cc410ff 95 if (!trendFileName)
96 return 3;
6c125480 97
7cc410ff 98 if (!fin)
99 return 4;
6c125480 100
7cc410ff 101 Int_t runNumber;
102 Double_t avTime=0., peakTime=0., spreadTime=0., peakTimeErr=0., spreadTimeErr=0.,negTimeRatio=0.,
103 avRawTime=0., peakRawTime=0., spreadRawTime=0., peakRawTimeErr=0., spreadRawTimeErr=0.,
104 avTot=0., peakTot=0.,spreadTot=0., peakTotErr=0.,spreadTotErr=0.,
105 orphansRatio=0., avL=0., negLratio=0.,
106 effPt1=0., effPt2=0., matchEffLinFit1Gev=0.,matchEffLinFit1GevErr=0.;
107 Double_t avDiffTime=0.,peakDiffTime=0., spreadDiffTime=0.,peakDiffTimeErr=0., spreadDiffTimeErr=0.,avT0fillRes=0.;
3d9550f8 108
7cc410ff 109 Double_t avT0A=0.,peakT0A=0., spreadT0A=0.,peakT0AErr=0., spreadT0AErr=0.;
110 Double_t avT0C=0.,peakT0C=0., spreadT0C=0.,peakT0CErr=0., spreadT0CErr=0.;
111 Double_t avT0AC=0.,peakT0AC=0., spreadT0AC=0.,peakT0ACErr=0., spreadT0ACErr=0.;
112 Double_t avT0res=0.,peakT0res=0., spreadT0res=0.,peakT0resErr=0., spreadT0resErr=0.;
113 Int_t avMulti=0;
114 Float_t fractionEventsWHits=0;
3d9550f8 115
6c125480 116 TTree * ttree = (TTree*) fin->CloneTree();
7cc410ff 117 ttree->SetBranchAddress("run",&runNumber);
3d9550f8 118
7cc410ff 119 ttree->SetBranchAddress("avTime",&avTime); //mean time
120 ttree->SetBranchAddress("peakTime",&peakTime); //main peak time after fit
121 ttree->SetBranchAddress("spreadTime",&spreadTime); //spread of main peak of time after fit
122 ttree->SetBranchAddress("peakTimeErr",&peakTimeErr); //main peak time after fit error
123 ttree->SetBranchAddress("spreadTimeErr",&spreadTimeErr); //spread of main peak of time after fit error
3d9550f8 124
7cc410ff 125 ttree->SetBranchAddress("negTimeRatio",&negTimeRatio); //negative time ratio
3d9550f8 126
7cc410ff 127 ttree->SetBranchAddress("avRawTime",&avRawTime); //mean raw time
128 ttree->SetBranchAddress("peakRawTime",&peakRawTime); //mean peak of raw time after fit
129 ttree->SetBranchAddress("spreadRawTime",&spreadRawTime); //spread of main peak of raw time after fit
130 ttree->SetBranchAddress("peakRawTimeErr",&peakRawTimeErr); //main peak raw time after fit error
131 ttree->SetBranchAddress("spreadRawTimeErr",&spreadRawTimeErr); //spread of raw main peak of time after fit error
3d9550f8 132
7cc410ff 133 ttree->SetBranchAddress("avTot",&avTot); //main peak tot
134 ttree->SetBranchAddress("peakTot",&peakTot); // main peak of tot after fit
135 ttree->SetBranchAddress("spreadTot",&spreadTot); //spread of main peak of tot after fit
136 ttree->SetBranchAddress("peakTotErr",&peakTotErr); // main peak of tot after fit
137 ttree->SetBranchAddress("spreadTotErr",&spreadTotErr); //spread of main peak of tot after fit
3d9550f8 138
7cc410ff 139 ttree->SetBranchAddress("orphansRatio",&orphansRatio); //orphans ratio
3d9550f8 140
7cc410ff 141 ttree->SetBranchAddress("avL",&avL); //mean track length
142 ttree->SetBranchAddress("negLratio",&negLratio);//ratio of tracks with track length <350 cm
3d9550f8 143
7cc410ff 144 ttree->SetBranchAddress("effPt1",&effPt1);//matching eff at 1 GeV/c
145 ttree->SetBranchAddress("effPt2",&effPt2); //matching eff at 2 GeV/c
146 ttree->SetBranchAddress("matchEffLinFit1Gev",&matchEffLinFit1Gev);//matching eff fit param
147 ttree->SetBranchAddress("matchEffLinFit1GevErr",&matchEffLinFit1GevErr);////matching eff fit param error
3d9550f8 148
7cc410ff 149 ttree->SetBranchAddress("avPiDiffTime",&avDiffTime); //mean t-texp
150 ttree->SetBranchAddress("peakPiDiffTime",&peakDiffTime); //main peak t-texp after fit
151 ttree->SetBranchAddress("spreadPiDiffTime",&spreadDiffTime); //spread of main peak t-texp after fit
152 ttree->SetBranchAddress("peakPiDiffTimeErr",&peakDiffTimeErr); //main peak t-texp after fit error
153 ttree->SetBranchAddress("spreadPiDiffTimeErr",&spreadDiffTimeErr); //spread of main peak of t-texp after fit error
3d9550f8 154
7cc410ff 155 ttree->SetBranchAddress("avT0A",&avT0A); //main peak t0A
156 ttree->SetBranchAddress("peakT0A",&peakT0A); // main peak of t0A after fit
157 ttree->SetBranchAddress("spreadT0A",&spreadT0A); //spread of main peak of t0A after fit
158 ttree->SetBranchAddress("peakT0AErr",&peakT0AErr); // main peak of t0A after fit
159 ttree->SetBranchAddress("spreadT0AErr",&spreadT0AErr); //spread of main peak of t0A after fit
3d9550f8 160
7cc410ff 161 ttree->SetBranchAddress("avT0C",&avT0C); //main peak t0C
162 ttree->SetBranchAddress("peakT0C",&peakT0C); // main peak of t0C after fit
163 ttree->SetBranchAddress("spreadT0C",&spreadT0C); //spread of main peak of t0C after fit
164 ttree->SetBranchAddress("peakT0CErr",&peakT0CErr); // main peak of t0C after fit
165 ttree->SetBranchAddress("spreadT0CErr",&spreadT0CErr); //spread of main peak of t0C after fit
3d9550f8 166
7cc410ff 167 ttree->SetBranchAddress("avT0AC",&avT0AC); //main peak t0AC
168 ttree->SetBranchAddress("peakT0AC",&peakT0AC); // main peak of t0AC after fit
169 ttree->SetBranchAddress("spreadT0AC",&spreadT0AC); //spread of main peak of t0AC after fit
170 ttree->SetBranchAddress("peakT0ACErr",&peakT0ACErr); // main peak of t0AC after fit
171 ttree->SetBranchAddress("spreadT0ACErr",&spreadT0ACErr); //spread of main peak of t0AC after fit
3d9550f8 172
7cc410ff 173 ttree->SetBranchAddress("avT0res",&avT0res); //main peak t0AC
174 ttree->SetBranchAddress("peakT0res",&peakT0res); // main peak of t0AC after fit
175 ttree->SetBranchAddress("spreadT0res",&spreadT0res); //spread of main peak of t0AC after fit
176 ttree->SetBranchAddress("peakT0resErr",&peakT0resErr); // main peak of t0AC after fit
177 ttree->SetBranchAddress("spreadT0resErr",&spreadT0resErr); //spread of main peak of t0AC after fit
178 ttree->SetBranchAddress("avT0fillRes",&avT0fillRes); //t0 fill res
179
180 Int_t nRuns=ttree->GetEntries();
181 TList lista;
3d9550f8 182
6c125480 183 TH1F * hAvDiffTimeVsRun=new TH1F("hAvDiffTimeVsRun","Mean t-t_{exp} (no fit);run;<t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//, 600, 0. , 600.);
7cc410ff 184 hAvDiffTimeVsRun->SetDrawOption("E1");
185 hAvDiffTimeVsRun->SetMarkerStyle(20);
186 hAvDiffTimeVsRun->SetMarkerColor(kBlue);
187 // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);
188
6c125480 189 TH1F * hPeakDiffTimeVsRun=new TH1F("hPeakDiffTimeVsRun","t-t_{exp} (gaussian fit) ;run; <t^{TOF}-t_{exp,#pi}> (ps)",nRuns,0., nRuns);//,600, 0. , 600. );
7cc410ff 190 hPeakDiffTimeVsRun->SetDrawOption("E1");
191 hPeakDiffTimeVsRun->SetMarkerStyle(20);
192 hPeakDiffTimeVsRun->SetMarkerColor(kBlue);
3d9550f8 193
6c125480 194 TH1F * hSpreadDiffTimeVsRun=new TH1F("hSpreadDiffTimeVsRun","#sigma(t-t_{exp}) (gaussian fit);run; #sigma(t^{TOF}-t_{exp,#pi}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
7cc410ff 195 hSpreadDiffTimeVsRun->SetDrawOption("E1");
196 hSpreadDiffTimeVsRun->SetMarkerStyle(20);
197 hSpreadDiffTimeVsRun->SetMarkerColor(kBlue);
198
6c125480 199 TH1F * hAvTimeVsRun=new TH1F("hAvTimeVsRun","<t^{TOF}>;run;<t^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
7cc410ff 200 hAvTimeVsRun->SetDrawOption("E1");
201 hAvTimeVsRun->SetMarkerStyle(20);
202 hAvTimeVsRun->SetMarkerColor(kBlue);
203 // hAvTimeVsRun->GetYaxis()->SetRangeUser(0.0, 50.0);
204
6c125480 205 TH1F * hPeakTimeVsRun=new TH1F("hPeakTimeVsRun","Peak value of t^{TOF} (landau fit);run;t_{peak}^{TOF} (ns)",nRuns,0., nRuns);//,600, 0. , 600. );
7cc410ff 206 hPeakTimeVsRun->SetDrawOption("E1");
207 hPeakTimeVsRun->SetMarkerStyle(20);
208 hPeakTimeVsRun->SetMarkerColor(kBlue);
3d9550f8 209
6c125480 210 TH1F * hSpreadTimeVsRun=new TH1F("hSpreadTimeVsRun","Spread of t^{TOF} (landau fit);run; #sigma(t^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
7cc410ff 211 hSpreadTimeVsRun->SetDrawOption("E1");
212 hSpreadTimeVsRun->SetMarkerStyle(20);
213 hSpreadTimeVsRun->SetMarkerColor(kBlue);
3d9550f8 214
6c125480 215 TH1F * hAvRawTimeVsRun=new TH1F("hAvRawTimeVsRun","Peak value of raw t^{TOF};run;<t_{raw}^{TOF}> (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
7cc410ff 216 hAvRawTimeVsRun->SetDrawOption("E1");
217 hAvRawTimeVsRun->SetMarkerStyle(21);
218 hAvRawTimeVsRun->SetMarkerColor(kGreen);
219
6c125480 220 TH1F * hPeakRawTimeVsRun=new TH1F("hPeakRawTimeVsRun","Peak value of raw t^{TOF} (landau fit);run;t_{peak,raw}^{TOF} (ns)",nRuns,0., nRuns);//, 600, 0. , 600.);
7cc410ff 221 hPeakRawTimeVsRun->SetDrawOption("E1");
222 hPeakRawTimeVsRun->SetMarkerStyle(21);
223 hPeakRawTimeVsRun->SetMarkerColor(kGreen);
224
6c125480 225 TH1F * hSpreadRawTimeVsRun=new TH1F("hSpreadRawTimeVsRun","Spread of raw t^{TOF} (landau fit);run;#sigma(t_{raw}^{TOF}) (ns)",nRuns,0., nRuns);//, 100, 0. , 100.);
7cc410ff 226 hSpreadRawTimeVsRun->SetDrawOption("E1");
227 hSpreadRawTimeVsRun->SetMarkerStyle(21);
228 hSpreadRawTimeVsRun->SetMarkerColor(kGreen);
3d9550f8 229
6c125480 230 TH1F * hAvTotVsRun=new TH1F("hAvTotVsRun","<ToT> (no fit);run;<ToT> (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
7cc410ff 231 hAvTotVsRun->SetDrawOption("E1");
232 hAvTotVsRun->SetMarkerStyle(22);
3d9550f8 233
6c125480 234 TH1F * hPeakTotVsRun=new TH1F("hPeakTotVsRun","<ToT> (gaussian fit);run;ToT_{peak} (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
7cc410ff 235 hPeakTotVsRun->SetDrawOption("E1");
236 hPeakTotVsRun->SetMarkerStyle(22);
3d9550f8 237
6c125480 238 TH1F * hSpreadTotVsRun=new TH1F("hSpreadTotVsRun","#sigma(ToT) (gaussian fit);#sigma(ToT) (ns)",nRuns,0., nRuns);//, 50, 0. , 50.);
7cc410ff 239 hSpreadTotVsRun->SetDrawOption("E1");
240 hSpreadTotVsRun->SetMarkerStyle(22);
3d9550f8 241
6c125480 242 TH1F * hNegTimeRatioVsRun=new TH1F("hNegTimeRatioVsRun","Ratio of tracks with t^{TOF}<12.5 ns; run; ratio of tracks with t^{TOF}<12.5 ns (%)",nRuns, 0., nRuns);//, 100, 0. , 100.);
7cc410ff 243 hNegTimeRatioVsRun->SetDrawOption("E");
244
6c125480 245 TH1F * hOrphansRatioVsRun=new TH1F("hOrphansRatioVsRun","Ratio of orphans (hits with ToT=0); run; ratio of orphans (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
7cc410ff 246 hOrphansRatioVsRun->SetDrawOption("E");
247
6c125480 248 TH1F * hMeanLVsRun=new TH1F("hMeanLVsRun","Average track length;run; <L> (cm)",nRuns, 0., nRuns);//, 350, 350. , 700.);
7cc410ff 249 hMeanLVsRun->SetDrawOption("E");
6c125480 250 TH1F * hNegLRatioVsRun=new TH1F("hNegLRatioVsRun","Ratio of tracks with L<350 cm;run; ratio of tracks with L<350 cm (%)",nRuns, 0., nRuns);//, 1000, 0. , 100.);
7cc410ff 251 hNegLRatioVsRun->SetDrawOption("E");
6c125480 252 TH1F * hMatchEffVsRun=new TH1F("hMatchEffVsRun","Matching efficiency (linear fit for p_{T}>1.0 GeV/c);run;matching efficiency (pT>1.0 GeV/c)",nRuns, 0., nRuns);//, 100, 0. , 1.);
7cc410ff 253 hMatchEffVsRun->SetDrawOption("E");
6c125480 254 TH1F * hMatchEffVsRun1=new TH1F("hMatchEffVsRun1","Matching efficiency (value for p_{T}=1.0 GeV/c);run;matching efficiency (pT=1.0 GeV/c)",nRuns, 0., nRuns);
7cc410ff 255 hMatchEffVsRun1->SetDrawOption("E");
6c125480 256 TH1F * hPeakT0AVsRun=new TH1F("hPeakT0AVsRun","Peak value of T0A (gaussian fit);run;t0A (ps)",nRuns,0., nRuns);
257 TH1F * hPeakT0CVsRun=new TH1F("hPeakT0CVsRun","Peak value of T0C (gaussian fit);run;t0AC (ps)",nRuns,0., nRuns);
258 TH1F * hPeakT0ACVsRun=new TH1F("hPeakT0ACVsRun","Peak value of T0AC (gaussian fit);run;t0AC (ps)",nRuns,0., nRuns);
259 TH1F * hT0fillResVsRun=new TH1F("hT0fillResVsRun","t0_fill spread;run;t0_spread (ps)",nRuns,0., nRuns);
3d9550f8 260
7cc410ff 261 lista.Add(hAvDiffTimeVsRun);
262 lista.Add(hPeakDiffTimeVsRun);
263 lista.Add(hSpreadDiffTimeVsRun);
264 lista.Add(hAvTimeVsRun);
265 lista.Add(hPeakTimeVsRun);
266 lista.Add(hSpreadTimeVsRun);
267 lista.Add( hAvRawTimeVsRun);
268 lista.Add( hPeakRawTimeVsRun);
269 lista.Add( hSpreadRawTimeVsRun);
270 lista.Add( hAvTotVsRun);
271 lista.Add( hPeakTotVsRun);
272 lista.Add( hSpreadTotVsRun);
273 lista.Add( hNegTimeRatioVsRun);
274 lista.Add( hOrphansRatioVsRun);
275 lista.Add( hMeanLVsRun);
276 lista.Add( hNegLRatioVsRun);
277 lista.Add( hMatchEffVsRun);
278 lista.Add(hPeakT0AVsRun);
279 lista.Add(hPeakT0CVsRun);
280 lista.Add(hPeakT0ACVsRun);
281 lista.Add(hT0fillResVsRun);
282 char runlabel[6];
3d9550f8 283
7cc410ff 284 for (Int_t irun=0;irun<nRuns;irun++){
285 ttree->GetEntry(irun);
3d9550f8 286
7cc410ff 287 sprintf(runlabel,"%i",runNumber);
3d9550f8 288
7cc410ff 289 hAvDiffTimeVsRun->SetBinContent(irun+1, avDiffTime);
290 hAvDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 291
7cc410ff 292 hPeakDiffTimeVsRun->SetBinContent(irun+1,peakDiffTime);
293 hPeakDiffTimeVsRun->SetBinError(irun+1,peakDiffTimeErr);
294 hPeakDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 295
7cc410ff 296 hSpreadDiffTimeVsRun->SetBinContent(irun+1,spreadDiffTime);
297 hSpreadDiffTimeVsRun->SetBinError(irun+1,spreadDiffTimeErr);
298 hSpreadDiffTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 299
7cc410ff 300 hAvTimeVsRun->SetBinContent(irun+1, avTime);
301 hAvTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 302
7cc410ff 303 hPeakTimeVsRun->SetBinContent(irun+1,peakTime);
304 hPeakTimeVsRun->SetBinError(irun+1,peakTimeErr);
305 hPeakTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 306
7cc410ff 307 hSpreadTimeVsRun->SetBinContent(irun+1,spreadTime);
308 hSpreadTimeVsRun->SetBinError(irun+1,spreadTimeErr);
309 hSpreadTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 310
7cc410ff 311 hAvRawTimeVsRun->SetBinContent(irun+1, avRawTime);
312 hAvRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 313
7cc410ff 314 hPeakRawTimeVsRun->SetBinContent(irun+1,peakRawTime);
315 hPeakRawTimeVsRun->SetBinError(irun+1,peakRawTimeErr);
316 hPeakRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 317
7cc410ff 318 hSpreadRawTimeVsRun->SetBinContent(irun+1,spreadRawTime);
319 hSpreadRawTimeVsRun->SetBinError(irun+1,spreadRawTimeErr);
320 hSpreadRawTimeVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 321
db768bb3 322 hAvTotVsRun->SetBinContent(irun+1,avTot);
7cc410ff 323 hAvTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 324
db768bb3 325 hPeakTotVsRun->SetBinContent(irun+1,peakTot);
7cc410ff 326 hPeakTotVsRun->SetBinError(irun+1,peakTotErr);
327 hPeakTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 328
db768bb3 329 hSpreadTotVsRun->SetBinContent(irun+1,spreadTot);
7cc410ff 330 hSpreadTotVsRun->SetBinError(irun+1,spreadTotErr);
331 hSpreadTotVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 332
db768bb3 333 hNegTimeRatioVsRun->SetBinContent(irun+1,negTimeRatio);
7cc410ff 334 hNegTimeRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 335
db768bb3 336 hOrphansRatioVsRun->SetBinContent(irun+1,orphansRatio);
7cc410ff 337 hOrphansRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 338
db768bb3 339 hMeanLVsRun->SetBinContent(irun+1,avL);
7cc410ff 340 hMeanLVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 341
db768bb3 342 hNegLRatioVsRun->SetBinContent(irun+1,negLratio);
7cc410ff 343 hNegLRatioVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 344
db768bb3 345 hMatchEffVsRun->SetBinContent(irun+1,matchEffLinFit1Gev);
7cc410ff 346 hMatchEffVsRun->SetBinError(irun+1,matchEffLinFit1GevErr);
347 hMatchEffVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 348
7cc410ff 349 hPeakT0AVsRun->SetBinContent(irun+1,peakT0A);
350 hPeakT0AVsRun->SetBinError(irun+1,spreadT0A);
351 hPeakT0AVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 352
7cc410ff 353 hPeakT0CVsRun->SetBinContent(irun+1,peakT0C);
354 hPeakT0CVsRun->SetBinError(irun+1,spreadT0C);
355 hPeakT0CVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 356
7cc410ff 357 hPeakT0ACVsRun->SetBinContent(irun+1,peakT0AC);
358 hPeakT0ACVsRun->SetBinError(irun+1,spreadT0AC);
359 hPeakT0ACVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
360
361 hT0fillResVsRun->SetBinContent(irun+1,avT0fillRes);
362 hT0fillResVsRun->GetXaxis()->SetBinLabel(irun+1,runlabel);
3d9550f8 363
7cc410ff 364 }
3d9550f8 365
7cc410ff 366 char outfilename[200];
367 sprintf(outfilename, "trend_%s",trendFileName);
368 TFile * fout=new TFile(outfilename,"recreate");
369 fout->cd();
370 lista.Write();
371 fout->Close();
372
373 TString plotDir(Form("PlotsTrending"));
374 gSystem->Exec(Form("mkdir %s",plotDir.Data()));
375
7cc410ff 376 TCanvas* cPeakDiffTimeVsRun = new TCanvas("cPeakDiffTimeVsRun","cPeakDiffTimeVsRun", 50,50,750,550);
377 hPeakDiffTimeVsRun->Draw();
80956e04 378 cPeakDiffTimeVsRun->Print(Form("%s/cPeakDiffTimeVsRun.png",plotDir.Data()));
7cc410ff 379
380 TCanvas* cSpreadDiffTimeVsRun = new TCanvas("cSpreadDiffTimeVsRun","cSpreadDiffTimeVsRun", 50,50,750,550);
381 hSpreadDiffTimeVsRun->Draw();
80956e04 382 cSpreadDiffTimeVsRun->Print(Form("%s/cSpreadDiffTimeVsRun.png",plotDir.Data()));
7cc410ff 383
7cc410ff 384 TCanvas* cMatchEffVsRun = new TCanvas("cMatchEffVsRun","cMatchEffVsRun", 50,50,750,550);
385 hMatchEffVsRun->Draw();
80956e04 386 cMatchEffVsRun->Print(Form("%s/cMatchEffVsRun.png",plotDir.Data()));
7cc410ff 387
388 TCanvas* cPeakT0AVsRun = new TCanvas("cPeakT0AVsRun","cPeakT0AVsRun", 50,50,750,550);
389 hPeakT0AVsRun->Draw();
390 cPeakT0AVsRun->Print(Form("%s/cPeakT0AVsRun.png",plotDir.Data()));
391
392 TCanvas* cPeakT0CVsRun = new TCanvas("cPeakT0CVsRun","cPeakT0CVsRun", 50,50,750,550);
393 hPeakT0CVsRun->Draw();
394 cPeakT0CVsRun->Print(Form("%s/cPeakT0CVsRun.png",plotDir.Data()));
395
396 TCanvas* cPeakT0ACVsRun = new TCanvas("cPeakT0ACVsRun","cPeakT0ACVsRun", 50,50,750,550);
397 hPeakT0ACVsRun->Draw();
398 cPeakT0ACVsRun->Print(Form("%s/cPeakT0ACVsRun.png",plotDir.Data()));
399
400 TCanvas* cT0fillResVsRun = new TCanvas("cT0fillResVsRun","cT0fillResVsRun", 50,50,750,550);
401 hT0fillResVsRun->Draw();
402 cT0fillResVsRun->Print(Form("%s/cT0fillResVsRun.png",plotDir.Data()));
403
6c125480 404 if (displayAll) {
405 TCanvas* cAvDiffTimeVsRun = new TCanvas("cAvDiffTimeVsRun","cAvDiffTimeVsRun",50,50,750,550);
406 gPad->SetGridx();
407 gPad->SetGridy();
408 hAvDiffTimeVsRun->Draw();
409 cAvDiffTimeVsRun->Print(Form("%s/cAvDiffTimeVsRun.png",plotDir.Data()));
410
411 TCanvas* cAvTimeVsRun = new TCanvas("cAvTimeVsRun","cAvTimeVsRun", 50,50,750,550);
412 hAvTimeVsRun->Draw();
413 cAvTimeVsRun->Print(Form("%s/cAvTimeVsRun.png",plotDir.Data()));
414
415 TCanvas* cPeakTimeVsRun = new TCanvas("cPeakTimeVsRun","cPeakTimeVsRun", 50,50,750,550);
416 hPeakTimeVsRun->Draw();
417 cPeakTimeVsRun->Print(Form("%s/cPeakTimeVsRun.png",plotDir.Data()));
418
419 TCanvas* cSpreadTimeVsRun = new TCanvas("cSpreadTimeVsRun","cSpreadTimeVsRun", 50,50,750,550);
420 hSpreadTimeVsRun->Draw();
421 cSpreadTimeVsRun->Print(Form("%s/cSpreadTimeVsRun.png",plotDir.Data()));
422
423 TCanvas* cAvRawTimeVsRun = new TCanvas("cAvRawTimeVsRun","cAvRawTimeVsRun", 50,50,750,550);
424 hAvRawTimeVsRun->Draw();
425 cAvRawTimeVsRun->Print(Form("%s/cAvRawTimeVsRun.png",plotDir.Data()));
426
427 TCanvas* cPeakRawTimeVsRun = new TCanvas("cPeakRawTimeVsRun","cPeakRawTimeVsRun", 50,50,750,550);
428 hPeakRawTimeVsRun->Draw();
429 cPeakRawTimeVsRun->Print(Form("%s/cPeakRawTimeVsRun.png",plotDir.Data()));
430
431 TCanvas* cSpreadRawTimeVsRun = new TCanvas("cSpreadRawTimeVsRun","cSpreadRawTimeVsRun", 50,50,750,550);
432 hSpreadRawTimeVsRun->Draw();
433 cSpreadRawTimeVsRun->Print(Form("%s/cSpreadRawTimeVsRun.png",plotDir.Data()));
434
435 TCanvas* cAvTotVsRun = new TCanvas("cAvTotVsRun","cAvTotVsRun", 50,50,750,550);
436 hAvTotVsRun->Draw();
437 cAvTotVsRun->Print(Form("%s/cAvTotVsRun.png",plotDir.Data()));
438
439 TCanvas* cPeakTotVsRun = new TCanvas("cPeakTotVsRun","cPeakTotVsRun", 50,50,750,550);
440 hPeakTotVsRun->Draw();
441 cPeakTotVsRun->Print(Form("%s/cPeakTotVsRun.png",plotDir.Data()));
442
443 TCanvas* cSpreadTotVsRun = new TCanvas("cSpreadTotVsRun","cSpreadTotVsRun", 50,50,750,550);
444 hSpreadTotVsRun->Draw();
445 cSpreadTotVsRun->Print(Form("%s/cSpreadTotVsRun.png",plotDir.Data()));
446
447 TCanvas* cNegTimeRatioVsRun = new TCanvas("cNegTimeRatioVsRun","cNegTimeRatioVsRun", 50,50,750,550);
448 hNegTimeRatioVsRun->Draw();
449 cNegTimeRatioVsRun->Print(Form("%s/cNegTimeRatioVsRun.png",plotDir.Data()));
450
451 TCanvas* cOrphansRatioVsRun = new TCanvas("cOrphansRatioVsRun","cOrphansRatioVsRun", 50,50,750,550);
452 hOrphansRatioVsRun->Draw();
453 cOrphansRatioVsRun->Print(Form("%s/cOrphansRatioVsRun.png",plotDir.Data()));
454
455 TCanvas* cMeanLVsRun = new TCanvas("cMeanLVsRun","cMeanLVsRun", 50,50,750,550);
456 hMeanLVsRun->Draw();
457 cMeanLVsRun->Print(Form("%s/cMeanLVsRun.png",plotDir.Data()));
458
459 TCanvas* cNegLRatioVsRun = new TCanvas("cNegLRatioVsRun","cNegLRatioVsRun", 50,50,750,550);
460 hNegLRatioVsRun->Draw();
461 cNegLRatioVsRun->Print(Form("%s/cNegLRatioVsRun.png",plotDir.Data()));
462 }
463
7cc410ff 464 return 0;
3d9550f8 465}
466
6c125480 467//-------------------------------------------------------------------------
468Int_t MakePostQAtree(Int_t runNumber, char * postFileName="postQA.0.root",char * treePostFileName="treePostQA.0.root"){
469
470 TFile *postfile=TFile::Open(postFileName);
471 if (!postfile) {
472 printf("Post-analysis output not found - cannot perform trending analysis. Exiting.");
473 return -1;
474 }
475 Printf("============== Getting post-analysis info for run %i ===============\n",runNumber);
476 TFile * trendFile=new TFile(treePostFileName,"recreate");
477
478 Double_t avTime=-9999., peakTime=-9999., spreadTime=-9999., peakTimeErr=-9999., spreadTimeErr=-9999., negTimeRatio=-9999.,
479 avRawTime=-9999., peakRawTime=-9999., spreadRawTime=-9999., peakRawTimeErr=-9999., spreadRawTimeErr=-9999.,
480 avTot=-9999., peakTot=-9999.,spreadTot=-9999., peakTotErr=-9999.,spreadTotErr=-9999.,
481 orphansRatio=-9999., avL=-9999., negLratio=-9999.,
482 effPt1=-9999., effPt2=-9999., matchEffLinFit1Gev=-9999.,matchEffLinFit1GevErr=-9999.;
483
484 Double_t avPiDiffTime=-9999.,peakPiDiffTime=-9999., spreadPiDiffTime=-9999.,peakPiDiffTimeErr=-9999., spreadPiDiffTimeErr=-9999.;
485
486 Double_t avT0A=-9999.,peakT0A=-9999., spreadT0A=-9999.,peakT0AErr=-9999., spreadT0AErr=-9999.;
487 Double_t avT0C=-9999.,peakT0C=-9999., spreadT0C=-9999.,peakT0CErr=-9999., spreadT0CErr=-9999.;
488 Double_t avT0AC=-9999.,peakT0AC=-9999., spreadT0AC=-9999.,peakT0ACErr=-9999., spreadT0ACErr=-9999.;
489 Double_t avT0res=-9999.,peakT0res=-9999., spreadT0res=-9999.,peakT0resErr=-9999., spreadT0resErr=-9999.;
490 Double_t avT0fillRes=-9999.;
491
492 Int_t avMulti=0;
493 Float_t fractionEventsWHits=-9999.;
494
495 TTree * ttree=new TTree("trendTree","tree of trending variables");
496 ttree->Branch("run",&runNumber,"run/I");
497 ttree->Branch("avMulti",&avMulti,"avMulti/I");
498 ttree->Branch("fractionEventsWHits",&fractionEventsWHits,"fractionEventsWHits/F");
499 ttree->Branch("avTime",&avTime,"avTime/D"); //mean time
500 ttree->Branch("peakTime",&peakTime,"peakTime/D"); //main peak time after fit
501 ttree->Branch("spreadTime",&spreadTime,"spreadTime/D"); //spread of main peak of time after fit
502 ttree->Branch("peakTimeErr",&peakTimeErr,"peakTimeErr/D"); //main peak time after fit error
503 ttree->Branch("spreadTimeErr",&spreadTimeErr,"spreadTimeErr/D"); //spread of main peak of time after fit error
504 ttree->Branch("negTimeRatio",&negTimeRatio,"negTimeRatio/D"); //negative time ratio
505
506 ttree->Branch("avRawTime",&avRawTime,"avRawTime/D"); //mean raw time
507 ttree->Branch("peakRawTime",&peakRawTime,"peakRawTime/D"); //mean peak of RAW TIME after fit
508 ttree->Branch("spreadRawTime",&spreadRawTime,"spreadRawTime/D"); //spread of main peak of raw time after fit
509 ttree->Branch("peakRawTimeErr",&peakRawTimeErr,"peakRawTimeErr/D"); //main peak raw time after fit error
510 ttree->Branch("spreadRawTimeErr",&spreadRawTimeErr,"spreadRawTimeErr/D"); //spread of raw main peak of time after fit error
511
512 ttree->Branch("avTot",&avTot,"avTot/D"); //main peak tot
513 ttree->Branch("peakTot",&peakTot,"peakTot/D"); // main peak of tot after fit
514 ttree->Branch("spreadTot",&spreadTot,"spreadTot/D"); //spread of main peak of tot after fit
515 ttree->Branch("peakTotErr",&peakTotErr,"peakTotErr/D"); // main peak of tot after fit
516 ttree->Branch("spreadTotErr",&spreadTotErr,"spreadTotErr/D"); //spread of main peak of tot after fit
517
518 ttree->Branch("orphansRatio",&orphansRatio,"orphansRatio/D"); //orphans ratio
519
520 ttree->Branch("avL",&avL,"avL/D"); //mean track length
521 ttree->Branch("negLratio",&negLratio,"negLratio/D");//ratio of tracks with track length <350 cm
522
523 ttree->Branch("effPt1",&effPt1,"effPt1/D");//matching eff at 1 GeV/c
524 ttree->Branch("effPt2",&effPt2,"effPt2/D"); //matching eff at 2 GeV/c
525 ttree->Branch("matchEffLinFit1Gev",&matchEffLinFit1Gev,"matchEffLinFit1Gev/D");//matching eff fit param
526 ttree->Branch("matchEffLinFit1GevErr",&matchEffLinFit1GevErr,"matchEffLinFit1GevErr/D");////matching eff fit param error
527
528 ttree->Branch("avPiDiffTime",&avPiDiffTime,"avPiDiffTime/D"); //mean t-texp
529 ttree->Branch("peakPiDiffTime",&peakPiDiffTime,"peakPiDiffTime/D"); //main peak t-texp after fit
530 ttree->Branch("spreadPiDiffTime",&spreadPiDiffTime,"spreadPiDiffTime/D"); //spread of main peak t-texp after fit
531 ttree->Branch("peakPiDiffTimeErr",&peakPiDiffTimeErr,"peakPiDiffTimeErr/D"); //main peak t-texp after fit error
532 ttree->Branch("spreadPiDiffTimeErr",&spreadPiDiffTimeErr,"spreadPiDiffTimeErr/D"); //spread of main peak of t-texp after fit error
533
534 ttree->Branch("avT0A",&avT0A,"avT0A/D"); //main peak t0A
535 ttree->Branch("peakT0A",&peakT0A,"peakT0A/D"); // main peak of t0A after fit
536 ttree->Branch("spreadT0A",&spreadT0A,"spreadTot/D"); //spread of main peak of t0A after fit
537 ttree->Branch("peakT0AErr",&peakT0AErr,"peakT0AErr/D"); // main peak of t0A after fit
538 ttree->Branch("spreadT0AErr",&spreadT0AErr,"spreadT0AErr/D"); //spread of main peak of t0A after fit
539
540 ttree->Branch("avT0C",&avT0C,"avT0C/D"); //main peak t0C
541 ttree->Branch("peakT0C",&peakT0C,"peakT0C/D"); // main peak of t0C after fit
542 ttree->Branch("spreadT0C",&spreadT0C,"spreadT0C/D"); //spread of main peak of t0C after fit
543 ttree->Branch("peakT0CErr",&peakT0CErr,"peakT0CErr/D"); // main peak of t0C after fit
544 ttree->Branch("spreadT0CErr",&spreadT0CErr,"spreadT0CErr/D"); //spread of main peak of t0C after fit
545
546 ttree->Branch("avT0AC",&avT0AC,"avT0AC/D"); //main peak t0AC
547 ttree->Branch("peakT0AC",&peakT0AC,"peakT0AC/D"); // main peak of t0AC after fit
548 ttree->Branch("spreadT0AC",&spreadT0AC,"spreadT0AC/D"); //spread of main peak of t0AC after fit
549 ttree->Branch("peakT0ACErr",&peakT0ACErr,"peakT0ACErr/D"); // main peak of t0AC after fit
550 ttree->Branch("spreadT0ACErr",&spreadT0ACErr,"spreadT0ACErr/D"); //spread of main peak of t0AC after fit
551
552 ttree->Branch("avT0res",&avT0res,"avT0res/D"); //main peak t0AC
553 ttree->Branch("peakT0res",&peakT0res,"peakT0res/D"); // main peak of t0AC after fit
554 ttree->Branch("spreadT0res",&spreadT0res,"spreadT0res/D"); //spread of main peak of t0AC after fit
555 ttree->Branch("peakT0resErr",&peakT0resErr,"peakT0resErr/D"); // main peak of t0AC after fit
556 ttree->Branch("spreadT0resErr",&spreadT0resErr,"spreadT0resErr/D"); //spread of main peak of t0AC after fit
557 ttree->Branch("avT0fillRes",&avT0fillRes,"avT0fillRes/D"); //t0 fill res
558
559 //postfile->ls();
560 //save quantities for trending
561
562 //--------------------------------- Multiplicity ----------------------------------//
563 TH1F*hMulti=(TH1F*)postfile->Get("hTOFmatchedPerEvt");
564 if ((hMulti)&&(hMulti->GetEntries()>0)) {
565 avMulti=hMulti->GetMean();
566 }
567
568 //--------------------------------- T0F signal ----------------------------------//
569
570 TH1F*hTime=(TH1F*)postfile->Get("hTOFmatchedESDtime");
571 if ((hTime)&&(hTime->GetEntries()>0)) {
572 avTime=hTime->GetMean();
573 hTime->Fit("landau","","",0.,50.);
574 peakTime=(hTime->GetFunction("landau"))->GetParameter(1);
575 spreadTime=(hTime->GetFunction("landau"))->GetParameter(2);
576 peakTimeErr=(hTime->GetFunction("landau"))->GetParError(1);
577 spreadTimeErr=(hTime->GetFunction("landau"))->GetParError(2);
578
579 negTimeRatio=((Double_t)hTime->Integral(1,3)*100.)/((Double_t)hTime->Integral());
580 printf("Main peak time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
581 printf("Main peak time (landau): spread = %f +- %f\n",spreadTime,spreadTimeErr );
582 printf("Ratio of tracks with time<12.5 ns / total = %f\n",negTimeRatio );
583
584 //add integral of main peak over total
585 }
586 printf("---------------------------------------------------------------- \n");
587 TH1F * hRawTime = (TH1F*)postfile->Get("hTOFmatchedESDrawTime");
588 if ((hRawTime)&&(hRawTime->GetEntries()>0)){
589 avRawTime=hRawTime->GetMean();
590 hRawTime->Fit("landau","","",200.,250.);
591 peakRawTime=(hRawTime->GetFunction("landau"))->GetParameter(1);
592 spreadRawTime=(hRawTime->GetFunction("landau"))->GetParameter(2);
593 peakRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(1);
594 spreadRawTimeErr=(hRawTime->GetFunction("landau"))->GetParError(2);
595 printf("Main peak raw time (landau): mean = %f +- %f\n",peakTime,peakTimeErr );
596 printf("Main peak raw time (landau): spread = %f +- %f\n",spreadRawTime,spreadRawTimeErr );
597 }
598
599 printf("---------------------------------------------------------------- \n");
600
601 TH1F * hTot = (TH1F*)postfile->Get("hTOFmatchedESDToT");
602 if ((hTot)&&(hTot->GetEntries()>0)){
603 avTot=hTot->GetMean();
604 hTot->Fit("gaus","","",0.,50.);
605 peakTot=(hTot->GetFunction("gaus"))->GetParameter(1);
606 spreadTot=(hTot->GetFunction("gaus"))->GetParameter(2);
607 peakTotErr=(hTot->GetFunction("gaus"))->GetParError(1);
608 spreadTotErr=(hTot->GetFunction("gaus"))->GetParError(2);
609 printf("Main peak ToT (gaus): mean = %f +- %f\n",peakTot,peakTotErr );
610 printf("Main peak ToT (gaus): spread = %f +- %f\n",spreadTot,spreadTotErr );
611 }
612 printf("---------------------------------------------------------------- \n");
613 TH1F * hOrphansRatio=(TH1F*)postfile->Get("hOrphansRatio");
614 if (hOrphansRatio)
615 orphansRatio=hOrphansRatio->GetMean();
616
617 TH1F * hL=(TH1F*)postfile->Get("hTOFmatchedESDtrkLength");
618 if (hL)
619 avL=hL->GetMean();
620
621 TH1F *hLnegRatio =(TH1F*)postfile->Get("hLnegRatio");
622 if (hLnegRatio)
623 negLratio=hLnegRatio->GetMean();
624
625 //--------------------------------- matching eff ----------------------------------//
626
627 //Double_t linFitEff1Param[3]={0.,0.,0.};
628 TH1F *hMatchingVsPt =(TH1F*)postfile->Get("hTOFmatchedESDPt");
629 if (hMatchingVsPt) {
630 if (hMatchingVsPt->GetEntries()>0){
631 hMatchingVsPt->Fit("pol0","","",1.0,5.);
632 hMatchingVsPt->Draw();
633 if (hMatchingVsPt->GetFunction("pol0")){
634 matchEffLinFit1Gev=(hMatchingVsPt->GetFunction("pol0"))->GetParameter(0);
635 matchEffLinFit1GevErr=(hMatchingVsPt->GetFunction("pol0"))->GetParError(0);
636 printf("Matching efficiency fit param is %f +- %f\n",matchEffLinFit1Gev,matchEffLinFit1GevErr );
637 }
638 } else {
639 printf("WARNING: matching efficiency plot has 0 entries. Skipped!\n");
640 }
641 } else {
642 printf("WARNING: cannot retrieve matching efficiency plot\n");
643 }
644
645 //--------------------------------- t-texp ----------------------------------//
646
647 TH1F*hPiDiffTime=(TH1F*)postfile->Get("hTOFmatchedExpTimePi");
648 if ((hPiDiffTime)&&(hPiDiffTime->GetEntries()>0)) {
649 avPiDiffTime=hPiDiffTime->GetMean();
650 hPiDiffTime->Fit("gaus","","",-1000.,500.);
651 if (hPiDiffTime->GetFunction("gaus")){
652 peakPiDiffTime=(hPiDiffTime->GetFunction("gaus"))->GetParameter(1);
653 spreadPiDiffTime=(hPiDiffTime->GetFunction("gaus"))->GetParameter(2);
654 peakPiDiffTimeErr=(hPiDiffTime->GetFunction("gaus"))->GetParError(1);
655 spreadPiDiffTimeErr=(hPiDiffTime->GetFunction("gaus"))->GetParError(2);
656 printf("Main peak t-t_exp (gaus): mean = %f +- %f\n",peakPiDiffTime,peakPiDiffTimeErr );
657 printf("Main peak t-t_exp (gaus): spread = %f +- %f\n",spreadPiDiffTime,spreadPiDiffTimeErr );
658 }
659 }
660 //--------------------------------- T0 detector ----------------------------------//
661
662 TH1F*hT0A=(TH1F*)postfile->Get("hEventT0DetA");
663 if ((hT0A)&&(hT0A->GetEntries()>0)) {
664 avhT0A=hT0A->GetMean();
665 hT0A->Fit("gaus");
666 peakT0A=(hT0A->GetFunction("gaus"))->GetParameter(1);
667 spreadT0A=(hT0A->GetFunction("gaus"))->GetParameter(2);
668 peakT0AErr=(hT0A->GetFunction("gaus"))->GetParError(1);
669 spreadT0AErr=(hT0A->GetFunction("gaus"))->GetParError(2);
670 printf("Main peak T0A(gaus): mean = %f +- %f\n",peakT0A,peakT0AErr );
671 printf("Main peak T0A (gaus): spread = %f +- %f\n",spreadT0A,spreadT0AErr );
672 //add integral of main peak over total
673 }
674
675 TH1F*hT0C=(TH1F*)postfile->Get("hEventT0DetC");
676 if ((hT0C)&&(hT0C->GetEntries()>0)) {
677 avhT0C=hT0C->GetMean();
678 hT0C->Fit("gaus");
679 peakT0C=(hT0C->GetFunction("gaus"))->GetParameter(1);
680 spreadT0C=(hT0C->GetFunction("gaus"))->GetParameter(2);
681 peakT0CErr=(hT0C->GetFunction("gaus"))->GetParError(1);
682 spreadT0CErr=(hT0C->GetFunction("gaus"))->GetParError(2);
683 printf("Main peak T0C(gaus): mean = %f +- %f\n",peakT0C,peakT0CErr );
684 printf("Main peak T0C (gaus): spread = %f +- %f\n",spreadT0C,spreadT0CErr );
685 //add integral of main peak over total
686 }
687
688 TH1F*hT0AC=(TH1F*)postfile->Get("hEventT0DetAND");
689 if ((hT0AC)&&(hT0AC->GetEntries()>0)) {
690 avhT0AC=hT0AC->GetMean();
691 hT0AC->Fit("gaus");
692 peakT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(1);
693 spreadT0AC=(hT0AC->GetFunction("gaus"))->GetParameter(2);
694 peakT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(1);
695 spreadT0ACErr=(hT0AC->GetFunction("gaus"))->GetParError(2);
696 printf("Main peak T0AC(gaus): mean = %f +- %f\n",peakT0AC,peakT0ACErr );
697 printf("Main peak T0AC (gaus): spread = %f +- %f\n",spreadT0AC,spreadT0ACErr );
698 }
699
700 TH1F*hT0res=(TH1F*)postfile->Get("hT0DetRes");
701 if ((hT0res)&&(hT0res->GetEntries()>0)) {
702 avhT0res=hT0res->GetMean();
703 hT0res->Fit("gaus");
704 peakT0res=(hT0res->GetFunction("gaus"))->GetParameter(1);
705 spreadT0res=(hT0res->GetFunction("gaus"))->GetParameter(2);
706 peakT0resErr=(hT0res->GetFunction("gaus"))->GetParError(1);
707 spreadT0resErr=(hT0res->GetFunction("gaus"))->GetParError(2);
708 printf("Main peak T0res(gaus): mean = %f +- %f\n",peakT0res,peakT0resErr );
709 printf("Main peak T0res (gaus): spread = %f +- %f\n",spreadT0res,spreadT0resErr );
710 //add integral of main peak over total
711 }
712
713 TH1F*hT0fillRes=(TH1F*)postfile->Get("hT0fillRes");
714 if ((hT0fillRes)&&(hT0fillRes->GetEntries()>0)) {
715 avT0fillRes=hT0fillRes->GetMean();
716 }
717
718 ttree->Fill();
719 printf("============== Saving trending quantities in tree for run %i ===============\n",runNumber);
720 if (postfile->IsOpen()) {
721 printf("Trying to close\n");
722 postfile->Close();
723 }
724
725 trendFile->cd();
726 ttree->Write();
727 trendFile->Close();
728 return 0;
729}
730
3d9550f8 731//------------------------------------------------------------------------------------
732
733Int_t RunESDQApostAnalysis(char *qafilename=NULL, Int_t runNumber=-1, Bool_t IsOnGrid=kFALSE, Bool_t canvasE=kFALSE) {
734
7cc410ff 735 Bool_t debug=kFALSE;
3d9550f8 736
7cc410ff 737 /*access qa PWG1 output files - saved locally or on grid as specified by the second argument */
3d9550f8 738
7cc410ff 739 char defaultQAoutput[30]="QAresults.root";
740 if (IsOnGrid) TGrid::Connect("alien://");
741 TFile * fin= TFile::Open(qafilename,"r");
742 printf("Opening file %s\n",qafilename);
743 if (!fin) {
744 printf("ERROR: QA output not found. Exiting with status -1\n");
745 return -1;
746 } else {
747 printf("INFO: QA output file %s open. \n",fin->GetName());
748 }
3d9550f8 749
750
7cc410ff 751 //access histograms lists
752 char tofQAdirName[15]="TOF_Performance";
753 char genListName[15]="cGeneralTOFqa";
754 char t0ListName[15]="cTimeZeroTOFqa";
755 char pidListName[15]="cPIDTOFqa";
756 char posListName[15]="cPositiveTOFqa";
757 char negListName[15]="cNegativeTOFqa";
3d9550f8 758
7cc410ff 759 TDirectoryFile * tofQAdir=(TDirectoryFile*)fin->Get(tofQAdirName);
760 if(debug){
761 printf("------------------------------------------------------------------\n");
762 tofQAdir->ls();
763 printf("------------------------------------------------------------------\n");
764 }
3d9550f8 765
7cc410ff 766 TList * generalList=(TList*)tofQAdir->Get(genListName);
767 TList *timeZeroList=(TList*)tofQAdir->Get(t0ListName);
768 TList *pidList=(TList*)tofQAdir->Get(pidListName);
769 TList *posList=(TList*)tofQAdir->Get(posListName);
770 TList *negList=(TList*)tofQAdir->Get(negListName);
771
772 if (!generalList) printf("WARNING: general QA histograms absent or not accessible\n");
773 if (!timeZeroList) printf("WARNING: timeZero QA histograms absent or not accessible\n");
774 if (!pidList) printf("WARNING: PID QA histograms absent or not accessible\n");
775 if (!posList) printf("WARNING: general QA histograms for positive tracks absent or not accessible\n");
776 if (!negList) printf("WARNING: general QA histograms for negative tracks absent or not accessible\n");
777
778 if ( (!generalList) && (!timeZeroList) && (!pidList) ){
779 printf("ERROR: no QA available \n");
780 return 1;
781 }
3d9550f8 782
7cc410ff 783 if (debug){
784 generalList->ls();
785 printf("------------------------------------------------------------------\n");
786 timeZeroList->ls();
787 printf("------------------------------------------------------------------\n");
788 pidList->ls();
789 printf("------------------------------------------------------------------\n");
790 }
791
792 /*set graphic style*/
793 gStyle->SetCanvasColor(kWhite);
794 gStyle->SetFrameFillColor(kWhite);
795 gStyle->SetFrameBorderMode(0);
796 gStyle->SetCanvasBorderMode(0);
797 gStyle->SetTitleFillColor(kWhite);
798 gStyle->SetTitleBorderSize(0) ;
799 gStyle->SetTitleFont(42);
800 gStyle->SetTextFont(42);
801 //gStyle->SetPalette(1);
802 gStyle->SetStatColor(kWhite);
803 gStyle->SetStatBorderSize(1);
804 gStyle->SetOptStat(0);
3d9550f8 805
7cc410ff 806 //DEFINE OUTPUT FILE
807 char outfilename[60];
808 sprintf(outfilename,"postQA_%i.root",runNumber);
809 TFile * fout=new TFile(outfilename,"recreate");
810
811 TH1I* hRunNumber=new TH1I("hRunNumber","hRunNumber;run",1,runNumber,runNumber+1);
812 hRunNumber->Fill(runNumber);
813
814 //-------------------------------------------------------------
815 /*GENERAL MONITOR - MULTIPLICITY*/
816 TH1F*hMulti= (TH1F*) generalList->At(0);
817
818 TH1F* hFractionEventsWhits=new TH1F("hFractionEventsWhits","hFractionEventsWhits;fraction of events with hits (%)",200,0.,100.);
819 Float_t fraction=0.0;
820 if (hMulti->GetEntries()>0.0) fraction=((Float_t) hMulti->GetBinContent(1))/((Float_t) hMulti->GetEntries());
821 else fraction=0.0;
822 hFractionEventsWhits->Fill(fraction*100.);
823
824 //-------------------------------------------------------------
825 /*GENERAL MONITOR - TIMING AND GEOMETRY*/
826 TH1F * hTime = (TH1F*) generalList->At(1);
827 hTime->SetMarkerStyle(8);
828 hTime->SetMarkerSize(0.7);
829 hTime->SetMarkerColor(kBlue);
830 hTime->SetLineColor(kBlue);
831 hTime->SetFillColor(kBlue);
832 hTime->SetFillStyle(3001);
833 hTime->Rebin(2);
834 hTime->GetYaxis()->SetTitle("matched tracks");
835 hTime->GetYaxis()->SetTitleOffset(1.35);
3d9550f8 836
7cc410ff 837 TH1F * hRawTime = (TH1F*) generalList->At(2);
838 hRawTime->SetMarkerStyle(21);
839 hRawTime->SetMarkerSize(0.7);
840 hRawTime->SetMarkerColor(kGreen);
841 hRawTime->SetLineColor(kGreen);
842 hRawTime->SetFillColor(kGreen);
843 hRawTime->SetFillStyle(3001);
844 hRawTime->Rebin(2);
845 hRawTime->GetYaxis()->SetTitle("matched tracks");
846 hRawTime->GetYaxis()->SetTitleOffset(1.35);
3d9550f8 847
7cc410ff 848 TLegend *lTime = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
849 lTime->SetTextSize(0.04281433);
850 lTime->AddEntry(hRawTime, "raw","L");
851 lTime->AddEntry(hTime, "ESD","L");
852 lTime->SetFillColor(kWhite);
853 lTime->SetShadowColor(0);
854
855 TH1F * hTot = (TH1F*) generalList->At(3);
856 hTot->SetMarkerStyle(8);
857 hTot->SetMarkerSize(0.7);
858 hTot->SetMarkerColor(kViolet-3);
859 hTot->SetLineColor(kViolet-3);
860 hTot->SetFillColor(kViolet-3);
861 hTot->SetFillStyle(3001);
862 //hTime->SetDrawOption();
863 hTot->GetYaxis()->SetTitle("matched tracks");
864 hTot->GetYaxis()->SetTitleOffset(1.35);
3d9550f8 865
866
7cc410ff 867 char orphansTxt[200];
868 Float_t orphansRatio=0.0;
869 if (hTot->GetEntries()>1){
870 orphansRatio=((Float_t) hTot->GetBinContent(1))/((Float_t) hTot->GetEntries()) ;
871 }
872 sprintf(orphansTxt,"orphans/matched tracks = %.4f ",orphansRatio);
873 TH1F * hOrphansRatio=new TH1F("hOrphansRatio","Percentage of signals with only leading edge; percentage (%)",1000,0.,100.);
874 hOrphansRatio->Fill(orphansRatio*100.);
875
876
877 TPaveText *tOrphans = new TPaveText(0.38,0.63,0.88,0.7, "NDC");
878 //NDC sets coords relative to pad
879 tOrphans->SetBorderSize(0);
880 tOrphans->SetTextSize(0.045);
881 tOrphans->SetFillColor(0); //white background
882 tOrphans->SetTextAlign(12);
883 tOrphans->SetTextColor(kViolet-3);
884 tOrphans->AddText(orphansTxt);
3d9550f8 885
7cc410ff 886 TH1F * hL = (TH1F*) generalList->At(4);
887 hL->SetMarkerStyle(8);
888 hL->SetMarkerSize(0.7);
889 hL->SetMarkerColor(kOrange-3);
890 hL->SetLineColor(kOrange-3);
891 hL->SetFillColor(kOrange-3);
892 hL->SetFillStyle(3001);
893 //hTime->SetDrawOption();
894 hL->GetYaxis()->SetTitle("matched tracks");
895 hL->GetYaxis()->SetTitleOffset(1.35);
896
897 char negLengthTxt[200];
898 Float_t negLengthRatio=0.0;
899 if (hL->GetEntries()>1){
900 negLengthRatio=(hL->Integral(1,750))/((Float_t) hL->GetEntries()) ;
901 }
902 sprintf(negLengthTxt,"tracks with L<350cm /matched tracks = %.5f ",negLengthRatio);
903 TH1F * hLnegRatio=new TH1F("hLnegRatio","Ratio of TOF-matched tracks with L<350cm; ratio (%)",10000,0.,100.);
904 hLnegRatio->Fill(negLengthRatio*100);
3d9550f8 905
906
907
7cc410ff 908 TPaveText *tLength = new TPaveText(0.15,0.83,0.65,0.87, "NDC");
909 //NDC sets coords relative to pad
910 tLength->SetBorderSize(0);
911 tLength->SetTextSize(0.04);
912 tLength->SetFillColor(0); //white background
913 tLength->SetTextAlign(11);
914 tLength->SetTextColor(kOrange-3);
915 tLength->AddText(negLengthTxt);
3d9550f8 916
7cc410ff 917 if (canvasE){
918 TCanvas *cTrackProperties= new TCanvas("cTrackProperties","summary of matched tracks properties",900,900);
919 cTrackProperties->Divide(2,2);
920 cTrackProperties->cd(1);
921 gPad->SetLogy();
922 gPad->SetGridx();
923 gPad->SetGridy();
924 hTime->Draw("BAR");
925 hRawTime ->Draw("BARsame");
926 lTime->Draw();
927 cTrackProperties->cd(2);
928 gPad->SetGridx();
929 gPad->SetGridy();
930 gPad->SetLogy();
931 hTot->Draw("BAR");
932 tOrphans->Draw();
933 cTrackProperties->cd(3);
934 gPad->SetGridx();
935 gPad->SetGridy();
936 gPad->SetLogy();
937 hL->Draw("BAR");
938 tLength->Draw();
939 }
940 fout->cd();
941 hRunNumber->Write();
942 hMulti->Write();
943 hFractionEventsWhits->Write();
944 hTime->Write();
945 hRawTime->Write();
946 hTot->Write();
947 hOrphansRatio->Write();
948 hL->Write();
949 hLnegRatio->Write();
3d9550f8 950
7cc410ff 951 TH2F* hDxPos4profile = (TH2F*) generalList->At(14);
952 TH2F* hDxNeg4profile = (TH2F*) generalList->At(13);
3d9550f8 953
7cc410ff 954 char profilename[30];
955 const Int_t ybinMin = 0;
956 const Int_t ybinMax =hDxPos4profile->GetYaxis()->GetNbins() ;
957 sprintf(profilename,"profDxPos");
958 TProfile * profDxPos = (TProfile*)hDxPos4profile->ProfileX(profilename, ybinMin,ybinMax);
959 sprintf(profilename,"profDxNeg");
960 profDxPos->SetLineWidth(2);
961 TProfile * profDxNeg = (TProfile*)hDxNeg4profile->ProfileX(profilename, ybinMin, ybinMax);
962 profDxNeg->SetLineWidth(2);
3d9550f8 963
7cc410ff 964 TH1 *profRatioPosOverNegDx = (TH1*) profDxPos->Clone();
965 profRatioPosOverNegDx->SetName("profRatioPosOverNegDx");
966 profRatioPosOverNegDx->Divide((TH1*) profDxNeg);
967 profRatioPosOverNegDx->GetYaxis()->SetRangeUser(-5.,5.);
968 profRatioPosOverNegDx->GetXaxis()->SetRangeUser(0.,2.);
969 if (canvasE){
970 TCanvas *residuals= new TCanvas("residuals","residuals",900,450);
971 residuals->Divide(2,1);
972 residuals->cd(1);
973 gPad->SetGridx();
974 gPad->SetGridy();
975 hDxPos4profile->GetYaxis()->SetRangeUser(-5.,5.);
976 hDxPos4profile->Draw("colz");
977 profDxPos->SetLineColor(kRed);
978 profDxPos ->Draw("same");
979 residuals->cd(2);
980 gPad->SetGridx();
981 gPad->SetGridy();
982 hDxNeg4profile->GetYaxis()->SetRangeUser(-5.,5.);
983 hDxNeg4profile->Draw("colz");
984 profDxNeg->SetLineColor(kBlue);
985 profDxNeg->Draw("same");
986 }
987
988 fout->cd();
989 hDxPos4profile->Write();
990 hDxNeg4profile->Write();
991 profDxPos->Write();
992 profDxNeg->Write();
993 profRatioPosOverNegDx->Write();
994 //-------------------------------------------------------------
995 /* T0 DETECTOR MONITOR*/
996
997 TH1F * hT0AC = (TH1F*) timeZeroList->At(0);
998 hT0AC->SetMarkerStyle(8);
999 hT0AC->SetMarkerSize(0.7);
1000 hT0AC->SetMarkerColor(kRed);
1001 hT0AC->SetLineColor(kRed);
1002 hT0AC->SetFillColor(kRed);
1003 hT0AC->SetFillStyle(1001);
1004 hT0AC->Rebin(2);
1005 hT0AC->GetYaxis()->SetTitle("events");
1006 hT0AC->GetYaxis()->SetTitleOffset(1.35);
1007 hT0AC->GetXaxis()->SetLabelSize(0.03);
3d9550f8 1008
7cc410ff 1009 TH1F * hT0A = (TH1F*) timeZeroList->At(1);
1010 hT0A->SetMarkerStyle(8);
1011 hT0A->SetMarkerSize(0.7);
1012 hT0A->SetMarkerColor(kBlue);
1013 hT0A->SetLineColor(kBlue);
1014 hT0A->SetFillColor(kBlue);
1015 hT0A->SetFillStyle(1001);
1016 hT0A->Rebin(2);
1017 hT0A->GetYaxis()->SetTitle("events");
1018 hT0A->GetYaxis()->SetTitleOffset(1.35);
1019 hT0A->GetXaxis()->SetLabelSize(0.03);
1020
1021 TH1F * hT0C = (TH1F*) timeZeroList->At(2);
1022 hT0C->SetMarkerStyle(8);
1023 hT0C->SetMarkerSize(0.7);
1024 hT0C->SetMarkerColor(kGreen);
1025 hT0C->SetLineColor(kGreen);
1026 hT0C->SetFillColor(kGreen);
1027 hT0C->SetFillStyle(1001);
1028 hT0C->Rebin(2);
1029 hT0C->GetYaxis()->SetTitle("events");
1030 hT0C->GetYaxis()->SetTitleOffset(1.35);
1031 hT0C->GetXaxis()->SetLabelSize(0.03);
3d9550f8 1032
7cc410ff 1033 TLegend *lT0 = new TLegend(0.7125881,0.6052519,0.979435,0.7408306,NULL,"brNDC");
1034 lT0->SetTextSize(0.041);
1035 lT0->AddEntry(hT0AC, "T0 A&C","L");
1036 lT0->AddEntry(hT0A, "T0 A","L");
1037 lT0->AddEntry(hT0C, "T0 C","L");
1038 lT0->SetFillColor(kWhite);
1039 lT0->SetShadowColor(0);
3d9550f8 1040
7cc410ff 1041 TH1F * hT0res = (TH1F*) timeZeroList->At(3);
1042 hT0res->GetXaxis()->SetLabelSize(0.03);
1043 if (canvasE){
1044 TCanvas *cT0detector= new TCanvas("cT0detector","T0 detector",900,450);
1045 cT0detector->Divide(2,1);
1046 cT0detector->cd(1);
1047 gPad->SetGridx();
1048 gPad->SetGridy();
1049 hT0AC->Draw("BAR");
1050 hT0AC->SetTitle("timeZero measured by T0 detector");
1051 hT0A ->Draw("BARsame");
1052 hT0C ->Draw("BARsame");
1053 lT0->Draw();
1054 cT0detector->cd(2);
1055 gPad->SetGridx();
1056 gPad->SetGridy();
1057 // gPad->SetLogy();
1058 hT0res->Draw();
1059 // myText1->Draw();
1060 // cTrackProperties->cd(3);
1061 // gPad->SetLogy();
1062 // hL->Draw("BAR");
1063 // myText2->Draw();
1064 }
1065
1066 TH1F * hT0fillRes = (TH1F*) timeZeroList->At(8);
1067 hT0fillRes->GetXaxis()->SetLabelSize(0.03);
1068
1069 fout->cd();
1070 hT0AC->Write();
1071 hT0A->Write();
1072 hT0C->Write();
1073 hT0res->Write();
1074 hT0fillRes->Write();
1075 lT0->Write();
3d9550f8 1076
1077
7cc410ff 1078 //-------------------------------------------------------------
1079 /*MATCHING EFFICIENCY MONITOR*/
3d9550f8 1080
7cc410ff 1081 //TH1F * hMatchingVsP =new TH1F("hMatchingVsP","Matching probability vs. P; P(GeV/c); matching probability", 50, 0., 5. );
3d9550f8 1082
7cc410ff 1083 TH1F * hMatchingVsPt =new TH1F("hMatchingVsPt","Matching probability vs. Pt; Pt(GeV/c); matching probability", 50, 0., 5. );
3d9550f8 1084
7cc410ff 1085 TH1F * hMatchingVsEta =new TH1F("hMatchingVsEta","Matching probability vs. #\Eta; #\Eta; matching probability", 20, -1., 1.);
3d9550f8 1086
7cc410ff 1087 TH1F * hMatchingVsPhi =new TH1F("hMatchingVsPhi","Matching probability vs. Phi; Phi(rad); matching probability", 628, 0., 6.28);
3d9550f8 1088
7cc410ff 1089 /*/matching as function of p
1090 TH1F * hDenom=(TH1F*)generalList->At(9);
1091 if (hDenom) {
1092 hMatchingVsP=(TH1F*) generalList->At(5);
1093 hMatchingVsP->Rebin(5);
1094 hDenom->Rebin(5);
1095 hMatchingVsP->Divide(hDenom);
1096 hMatchingVsP->GetYaxis()->SetTitle("matching efficiency");
1097 hMatchingVsP->SetTitle("TOF matching efficiency as function of momentum");
1098 }*/
3d9550f8 1099
7cc410ff 1100 //matching as function of pT
3d9550f8 1101
7cc410ff 1102 // hDenom->Clear();
1103 TH1F * hDenom=(TH1F*)generalList->At(10);
1104 if (hDenom) {
1105 hMatchingVsPt=(TH1F*) generalList->At(6);
1106 hMatchingVsPt->Rebin(5);
1107 hDenom->Rebin(5);
1108 hMatchingVsPt->Divide(hDenom);
1109 hMatchingVsPt->GetYaxis()->SetTitle("matching efficiency");
1110 hMatchingVsPt->SetTitle("TOF matching efficiency as function of transverse momentum");
1111 hMatchingVsPt->GetYaxis()->SetRangeUser(0,1.2);
1112 }
3d9550f8 1113
7cc410ff 1114 //matching as function of eta
1115 hDenom->Clear();
1116 hDenom=(TH1F*)generalList->At(11);
1117 if (hDenom) {
1118 hMatchingVsEta=(TH1F*) generalList->At(7);
1119 hMatchingVsEta->Rebin(5);
1120 hDenom->Rebin(5);
1121 hMatchingVsEta->Divide(hDenom);
1122 hMatchingVsEta->GetXaxis()->SetRangeUser(-1,1);
1123 hMatchingVsEta->GetYaxis()->SetTitle("matching efficiency");
1124 hMatchingVsEta->GetYaxis()->SetRangeUser(0,1.2);
1125 hMatchingVsEta->SetTitle("TOF matching efficiency as function of pseudorapidity");
1126 }
1127 //matching as function of phi
1128 hDenom->Clear();
1129 hDenom=(TH1F*)generalList->At(12);
1130 if (hDenom) {
1131 hMatchingVsPhi=(TH1F*) generalList->At(8);
1132 //hMatchingVsPhi->Rebin(5);
1133 //hDenom->Rebin(5);
1134 hMatchingVsPhi->Divide(hDenom);
1135 hMatchingVsPhi->GetYaxis()->SetTitle("matching efficiency");
1136 hMatchingVsPhi->SetTitle("TOF matching efficiency as function of phi");
1137 hMatchingVsPhi->GetYaxis()->SetRangeUser(0,1.2);
1138 }
1139 if ( canvasE){
1140 TCanvas *cMatchingPerformance= new TCanvas("cMatchingPerformance","summary of matching performance",700,400);
1141 cMatchingPerformance->Divide(2,2);
1142 cMatchingPerformance->cd(1);
1143 gPad->SetGridx();
1144 gPad->SetGridy();
1145 hMatchingVsPt->Draw();
1146 cMatchingPerformance->cd(2);
1147 gPad->SetGridx();
1148 gPad->SetGridy();
1149 hMatchingVsEta->Draw();
1150 cMatchingPerformance->cd(3);
1151 gPad->SetGridx();
1152 gPad->SetGridy();
1153 hMatchingVsPhi->Draw();
1154 }
1155 fout->cd();
1156 hMatchingVsPt->Write();
1157 hMatchingVsEta->Write();
1158 hMatchingVsPhi->Write();
3d9550f8 1159
7cc410ff 1160 //----------------------------------------------------
1161 /* PID PERFORMANCE MONITOR */
1162
1163 TH2F * hBetaP=(TH2F*)pidList->At(0);
1164 hBetaP->GetYaxis()->SetRangeUser(0.,1.2);
1165 TH1F * hMass=(TH1F*)pidList->At(1);
1166 //hMass->SetMarkerColor(kBlue);
1167 //hMass->SetLineColor(kBlue);
1168 hMass->SetFillColor(kAzure+10);
1169 hMass->SetFillStyle(1001);
1170 hMass->Rebin(2);
1171 hMass->GetYaxis()->SetTitle("tracks");
1172 hMass->GetYaxis()->SetTitleOffset(1.35);
1173 hMass->GetXaxis()->SetLabelSize(0.03);
1174
1175 TH1F * hPionDiff=(TH1F*)pidList->At(3);
3d9550f8 1176
1177
7cc410ff 1178 TH2F * hDiffTimePi=(TH2F*)pidList->At(4);
1179 hDiffTimePi->GetYaxis()->SetRangeUser(-2000.,2000.);
6c125480 1180 hDiffTimePi->SetTitle("PIONS t-t_{exp,#pi} (from tracking) vs. P");
1181 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
7cc410ff 1182 sprintf(profilename,"profDiffTimePi");
3d9550f8 1183
7cc410ff 1184 TProfile * profDiffTimePi = (TProfile*)hDiffTimePi->ProfileX(profilename, 490, 510);
1185 profDiffTimePi->SetLineWidth(2);
1186 profDiffTimePi->SetLineColor(kRed+2);
1187
1188 TH2F * hDiffTimePiTh=(TH2F*)pidList->At(6);
1189 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1190 sprintf(profilename,"profDiffTimePiTh");
1191 hDiffTimePiTh->GetYaxis()->SetRangeUser(-2000.,2000.);
3d9550f8 1192
7cc410ff 1193 TProfile * profDiffTimePiTh = (TProfile*)hDiffTimePiTh->ProfileX(profilename, 490, 510);
1194 profDiffTimePiTh->SetLineWidth(2);
1195 profDiffTimePiTh->SetLineColor(kRed+2);
1196
1197 TH2F * hDiffTimeKa=(TH2F*)pidList->At(9);
1198 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
6c125480 1199 hDiffTimeKa->SetTitle("KAONS t-t_{exp,K} (from tracking) vs. P");
7cc410ff 1200 sprintf(profilename,"profDiffTimeKa");
1201 hDiffTimeKa->GetYaxis()->SetRangeUser(-2000.,2000.);
3d9550f8 1202
7cc410ff 1203 TProfile * profDiffTimeKa = (TProfile*)hDiffTimeKa->ProfileX(profilename, 490, 510);
1204 profDiffTimeKa->SetLineWidth(2);
1205 profDiffTimeKa->SetLineColor(kBlue);
1206
1207 TH2F * hDiffTimeKaTh=(TH2F*)pidList->At(11);
1208 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1209 sprintf(profilename,"profDiffTimeKaTh");
1210 hDiffTimeKaTh->GetYaxis()->SetRangeUser(-2000.,2000.);
1211 TProfile * profDiffTimeKaTh = (TProfile*)hDiffTimeKaTh->ProfileX(profilename, 490, 510);
1212 profDiffTimeKaTh->SetLineWidth(2);
1213 profDiffTimeKaTh->SetLineColor(kBlue);
3d9550f8 1214
7cc410ff 1215 TH2F * hDiffTimePro=(TH2F*)pidList->At(14);
1216 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1217 sprintf(profilename,"profDiffTimePro");
6c125480 1218 hDiffTimePro->SetTitle("PROTONS t-t_{exp,p} (from tracking) vs. P");
7cc410ff 1219 hDiffTimePro->GetYaxis()->SetRangeUser(-2000.,2000.);
1220 TProfile * profDiffTimePro = (TProfile*)hDiffTimePro->ProfileX(profilename, 490, 510);
1221 profDiffTimePro->SetLineWidth(2);
1222 profDiffTimePro->SetLineColor(kGreen+2);
1223
1224 TH2F * hDiffTimeProTh=(TH2F*)pidList->At(16);
1225 //hDiffTime->GetYaxis()->Rebin(2);//1 bin=10 ps
1226 sprintf(profilename,"profDiffTimeProTh");
1227 hDiffTimeProTh->GetYaxis()->SetRangeUser(-2000.,2000.);
1228 TProfile * profDiffTimeProTh = (TProfile*)hDiffTimeProTh->ProfileX(profilename, 490, 510);
1229 profDiffTimeProTh->SetLineWidth(2);
1230 profDiffTimeProTh->SetLineColor(kGreen+2);
1231
1232 if (canvasE){
1233 TCanvas *cPidPerformance= new TCanvas("cPidPerformance","summary of pid performance",800,800);
1234 cPidPerformance->Divide(2,1);
1235 cPidPerformance->cd(1);
1236 gPad->SetGridy();
1237 gPad->SetGridx();
1238 gPad->SetLogz();
1239 hBetaP->Draw("colz");
3d9550f8 1240
7cc410ff 1241 cPidPerformance->cd(2);
1242 gPad->SetGridx();
1243 gPad->SetGridy();
1244 gPad->SetLogy();
1245 hMass->Draw("HIST BAR");
3d9550f8 1246
7cc410ff 1247 TLegend * lPid=new TLegend(0.75,0.75,0.95,0.95,"PID");
1248 lPid->AddEntry(profDiffTimePi,"#pi^{#pm}","l");
1249 lPid->AddEntry(profDiffTimeKa,"K^{#pm}","l");
1250 lPid->AddEntry(profDiffTimePro,"p^{#pm}","l");
1251
1252 gStyle->SetOptStat(10);
1253 TCanvas *cPidPerformance2= new TCanvas("cPidPerformance2","summary of pid performance - tracking",700,700);
1254 cPidPerformance2->Divide(2,2);
1255 cPidPerformance2->cd(1);
1256 gPad->SetLogz();
1257 gPad->SetGridx();
1258 gPad->SetGridy();
1259 hDiffTimePi->Draw("colz");
1260 // profDiffTimePi->Draw("same");
3d9550f8 1261
7cc410ff 1262 cPidPerformance2->cd(2);
1263 gPad->SetLogz();
1264 gPad->SetGridx();
1265 gPad->SetGridy();
1266 hDiffTimeKa->Draw("colz");
1267 //profDiffTimeKa->Draw("same");
1268 cPidPerformance2->cd(3);
1269 gPad->SetLogz();
1270 hDiffTimePro->Draw("colz");
1271 // profDiffTimePro->Draw("same");
3d9550f8 1272
7cc410ff 1273 // cPidPerformance2->cd(4);
1274 // profDiffTimePi->Draw();
1275 // profDiffTimeKa->Draw("same");
1276 // profDiffTimePro->Draw("same");
1277 // lPid->Draw("same");
3d9550f8 1278
7cc410ff 1279 TCanvas *cPidPerformanceTh= new TCanvas("cPidPerformanceTh","summary of pid performance - theoretical times",700,700);
1280 cPidPerformanceTh->Divide(2,2);
1281 cPidPerformanceTh->cd(1);
1282 gPad->SetLogz();
1283 gPad->SetGridx();
1284 gPad->SetGridy();
1285 hDiffTimePiTh->Draw("colz");
1286 profDiffTimePiTh->Draw("same");
1287 cPidPerformanceTh->cd(2);
1288 gPad->SetLogz();
1289 gPad->SetGridx();
1290 gPad->SetGridy();
1291 hDiffTimeKaTh->Draw("colz");
1292 profDiffTimeKaTh->Draw("same");
1293 cPidPerformanceTh->cd(3);
1294 gPad->SetLogz();
1295 gPad->SetGridx();
1296 gPad->SetGridy();
1297 hDiffTimeProTh->Draw("colz");
1298 profDiffTimeProTh->Draw("same");
1299 // cPidPerformanceTh->cd(4);
1300 // profDiffTimePiTh->Draw();
1301 // profDiffTimeKaTh->Draw("same");
1302 // profDiffTimeProTh->Draw("same");
1303 // lPid->Draw("same");
1304 }
3d9550f8 1305
7cc410ff 1306 TH1F * hPionDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePi");
1307 TH1F * hKaonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimeKa");
1308 TH1F * hProtonDiff=(TH1F*)pidList->FindObject("hTOFmatchedExpTimePro");
3d9550f8 1309
1310
7cc410ff 1311 fout->cd();
1312 hPionDiff->Write();
1313 hKaonDiff->Write();
1314 hProtonDiff->Write();
1315
1316 hBetaP->Write();
1317 hMass->Write();
1318 hDiffTimePi->Write();
1319 profDiffTimePi->Write();
1320 hDiffTimeKa->Write();
1321 profDiffTimeKa->Write();
1322 hDiffTimePro->Write();
1323 profDiffTimePro->Write();
1324 //lPid->Draw();
1325 hDiffTimePiTh->Write();
1326 profDiffTimePiTh->Write();
1327 hDiffTimeKaTh->Write();
1328 profDiffTimeKaTh->Write();
1329 hDiffTimeProTh->Write();
1330 profDiffTimeProTh->Write();
3d9550f8 1331
7cc410ff 1332 //SIGMAS PID
1333 TH2F * hSigmaPi=(TH2F*)pidList->At(7);
1334 sprintf(profilename,"profSigmaPi");
1335 hSigmaPi->GetYaxis()->SetRangeUser(-5.,5.);
1336 TProfile * profSigmaPi = (TProfile*)hSigmaPi->ProfileX(profilename);
1337 profSigmaPi->SetLineWidth(2);
1338 profSigmaPi->SetLineColor(kRed+2);
1339
1340 TH2F * hSigmaKa=(TH2F*)pidList->At(12);
1341 sprintf(profilename,"profSigmaKa");
1342 hSigmaKa->GetYaxis()->SetRangeUser(-5.,5.);
1343 TProfile * profSigmaKa = (TProfile*)hSigmaKa->ProfileX(profilename);
1344 profSigmaKa->SetLineWidth(2);
1345 profSigmaKa->SetLineColor(kBlue);
1346
1347 TH2F * hSigmaPro=(TH2F*)pidList->At(17);
1348 sprintf(profilename,"profSigmaPro");
1349 hSigmaPro->GetYaxis()->SetRangeUser(-5.,5.);
1350 TProfile * profSigmaPro = (TProfile*)hSigmaPro->ProfileX(profilename);
1351 profSigmaPro->SetLineWidth(2);
1352 profSigmaPro->SetLineColor(kGreen+2);
1353
1354
1355 if (canvasE){
1356
1357 TLegend * lSigmaPid=new TLegend(0.75,0.75,0.95,0.95,"#sigma_{PID}");
1358 lSigmaPid->AddEntry(profSigmaPi,"#pi^{#pm}","l");
1359 lSigmaPid->AddEntry(profSigmaKa,"K^{#pm}","l");
1360 lSigmaPid->AddEntry(profSigmaPro,"p^{#pm}","l");
1361
1362 TCanvas *cPidPerformance3= new TCanvas("cPidPerformance3","summary of pid performance - sigmas",1200,400);
1363 cPidPerformance3->Divide(3,1);
1364 cPidPerformance3->cd(1);
1365 gPad->SetLogz();
1366 gPad->SetGridx();
1367 gPad->SetGridy();
1368
1369 hSigmaPi->Draw("colz");
1370 profSigmaPi->Draw("same");
1371
1372 cPidPerformance3->cd(2);
1373 gPad->SetLogz();
1374 gPad->SetGridx();
1375 gPad->SetGridy();
1376 hSigmaKa->Draw("colz");
1377 profSigmaKa->Draw("same");
1378
1379 cPidPerformance3->cd(3);
1380 gPad->SetGridx();
1381 gPad->SetGridy();
1382 gPad->SetLogz();
1383 hSigmaPro->Draw("colz");
1384 profSigmaPro->Draw("same");
1385 }
1386
1387 fout->cd();
1388 hSigmaPi->Write();
1389 profSigmaPi->Write();
1390 hSigmaKa->Write();
1391 profSigmaKa->Write();
1392 hSigmaPro->Write();
1393 profSigmaPro->Write();
1394
2e4f8a9f 1395 TH2F* hTOFmatchedDzVsStrip = (TH2F*)generalList->FindObject("hTOFmatchedDzVsStrip");
1396
7cc410ff 1397 if (canvasE){
7cc410ff 1398 TCanvas* cProfile = new TCanvas("cProfile","cProfile",50,50,750,550);
1399 gStyle->SetOptStat(0);
1400 hTOFmatchedDzVsStrip->Draw("colz");
1401 Int_t binmin = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(-3);
1402 Int_t binmax = hTOFmatchedDzVsStrip->GetYaxis()->FindBin(3);
1403 TProfile* hDzProfile = (TProfile*)hTOFmatchedDzVsStrip->ProfileX("hDzProfile",binmin, binmax);
1404 hDzProfile->SetLineWidth(3);
1405 hDzProfile->Draw("same");
1406 cProfile->SetGridx();
1407 cProfile->SetGridy();
1408 TString plotDir(Form("Plots_run%d",runNumber));
1409 gSystem->Exec(Form("mkdir %s",plotDir.Data()));
1410 cPidPerformance3->Print(Form("%s/PID_sigmas.png",plotDir.Data()));
1411 cPidPerformance->Print(Form("%s/PID.png",plotDir.Data()));
6c125480 1412 cPidPerformanceTh->Print(Form("%s/PID_theoreticalTimes.png",plotDir.Data()));
7cc410ff 1413 cPidPerformance2->Print(Form("%s/PID_ExpTimes.png",plotDir.Data()));
1414 cMatchingPerformance->Print(Form("%s/Matching.png",plotDir.Data()));
1415 cT0detector->Print(Form("%s/T0Detector.png",plotDir.Data()));
1416 cTrackProperties->Print(Form("%s/TrackProperties.png",plotDir.Data()));
1417 residuals->Print(Form("%s/Residuals.png",plotDir.Data()));
1418 cProfile->Print(Form("%s/ProfileDZvsStripNumber.png",plotDir.Data()));
1419 }
2e4f8a9f 1420 fout->cd();
1421 hTOFmatchedDzVsStrip->Write();
7cc410ff 1422
1423 return 0;
3d9550f8 1424}
1425
1426//----------------------------------------------------------
1427char * SetQAtrainOutputName(Int_t run=0,Int_t year=2011,char *period="LHC11a", char* pass="cpass1",Int_t trainId=76){
1428
7cc410ff 1429 char infile[200];
1430 sprintf(infile,"alien:///alice/data/%i/%s/000%d/ESDs/%s/QA%i/QAresults.root",year,period,runNumber,pass,trainId);
1431 return infile;
3d9550f8 1432
1433}
1434
1435
1436