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