]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGPP/TOF/AliAnalysisTaskTOFqa.cxx
Bug fix in phi distribution for matching efficiency
[u/mrichter/AliRoot.git] / PWGPP / TOF / AliAnalysisTaskTOFqa.cxx
1 /*  created by fbellini@cern.ch on 14/09/2010 */
2 /*  last modified by fbellini   on 31/03/2010 */
3
4
5 #ifndef ALIANALYSISTASKTOFQA_CXX
6 #define ALIANALYSISTASKTOFQA_CXX
7
8 #include "TChain.h"
9 #include "TTree.h"
10 #include "TH1F.h"
11 #include "TH2F.h"
12 #include "TCanvas.h"
13 #include "AliAnalysisTaskSE.h"
14 #include "AliAnalysisManager.h"
15 #include "AliESDEvent.h"
16 #include "AliESDInputHandler.h"
17 #include "AliESDpid.h"
18 #include "AliAnalysisTaskTOFqa.h"
19 #include "AliAnalysisFilter.h"
20 #include "AliESDtrackCuts.h"
21 #include "AliLog.h"
22 #include "AliTOFRawStream.h"
23 #include "AliTOFGeometry.h"
24
25 ClassImp(AliAnalysisTaskTOFqa)
26
27 //________________________________________________________________________
28 AliAnalysisTaskTOFqa::AliAnalysisTaskTOFqa() :
29   fRunNumber(0), 
30   fESD(0x0), 
31   fTrackFilter(0x0), 
32   fVertex(0x0),
33   fESDpid(new AliESDpid()),
34   fNTOFtracks(0), 
35 //  fNPrimaryTracks(0), 
36   fEnableAdvancedCheck(kFALSE),
37   fExpTimeBinWidth(24.4),
38   fExpTimeRangeMin(-25010.),
39   fExpTimeRangeMax(25010.),
40   fExpTimeSmallRangeMin(-5002.),
41   fExpTimeSmallRangeMax(5002.),
42   fHlist(0x0),
43   fHlistTimeZero(0x0),
44   fHlistPID(0x0),
45   fHpos(0x0),
46   fHneg(0x0)
47  {
48   // Default constructor
49    
50    for (Int_t j=0;j<3;j++ ) {
51      if (j<3) fT0[j]=0.0;
52      fSigmaSpecie[j]=0.0;
53      fTrkExpTimes[j]=0.0;
54      fThExpTimes[j]=0.0;
55    }
56  }
57 //________________________________________________________________________
58 AliAnalysisTaskTOFqa::AliAnalysisTaskTOFqa(const char *name) : 
59   AliAnalysisTaskSE(name), 
60   fRunNumber(0), 
61   fESD(0x0), 
62   fTrackFilter(0x0),
63   fVertex(0x0),
64   fESDpid(new AliESDpid()),
65   fNTOFtracks(0), 
66   // fNPrimaryTracks(0),
67   fEnableAdvancedCheck(kFALSE),
68   fExpTimeBinWidth(24.4),
69   fExpTimeRangeMin(-25010.),
70   fExpTimeRangeMax(25010.),
71   fExpTimeSmallRangeMin(-5002.),
72   fExpTimeSmallRangeMax(5002.),
73   fHlist(0x0),
74   fHlistTimeZero(0),
75   fHlistPID(0x0),
76   fHpos(0x0),
77   fHneg(0x0)
78  {
79   // Constructor
80   // Define input and output slots here
81    Info("AliAnalysisTaskTOFqa","Calling Constructor");
82    
83    for (Int_t j=0;j<5;j++ ) {
84      if (j<3) fT0[j]=0.0;
85      fSigmaSpecie[j]=0.0;
86      fTrkExpTimes[j]=0.0;
87      fThExpTimes[j]=0.0;
88    }
89    // Input slot #0 works with a TChain
90    DefineInput(0, TChain::Class());
91    
92    // Output slot #0 writes into a TH1 container
93    // Output slot #1 writes into a user defined  container
94    DefineOutput(1, TList::Class());
95    DefineOutput(2, TList::Class());
96    DefineOutput(3, TList::Class());
97    DefineOutput(4, TList::Class());
98    DefineOutput(5, TList::Class());
99  }
100
101 //________________________________________________________________________
102 AliAnalysisTaskTOFqa::AliAnalysisTaskTOFqa(const AliAnalysisTaskTOFqa& copy) 
103 : AliAnalysisTaskSE(), 
104   fRunNumber(copy.fRunNumber), 
105   fESD(copy.fESD), 
106   fTrackFilter(copy.fTrackFilter), 
107   fVertex(copy.fVertex),
108   fESDpid(copy.fESDpid),
109   fNTOFtracks(copy.fNTOFtracks), 
110   //fNPrimaryTracks(copy.fNPrimaryTracks), 
111   fEnableAdvancedCheck(copy.fEnableAdvancedCheck),
112   fExpTimeBinWidth(copy.fExpTimeBinWidth),
113   fExpTimeRangeMin(copy.fExpTimeRangeMin),
114   fExpTimeRangeMax(copy.fExpTimeRangeMax),
115   fExpTimeSmallRangeMin(copy.fExpTimeSmallRangeMin),
116   fExpTimeSmallRangeMax(copy.fExpTimeSmallRangeMax),
117   fHlist(copy.fHlist),
118   fHlistTimeZero(copy.fHlistTimeZero),
119   fHlistPID(copy.fHlistPID),
120   fHpos(copy.fHpos),
121   fHneg(copy.fHneg)
122 {
123   // Copy constructor
124    for (Int_t j=0;j<5;j++ ) {
125      if (j<3) fT0[j]=copy.fT0[j];
126      fSigmaSpecie[j]=copy.fSigmaSpecie[j];
127      fTrkExpTimes[j]=copy.fTrkExpTimes[j];
128      fThExpTimes[j]=copy.fThExpTimes[j];
129    }
130   
131
132 }
133
134 //___________________________________________________________________________
135 AliAnalysisTaskTOFqa& AliAnalysisTaskTOFqa::operator=(const AliAnalysisTaskTOFqa& copy) 
136 {
137   //
138   // Assignment operator
139   //
140   if (this!=&copy) {
141     AliAnalysisTaskSE::operator=(copy) ;
142     fRunNumber=copy.fRunNumber; 
143     fESD=copy.fESD;
144     fTrackFilter=copy.fTrackFilter;
145     fVertex=copy.fVertex;
146     fESDpid=copy.fESDpid;
147     fNTOFtracks=copy.fNTOFtracks; 
148     fEnableAdvancedCheck=copy.fEnableAdvancedCheck;
149     fEnableAdvancedCheck=copy.fEnableAdvancedCheck;
150     fExpTimeBinWidth=copy.fExpTimeBinWidth;
151     fExpTimeRangeMin=copy.fExpTimeRangeMin;
152     fExpTimeRangeMax=copy.fExpTimeRangeMax;
153     fExpTimeSmallRangeMin=copy.fExpTimeSmallRangeMin;
154     fExpTimeSmallRangeMax=copy.fExpTimeSmallRangeMax;
155     
156     //fNPrimaryTracks=copy.fNPrimaryTracks; 
157     for (Int_t j=0;j<5;j++ ) {
158       if (j<3) fT0[j]=copy.fT0[j];
159       fSigmaSpecie[j]=copy.fSigmaSpecie[j];
160       fTrkExpTimes[j]=copy.fTrkExpTimes[j];
161       fThExpTimes[j]=copy.fThExpTimes[j];
162     }
163     fHlist=copy.fHlist;
164     fHlistTimeZero=copy.fHlistTimeZero;
165     fHlistPID=copy.fHlistPID;
166     fHpos=copy.fHpos;
167     fHneg=copy.fHneg;
168   }
169   return *this;
170 }
171
172 //___________________________________________________________________________
173 AliAnalysisTaskTOFqa::~AliAnalysisTaskTOFqa() {
174   //
175   //destructor
176   //
177
178   Info("~AliAnalysisTaskTOFqa","Calling Destructor");
179   if (fESDpid) delete fESDpid;
180   if (fVertex) delete fVertex;
181   if (fTrackFilter) delete fTrackFilter;
182   if (AliAnalysisManager::GetAnalysisManager()->IsProofMode()) return;  
183   if (fHlist) {
184     delete fHlist;
185     fHlist = 0;
186   }
187   if (fHlistTimeZero) {
188     delete fHlistTimeZero;
189     fHlistTimeZero = 0;
190   }
191   if (fHlistPID){
192     delete fHlistPID;
193     fHlistPID = 0;
194   }
195   if (fHpos){
196     delete fHpos;
197     fHpos = 0;
198   }
199   if (fHneg){
200     delete fHneg;
201     fHneg = 0;
202   }
203 }
204
205 //________________________________________________________________________
206 void AliAnalysisTaskTOFqa::UserCreateOutputObjects()
207 {
208   //Defines output objects and histograms
209   Info("CreateOutputObjects","CreateOutputObjects (TList) of task %s", GetName());
210   OpenFile(1);
211   if (!fHlist) fHlist = new TList();    
212   fHlist->SetOwner(kTRUE);
213   if (!fHlistTimeZero) fHlistTimeZero = new TList();    
214   fHlistTimeZero->SetOwner(kTRUE);
215   if (!fHlistPID) fHlistPID = new TList();      
216   fHlistPID->SetOwner(kTRUE);
217   if (!fHpos) fHpos = new TList();      
218   fHpos->SetOwner(kTRUE);
219   if (!fHneg) fHneg = new TList();      
220   fHneg->SetOwner(kTRUE);
221
222   Int_t nExpTimeBins=1;
223   Int_t nExpTimeSmallBins=1;
224   
225   if (fExpTimeRangeMax<fExpTimeRangeMin) {
226     SetExpTimeHistoRange(-25010.,25010.);
227   }
228   nExpTimeBins = TMath::Nint((fExpTimeRangeMax - fExpTimeRangeMin)/fExpTimeBinWidth);//ps
229   fExpTimeRangeMax=fExpTimeRangeMin+nExpTimeBins*fExpTimeBinWidth;//ps
230   
231   if (fExpTimeSmallRangeMax<fExpTimeSmallRangeMin) {
232     SetExpTimeHistoSmallRange(-5002.,5002.);
233   }
234   nExpTimeSmallBins = TMath::Nint((fExpTimeSmallRangeMax - fExpTimeSmallRangeMin)/fExpTimeBinWidth);//ps
235   fExpTimeSmallRangeMax=fExpTimeSmallRangeMin+nExpTimeSmallBins*fExpTimeBinWidth;//ps
236   
237   //  nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax
238   //  nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax
239
240 //0
241   TH1I* hTOFmatchedESDperEvt = new TH1I("hTOFmatchedPerEvt", "Matched TOF tracks per event (|#eta| #leq 0.8 and pT #geq 0.3 GeV/c);TOF-matched ESD tracks;Events", 100, 0, 100) ;  
242   hTOFmatchedESDperEvt->Sumw2() ;
243   hTOFmatchedESDperEvt->SetLineWidth(2);
244   hTOFmatchedESDperEvt->SetLineColor(kBlue);
245   hTOFmatchedESDperEvt->SetMarkerStyle(20);
246   hTOFmatchedESDperEvt->SetMarkerSize(0.8);
247   hTOFmatchedESDperEvt->SetMarkerColor(kBlue);
248   fHlist->AddLast(hTOFmatchedESDperEvt) ;
249   //1
250   TH1F* hTOFmatchedESDtime = new TH1F("hTOFmatchedESDtime", "Matched  ESDs tracks: TOF Time spectrum; t [ns];Counts", 250, 0., 610. ) ; 
251   hTOFmatchedESDtime->Sumw2() ;
252   hTOFmatchedESDtime->SetLineWidth(2);
253   hTOFmatchedESDtime->SetLineColor(kBlue);
254   hTOFmatchedESDtime->SetFillColor(kBlue);
255   hTOFmatchedESDtime->SetDrawOption("BAR");
256   fHlist->AddLast(hTOFmatchedESDtime) ;
257   //2
258   TH1F* hTOFmatchedESDrawTime = new TH1F("hTOFmatchedESDrawTime", "Matched ESDs tracks: TOF raw Time spectrum;t_{raw} [ns];Counts", 250, 0., 610.) ; 
259   hTOFmatchedESDrawTime->Sumw2() ;
260   hTOFmatchedESDrawTime->SetLineWidth(2);
261   hTOFmatchedESDrawTime->SetLineColor(kAzure+2);
262   hTOFmatchedESDrawTime->SetFillColor(kAzure+2);
263   hTOFmatchedESDrawTime->SetDrawOption("BAR");
264   fHlist->AddLast(hTOFmatchedESDrawTime) ;
265   //3
266   TH1F* hTOFmatchedESDToT = new TH1F("hTOFmatchedESDToT", "Matched ESDs tracks: TOF ToT spectrum; ToT [ns];Counts",100, 0., 48.8) ; 
267   hTOFmatchedESDToT->Sumw2() ;
268   hTOFmatchedESDToT->SetLineColor(kOrange+1);
269   hTOFmatchedESDToT->SetMarkerColor(kOrange+1);
270   hTOFmatchedESDToT->SetFillColor(kOrange+1);
271   hTOFmatchedESDToT->SetDrawOption("BAR");
272   fHlist->AddLast(hTOFmatchedESDToT) ;
273   //4
274   TH1F* hTOFmatchedESDtrkLength  = new TH1F("hTOFmatchedESDtrkLength", "Matched ESDs tracks length; Track length [cm];Counts", 1200, -400., 800) ; 
275   hTOFmatchedESDtrkLength->Sumw2();
276   hTOFmatchedESDtrkLength->SetLineColor(kViolet-3);
277   hTOFmatchedESDtrkLength->SetMarkerColor(kViolet-3);
278   hTOFmatchedESDtrkLength->SetFillColor(kViolet-3);
279   hTOFmatchedESDtrkLength->SetDrawOption("BAR"); 
280   fHlist->AddLast(hTOFmatchedESDtrkLength);
281   //5
282   TH1F* hTOFmatchedESDP  = new TH1F("hTOFmatchedESDP", "TPC-TOF matched tracks momentum distribution (GeV/c); p (GeV/c);tracks", 500,0.,5.) ;  
283   hTOFmatchedESDP->Sumw2() ;
284   hTOFmatchedESDP->SetLineColor(kBlue);
285   hTOFmatchedESDP->SetMarkerStyle(20);
286   hTOFmatchedESDP->SetMarkerSize(0.7);
287   hTOFmatchedESDP->SetMarkerColor(kBlue);
288   fHlist->AddLast(hTOFmatchedESDP) ; 
289   //6
290   TH1F* hTOFmatchedESDPt  = new TH1F("hTOFmatchedESDPt", "TPC-TOF matched tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500,0.,5.) ;  
291   hTOFmatchedESDPt->Sumw2() ;
292   hTOFmatchedESDPt->SetLineColor(kBlue);
293   hTOFmatchedESDPt->SetMarkerStyle(21);
294   hTOFmatchedESDPt->SetMarkerSize(0.7);
295   hTOFmatchedESDPt->SetMarkerColor(kBlue);
296   fHlist->AddLast(hTOFmatchedESDPt) ; 
297
298   //7
299   TH1F* hTOFmatchedESDeta = new TH1F("hTOFmatchedESDeta", "Matched ESDtracks #eta (p_{T} #geq 0.5 GeV/c); #eta;Counts", 200, -1., 1.) ; 
300   hTOFmatchedESDeta->Sumw2();
301   hTOFmatchedESDeta->SetLineColor(kBlue);
302   fHlist->AddLast(hTOFmatchedESDeta) ; 
303   //8
304    TH1F* hTOFmatchedESDphi = new TH1F("hTOFmatchedESDphi", "Matched ESDtracks #phi; #phi (deg);Counts", 72, 0., 360.) ; 
305   hTOFmatchedESDphi->Sumw2();
306   hTOFmatchedESDphi->SetLineColor(kBlue);
307   fHlist->AddLast(hTOFmatchedESDphi) ; 
308
309   //9
310   TH1F* hESDprimaryTrackP = new TH1F("hESDprimaryTrackP", "All ESDs tracks p distribution (GeV/c); p(GeV/c);tracks", 500, 0., 5.0) ;  
311   hESDprimaryTrackP->Sumw2();
312   hESDprimaryTrackP->SetLineWidth(1);
313   hESDprimaryTrackP->SetMarkerStyle(24);
314   hESDprimaryTrackP->SetMarkerSize(0.7);
315   hESDprimaryTrackP->SetMarkerColor(kRed);
316   hESDprimaryTrackP->SetLineColor(kRed);
317   fHlist->AddLast(hESDprimaryTrackP);
318   //10
319   TH1F* hESDprimaryTrackPt = new TH1F("hESDprimaryTrackPt", "ESDs primary tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
320   hESDprimaryTrackPt->Sumw2();
321   hESDprimaryTrackPt->SetLineWidth(1);
322   hESDprimaryTrackPt->SetMarkerStyle(25);
323   hESDprimaryTrackPt->SetMarkerSize(0.7);
324   hESDprimaryTrackPt->SetLineColor(kRed);
325   hESDprimaryTrackPt->SetMarkerColor(kRed);
326   fHlist->AddLast(hESDprimaryTrackPt);
327   //11
328   TH1F* hTOFprimaryESDeta = new TH1F("hTOFprimaryESDeta", "Primary ESDtracks #eta (p_{T} #geq 0.5 GeV/c); #eta;Counts",200, -1., 1.) ; 
329   hTOFprimaryESDeta->Sumw2();
330   hTOFprimaryESDeta->SetLineColor(kRed);
331   fHlist->AddLast(hTOFprimaryESDeta) ; 
332   //12
333   TH1F* hTOFprimaryESDphi = new TH1F("hTOFprimaryESDphi", "Primary ESDtracks #phi;#phi (deg);Counts", 72, 0., 360.) ; 
334   hTOFprimaryESDphi->Sumw2();
335   hTOFprimaryESDphi->SetLineColor(kRed);
336   fHlist->AddLast(hTOFprimaryESDphi) ; 
337   //13
338   TH2F* hTOFmatchedDxVsPtPos = new TH2F("hTOFmatchedDxVsPtPos", "Dx vs p_{T} for positive tracks;p_{T} (GeV/c); Dx [cm]; hits", 500,0.,5.,200, -10., 10.) ; 
339   hTOFmatchedDxVsPtPos->Sumw2();
340   fHlist->AddLast(hTOFmatchedDxVsPtPos) ; 
341  //14
342   TH2F* hTOFmatchedDxVsPtNeg = new TH2F("hTOFmatchedDxVsPtNeg", "Dx vs p_{T} for negative tracks;p_{T} (GeV/c); Dx [cm]; hits", 500,0.,5.,200, -10., 10.) ; 
343   hTOFmatchedDxVsPtNeg->Sumw2();
344   fHlist->AddLast(hTOFmatchedDxVsPtNeg) ; 
345
346   //15
347   TH2F* hTOFmatchedDzVsStrip = new TH2F("hTOFmatchedDzVsStrip", "Dz vs strip; strip (#eta); Dz [cm]; hits", 92,0.,92.,200, -10., 10.) ; 
348   hTOFmatchedDzVsStrip->Sumw2();
349   fHlist->AddLast(hTOFmatchedDzVsStrip) ; 
350  
351  //----------------------------------------------timeZero QA plots
352   //TimeZero 0
353   TH1D* hEventT0DetAND = new TH1D("hEventT0DetAND", "Event timeZero from T0AC detector ; t0 [ps]; events", 1000, -25000., 25000. ) ; 
354   hEventT0DetAND->Sumw2() ;
355   hEventT0DetAND->SetLineWidth(2);
356   hEventT0DetAND->SetLineColor(kRed);
357   hEventT0DetAND->SetFillColor(kRed);
358   fHlistTimeZero->AddLast(hEventT0DetAND) ;
359
360   //TImeZero 1
361   TH1D* hEventT0DetA = new TH1D("hEventT0DetA", "Event timeZero from T0A detector; t0 [ps]; events", 1000, -25000., 25000. ) ; 
362   hEventT0DetA->Sumw2() ;
363   hEventT0DetA->SetLineWidth(2);
364   hEventT0DetA->SetLineColor(kBlue);
365   hEventT0DetA->SetFillColor(kBlue);
366   fHlistTimeZero->AddLast(hEventT0DetA) ;
367
368    //TImeZero 2
369   TH1D* hEventT0DetC = new TH1D("hEventT0DetC", "Event timeZero from T0C detector; t0 [ps]; events", 1000, -25000., 25000.) ; 
370   hEventT0DetC->Sumw2() ;
371   hEventT0DetC->SetLineWidth(2);
372   hEventT0DetC->SetLineColor(kGreen);
373   hEventT0DetC->SetFillColor(kGreen);
374   fHlistTimeZero->AddLast(hEventT0DetC);
375
376    //TimeZero 3
377   TH1F* hT0DetRes = new TH1F("hT0DetRes", "T0 detector (T0A-T0C)/2; (T0A-T0C)/2 [ps]; events", 200, -500.,500. ) ; 
378   hT0DetRes->Sumw2() ;
379   hT0DetRes->SetMarkerStyle(24);
380   hT0DetRes->SetMarkerSize(0.7);
381   hT0DetRes->SetMarkerColor(kMagenta+2);
382   hT0DetRes->SetLineColor(kMagenta+2);
383   hT0DetRes->SetFillColor(kMagenta+2);  
384   fHlistTimeZero->AddLast(hT0DetRes) ; 
385
386      //timeZero 4
387   TH1F* hT0fill = new TH1F("hT0fill", "Event timeZero of fill; t0 [ps]; events", 1000, -25000., 25000. ) ; 
388   hT0fill->Sumw2() ;
389   hT0fill->SetMarkerStyle(20);
390   hT0fill->SetMarkerColor(kBlack);
391   hT0fill->SetLineColor(kBlack);
392   fHlistTimeZero->AddLast(hT0fill) ; 
393
394   //TimeZero 5
395   TH1F* hT0TOF = new TH1F("hT0TOF", "Event timeZero estimated by TOF; t0 [ps]; events", 1000, -25000., 25000. ) ; 
396   hT0TOF->Sumw2() ;
397   hT0TOF->SetMarkerStyle(20);
398   hT0TOF->SetMarkerColor(kBlue);
399   hT0TOF->SetLineColor(kBlue);
400   hT0TOF->SetFillColor(kBlue);
401   fHlistTimeZero->AddLast(hT0TOF) ;
402
403
404    //timeZero 6
405   TH1F* hT0T0 = new TH1F("hT0T0", "Event timeZero measured by T0 detector (best between AC, A, C); t0 [ps]; events", 1000, -25000.,25000. ) ; 
406   hT0T0->Sumw2() ;
407   hT0T0->SetMarkerStyle(20);
408   hT0T0->SetMarkerColor(kGreen+1);
409   hT0T0->SetLineColor(kGreen+1);
410   hT0T0->SetFillColor(kGreen+1);
411   fHlistTimeZero->AddLast(hT0T0) ; 
412
413    //timeZero 7
414   TH1F* hT0best = new TH1F("hT0best", "Event timeZero estimated as T0best; t0 [ps]; events", 1000, -25000.,25000. ) ; 
415   hT0best->Sumw2() ;
416   hT0best->SetMarkerStyle(20);
417   hT0best->SetMarkerColor(kRed);
418   hT0best->SetLineColor(kRed);
419   hT0best->SetFillColor(kRed); 
420   fHlistTimeZero->AddLast(hT0best) ; 
421
422    //TimeZero 8
423   TH1F* hT0fillRes = new TH1F("hT0fillRes", "Resolution of fillT0; #sigma_{fillT0} [ps];events", 250, 0.,250. ) ; 
424   hT0fillRes->Sumw2() ;
425   hT0fillRes->SetMarkerStyle(21);
426   hT0fillRes->SetMarkerColor(kBlack);
427   hT0fillRes->SetLineColor(kBlack);
428   hT0fillRes->SetFillColor(kBlack); 
429   fHlistTimeZero->AddLast(hT0fillRes) ; 
430  
431   //TimeZero 9
432   TH1F* hT0TOFRes = new TH1F("hT0TOFRes", "Resolution of timeZero from TOF; #sigma_{TOFT0} [ps];events", 250, 0.,250. ) ; 
433   hT0TOFRes->Sumw2() ;
434   hT0TOFRes->SetLineWidth(1);
435   hT0TOFRes->SetMarkerStyle(21);
436   hT0TOFRes->SetMarkerColor(kBlue);
437   hT0TOFRes->SetLineColor(kBlue);
438   hT0TOFRes->SetFillColor(kBlue); 
439   fHlistTimeZero->AddLast(hT0TOFRes) ; 
440
441    //TimeZero 10
442   TH1F* hT0T0Res = new TH1F("hT0T0Res", "Resolution of timeZero from T0;#sigma_{T0T0}  [ps];events", 250, -0., 250. ) ; 
443   hT0T0Res->Sumw2() ;
444   hT0T0Res->SetMarkerStyle(21);
445   hT0T0Res->SetMarkerColor(kGreen+1);
446   hT0T0Res->SetLineColor(kGreen+1);
447   hT0T0Res->SetFillColor(kGreen+1); 
448   fHlistTimeZero->AddLast(hT0T0Res) ; 
449
450    //TimeZero 11
451   TH1F* hT0bestRes = new TH1F("hT0bestRes", "Resolution of bestT0; #sigma_{bestT0} [ps];events", 250, 0.,250. ) ; 
452   hT0bestRes->Sumw2() ;
453   hT0bestRes->SetMarkerStyle(21);
454   hT0bestRes->SetMarkerColor(kRed);
455   hT0bestRes->SetLineColor(kRed);
456   hT0bestRes->SetFillColor(kRed); 
457   fHlistTimeZero->AddLast(hT0bestRes) ; 
458
459   //timeZero 12
460   TH2F* hT0TOFvsNtrk = new TH2F("hT0TOFvsNtrk", "Event timeZero estimated by TOF vs. number of tracks in event;TOF-matching tracks; t0 [ps]", 100, 0., 100.,1000,-25000.,25000. ) ; 
461   hT0TOFvsNtrk->Sumw2() ;
462   fHlistTimeZero->AddLast(hT0TOFvsNtrk) ;
463
464  //TimeZero 13
465   TH2F* hEventT0MeanVsVtx = new TH2F("hEventT0MeanVsVtx", "T0 detector: mean vs vertex ; (t0_{A}-t0_{C})/2 [ns]; (t0_{A}+t0_{C})/2 [ns]; events", 500, -25., 25., 500, -25., 25. ) ; 
466   hEventT0MeanVsVtx->Sumw2() ;
467   fHlistTimeZero->AddLast(hEventT0MeanVsVtx) ;
468
469  //TimeZero 14
470   TH2F* hEventV0MeanVsVtx = new TH2F("hEventV0MeanVsVtx", "V0 detector: mean vs vertex ; (V0_{A}-V0_{C})/2 [ns]; (V0_{A}+V0_{C})/2 [ns]; events", 500, -50., 50., 500, -50., 50. ) ; 
471   hEventV0MeanVsVtx->Sumw2() ;
472   fHlistTimeZero->AddLast(hEventV0MeanVsVtx) ;
473 //--------------------------------------------- TOF PID QA plots
474   //PID 0
475   TH2F* hTOFmatchedESDpVsBeta  = new TH2F("hTOFmatchedESDpVsBeta", "Matched ESDs tracks beta vs. p; p(GeV/c); beta", 500, 0.0, 5.0, 150, 0., 1.5) ; 
476   fHlistPID->AddLast(hTOFmatchedESDpVsBeta);
477   
478   //PID 1 
479   TH1F* hTOFmatchedMass= new TH1F("hTOFmatchedMass","Matched ESD tracks mass distribution - (L>0); M (GeV/c^{2}); entries", 500, 0., 5. );
480   hTOFmatchedMass->Sumw2();
481   hTOFmatchedMass->SetLineWidth(2);
482   hTOFmatchedMass->SetLineColor(kBlue);
483   hTOFmatchedMass->SetLineColor(kBlue);
484   fHlistPID->AddLast(hTOFmatchedMass);
485   
486   //PID 2
487   TH2F* hTOFmatchedExpTimePiVsEta = new TH2F("hTOFmatchedExpTimePiVsEta", "ESDs t_{TOF}-t_{#pi,exp} (from tracking); strip (#eta); t_{TOF}-t_{#pi,exp} [ps]", 92, 0, 92,  nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
488   hTOFmatchedExpTimePiVsEta->Sumw2() ;
489   fHlistPID->AddLast(hTOFmatchedExpTimePiVsEta) ;
490   
491   //PID 3
492   TH1F* hTOFmatchedExpTimePi = new TH1F("hTOFmatchedExpTimePi", "ESDs t_{TOF}-t_{#pi,exp} (from tracking); t_{TOF}-t_{#pi,exp} [ps];Counts", nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
493   hTOFmatchedExpTimePi->Sumw2() ;
494   hTOFmatchedExpTimePi->SetLineWidth(1);
495   hTOFmatchedExpTimePi->SetLineColor(kRed);
496   hTOFmatchedExpTimePi->SetMarkerStyle(20);
497   hTOFmatchedExpTimePi->SetMarkerSize(0.8); 
498   hTOFmatchedExpTimePi->SetMarkerColor(kRed);
499   fHlistPID->AddLast(hTOFmatchedExpTimePi) ;
500   
501   //PID 4
502   TH2F* hTOFmatchedExpTimePiVsP = new TH2F("hTOFmatchedExpTimePiVsP", "ESDs t_{TOF}-t_{#pi,exp} (from tracking) Vs P ; p (GeV/c);t_{TOF}-t_{#pi,exp} [ps];Counts",500, 0.,5., nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
503   hTOFmatchedExpTimePiVsP->Sumw2() ;
504   fHlistPID->AddLast(hTOFmatchedExpTimePiVsP) ;
505
506   //PID 5
507   TH1F* hTOFtheoreticalExpTimePi = new TH1F("hTOFtheoreticalExpTimePi", "ESDs t_{TOF}-t_{#pi,exp} (theoretical); t_{TOF}-t_{#pi,exp} [ps];Counts", nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
508   hTOFtheoreticalExpTimePi->Sumw2() ;
509   hTOFtheoreticalExpTimePi->SetLineWidth(1);
510   hTOFtheoreticalExpTimePi->SetLineColor(kRed);
511   hTOFtheoreticalExpTimePi->SetMarkerStyle(24);
512   hTOFtheoreticalExpTimePi->SetMarkerSize(0.8); 
513   hTOFtheoreticalExpTimePi->SetMarkerColor(kRed);
514   fHlistPID->AddLast(hTOFtheoreticalExpTimePi) ;
515
516   //PID 6
517   TH2F* hTOFtheoreticalExpTimePiVsP = new TH2F("hTOFtheoreticalExpTimePiVsP", "ESDs t_{TOF}-t_{#pi,exp} (theoretical) Vs P ; p (GeV/c);t_{TOF}-t_{#pi,exp} [ps];Counts",500, 0.,5., nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
518   hTOFtheoreticalExpTimePiVsP->Sumw2() ;
519   fHlistPID->AddLast(hTOFtheoreticalExpTimePiVsP) ;
520
521   //PID 7
522   TH2F* hTOFExpSigmaPi = new TH2F("hTOFExpSigmaPi", "ESDs TOF n#sigma_{PID,#pi} vs p_{T}; p_{T} (GeV/c); n#sigma_{PID,#pi};Tracks", 500,0.,5.,200, -10., 10. ) ; 
523   hTOFExpSigmaPi->Sumw2() ;
524   fHlistPID->AddLast(hTOFExpSigmaPi) ;
525
526   //PID 8
527   TH1F* hTOFmatchedExpTimeKa = new TH1F("hTOFmatchedExpTimeKa", "ESDs t_{TOF}-t_{K,exp} (from tracking); t_{TOF}-t_{K,exp} [ps];Counts", nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
528   hTOFmatchedExpTimeKa->Sumw2() ;
529   hTOFmatchedExpTimeKa->SetLineWidth(1);
530   hTOFmatchedExpTimeKa->SetLineColor(kBlue);
531   hTOFmatchedExpTimeKa->SetMarkerStyle(21);
532   hTOFmatchedExpTimeKa->SetMarkerSize(0.8); 
533   hTOFmatchedExpTimeKa->SetMarkerColor(kBlue);
534   fHlistPID->AddLast(hTOFmatchedExpTimeKa);
535
536   //PID 9
537   TH2F* hTOFmatchedExpTimeKaVsP = new TH2F("hTOFmatchedExpTimeKaVsP", "ESDs t_{TOF}-t_{K,exp} (from tracking) Vs P ; p (GeV/c);t_{TOF}-t_{K,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
538   hTOFmatchedExpTimeKaVsP->Sumw2() ;
539   fHlistPID->AddLast(hTOFmatchedExpTimeKaVsP) ; 
540   
541   //PID 10
542   TH1F* hTOFtheoreticalExpTimeKa = new TH1F("hTOFtheoreticalExpTimeKa", "ESDs t_{TOF}-t_{K,exp} (theoretical); t_{TOF}-t_{K,exp} [ps];Counts", nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
543   hTOFtheoreticalExpTimeKa->Sumw2() ;
544   hTOFtheoreticalExpTimeKa->SetLineWidth(1);
545   hTOFtheoreticalExpTimeKa->SetLineColor(kBlue);
546   hTOFtheoreticalExpTimeKa->SetMarkerStyle(24);
547   hTOFtheoreticalExpTimeKa->SetMarkerSize(0.8); 
548   hTOFtheoreticalExpTimeKa->SetMarkerColor(kBlue);
549   fHlistPID->AddLast(hTOFtheoreticalExpTimeKa) ;  
550   
551   //PID 11
552   TH2F* hTOFtheoreticalExpTimeKaVsP = new TH2F("hTOFtheoreticalExpTimeKaVsP", "ESDs t_{TOF}-t_{K,exp} (theoretical) Vs P ; p (GeV/c);t_{TOF}-t_{K,exp} [ps];Counts",500, 0.,5., nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
553   hTOFtheoreticalExpTimeKaVsP->Sumw2() ;
554   fHlistPID->AddLast(hTOFtheoreticalExpTimeKaVsP) ; 
555   
556   //PID 12
557   TH2F* hTOFExpSigmaKa = new TH2F("hTOFExpSigmaKa", "ESDs TOF n#sigma_{PID,K} vs p_{T}; p_{T} (GeV/c);n#sigma_{PID,K};Tracks", 500, 0.,5.,200, -10., 10. ) ; 
558   hTOFExpSigmaKa->Sumw2() ;
559   fHlistPID->AddLast(hTOFExpSigmaKa) ;
560   
561   //PID 13
562   TH1F* hTOFmatchedExpTimePro = new TH1F("hTOFmatchedExpTimePro", "ESDs t_{TOF}-t_{p,exp} (from tracking); t_{TOF}-t_{p,exp} [ps];Counts", nExpTimeBins, fExpTimeRangeMin,fExpTimeRangeMax) ; 
563   hTOFmatchedExpTimePro->Sumw2() ;
564   hTOFmatchedExpTimePro->SetLineWidth(1);
565   hTOFmatchedExpTimePro->SetLineColor(kGreen+1);
566   hTOFmatchedExpTimePro->SetMarkerStyle(22);
567   hTOFmatchedExpTimePro->SetMarkerSize(0.8); 
568   hTOFmatchedExpTimePro->SetMarkerColor(kGreen+1);
569   fHlistPID->AddLast(hTOFmatchedExpTimePro) ;
570
571    //PID 14
572   TH2F* hTOFmatchedExpTimeProVsP = new TH2F("hTOFmatchedExpTimeProVsP", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P ; p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5., nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
573   hTOFmatchedExpTimeProVsP->Sumw2() ;
574   fHlistPID->AddLast(hTOFmatchedExpTimeProVsP) ;
575   
576   //PID 15
577   TH1F* hTOFtheoreticalExpTimePro = new TH1F("hTOFtheoreticalExpTimePro", "ESDs t_{TOF}-t_{p,exp} (theoretical); t_{TOF}-t_{p,exp} [ps];Counts", nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
578   hTOFtheoreticalExpTimePro->Sumw2() ;
579   hTOFtheoreticalExpTimePro->SetLineWidth(1);
580   hTOFtheoreticalExpTimePro->SetLineColor(kGreen+1);
581   hTOFtheoreticalExpTimePro->SetMarkerStyle(26);
582   hTOFtheoreticalExpTimePro->SetMarkerSize(0.8); 
583   hTOFtheoreticalExpTimePro->SetMarkerColor(kGreen+1);
584   fHlistPID->AddLast(hTOFtheoreticalExpTimePro) ;
585
586   //PID 16
587   TH2F* hTOFtheoreticalExpTimeProVsP = new TH2F("hTOFtheoreticalExpTimeProVsP", "ESDs t_{TOF}-t_{p,exp} (theoretical) Vs P ; p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5., nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
588   hTOFtheoreticalExpTimeProVsP->Sumw2() ;
589   fHlistPID->AddLast(hTOFtheoreticalExpTimeProVsP) ;
590
591   //PID 17
592   TH2F* hTOFExpSigmaPro = new TH2F("hTOFExpSigmaPro", "ESDs TOF n#sigma_{PID,p} vs. p_{T}; p_{T} (GeV/c); n#sigma_{PID,p};Tracks", 500, 0.,5.,200, -10., 10. ) ; 
593   hTOFExpSigmaPro->Sumw2() ;
594   fHlistPID->AddLast(hTOFExpSigmaPro) ;
595
596    //PID 18
597   TH2F* hTOFmatchedExpTimePiVsPTRDPos = new TH2F("hTOFmatchedExpTimePiVsPTRDPos", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (#phi_{outerTPC}#leq 30 || 150 #leq#phi_{outerTPC}#leq 230 || #phi_{outerTPC}#geq 310 ) ; p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5., nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
598   hTOFmatchedExpTimePiVsPTRDPos->Sumw2() ;
599   if (fEnableAdvancedCheck)
600     fHlistPID->AddLast(hTOFmatchedExpTimePiVsPTRDPos) ;
601
602    //PID 19
603   TH2F* hTOFmatchedExpTimePiVsPNoTRDPos = new TH2F("hTOFmatchedExpTimePiVsPNoTRDPos", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (50 #leq#phi_{outerTPC}#leq 130 || 250 #leq#phi_{outerTPC}#leq 290); p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5., nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
604   hTOFmatchedExpTimePiVsPNoTRDPos->Sumw2() ;
605   if (fEnableAdvancedCheck)
606     fHlistPID->AddLast(hTOFmatchedExpTimePiVsPNoTRDPos) ;
607
608    //PID 20
609   TH2F* hTOFmatchedExpTimePiVsPTRDNeg = new TH2F("hTOFmatchedExpTimePiVsPTRDNeg", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (#phi_{outerTPC}#leq 30 || 150 #leq#phi_{outerTPC}#leq 230 || #phi_{outerTPC}#geq 310 ) ; p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5., nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
610   hTOFmatchedExpTimePiVsPTRDNeg->Sumw2() ;
611   if (fEnableAdvancedCheck)
612     fHlistPID->AddLast(hTOFmatchedExpTimePiVsPTRDNeg) ;
613
614    //PID 21
615   TH2F* hTOFmatchedExpTimePiVsPNoTRDNeg = new TH2F("hTOFmatchedExpTimePiVsPNoTRDNeg", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (50 #leq#phi_{outerTPC}#leq 130 || 250 #leq#phi_{outerTPC}#leq 290); p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
616   hTOFmatchedExpTimePiVsPNoTRDNeg->Sumw2() ;
617   if (fEnableAdvancedCheck)
618     fHlistPID->AddLast(hTOFmatchedExpTimePiVsPNoTRDNeg) ;
619   
620  //PID 22
621   TH2F* hTOFmatchedExpTimeKaVsPTRDPos = new TH2F("hTOFmatchedExpTimeKaVsPTRDPos", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (#phi_{outerTPC}#leq 30 || 150 #leq#phi_{outerTPC}#leq 230 || #phi_{outerTPC}#geq 310 ) ; p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
622   hTOFmatchedExpTimeKaVsPTRDPos->Sumw2() ;
623   if (fEnableAdvancedCheck)
624     fHlistPID->AddLast(hTOFmatchedExpTimeKaVsPTRDPos) ;
625   
626    //PID 23
627   TH2F* hTOFmatchedExpTimeKaVsPNoTRDPos = new TH2F("hTOFmatchedExpTimeKaVsPNoTRDPos", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (50 #leq#phi_{outerTPC}#leq 130 || 250 #leq#phi_{outerTPC}#leq 290); p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
628   hTOFmatchedExpTimeKaVsPNoTRDPos->Sumw2() ;
629     if (fEnableAdvancedCheck)
630       fHlistPID->AddLast(hTOFmatchedExpTimeKaVsPNoTRDPos) ;
631
632    //PID 24
633   TH2F* hTOFmatchedExpTimeKaVsPTRDNeg = new TH2F("hTOFmatchedExpTimeKaVsPTRDNeg", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (#phi_{outerTPC}#leq 30 || 150 #leq#phi_{outerTPC}#leq 230 || #phi_{outerTPC}#geq 310 ) ; p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
634   hTOFmatchedExpTimeKaVsPTRDNeg->Sumw2() ;
635   if (fEnableAdvancedCheck)
636     fHlistPID->AddLast(hTOFmatchedExpTimeKaVsPTRDNeg) ;
637
638    //PID 25
639   TH2F* hTOFmatchedExpTimeKaVsPNoTRDNeg = new TH2F("hTOFmatchedExpTimeKaVsPNoTRDNeg", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (50 #leq#phi_{outerTPC}#leq 130 || 250 #leq#phi_{outerTPC}#leq 290); p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
640   hTOFmatchedExpTimeKaVsPNoTRDNeg->Sumw2() ;
641   if (fEnableAdvancedCheck)
642     fHlistPID->AddLast(hTOFmatchedExpTimeKaVsPNoTRDNeg) ;
643     
644  //PID 26
645   TH2F* hTOFmatchedExpTimeProVsPTRDPos = new TH2F("hTOFmatchedExpTimeProVsPTRDPos", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (#phi_{outerTPC}#leq 30 || 150 #leq#phi_{outerTPC}#leq 230 || #phi_{outerTPC}#geq 310 ) ; p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
646   hTOFmatchedExpTimeProVsPTRDPos->Sumw2() ;
647   if (fEnableAdvancedCheck)
648     fHlistPID->AddLast(hTOFmatchedExpTimeProVsPTRDPos) ;
649   
650    //PID 27
651   TH2F* hTOFmatchedExpTimeProVsPNoTRDPos = new TH2F("hTOFmatchedExpTimeProVsPNoTRDPos", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (50 #leq#phi_{outerTPC}#leq 130 || 250 #leq#phi_{outerTPC}#leq 290); p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
652   hTOFmatchedExpTimeProVsPNoTRDPos->Sumw2() ;
653     if (fEnableAdvancedCheck)
654       fHlistPID->AddLast(hTOFmatchedExpTimeProVsPNoTRDPos) ;
655     
656     //PID 28
657    TH2F* hTOFmatchedExpTimeProVsPTRDNeg = new TH2F("hTOFmatchedExpTimeProVsPTRDNeg", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (#phi_{outerTPC}#leq 30 || 150 #leq#phi_{outerTPC}#leq 230 || #phi_{outerTPC}#geq 310 ) ; p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
658     hTOFmatchedExpTimeProVsPTRDNeg->Sumw2() ;
659     if (fEnableAdvancedCheck)
660       fHlistPID->AddLast(hTOFmatchedExpTimeProVsPTRDNeg) ;
661
662    //PID 29
663   TH2F* hTOFmatchedExpTimeProVsPNoTRDNeg = new TH2F("hTOFmatchedExpTimeProVsPNoTRDNeg", "ESDs t_{TOF}-t_{p,exp} (from tracking) Vs P (50 #leq#phi_{outerTPC}#leq 130 || 250 #leq#phi_{outerTPC}#leq 290); p (GeV/c);t_{TOF}-t_{p,exp} [ps];Counts",500, 0.,5.,nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
664   hTOFmatchedExpTimeProVsPNoTRDNeg->Sumw2() ;
665   if (fEnableAdvancedCheck)
666     fHlistPID->AddLast(hTOFmatchedExpTimeProVsPNoTRDNeg) ;
667
668 //PID 30
669   TH1F* hTOFmatchedTimePion1GeV = new TH1F("hTOFmatchedTimePion1GeV", "ESDs t_{TOF}-t_{0}^{TOF}-t_{#pi,exp} (from tracking) for 0.95 <= p_{T} <= 1.05 GeV/c; t_{TOF}-t_{0}^{TOF}-t_{#pi,exp} [ps];Counts", nExpTimeBins, fExpTimeRangeMin, fExpTimeRangeMax) ; 
670   hTOFmatchedTimePion1GeV->Sumw2() ;
671   hTOFmatchedTimePion1GeV->SetLineWidth(1);
672   hTOFmatchedTimePion1GeV->SetLineColor(kBlue);
673   hTOFmatchedTimePion1GeV->SetMarkerStyle(20);
674   hTOFmatchedTimePion1GeV->SetMarkerSize(0.8); 
675   hTOFmatchedTimePion1GeV->SetMarkerColor(kBlue);
676   fHlistPID->AddLast(hTOFmatchedTimePion1GeV) ;
677   
678   //----------------------------------------------------------POSITIVE TRACKS
679   //0
680   TH1F* hTOFmatchedESDtrkLengthPos  = new TH1F("hTOFmatchedESDtrkLengthPos", "Matched positive ESDs tracks length; Track length [cm];Counts", 1600, -800., 800) ; 
681   hTOFmatchedESDtrkLengthPos->Sumw2();
682   hTOFmatchedESDtrkLengthPos->SetLineColor(kRed);
683   hTOFmatchedESDtrkLengthPos->SetMarkerColor(kRed);
684   hTOFmatchedESDtrkLengthPos->SetFillColor(kRed);
685   hTOFmatchedESDtrkLengthPos->SetDrawOption("BAR"); 
686   if (fEnableAdvancedCheck)
687     fHpos->AddLast(hTOFmatchedESDtrkLengthPos);
688   //1
689   TH1F* hTOFmatchedESDPPos  = new TH1F("hTOFmatchedESDPPos", "TPC-TOF matched positive tracks momentum distribution (GeV/c); p (GeV/c);tracks", 500,0.,5.) ;  
690   hTOFmatchedESDPPos->Sumw2() ;
691   hTOFmatchedESDPPos->SetLineColor(kRed);
692   hTOFmatchedESDPPos->SetMarkerStyle(20);
693   hTOFmatchedESDPPos->SetMarkerSize(0.7);
694   hTOFmatchedESDPPos->SetMarkerColor(kRed);
695   if (fEnableAdvancedCheck)
696     fHpos->AddLast(hTOFmatchedESDPPos) ; 
697   //2
698   TH1F* hTOFmatchedESDPtPos  = new TH1F("hTOFmatchedESDPtPos", "TPC-TOF positive matched tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500,0.,5.) ;  
699   hTOFmatchedESDPtPos->Sumw2() ;
700   hTOFmatchedESDPtPos->SetLineColor(kRed);
701   hTOFmatchedESDPtPos->SetMarkerStyle(21);
702   hTOFmatchedESDPtPos->SetMarkerSize(0.7);
703   hTOFmatchedESDPtPos->SetMarkerColor(kRed);
704   if (fEnableAdvancedCheck)
705     fHpos->AddLast(hTOFmatchedESDPtPos) ; 
706
707   //3
708   TH1F* hTOFmatchedESDetaPos = new TH1F("hTOFmatchedESDetaPos", "Matched positive ESD tracks #eta (p_{T} #geq 0.5 GeV/c); eta;Counts", 200, -1., 1.) ; 
709   hTOFmatchedESDetaPos->Sumw2();
710   hTOFmatchedESDetaPos->SetLineColor(kRed);
711     if (fEnableAdvancedCheck)
712 fHpos->AddLast(hTOFmatchedESDetaPos) ; 
713   //4
714    TH1F* hTOFmatchedESDphiPos = new TH1F("hTOFmatchedESDphiPos", "Matched Positive ESD tracks #phi; #phi (deg);Counts", 72, 0., 360.) ; 
715   hTOFmatchedESDphiPos->Sumw2();
716   hTOFmatchedESDphiPos->SetLineColor(kRed);
717   if (fEnableAdvancedCheck)
718   fHpos->AddLast(hTOFmatchedESDphiPos) ; 
719
720   //5
721   TH1F* hESDmatchedTrackPtPosTRDout = new TH1F("hESDmatchedTrackPtPosTRDout", "ESDs Pos matched tracks p_{T} with kTRDout distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
722   hESDmatchedTrackPtPosTRDout->Sumw2();
723   hESDmatchedTrackPtPosTRDout->SetLineWidth(1);
724   hESDmatchedTrackPtPosTRDout->SetMarkerStyle(20);
725   hESDmatchedTrackPtPosTRDout->SetMarkerSize(0.7);
726   hESDmatchedTrackPtPosTRDout->SetLineColor(kRed);
727   hESDmatchedTrackPtPosTRDout->SetMarkerColor(kRed);
728   if (fEnableAdvancedCheck)
729   fHpos->AddLast(hESDmatchedTrackPtPosTRDout);
730
731   //6
732   TH1F* hESDmatchedTrackPtPosNoTRDout = new TH1F("hESDmatchedTrackPtPosNoTRDout", "ESDs Pos matched tracks p_{T} with !kTRDout distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
733   hESDmatchedTrackPtPosNoTRDout->Sumw2();
734   hESDmatchedTrackPtPosNoTRDout->SetLineWidth(1);
735   hESDmatchedTrackPtPosNoTRDout->SetMarkerStyle(25);
736   hESDmatchedTrackPtPosNoTRDout->SetMarkerSize(0.7);
737   hESDmatchedTrackPtPosNoTRDout->SetLineColor(kRed);
738   hESDmatchedTrackPtPosNoTRDout->SetMarkerColor(kRed);
739   if (fEnableAdvancedCheck)
740   fHpos->AddLast(hESDmatchedTrackPtPosNoTRDout);
741
742   //7
743   TH1F* hESDprimaryTrackPPos = new TH1F("hESDprimaryTrackPPos", "All Pos ESDs tracks p distribution (GeV/c); p(GeV/c);tracks", 500, 0., 5.0) ;  
744   hESDprimaryTrackPPos->Sumw2();
745   hESDprimaryTrackPPos->SetLineWidth(1);
746   hESDprimaryTrackPPos->SetMarkerStyle(24);
747   hESDprimaryTrackPPos->SetMarkerSize(0.7);
748   hESDprimaryTrackPPos->SetMarkerColor(kRed);
749   hESDprimaryTrackPPos->SetLineColor(kRed);
750   if (fEnableAdvancedCheck)
751   fHpos->AddLast(hESDprimaryTrackPPos);
752   //8
753   TH1F* hESDprimaryTrackPtPos = new TH1F("hESDprimaryTrackPtPos", "ESDs Pos primary tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
754   hESDprimaryTrackPtPos->Sumw2();
755   hESDprimaryTrackPtPos->SetLineWidth(1);
756   hESDprimaryTrackPtPos->SetMarkerStyle(25);
757   hESDprimaryTrackPtPos->SetMarkerSize(0.7);
758   hESDprimaryTrackPtPos->SetLineColor(kRed);
759   hESDprimaryTrackPtPos->SetMarkerColor(kRed);
760   if (fEnableAdvancedCheck)
761   fHpos->AddLast(hESDprimaryTrackPtPos);
762   //9
763   TH1F* hTOFprimaryESDetaPos = new TH1F("hTOFprimaryESDetaPos", "Primary ESD Pos tracks #eta (p_{T} #geq 0.5 GeV/c); #eta;Counts", 200, -1., 1.) ; 
764   hTOFprimaryESDetaPos->Sumw2();
765   hTOFprimaryESDetaPos->SetLineColor(kRed);
766   if (fEnableAdvancedCheck)
767   fHpos->AddLast(hTOFprimaryESDetaPos) ; 
768   //10
769   TH1F* hTOFprimaryESDphiPos = new TH1F("hTOFprimaryESDphiPos", "Primary ESD Pos tracks #phi;#phi (deg);Counts", 72, 0., 360.) ; 
770   hTOFprimaryESDphiPos->Sumw2();
771   hTOFprimaryESDphiPos->SetLineColor(kRed);
772   if (fEnableAdvancedCheck)
773   fHpos->AddLast(hTOFprimaryESDphiPos) ; 
774
775   //11
776   TH1F* hESDprimaryTrackPtPosTRDout = new TH1F("hESDprimaryTrackPtPosTRDout", "ESDs Pos primary tracks p_{T} with kTRDout distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
777   hESDprimaryTrackPtPosTRDout->Sumw2();
778   hESDprimaryTrackPtPosTRDout->SetLineWidth(1);
779   hESDprimaryTrackPtPosTRDout->SetMarkerStyle(20);
780   hESDprimaryTrackPtPosTRDout->SetMarkerSize(0.7);
781   hESDprimaryTrackPtPosTRDout->SetLineColor(kRed);
782   hESDprimaryTrackPtPosTRDout->SetMarkerColor(kRed);
783   if (fEnableAdvancedCheck)
784   fHpos->AddLast(hESDprimaryTrackPtPosTRDout);
785
786   //12
787   TH1F* hESDprimaryTrackPtPosNoTRDout = new TH1F("hESDprimaryTrackPtPosNoTRDout", "ESDs Pos primary tracks p_{T} with !kTRDout distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
788   hESDprimaryTrackPtPosNoTRDout->Sumw2();
789   hESDprimaryTrackPtPosNoTRDout->SetLineWidth(1);
790   hESDprimaryTrackPtPosNoTRDout->SetMarkerStyle(25);
791   hESDprimaryTrackPtPosNoTRDout->SetMarkerSize(0.7);
792   hESDprimaryTrackPtPosNoTRDout->SetLineColor(kRed);
793   hESDprimaryTrackPtPosNoTRDout->SetMarkerColor(kRed);
794   if (fEnableAdvancedCheck)
795   fHpos->AddLast(hESDprimaryTrackPtPosNoTRDout);
796
797     //13
798   TH1F* hESDprimaryTrackEtaPosTRDout = new TH1F("hESDprimaryTrackEtaPosTRDout", "ESDs Pos primary tracks #eta with kTRDout distribution; #eta;tracks", 200, -1.0, 1.0) ;  
799   hESDprimaryTrackEtaPosTRDout->Sumw2();
800   hESDprimaryTrackEtaPosTRDout->SetLineWidth(1);
801   hESDprimaryTrackEtaPosTRDout->SetMarkerStyle(20);
802   hESDprimaryTrackEtaPosTRDout->SetMarkerSize(0.7);
803   hESDprimaryTrackEtaPosTRDout->SetLineColor(kBlue);
804   hESDprimaryTrackEtaPosTRDout->SetMarkerColor(kBlue);
805   if (fEnableAdvancedCheck)
806   fHpos->AddLast(hESDprimaryTrackEtaPosTRDout);
807
808   //14
809   TH1F* hESDprimaryTrackEtaPosNoTRDout = new TH1F("hESDprimaryTrackEtaPosNoTRDout", "ESDs Pos primary tracks #eta with !kTRDout distribution;#eta;tracks", 200, -1.0, 1.0) ;  
810   hESDprimaryTrackEtaPosNoTRDout->Sumw2();
811   hESDprimaryTrackEtaPosNoTRDout->SetLineWidth(1);
812   hESDprimaryTrackEtaPosNoTRDout->SetMarkerStyle(25);
813   hESDprimaryTrackEtaPosNoTRDout->SetMarkerSize(0.7);
814   hESDprimaryTrackEtaPosNoTRDout->SetLineColor(kBlue);
815   hESDprimaryTrackEtaPosNoTRDout->SetMarkerColor(kBlue);
816   if (fEnableAdvancedCheck)
817   fHpos->AddLast(hESDprimaryTrackEtaPosNoTRDout);
818
819   //15
820   TH1F* hESDprimaryTrackPhiPosTRDout = new TH1F("hESDprimaryTrackPhiPosTRDout", "ESDs Pos primary tracks #phi with kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
821   hESDprimaryTrackPhiPosTRDout->Sumw2();
822   hESDprimaryTrackPhiPosTRDout->SetLineWidth(1);
823   hESDprimaryTrackPhiPosTRDout->SetMarkerStyle(20);
824   hESDprimaryTrackPhiPosTRDout->SetMarkerSize(0.7);
825   hESDprimaryTrackPhiPosTRDout->SetLineColor(kBlue);
826   hESDprimaryTrackPhiPosTRDout->SetMarkerColor(kBlue);
827   if (fEnableAdvancedCheck)
828   fHpos->AddLast(hESDprimaryTrackPhiPosTRDout);
829
830   //16
831   TH1F* hESDprimaryTrackPhiPosNoTRDout = new TH1F("hESDprimaryTrackPhiPosNoTRDout", "ESDs Pos primary tracks #phi with !kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
832   hESDprimaryTrackPhiPosNoTRDout->Sumw2();
833   hESDprimaryTrackPhiPosNoTRDout->SetLineWidth(1);
834   hESDprimaryTrackPhiPosNoTRDout->SetMarkerStyle(25);
835   hESDprimaryTrackPhiPosNoTRDout->SetMarkerSize(0.7);
836   hESDprimaryTrackPhiPosNoTRDout->SetLineColor(kBlue);
837   hESDprimaryTrackPhiPosNoTRDout->SetMarkerColor(kBlue);
838   if (fEnableAdvancedCheck)
839   fHpos->AddLast(hESDprimaryTrackPhiPosNoTRDout);
840
841   //POS 17
842   TH2F* hTOFmatchedExpTimeProVsPhiPos = new TH2F("hTOFmatchedExpTimeProVsPhiPos", "ESDs t_{TOF}-t_{p,exp} vs #phi at TOF (r=378.cm) (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., 500, -5000., 5000. ) ; 
843   hTOFmatchedExpTimeProVsPhiPos->Sumw2() ;
844   if (fEnableAdvancedCheck)
845   fHpos->AddLast(hTOFmatchedExpTimeProVsPhiPos) ;
846
847   //POS 18
848   TH2F* hTOFmatchedExpTimeProVsPhiVertexPos = new TH2F("hTOFmatchedExpTimeProVsPhiVertexPos", "ESDs t_{TOF}-t_{p,exp} vs #phi at vtx (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
849   hTOFmatchedExpTimeProVsPhiVertexPos->Sumw2() ;
850   if (fEnableAdvancedCheck)
851   fHpos->AddLast(hTOFmatchedExpTimeProVsPhiVertexPos) ;
852
853   //POS 19
854   TH2F* hTOFmatchedExpTimeProVsPhiTPCPos = new TH2F("hTOFmatchedExpTimeProVsPhiTPCPos", "ESDs t_{TOF}-t_{p,exp} vs #phi at outer TPC (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
855   hTOFmatchedExpTimeProVsPhiTPCPos->Sumw2() ;
856   if (fEnableAdvancedCheck)
857   fHpos->AddLast(hTOFmatchedExpTimeProVsPhiTPCPos) ;
858
859    //20
860   TH1F* hESDmatchedTrackEtaPosTRDout = new TH1F("hESDmatchedTrackEtaPosTRDout", "ESDs Pos matched tracks #eta with kTRDout distribution; #eta;tracks", 200, -1.0, 1.0) ;  
861   hESDmatchedTrackEtaPosTRDout->Sumw2();
862   hESDmatchedTrackEtaPosTRDout->SetLineWidth(1);
863   hESDmatchedTrackEtaPosTRDout->SetMarkerStyle(20);
864   hESDmatchedTrackEtaPosTRDout->SetMarkerSize(0.7);
865   hESDmatchedTrackEtaPosTRDout->SetLineColor(kBlue);
866   hESDmatchedTrackEtaPosTRDout->SetMarkerColor(kBlue);
867   if (fEnableAdvancedCheck)
868   fHpos->AddLast(hESDmatchedTrackEtaPosTRDout);
869
870   //21
871   TH1F* hESDmatchedTrackEtaPosNoTRDout = new TH1F("hESDmatchedTrackEtaPosNoTRDout", "ESDs Pos matched tracks #eta with !kTRDout distribution;#eta;tracks", 200, -1.0, 1.0) ;  
872   hESDmatchedTrackEtaPosNoTRDout->Sumw2();
873   hESDmatchedTrackEtaPosNoTRDout->SetLineWidth(1);
874   hESDmatchedTrackEtaPosNoTRDout->SetMarkerStyle(25);
875   hESDmatchedTrackEtaPosNoTRDout->SetMarkerSize(0.7);
876   hESDmatchedTrackEtaPosNoTRDout->SetLineColor(kBlue);
877   hESDmatchedTrackEtaPosNoTRDout->SetMarkerColor(kBlue);
878   if (fEnableAdvancedCheck)
879   fHpos->AddLast(hESDmatchedTrackEtaPosNoTRDout);
880
881   //22
882   TH1F* hESDmatchedTrackPhiPosTRDout = new TH1F("hESDmatchedTrackPhiPosTRDout", "ESDs Pos matched tracks #phi with kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
883   hESDmatchedTrackPhiPosTRDout->Sumw2();
884   hESDmatchedTrackPhiPosTRDout->SetLineWidth(1);
885   hESDmatchedTrackPhiPosTRDout->SetMarkerStyle(20);
886   hESDmatchedTrackPhiPosTRDout->SetMarkerSize(0.7);
887   hESDmatchedTrackPhiPosTRDout->SetLineColor(kBlue);
888   hESDmatchedTrackPhiPosTRDout->SetMarkerColor(kBlue);
889   if (fEnableAdvancedCheck)
890   fHpos->AddLast(hESDmatchedTrackPhiPosTRDout);
891
892   //23
893   TH1F* hESDmatchedTrackPhiPosNoTRDout = new TH1F("hESDmatchedTrackPhiPosNoTRDout", "ESDs Pos matched tracks #phi with !kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
894   hESDmatchedTrackPhiPosNoTRDout->Sumw2();
895   hESDmatchedTrackPhiPosNoTRDout->SetLineWidth(1);
896   hESDmatchedTrackPhiPosNoTRDout->SetMarkerStyle(25);
897   hESDmatchedTrackPhiPosNoTRDout->SetMarkerSize(0.7);
898   hESDmatchedTrackPhiPosNoTRDout->SetLineColor(kBlue);
899   hESDmatchedTrackPhiPosNoTRDout->SetMarkerColor(kBlue);
900   if (fEnableAdvancedCheck)
901   fHpos->AddLast(hESDmatchedTrackPhiPosNoTRDout);
902
903   //POS 24
904   TH2F* hTOFmatchedExpTimePiVsPhiTPCPos = new TH2F("hTOFmatchedExpTimePiVsPhiTPCPos", "ESDs t_{TOF}-t_{#pi,exp} vs #phi at outer TPC (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
905   hTOFmatchedExpTimePiVsPhiTPCPos->Sumw2() ;
906   if (fEnableAdvancedCheck)
907   fHpos->AddLast(hTOFmatchedExpTimePiVsPhiTPCPos) ;
908
909   //POS 25
910   TH2F* hTOFmatchedExpTimeKaVsPhiTPCPos = new TH2F("hTOFmatchedExpTimeKaVsPhiTPCPos", "ESDs t_{TOF}-t_{K,exp} vs #phi at outer TPC (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
911   hTOFmatchedExpTimeKaVsPhiTPCPos->Sumw2() ;
912   if (fEnableAdvancedCheck)
913   fHpos->AddLast(hTOFmatchedExpTimeKaVsPhiTPCPos) ;
914
915 //----------------------------------------------------------NEGATIVE TRACKS
916   //0
917   TH1F* hTOFmatchedESDtrkLengthNeg  = new TH1F("hTOFmatchedESDtrkLengthNeg", "Matched positive ESDs tracks length; Track length [cm];Counts", 1600, -800., 800) ; 
918   hTOFmatchedESDtrkLengthNeg->Sumw2();
919   hTOFmatchedESDtrkLengthNeg->SetLineColor(kBlue);
920   hTOFmatchedESDtrkLengthNeg->SetMarkerColor(kBlue);
921   hTOFmatchedESDtrkLengthNeg->SetFillColor(kBlue);
922   hTOFmatchedESDtrkLengthNeg->SetDrawOption("BAR"); 
923   if (fEnableAdvancedCheck)
924   fHneg->AddLast(hTOFmatchedESDtrkLengthNeg);
925   //1
926   TH1F* hTOFmatchedESDPNeg  = new TH1F("hTOFmatchedESDPNeg", "TPC-TOF matched positive tracks momentum distribution (GeV/c); p (GeV/c);tracks", 500,0.,5.) ;  
927   hTOFmatchedESDPNeg->Sumw2() ;
928   hTOFmatchedESDPNeg->SetLineColor(kBlue);
929   hTOFmatchedESDPNeg->SetMarkerStyle(20);
930   hTOFmatchedESDPNeg->SetMarkerSize(0.7);
931   hTOFmatchedESDPNeg->SetMarkerColor(kBlue);
932   if (fEnableAdvancedCheck)
933   fHneg->AddLast(hTOFmatchedESDPNeg) ; 
934   //2
935   TH1F* hTOFmatchedESDPtNeg  = new TH1F("hTOFmatchedESDPtNeg", "TPC-TOF positive matched tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500,0.,5.) ;  
936   hTOFmatchedESDPtNeg->Sumw2() ;
937   hTOFmatchedESDPtNeg->SetLineColor(kBlue);
938   hTOFmatchedESDPtNeg->SetMarkerStyle(21);
939   hTOFmatchedESDPtNeg->SetMarkerSize(0.7);
940   hTOFmatchedESDPtNeg->SetMarkerColor(kBlue);
941   if (fEnableAdvancedCheck)
942   fHneg->AddLast(hTOFmatchedESDPtNeg) ; 
943
944   //3
945   TH1F* hTOFmatchedESDetaNeg = new TH1F("hTOFmatchedESDetaNeg", "Matched positive ESD tracks #eta (p_{T} #geq 0.5 GeV/c); eta;Counts", 200, -1., 1.) ; 
946   hTOFmatchedESDetaNeg->Sumw2();
947   hTOFmatchedESDetaNeg->SetLineColor(kBlue);
948   if (fEnableAdvancedCheck)
949   fHneg->AddLast(hTOFmatchedESDetaNeg) ; 
950   //4
951    TH1F* hTOFmatchedESDphiNeg = new TH1F("hTOFmatchedESDphiNeg", "Matched Negitive ESD tracks #phi; #phi (deg);Counts", 72, 0., 360.) ; 
952   hTOFmatchedESDphiNeg->Sumw2();
953   hTOFmatchedESDphiNeg->SetLineColor(kBlue);
954   if (fEnableAdvancedCheck)
955   fHneg->AddLast(hTOFmatchedESDphiNeg) ; 
956
957   //5
958   TH1F* hESDmatchedTrackPtNegTRDout = new TH1F("hESDmatchedTrackPtNegTRDout", "ESDs Neg matched tracks p_{T} with kTRDout distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
959   hESDmatchedTrackPtNegTRDout->Sumw2();
960   hESDmatchedTrackPtNegTRDout->SetLineWidth(1);
961   hESDmatchedTrackPtNegTRDout->SetMarkerStyle(20);
962   hESDmatchedTrackPtNegTRDout->SetMarkerSize(0.7);
963   hESDmatchedTrackPtNegTRDout->SetLineColor(kBlue);
964   hESDmatchedTrackPtNegTRDout->SetMarkerColor(kBlue);
965   if (fEnableAdvancedCheck)
966   fHneg->AddLast(hESDmatchedTrackPtNegTRDout);
967
968   //6
969   TH1F* hESDmatchedTrackPtNegNoTRDout = new TH1F("hESDmatchedTrackPtNegNoTRDout", "ESDs Neg matched tracks p_{T} with !kTRDout distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
970   hESDmatchedTrackPtNegNoTRDout->Sumw2();
971   hESDmatchedTrackPtNegNoTRDout->SetLineWidth(1);
972   hESDmatchedTrackPtNegNoTRDout->SetMarkerStyle(25);
973   hESDmatchedTrackPtNegNoTRDout->SetMarkerSize(0.7);
974   hESDmatchedTrackPtNegNoTRDout->SetLineColor(kBlue);
975   hESDmatchedTrackPtNegNoTRDout->SetMarkerColor(kBlue);
976   if (fEnableAdvancedCheck)
977   fHneg->AddLast(hESDmatchedTrackPtNegNoTRDout);
978
979   //7
980   TH1F* hESDprimaryTrackPNeg = new TH1F("hESDprimaryTrackPNeg", "All Neg ESDs tracks p distribution (GeV/c); p(GeV/c);tracks", 500, 0., 5.0) ;  
981   hESDprimaryTrackPNeg->Sumw2();
982   hESDprimaryTrackPNeg->SetLineWidth(1);
983   hESDprimaryTrackPNeg->SetMarkerStyle(24);
984   hESDprimaryTrackPNeg->SetMarkerSize(0.7);
985   hESDprimaryTrackPNeg->SetMarkerColor(kBlue);
986   hESDprimaryTrackPNeg->SetLineColor(kBlue);
987   if (fEnableAdvancedCheck)
988   fHneg->AddLast(hESDprimaryTrackPNeg);
989   //8
990   TH1F* hESDprimaryTrackPtNeg = new TH1F("hESDprimaryTrackPtNeg", "ESDs Neg primary tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
991   hESDprimaryTrackPtNeg->Sumw2();
992   hESDprimaryTrackPtNeg->SetLineWidth(1);
993   hESDprimaryTrackPtNeg->SetMarkerStyle(25);
994   hESDprimaryTrackPtNeg->SetMarkerSize(0.7);
995   hESDprimaryTrackPtNeg->SetLineColor(kBlue);
996   hESDprimaryTrackPtNeg->SetMarkerColor(kBlue);
997   if (fEnableAdvancedCheck)
998   fHneg->AddLast(hESDprimaryTrackPtNeg);
999   //9
1000   TH1F* hTOFprimaryESDetaNeg = new TH1F("hTOFprimaryESDetaNeg", "Primary ESD Neg tracks #eta (p_{T} #geq 0.5 GeV/c); #eta;Counts", 200, -1., 1.) ; 
1001   hTOFprimaryESDetaNeg->Sumw2();
1002   hTOFprimaryESDetaNeg->SetLineColor(kBlue);
1003   if (fEnableAdvancedCheck)
1004   fHneg->AddLast(hTOFprimaryESDetaNeg) ; 
1005   //10
1006   TH1F* hTOFprimaryESDphiNeg = new TH1F("hTOFprimaryESDphiNeg", "Primary ESD Neg tracks #phi;#phi (deg);Counts", 72, 0., 360.) ; 
1007   hTOFprimaryESDphiNeg->Sumw2();
1008   hTOFprimaryESDphiNeg->SetLineColor(kBlue);
1009   if (fEnableAdvancedCheck)
1010   fHneg->AddLast(hTOFprimaryESDphiNeg) ; 
1011
1012  //11
1013   TH1F* hESDprimaryTrackPtNegTRDout = new TH1F("hESDprimaryTrackPtNegTRDout", "ESDs Neg primary tracks p_{T} with kTRDout distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
1014   hESDprimaryTrackPtNegTRDout->Sumw2();
1015   hESDprimaryTrackPtNegTRDout->SetLineWidth(1);
1016   hESDprimaryTrackPtNegTRDout->SetMarkerStyle(20);
1017   hESDprimaryTrackPtNegTRDout->SetMarkerSize(0.7);
1018   hESDprimaryTrackPtNegTRDout->SetLineColor(kBlue);
1019   hESDprimaryTrackPtNegTRDout->SetMarkerColor(kBlue);
1020   if (fEnableAdvancedCheck)
1021   fHneg->AddLast(hESDprimaryTrackPtNegTRDout);
1022
1023   //12
1024   TH1F* hESDprimaryTrackPtNegNoTRDout = new TH1F("hESDprimaryTrackPtNegNoTRDout", "ESDs Neg primary tracks p_{T} with !kTRDout distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
1025   hESDprimaryTrackPtNegNoTRDout->Sumw2();
1026   hESDprimaryTrackPtNegNoTRDout->SetLineWidth(1);
1027   hESDprimaryTrackPtNegNoTRDout->SetMarkerStyle(25);
1028   hESDprimaryTrackPtNegNoTRDout->SetMarkerSize(0.7);
1029   hESDprimaryTrackPtNegNoTRDout->SetLineColor(kBlue);
1030   hESDprimaryTrackPtNegNoTRDout->SetMarkerColor(kBlue);
1031   if (fEnableAdvancedCheck)
1032   fHneg->AddLast(hESDprimaryTrackPtNegNoTRDout);
1033
1034   //13
1035   TH1F* hESDprimaryTrackEtaNegTRDout = new TH1F("hESDprimaryTrackEtaNegTRDout", "ESDs Neg primary tracks #eta with kTRDout distribution; #eta;tracks", 200, -1.0, 1.0) ;  
1036   hESDprimaryTrackEtaNegTRDout->Sumw2();
1037   hESDprimaryTrackEtaNegTRDout->SetLineWidth(1);
1038   hESDprimaryTrackEtaNegTRDout->SetMarkerStyle(20);
1039   hESDprimaryTrackEtaNegTRDout->SetMarkerSize(0.7);
1040   hESDprimaryTrackEtaNegTRDout->SetLineColor(kBlue);
1041   hESDprimaryTrackEtaNegTRDout->SetMarkerColor(kBlue);
1042   if (fEnableAdvancedCheck)
1043   fHneg->AddLast(hESDprimaryTrackEtaNegTRDout);
1044
1045   //14
1046   TH1F* hESDprimaryTrackEtaNegNoTRDout = new TH1F("hESDprimaryTrackEtaNegNoTRDout", "ESDs Neg primary tracks #eta with !kTRDout distribution;#eta;tracks", 200, -1.0, 1.0) ;  
1047   hESDprimaryTrackEtaNegNoTRDout->Sumw2();
1048   hESDprimaryTrackEtaNegNoTRDout->SetLineWidth(1);
1049   hESDprimaryTrackEtaNegNoTRDout->SetMarkerStyle(25);
1050   hESDprimaryTrackEtaNegNoTRDout->SetMarkerSize(0.7);
1051   hESDprimaryTrackEtaNegNoTRDout->SetLineColor(kBlue);
1052   hESDprimaryTrackEtaNegNoTRDout->SetMarkerColor(kBlue);
1053   if (fEnableAdvancedCheck)
1054   fHneg->AddLast(hESDprimaryTrackEtaNegNoTRDout);
1055
1056   //15
1057   TH1F* hESDprimaryTrackPhiNegTRDout = new TH1F("hESDprimaryTrackPhiNegTRDout", "ESDs Neg primary tracks #phi with kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
1058   hESDprimaryTrackPhiNegTRDout->Sumw2();
1059   hESDprimaryTrackPhiNegTRDout->SetLineWidth(1);
1060   hESDprimaryTrackPhiNegTRDout->SetMarkerStyle(20);
1061   hESDprimaryTrackPhiNegTRDout->SetMarkerSize(0.7);
1062   hESDprimaryTrackPhiNegTRDout->SetLineColor(kBlue);
1063   hESDprimaryTrackPhiNegTRDout->SetMarkerColor(kBlue);
1064   if (fEnableAdvancedCheck)
1065   fHneg->AddLast(hESDprimaryTrackPhiNegTRDout);
1066
1067   //16
1068   TH1F* hESDprimaryTrackPhiNegNoTRDout = new TH1F("hESDprimaryTrackPhiNegNoTRDout", "ESDs Neg primary tracks #phi with !kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
1069   hESDprimaryTrackPhiNegNoTRDout->Sumw2();
1070   hESDprimaryTrackPhiNegNoTRDout->SetLineWidth(1);
1071   hESDprimaryTrackPhiNegNoTRDout->SetMarkerStyle(25);
1072   hESDprimaryTrackPhiNegNoTRDout->SetMarkerSize(0.7);
1073   hESDprimaryTrackPhiNegNoTRDout->SetLineColor(kBlue);
1074   hESDprimaryTrackPhiNegNoTRDout->SetMarkerColor(kBlue);
1075   if (fEnableAdvancedCheck)
1076   fHneg->AddLast(hESDprimaryTrackPhiNegNoTRDout);
1077
1078   //NEG 17
1079   TH2F* hTOFmatchedExpTimeProVsPhiNeg = new TH2F("hTOFmatchedExpTimeProVsPhiNeg", "ESDs t_{TOF}-t_{p,exp} vs #phi at TOF (r=378.cm) (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
1080   hTOFmatchedExpTimeProVsPhiNeg->Sumw2() ;
1081   if (fEnableAdvancedCheck)
1082   fHneg->AddLast(hTOFmatchedExpTimeProVsPhiNeg) ;
1083
1084   //NEG 18
1085   TH2F* hTOFmatchedExpTimeProVsPhiVertexNeg = new TH2F("hTOFmatchedExpTimeProVsPhiVertexNeg", "ESDs t_{TOF}-t_{p,exp} vs #phi at vtx (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
1086   hTOFmatchedExpTimeProVsPhiVertexNeg->Sumw2() ;
1087   if (fEnableAdvancedCheck)
1088   fHneg->AddLast(hTOFmatchedExpTimeProVsPhiVertexNeg) ;
1089
1090   //NEG 19
1091   TH2F* hTOFmatchedExpTimeProVsPhiTPCNeg = new TH2F("hTOFmatchedExpTimeProVsPhiTPCNeg", "ESDs t_{TOF}-t_{p,exp} vs #phi at outer TPC (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
1092   hTOFmatchedExpTimeProVsPhiTPCNeg->Sumw2() ;
1093   if (fEnableAdvancedCheck)
1094   fHneg->AddLast(hTOFmatchedExpTimeProVsPhiTPCNeg) ;
1095
1096
1097   //20
1098   TH1F* hESDmatchedTrackEtaNegTRDout = new TH1F("hESDmatchedTrackEtaNegTRDout", "ESDs Neg matched tracks #eta with kTRDout distribution; #eta;tracks", 200, -1.0, 1.0) ;  
1099   hESDmatchedTrackEtaNegTRDout->Sumw2();
1100   hESDmatchedTrackEtaNegTRDout->SetLineWidth(1);
1101   hESDmatchedTrackEtaNegTRDout->SetMarkerStyle(20);
1102   hESDmatchedTrackEtaNegTRDout->SetMarkerSize(0.7);
1103   hESDmatchedTrackEtaNegTRDout->SetLineColor(kBlue);
1104   hESDmatchedTrackEtaNegTRDout->SetMarkerColor(kBlue);
1105   if (fEnableAdvancedCheck)
1106   fHneg->AddLast(hESDmatchedTrackEtaNegTRDout);
1107
1108   //21
1109   TH1F* hESDmatchedTrackEtaNegNoTRDout = new TH1F("hESDmatchedTrackEtaNegNoTRDout", "ESDs Neg matched tracks #eta with !kTRDout distribution;#eta;tracks", 200, -1.0, 1.0) ;  
1110   hESDmatchedTrackEtaNegNoTRDout->Sumw2();
1111   hESDmatchedTrackEtaNegNoTRDout->SetLineWidth(1);
1112   hESDmatchedTrackEtaNegNoTRDout->SetMarkerStyle(25);
1113   hESDmatchedTrackEtaNegNoTRDout->SetMarkerSize(0.7);
1114   hESDmatchedTrackEtaNegNoTRDout->SetLineColor(kBlue);
1115   hESDmatchedTrackEtaNegNoTRDout->SetMarkerColor(kBlue);
1116   if (fEnableAdvancedCheck)
1117   fHneg->AddLast(hESDmatchedTrackEtaNegNoTRDout);
1118
1119   //22
1120   TH1F* hESDmatchedTrackPhiNegTRDout = new TH1F("hESDmatchedTrackPhiNegTRDout", "ESDs Neg matched tracks #phi with kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
1121   hESDmatchedTrackPhiNegTRDout->Sumw2();
1122   hESDmatchedTrackPhiNegTRDout->SetLineWidth(1);
1123   hESDmatchedTrackPhiNegTRDout->SetMarkerStyle(20);
1124   hESDmatchedTrackPhiNegTRDout->SetMarkerSize(0.7);
1125   hESDmatchedTrackPhiNegTRDout->SetLineColor(kBlue);
1126   hESDmatchedTrackPhiNegTRDout->SetMarkerColor(kBlue);
1127   if (fEnableAdvancedCheck)
1128   fHneg->AddLast(hESDmatchedTrackPhiNegTRDout);
1129
1130   //23
1131   TH1F* hESDmatchedTrackPhiNegNoTRDout = new TH1F("hESDmatchedTrackPhiNegNoTRDout", "ESDs Neg matched tracks #phi with !kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
1132   hESDmatchedTrackPhiNegNoTRDout->Sumw2();
1133   hESDmatchedTrackPhiNegNoTRDout->SetLineWidth(1);
1134   hESDmatchedTrackPhiNegNoTRDout->SetMarkerStyle(25);
1135   hESDmatchedTrackPhiNegNoTRDout->SetMarkerSize(0.7);
1136   hESDmatchedTrackPhiNegNoTRDout->SetLineColor(kBlue);
1137   hESDmatchedTrackPhiNegNoTRDout->SetMarkerColor(kBlue);
1138   if (fEnableAdvancedCheck)
1139   fHneg->AddLast(hESDmatchedTrackPhiNegNoTRDout);
1140  
1141  //NEG 24
1142   TH2F* hTOFmatchedExpTimePiVsPhiTPCNeg = new TH2F("hTOFmatchedExpTimePiVsPhiTPCNeg", "ESDs t_{TOF}-t_{#pi,exp} vs #phi at outer TPC (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
1143   hTOFmatchedExpTimePiVsPhiTPCNeg->Sumw2() ;
1144   if (fEnableAdvancedCheck)
1145   fHneg->AddLast(hTOFmatchedExpTimePiVsPhiTPCNeg) ;
1146
1147   //NEG 25
1148   TH2F* hTOFmatchedExpTimeKaVsPhiTPCNeg = new TH2F("hTOFmatchedExpTimeKaVsPhiTPCNeg", "ESDs t_{TOF}-t_{K,exp} vs #phi at outer TPC (p_{T}<1GeV/c);#phi (deg); t_{TOF}-t_{p,exp} [ps];Counts",72, 0.,360., nExpTimeSmallBins, fExpTimeSmallRangeMin, fExpTimeSmallRangeMax) ; 
1149   hTOFmatchedExpTimeKaVsPhiTPCNeg->Sumw2() ;
1150   if (fEnableAdvancedCheck)
1151   fHneg->AddLast(hTOFmatchedExpTimeKaVsPhiTPCNeg) ;
1152
1153   PostData(1, fHlist);
1154   PostData(2, fHlistTimeZero);
1155   PostData(3, fHlistPID);
1156   PostData(4, fHpos);
1157   PostData(5, fHneg);
1158 }
1159 //________________________________________________________________________
1160 void AliAnalysisTaskTOFqa::UserExec(Option_t *) 
1161
1162   /* Main - executed for each event.
1163     It extracts event information and track information after selecting 
1164     primary tracks via standard cuts. */
1165   
1166   AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
1167   if (!esdH) {
1168     Printf("ERROR: Could not get ESDInputHandler");
1169     return;
1170   } else {
1171     fESD = (AliESDEvent*) esdH->GetEvent();
1172   } 
1173   
1174   if (!fESD) {
1175     Printf("ERROR: fESD not available");
1176     return;
1177   }
1178
1179   // info from V0 detector QA 
1180   AliESDVZERO * vzero = fESD->GetVZEROData();
1181   Float_t V0Atime = vzero->GetV0ATime();
1182   Float_t V0Ctime = vzero->GetV0CTime(); 
1183   ((TH2F*)fHlistTimeZero->FindObject("hEventV0MeanVsVtx"))->Fill((V0Atime-V0Ctime)*0.5,(V0Atime+V0Ctime)*0.5);
1184
1185   
1186   // info from T0 detector QA 
1187   for (Int_t j=0;j<3;j++){
1188     fT0[j]= (Float_t) fESD->GetT0TOF(j);//ps
1189     if (fT0[j]>90000.) fT0[j]=99999.;//fix old default values to the new one
1190   }
1191   Float_t t0cut = 90000.; 
1192   //Float_t t0cut =3 * t0spread; //use this cut to check t0 used in tof response
1193   // if(t0cut < 500) t0cut = 500;
1194   
1195   if(TMath::Abs(fT0[1]) < t0cut && TMath::Abs(fT0[2]) < t0cut ) {
1196     //&& TMath::Abs(fT0[2]-fT0[1]) < 500)  //add this condition to check t0 used in tof response
1197     ((TH1F*)fHlistTimeZero->FindObject("hT0DetRes"))->Fill((fT0[2]-fT0[1])*0.5);
1198     ((TH1F*)fHlistTimeZero->FindObject("hEventT0DetAND"))->Fill(fT0[0]);  
1199     ((TH2F*)fHlistTimeZero->FindObject("hEventT0MeanVsVtx"))->Fill((fT0[2]-fT0[1])*0.5,(fT0[2]+fT0[1])*0.5);
1200   } 
1201   if(TMath::Abs(fT0[1]) < t0cut){
1202     ((TH1F*)fHlistTimeZero->FindObject("hEventT0DetA"))->Fill(fT0[1]);   
1203   }
1204   if(TMath::Abs(fT0[2]) < t0cut){
1205           ((TH1F*)fHlistTimeZero->FindObject("hEventT0DetC"))->Fill(fT0[2]);
1206   }
1207   
1208   //  event timeZero QA via AliESDpid::SetTOFResponse() 
1209   Double_t timeZero[4]={99999.,99999.,99999.,99999.};
1210   Double_t timeZeroRes[4]={99999.,99999.,99999.,99999.}; 
1211   
1212   TString timeZeroHisto[4]={"hT0fill","hT0TOF","hT0T0","hT0best"};
1213   TString timeZeroHistoRes[4]={"hT0fillRes","hT0TOFRes","hT0T0Res","hT0bestRes"};
1214   for (Int_t j=0;j<4;j++){
1215     fESDpid->SetTOFResponse(fESD, (AliESDpid::EStartTimeType_t) j);//(fill_t0, tof_t0, t0_t0, best_t0)
1216     timeZero[j]=fESDpid->GetTOFResponse().GetStartTime(10.); //timeZero for bin pT>10GeV/c
1217     timeZeroRes[j]=fESDpid->GetTOFResponse().GetStartTimeRes(10.); //timeZero for bin pT>10GeV/c
1218     ((TH1D*)(fHlistTimeZero->FindObject(timeZeroHisto[j].Data())))->Fill(timeZero[j]);
1219     ((TH1D*)(fHlistTimeZero->FindObject(timeZeroHistoRes[j].Data())))->Fill(timeZeroRes[j]);
1220   }
1221
1222   //re-set response tof_t0 for all other checks
1223   fESDpid->SetTOFResponse(fESD,AliESDpid::kTOF_T0);//(fill_t0, tof_t0, t0_t0, best_t0)
1224   
1225   // loop over ESD tracks 
1226   fNTOFtracks=0;
1227   // fNPrimaryTracks=0;
1228
1229   for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
1230     AliESDtrack* track = fESD->GetTrack(iTracks);
1231     if (!track) {
1232       Printf("ERROR: Could not receive track %d", iTracks);
1233       continue;
1234     }
1235
1236     //primary tracks selection: kTPCrefit and std cuts
1237     if (fTrackFilter){
1238             if(!fTrackFilter->IsSelected(track)) continue;
1239     }
1240     else{
1241             Printf("No track filter found, skipping the track loop");
1242             break;
1243     }
1244
1245     Double_t eta=track->Eta();
1246     if (TMath::Abs(eta)>0.8) continue; //cut for acceptance
1247
1248     Double_t mom=track->P();
1249     Double_t mom2 = mom*mom;
1250     Double_t length=track->GetIntegratedLength();
1251     Double_t pT = track->Pt();
1252     Double_t phi=track->Phi()*TMath::RadToDeg();
1253     track->GetIntegratedTimes(fTrkExpTimes);
1254       
1255     ((TH1F*)fHlist->FindObject("hESDprimaryTrackP"))->Fill(mom); 
1256     ((TH1F*)fHlist->FindObject("hESDprimaryTrackPt"))->Fill(pT); 
1257     if (pT>=0.5) {
1258       ((TH1F*)fHlist->FindObject("hTOFprimaryESDeta"))->Fill(eta);
1259       ((TH1F*)fHlist->FindObject("hTOFprimaryESDphi"))->Fill(phi);
1260     }
1261      //evaluate sign  
1262      if (fEnableAdvancedCheck){
1263        if (track->GetSign()>0){
1264         ((TH1F*)fHpos->FindObject("hESDprimaryTrackPPos"))->Fill(mom); 
1265         ((TH1F*)fHpos->FindObject("hESDprimaryTrackPtPos"))->Fill(pT);  
1266         if (pT>=0.5){
1267           ((TH1F*)fHpos->FindObject("hTOFprimaryESDetaPos"))->Fill(eta);
1268           ((TH1F*)fHpos->FindObject("hTOFprimaryESDphiPos"))->Fill(phi);
1269         }
1270         if ( (track->IsOn(AliESDtrack::kTRDout)) && (track->IsOn(AliESDtrack::kTPCout)) ) {
1271           ((TH1F*)fHpos->FindObject("hESDprimaryTrackPtPosTRDout"))->Fill(pT);
1272           if (pT>=0.5) {
1273             ((TH1F*)fHpos->FindObject("hESDprimaryTrackEtaPosTRDout"))->Fill(eta);
1274             ((TH1F*)fHpos->FindObject("hESDprimaryTrackPhiPosTRDout"))->Fill(phi);
1275           }
1276         }
1277         if ((!(track->IsOn(AliESDtrack::kTRDout)))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1278           ((TH1F*)fHpos->FindObject("hESDprimaryTrackPtPosNoTRDout"))->Fill(pT);
1279           if (pT>=0.5) {
1280             ((TH1F*)fHpos->FindObject("hESDprimaryTrackEtaPosNoTRDout"))->Fill(eta);
1281             ((TH1F*)fHpos->FindObject("hESDprimaryTrackPhiPosNoTRDout"))->Fill(phi);
1282           }
1283         }
1284        } //end positive 
1285        else {
1286                ((TH1F*)fHneg->FindObject("hESDprimaryTrackPNeg"))->Fill(mom); 
1287         ((TH1F*)fHneg->FindObject("hESDprimaryTrackPtNeg"))->Fill(pT); 
1288         if (pT>=0.5){
1289           ((TH1F*)fHneg->FindObject("hTOFprimaryESDetaNeg"))->Fill(eta);
1290           ((TH1F*)fHneg->FindObject("hTOFprimaryESDphiNeg"))->Fill(phi);                
1291         }
1292         if ((track->IsOn(AliESDtrack::kTRDout))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1293           ((TH1F*)fHneg->FindObject("hESDprimaryTrackPtNegTRDout"))->Fill(pT);
1294           if (pT>0.5) {
1295             ((TH1F*)fHneg->FindObject("hESDprimaryTrackEtaNegTRDout"))->Fill(eta);
1296             ((TH1F*)fHneg->FindObject("hESDprimaryTrackPhiNegTRDout"))->Fill(phi); 
1297           }
1298         }
1299         if  ((!(track->IsOn(AliESDtrack::kTRDout)))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1300           ((TH1F*)fHneg->FindObject("hESDprimaryTrackPtNegNoTRDout"))->Fill(pT);
1301           if (pT>0.5){
1302             ((TH1F*)fHneg->FindObject("hESDprimaryTrackEtaNegNoTRDout"))->Fill(eta);
1303             ((TH1F*)fHneg->FindObject("hESDprimaryTrackPhiNegNoTRDout"))->Fill(phi);
1304           }
1305         }
1306        }//end negative
1307      }//end flag advanced check
1308
1309     //matched tracks selection: kTOFout and kTIME
1310     if ( (track->IsOn(AliESDtrack::kTOFout)) &&
1311          (track->IsOn(AliESDtrack::kTIME)) &&
1312          (track->IsOn(AliESDtrack::kTPCout))  ) {      
1313       
1314       Double_t tofTime=track->GetTOFsignal();//in ps
1315       Double_t tofTimeRaw=track->GetTOFsignalRaw();//in ps
1316       Double_t tofToT=track->GetTOFsignalToT(); //in ps
1317       Int_t channel=track->GetTOFCalChannel(); 
1318       Int_t volId[5]; //(sector, plate,strip,padZ,padX)
1319       AliTOFGeometry::GetVolumeIndices(channel,volId);
1320       
1321       if (pT>=0.3) fNTOFtracks++; //matched counter
1322       Double_t tof= tofTime*1E-3; // ns, average T0 fill subtracted, no info from T0detector     
1323       ((TH1F*)fHlist->FindObject("hTOFmatchedESDtime"))->Fill(tof); //ns
1324       ((TH1F*)fHlist->FindObject("hTOFmatchedESDrawTime"))->Fill(tofTimeRaw*1E-3); //ns
1325       ((TH1F*)fHlist->FindObject("hTOFmatchedESDToT"))->Fill(tofToT);
1326       ((TH1F*)fHlist->FindObject("hTOFmatchedESDtrkLength"))->Fill(length);  
1327       ((TH1F*)fHlist->FindObject("hTOFmatchedESDP"))->Fill(mom);
1328       ((TH1F*)fHlist->FindObject("hTOFmatchedESDPt"))->Fill(pT);
1329       if (pT>=0.5){
1330         ((TH1F*)fHlist->FindObject("hTOFmatchedESDeta"))->Fill(eta);
1331         ((TH1F*)fHlist->FindObject("hTOFmatchedESDphi"))->Fill(phi);
1332       }
1333       if (track->GetSign()>0)
1334         ((TH2F*)fHlist->FindObject("hTOFmatchedDxVsPtPos"))->Fill(pT,track->GetTOFsignalDx());
1335       else ((TH2F*)fHlist->FindObject("hTOFmatchedDxVsPtNeg"))->Fill(pT,track->GetTOFsignalDx());
1336       ((TH2F*)fHlist->FindObject("hTOFmatchedDzVsStrip"))->Fill((Int_t)GetStripIndex(volId),track->GetTOFsignalDz());
1337    
1338       //evaluate sign
1339       if (fEnableAdvancedCheck){
1340         if (track->GetSign()>0){
1341           ((TH1F*)fHpos->FindObject("hTOFmatchedESDtrkLengthPos"))->Fill(length);  
1342           ((TH1F*)fHpos->FindObject("hTOFmatchedESDPPos"))->Fill(mom); 
1343           ((TH1F*)fHpos->FindObject("hTOFmatchedESDPtPos"))->Fill(pT); 
1344           if (pT>=0.5){
1345             ((TH1F*)fHpos->FindObject("hTOFmatchedESDetaPos"))->Fill(eta);
1346             ((TH1F*)fHpos->FindObject("hTOFmatchedESDphiPos"))->Fill(phi);
1347           }     
1348           if ( (track->IsOn(AliESDtrack::kTRDout))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1349             ((TH1F*)fHpos->FindObject("hESDmatchedTrackPtPosTRDout"))->Fill(pT);
1350             if (pT>=0.5){
1351               ((TH1F*)fHpos->FindObject("hESDmatchedTrackEtaPosTRDout"))->Fill(eta);
1352               ((TH1F*)fHpos->FindObject("hESDmatchedTrackPhiPosTRDout"))->Fill(phi);
1353             }
1354           } 
1355           if ((!(track->IsOn(AliESDtrack::kTRDout)))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1356             ((TH1F*)fHpos->FindObject("hESDmatchedTrackPtPosNoTRDout"))->Fill(pT);
1357             if (pT>=0.5) {
1358               ((TH1F*)fHpos->FindObject("hESDmatchedTrackEtaPosNoTRDout"))->Fill(eta);
1359               ((TH1F*)fHpos->FindObject("hESDmatchedTrackPhiPosNoTRDout"))->Fill(phi);
1360             }
1361           }
1362        }// END POSITIVE
1363        else {   
1364          ((TH1F*)fHneg->FindObject("hTOFmatchedESDtrkLengthNeg"))->Fill(length);  
1365          ((TH1F*)fHneg->FindObject("hTOFmatchedESDPNeg"))->Fill(mom); 
1366          ((TH1F*)fHneg->FindObject("hTOFmatchedESDPtNeg"))->Fill(pT); 
1367          if (pT>=0.5) {
1368            ((TH1F*)fHneg->FindObject("hTOFmatchedESDetaNeg"))->Fill(eta);
1369            ((TH1F*)fHneg->FindObject("hTOFmatchedESDphiNeg"))->Fill(phi);
1370          }        
1371          if ((track->IsOn(AliESDtrack::kTRDout))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1372            ((TH1F*)fHneg->FindObject("hESDmatchedTrackPtNegTRDout"))->Fill(pT);
1373            if (pT>=0.5) {
1374              ((TH1F*)fHneg->FindObject("hESDmatchedTrackEtaNegTRDout"))->Fill(eta);
1375              ((TH1F*)fHneg->FindObject("hESDmatchedTrackPhiNegTRDout"))->Fill(phi);         
1376            }
1377          }
1378          if ((!(track->IsOn(AliESDtrack::kTRDout)))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1379            ((TH1F*)fHneg->FindObject("hESDmatchedTrackPtNegNoTRDout"))->Fill(pT);
1380            if (pT>=0.5) {
1381              ((TH1F*)fHneg->FindObject("hESDmatchedTrackEtaNegNoTRDout"))->Fill(eta);
1382              ((TH1F*)fHneg->FindObject("hESDmatchedTrackPhiNegNoTRDout"))->Fill(phi);
1383            }
1384          }        
1385        }//end negative
1386       }//end advanced check
1387
1388       //basic PID performance check
1389       if (tof<=0) {
1390         printf("WARNING: track with negative TOF time found! Skipping this track for PID checks\n");
1391         continue;
1392       }
1393       if (mom2==0) {
1394         printf("WARNING: track with negative square momentum found! Skipping this track for PID checks\n");
1395         continue;
1396       }
1397       if (length<=0){
1398         printf("WARNING: track with negative length found!Skipping this track for PID checks\n");
1399         continue;
1400       }
1401       Double_t c=TMath::C()*1.E-9;// m/ns
1402       Double_t mass=0.; //GeV
1403       length =length*0.01; // in meters
1404       tof=tof*c;
1405       Double_t beta=length/tof;
1406       Double_t fact= (tof/length)*(tof/length) -1.;
1407       if(fact<=0) {
1408         mass = -mom*TMath::Sqrt(-fact);
1409       }else{ 
1410         mass = mom*TMath::Sqrt(fact); 
1411       }
1412       ((TH2F*)fHlistPID->FindObject("hTOFmatchedESDpVsBeta"))->Fill(mom,beta);
1413       ((TH1F*) fHlistPID->FindObject("hTOFmatchedMass"))->Fill(mass);
1414       
1415       //PID sigmas
1416       Bool_t isValidBeta[AliPID::kSPECIES]={0,0,0,0,0};
1417       for (Int_t specie = 0; specie < AliPID::kSPECIES; specie++){
1418         fSigmaSpecie[specie] = fESDpid->GetTOFResponse().GetExpectedSigma(mom, fTrkExpTimes[specie], AliPID::ParticleMass(specie));
1419         beta=1/TMath::Sqrt(1+AliPID::ParticleMass(specie)*AliPID::ParticleMass(specie)/(mom2));
1420         if (beta>0) {
1421           fThExpTimes[specie]=length*1.E3/(beta*c);//ps
1422           isValidBeta[specie]=kTRUE;
1423         } else {
1424           fThExpTimes[specie]=1E-10;
1425           isValidBeta[specie]=kFALSE;
1426         }
1427       }
1428       
1429       if (isValidBeta[AliPID::kPion]){
1430         ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimePiVsEta"))->Fill((Int_t)GetStripIndex(volId),tofTime-fTrkExpTimes[AliPID::kPion]);//ps
1431         ((TH1F*)fHlistPID->FindObject("hTOFmatchedExpTimePi"))->Fill(tofTime-fTrkExpTimes[AliPID::kPion]);//ps
1432         ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimePiVsP"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1433         if ((pT>=0.95)&&(pT<=1.05)){
1434           Double_t t0tofTrack=fESDpid->GetTOFResponse().GetStartTime(pT);
1435           ((TH1F*)fHlistPID->FindObject("hTOFmatchedTimePion1GeV"))->Fill(tofTime-t0tofTrack-fTrkExpTimes[AliPID::kPion]);
1436         }
1437         ((TH1F*)fHlistPID->FindObject("hTOFtheoreticalExpTimePi"))->Fill(tofTime-fThExpTimes[AliPID::kPion]);//ps
1438         ((TH2F*)fHlistPID->FindObject("hTOFtheoreticalExpTimePiVsP"))->Fill(mom,(tofTime-fThExpTimes[AliPID::kPion]));  
1439         ((TH2F*)fHlistPID->FindObject("hTOFExpSigmaPi"))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kPion])/fSigmaSpecie[AliPID::kPion]);
1440       }
1441       
1442       if (isValidBeta[AliPID::kKaon]){
1443         ((TH1F*)fHlistPID->FindObject("hTOFmatchedExpTimeKa"))->Fill(tofTime-fTrkExpTimes[AliPID::kKaon]);//ps
1444         ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeKaVsP"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1445         ((TH1F*)fHlistPID->FindObject("hTOFtheoreticalExpTimeKa"))->Fill(tofTime-fThExpTimes[AliPID::kKaon]);//ps
1446         ((TH2F*)fHlistPID->FindObject("hTOFtheoreticalExpTimeKaVsP"))->Fill(mom,(tofTime-fThExpTimes[AliPID::kKaon]));
1447         ((TH2F*)fHlistPID->FindObject("hTOFExpSigmaKa"))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kKaon])/fSigmaSpecie[AliPID::kKaon]);
1448       }
1449       if (isValidBeta[AliPID::kProton]){
1450         ((TH1F*)fHlistPID->FindObject("hTOFmatchedExpTimePro"))->Fill(tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1451         ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeProVsP"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1452         ((TH1F*)fHlistPID->FindObject("hTOFtheoreticalExpTimePro"))->Fill(tofTime-fThExpTimes[AliPID::kProton]);//ps
1453         ((TH2F*)fHlistPID->FindObject("hTOFtheoreticalExpTimeProVsP"))->Fill(mom,(tofTime-fThExpTimes[AliPID::kProton]));
1454         ((TH2F*)fHlistPID->FindObject("hTOFExpSigmaPro"))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kProton])/fSigmaSpecie[AliPID::kProton]);
1455       }
1456
1457       if (fEnableAdvancedCheck && (pT<1.)) {
1458         Double_t pos[3]={0.,0.,0.};
1459         track->GetXYZAt(378.,5.,pos);
1460         if ((pos[0]==0.)&&(pos[1]==0.)&&(pos[2]==0.))continue;
1461         
1462         Double_t phiTOF=TMath::ATan2(pos[1],pos[0])*TMath::RadToDeg();
1463         if (phiTOF<0) phiTOF+= (2*TMath::Pi()*TMath::RadToDeg());
1464         
1465         if (isValidBeta[AliPID::kProton]){
1466           if (track->GetSign()>0){
1467             ((TH2F*)fHpos->FindObject("hTOFmatchedExpTimeProVsPhiPos"))->Fill(phiTOF,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1468             ((TH2F*)fHpos->FindObject("hTOFmatchedExpTimeProVsPhiVertexPos"))->Fill(phi,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1469           } else {
1470             ((TH2F*)fHneg->FindObject("hTOFmatchedExpTimeProVsPhiNeg"))->Fill(phiTOF,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1471             ((TH2F*)fHneg->FindObject("hTOFmatchedExpTimeProVsPhiVertexNeg"))->Fill(phi,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1472           }
1473         }
1474         
1475         track->GetOuterXYZ(pos);
1476         Double_t phiOuterTPC=TMath::ATan2(pos[1],pos[0])*TMath::RadToDeg();
1477         if (phiOuterTPC<0) phiOuterTPC+= (2*TMath::Pi()*TMath::RadToDeg());
1478         
1479         if (track->GetSign()>0){
1480           if (isValidBeta[AliPID::kProton])
1481             ((TH2F*)fHpos->FindObject("hTOFmatchedExpTimeProVsPhiTPCPos"))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1482           if (isValidBeta[AliPID::kPion])
1483             ((TH2F*)fHpos->FindObject("hTOFmatchedExpTimePiVsPhiTPCPos"))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kPion]);//ps
1484           if (isValidBeta[AliPID::kKaon])
1485             ((TH2F*)fHpos->FindObject("hTOFmatchedExpTimeKaVsPhiTPCPos"))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kKaon]);//ps
1486           
1487           if ((phiOuterTPC<=30) || ((phiOuterTPC>=150)&&(phiOuterTPC<=230)) || (phiOuterTPC>=310) ) { //TRD sectors
1488             if (isValidBeta[AliPID::kPion])
1489               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimePiVsPTRDPos"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1490             if (isValidBeta[AliPID::kKaon])
1491               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeKaVsPTRDPos"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1492             if (isValidBeta[AliPID::kProton])
1493               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeProVsPTRDPos"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1494           }
1495           if ( ((phiOuterTPC>=50)&&(phiOuterTPC<=130)) || ((phiOuterTPC>=250)&&(phiOuterTPC<=290)) ) {//no TRD sectors
1496             if (isValidBeta[AliPID::kPion])
1497               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimePiVsPNoTRDPos"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1498             if (isValidBeta[AliPID::kKaon])
1499               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeKaVsPNoTRDPos"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1500             if (isValidBeta[AliPID::kProton])
1501               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeProVsPNoTRDPos"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1502           }
1503         }else{
1504           if (isValidBeta[AliPID::kPion])
1505             ((TH2F*)fHneg->FindObject("hTOFmatchedExpTimePiVsPhiTPCNeg"))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kPion]);//ps
1506           if (isValidBeta[AliPID::kKaon])
1507             ((TH2F*)fHneg->FindObject("hTOFmatchedExpTimeKaVsPhiTPCNeg"))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kKaon]);//ps
1508           if (isValidBeta[AliPID::kProton])
1509             ((TH2F*)fHneg->FindObject("hTOFmatchedExpTimeProVsPhiTPCNeg"))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1510           
1511           if ((phiOuterTPC<=30) || ((phiOuterTPC>=150)&&(phiOuterTPC<=230)) || (phiOuterTPC>=310) ) { //TRD sectors
1512             if (isValidBeta[AliPID::kPion])
1513               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimePiVsPTRDNeg"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1514             if (isValidBeta[AliPID::kKaon])
1515               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeKaVsPTRDNeg"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1516             if (isValidBeta[AliPID::kProton])
1517               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeProVsPTRDNeg"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1518           }
1519           if ( ((phiOuterTPC>=50)&&(phiOuterTPC<=130)) || ((phiOuterTPC>=250)&&(phiOuterTPC<=290)) ) {//no TRD sectors
1520             if (isValidBeta[AliPID::kPion])
1521               ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimePiVsPNoTRDNeg"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1522               if (isValidBeta[AliPID::kKaon])
1523                 ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeKaVsPNoTRDNeg"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1524               if (isValidBeta[AliPID::kProton])
1525                 ((TH2F*)fHlistPID->FindObject("hTOFmatchedExpTimeProVsPNoTRDNeg"))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1526           }
1527         }
1528         
1529       }//end advanced checks && cut on pT for t-texp phi distrib      
1530     }//matched
1531   }//end loop on tracks
1532   
1533   ((TH1F*)fHlist->FindObject("hTOFmatchedPerEvt"))->Fill(fNTOFtracks) ;
1534   ((TH2F*)fHlistTimeZero->FindObject("hT0TOFvsNtrk"))->Fill(fNTOFtracks,timeZero[AliESDpid::kTOF_T0]);
1535   
1536   PostData(1, fHlist);
1537   PostData(2, fHlistTimeZero);
1538   PostData(3, fHlistPID);
1539   PostData(4, fHpos);
1540   PostData(5, fHneg);
1541   
1542 }      
1543
1544 //________________________________________________________________________
1545 void AliAnalysisTaskTOFqa::Terminate(Option_t *) 
1546 {
1547   //check on output validity
1548   fHlist = dynamic_cast<TList*> (GetOutputData(1));
1549   if (!fHlist || !fHlistTimeZero) {
1550     Printf("ERROR: lists not available");
1551     return;   
1552   }   
1553  
1554 }
1555
1556 //---------------------------------------------------------------
1557 Int_t AliAnalysisTaskTOFqa::GetStripIndex(const Int_t * const in)
1558 {
1559   /* return tof strip index between 0 and 91 */
1560   
1561   Int_t nStripA = AliTOFGeometry::NStripA();
1562   Int_t nStripB = AliTOFGeometry::NStripB();
1563   Int_t nStripC = AliTOFGeometry::NStripC();
1564
1565   Int_t iplate = in[1];
1566   Int_t istrip = in[2];
1567   
1568   Int_t stripOffset = 0;
1569   switch (iplate) {
1570   case 0:
1571     stripOffset = 0;
1572       break;
1573   case 1:
1574     stripOffset = nStripC;
1575     break;
1576   case 2:
1577     stripOffset = nStripC+nStripB;
1578     break;
1579   case 3:
1580     stripOffset = nStripC+nStripB+nStripA;
1581     break;
1582   case 4:
1583     stripOffset = nStripC+nStripB+nStripA+nStripB;
1584     break;
1585   default:
1586     stripOffset=-1;
1587     break;
1588   };
1589   
1590   if (stripOffset<0 || stripOffset>92) return -1;
1591   else 
1592     return (stripOffset+istrip);
1593 }
1594
1595 #endif