]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/TOF/AliAnalysisTaskTOFqa.cxx
QA update.
[u/mrichter/AliRoot.git] / PWG1 / 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_{T} distribution (GeV/c); p_{T}(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_{bestT0} [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   hT0fillRes->SetMarkerStyle(21);
454   hT0fillRes->SetMarkerColor(kRed);
455   hT0fillRes->SetLineColor(kRed);
456   hT0fillRes->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   //----------------------------------------------------------POSITIVE TRACKS
669   //0
670   TH1F* hTOFmatchedESDtrkLengthPos  = new TH1F("hTOFmatchedESDtrkLengthPos", "Matched positive ESDs tracks length; Track length [cm];Counts", 1600, -800., 800) ; 
671   hTOFmatchedESDtrkLengthPos->Sumw2();
672   hTOFmatchedESDtrkLengthPos->SetLineColor(kRed);
673   hTOFmatchedESDtrkLengthPos->SetMarkerColor(kRed);
674   hTOFmatchedESDtrkLengthPos->SetFillColor(kRed);
675   hTOFmatchedESDtrkLengthPos->SetDrawOption("BAR"); 
676   if (fEnableAdvancedCheck)
677     fHpos->AddLast(hTOFmatchedESDtrkLengthPos);
678   //1
679   TH1F* hTOFmatchedESDPPos  = new TH1F("hTOFmatchedESDPPos", "TPC-TOF matched positive tracks momentum distribution (GeV/c); p (GeV/c);tracks", 500,0.,5.) ;  
680   hTOFmatchedESDPPos->Sumw2() ;
681   hTOFmatchedESDPPos->SetLineColor(kRed);
682   hTOFmatchedESDPPos->SetMarkerStyle(20);
683   hTOFmatchedESDPPos->SetMarkerSize(0.7);
684   hTOFmatchedESDPPos->SetMarkerColor(kRed);
685   if (fEnableAdvancedCheck)
686     fHpos->AddLast(hTOFmatchedESDPPos) ; 
687   //2
688   TH1F* hTOFmatchedESDPtPos  = new TH1F("hTOFmatchedESDPtPos", "TPC-TOF positive matched tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500,0.,5.) ;  
689   hTOFmatchedESDPtPos->Sumw2() ;
690   hTOFmatchedESDPtPos->SetLineColor(kRed);
691   hTOFmatchedESDPtPos->SetMarkerStyle(21);
692   hTOFmatchedESDPtPos->SetMarkerSize(0.7);
693   hTOFmatchedESDPtPos->SetMarkerColor(kRed);
694   if (fEnableAdvancedCheck)
695     fHpos->AddLast(hTOFmatchedESDPtPos) ; 
696
697   //3
698   TH1F* hTOFmatchedESDetaPos = new TH1F("hTOFmatchedESDetaPos", "Matched positive ESD tracks #eta (p_{T} #geq 0.5 GeV/c); eta;Counts", 200, -1., 1.) ; 
699   hTOFmatchedESDetaPos->Sumw2();
700   hTOFmatchedESDetaPos->SetLineColor(kRed);
701     if (fEnableAdvancedCheck)
702 fHpos->AddLast(hTOFmatchedESDetaPos) ; 
703   //4
704    TH1F* hTOFmatchedESDphiPos = new TH1F("hTOFmatchedESDphiPos", "Matched Positive ESD tracks #phi; #phi (deg);Counts", 72, 0., 360.) ; 
705   hTOFmatchedESDphiPos->Sumw2();
706   hTOFmatchedESDphiPos->SetLineColor(kRed);
707   if (fEnableAdvancedCheck)
708   fHpos->AddLast(hTOFmatchedESDphiPos) ; 
709
710   //5
711   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) ;  
712   hESDmatchedTrackPtPosTRDout->Sumw2();
713   hESDmatchedTrackPtPosTRDout->SetLineWidth(1);
714   hESDmatchedTrackPtPosTRDout->SetMarkerStyle(20);
715   hESDmatchedTrackPtPosTRDout->SetMarkerSize(0.7);
716   hESDmatchedTrackPtPosTRDout->SetLineColor(kRed);
717   hESDmatchedTrackPtPosTRDout->SetMarkerColor(kRed);
718   if (fEnableAdvancedCheck)
719   fHpos->AddLast(hESDmatchedTrackPtPosTRDout);
720
721   //6
722   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) ;  
723   hESDmatchedTrackPtPosNoTRDout->Sumw2();
724   hESDmatchedTrackPtPosNoTRDout->SetLineWidth(1);
725   hESDmatchedTrackPtPosNoTRDout->SetMarkerStyle(25);
726   hESDmatchedTrackPtPosNoTRDout->SetMarkerSize(0.7);
727   hESDmatchedTrackPtPosNoTRDout->SetLineColor(kRed);
728   hESDmatchedTrackPtPosNoTRDout->SetMarkerColor(kRed);
729   if (fEnableAdvancedCheck)
730   fHpos->AddLast(hESDmatchedTrackPtPosNoTRDout);
731
732   //7
733   TH1F* hESDprimaryTrackPPos = new TH1F("hESDprimaryTrackPPos", "All Pos ESDs tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0., 5.0) ;  
734   hESDprimaryTrackPPos->Sumw2();
735   hESDprimaryTrackPPos->SetLineWidth(1);
736   hESDprimaryTrackPPos->SetMarkerStyle(24);
737   hESDprimaryTrackPPos->SetMarkerSize(0.7);
738   hESDprimaryTrackPPos->SetMarkerColor(kRed);
739   hESDprimaryTrackPPos->SetLineColor(kRed);
740   if (fEnableAdvancedCheck)
741   fHpos->AddLast(hESDprimaryTrackPPos);
742   //8
743   TH1F* hESDprimaryTrackPtPos = new TH1F("hESDprimaryTrackPtPos", "ESDs Pos primary tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
744   hESDprimaryTrackPtPos->Sumw2();
745   hESDprimaryTrackPtPos->SetLineWidth(1);
746   hESDprimaryTrackPtPos->SetMarkerStyle(25);
747   hESDprimaryTrackPtPos->SetMarkerSize(0.7);
748   hESDprimaryTrackPtPos->SetLineColor(kRed);
749   hESDprimaryTrackPtPos->SetMarkerColor(kRed);
750   if (fEnableAdvancedCheck)
751   fHpos->AddLast(hESDprimaryTrackPtPos);
752   //9
753   TH1F* hTOFprimaryESDetaPos = new TH1F("hTOFprimaryESDetaPos", "Primary ESD Pos tracks #eta (p_{T} #geq 0.5 GeV/c); #eta;Counts", 200, -1., 1.) ; 
754   hTOFprimaryESDetaPos->Sumw2();
755   hTOFprimaryESDetaPos->SetLineColor(kRed);
756   if (fEnableAdvancedCheck)
757   fHpos->AddLast(hTOFprimaryESDetaPos) ; 
758   //10
759   TH1F* hTOFprimaryESDphiPos = new TH1F("hTOFprimaryESDphiPos", "Primary ESD Pos tracks #phi;#phi (deg);Counts", 72, 0., 360.) ; 
760   hTOFprimaryESDphiPos->Sumw2();
761   hTOFprimaryESDphiPos->SetLineColor(kRed);
762   if (fEnableAdvancedCheck)
763   fHpos->AddLast(hTOFprimaryESDphiPos) ; 
764
765   //11
766   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) ;  
767   hESDprimaryTrackPtPosTRDout->Sumw2();
768   hESDprimaryTrackPtPosTRDout->SetLineWidth(1);
769   hESDprimaryTrackPtPosTRDout->SetMarkerStyle(20);
770   hESDprimaryTrackPtPosTRDout->SetMarkerSize(0.7);
771   hESDprimaryTrackPtPosTRDout->SetLineColor(kRed);
772   hESDprimaryTrackPtPosTRDout->SetMarkerColor(kRed);
773   if (fEnableAdvancedCheck)
774   fHpos->AddLast(hESDprimaryTrackPtPosTRDout);
775
776   //12
777   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) ;  
778   hESDprimaryTrackPtPosNoTRDout->Sumw2();
779   hESDprimaryTrackPtPosNoTRDout->SetLineWidth(1);
780   hESDprimaryTrackPtPosNoTRDout->SetMarkerStyle(25);
781   hESDprimaryTrackPtPosNoTRDout->SetMarkerSize(0.7);
782   hESDprimaryTrackPtPosNoTRDout->SetLineColor(kRed);
783   hESDprimaryTrackPtPosNoTRDout->SetMarkerColor(kRed);
784   if (fEnableAdvancedCheck)
785   fHpos->AddLast(hESDprimaryTrackPtPosNoTRDout);
786
787     //13
788   TH1F* hESDprimaryTrackEtaPosTRDout = new TH1F("hESDprimaryTrackEtaPosTRDout", "ESDs Pos primary tracks #eta with kTRDout distribution; #eta;tracks", 200, -1.0, 1.0) ;  
789   hESDprimaryTrackEtaPosTRDout->Sumw2();
790   hESDprimaryTrackEtaPosTRDout->SetLineWidth(1);
791   hESDprimaryTrackEtaPosTRDout->SetMarkerStyle(20);
792   hESDprimaryTrackEtaPosTRDout->SetMarkerSize(0.7);
793   hESDprimaryTrackEtaPosTRDout->SetLineColor(kBlue);
794   hESDprimaryTrackEtaPosTRDout->SetMarkerColor(kBlue);
795   if (fEnableAdvancedCheck)
796   fHpos->AddLast(hESDprimaryTrackEtaPosTRDout);
797
798   //14
799   TH1F* hESDprimaryTrackEtaPosNoTRDout = new TH1F("hESDprimaryTrackEtaPosNoTRDout", "ESDs Pos primary tracks #eta with !kTRDout distribution;#eta;tracks", 200, -1.0, 1.0) ;  
800   hESDprimaryTrackEtaPosNoTRDout->Sumw2();
801   hESDprimaryTrackEtaPosNoTRDout->SetLineWidth(1);
802   hESDprimaryTrackEtaPosNoTRDout->SetMarkerStyle(25);
803   hESDprimaryTrackEtaPosNoTRDout->SetMarkerSize(0.7);
804   hESDprimaryTrackEtaPosNoTRDout->SetLineColor(kBlue);
805   hESDprimaryTrackEtaPosNoTRDout->SetMarkerColor(kBlue);
806   if (fEnableAdvancedCheck)
807   fHpos->AddLast(hESDprimaryTrackEtaPosNoTRDout);
808
809   //15
810   TH1F* hESDprimaryTrackPhiPosTRDout = new TH1F("hESDprimaryTrackPhiPosTRDout", "ESDs Pos primary tracks #phi with kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
811   hESDprimaryTrackPhiPosTRDout->Sumw2();
812   hESDprimaryTrackPhiPosTRDout->SetLineWidth(1);
813   hESDprimaryTrackPhiPosTRDout->SetMarkerStyle(20);
814   hESDprimaryTrackPhiPosTRDout->SetMarkerSize(0.7);
815   hESDprimaryTrackPhiPosTRDout->SetLineColor(kBlue);
816   hESDprimaryTrackPhiPosTRDout->SetMarkerColor(kBlue);
817   if (fEnableAdvancedCheck)
818   fHpos->AddLast(hESDprimaryTrackPhiPosTRDout);
819
820   //16
821   TH1F* hESDprimaryTrackPhiPosNoTRDout = new TH1F("hESDprimaryTrackPhiPosNoTRDout", "ESDs Pos primary tracks #phi with !kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
822   hESDprimaryTrackPhiPosNoTRDout->Sumw2();
823   hESDprimaryTrackPhiPosNoTRDout->SetLineWidth(1);
824   hESDprimaryTrackPhiPosNoTRDout->SetMarkerStyle(25);
825   hESDprimaryTrackPhiPosNoTRDout->SetMarkerSize(0.7);
826   hESDprimaryTrackPhiPosNoTRDout->SetLineColor(kBlue);
827   hESDprimaryTrackPhiPosNoTRDout->SetMarkerColor(kBlue);
828   if (fEnableAdvancedCheck)
829   fHpos->AddLast(hESDprimaryTrackPhiPosNoTRDout);
830
831   //POS 17
832   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. ) ; 
833   hTOFmatchedExpTimeProVsPhiPos->Sumw2() ;
834   if (fEnableAdvancedCheck)
835   fHpos->AddLast(hTOFmatchedExpTimeProVsPhiPos) ;
836
837   //POS 18
838   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) ; 
839   hTOFmatchedExpTimeProVsPhiVertexPos->Sumw2() ;
840   if (fEnableAdvancedCheck)
841   fHpos->AddLast(hTOFmatchedExpTimeProVsPhiVertexPos) ;
842
843   //POS 19
844   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) ; 
845   hTOFmatchedExpTimeProVsPhiTPCPos->Sumw2() ;
846   if (fEnableAdvancedCheck)
847   fHpos->AddLast(hTOFmatchedExpTimeProVsPhiTPCPos) ;
848
849    //20
850   TH1F* hESDmatchedTrackEtaPosTRDout = new TH1F("hESDmatchedTrackEtaPosTRDout", "ESDs Pos matched tracks #eta with kTRDout distribution; #eta;tracks", 200, -1.0, 1.0) ;  
851   hESDmatchedTrackEtaPosTRDout->Sumw2();
852   hESDmatchedTrackEtaPosTRDout->SetLineWidth(1);
853   hESDmatchedTrackEtaPosTRDout->SetMarkerStyle(20);
854   hESDmatchedTrackEtaPosTRDout->SetMarkerSize(0.7);
855   hESDmatchedTrackEtaPosTRDout->SetLineColor(kBlue);
856   hESDmatchedTrackEtaPosTRDout->SetMarkerColor(kBlue);
857   if (fEnableAdvancedCheck)
858   fHpos->AddLast(hESDmatchedTrackEtaPosTRDout);
859
860   //21
861   TH1F* hESDmatchedTrackEtaPosNoTRDout = new TH1F("hESDmatchedTrackEtaPosNoTRDout", "ESDs Pos matched tracks #eta with !kTRDout distribution;#eta;tracks", 200, -1.0, 1.0) ;  
862   hESDmatchedTrackEtaPosNoTRDout->Sumw2();
863   hESDmatchedTrackEtaPosNoTRDout->SetLineWidth(1);
864   hESDmatchedTrackEtaPosNoTRDout->SetMarkerStyle(25);
865   hESDmatchedTrackEtaPosNoTRDout->SetMarkerSize(0.7);
866   hESDmatchedTrackEtaPosNoTRDout->SetLineColor(kBlue);
867   hESDmatchedTrackEtaPosNoTRDout->SetMarkerColor(kBlue);
868   if (fEnableAdvancedCheck)
869   fHpos->AddLast(hESDmatchedTrackEtaPosNoTRDout);
870
871   //22
872   TH1F* hESDmatchedTrackPhiPosTRDout = new TH1F("hESDmatchedTrackPhiPosTRDout", "ESDs Pos matched tracks #phi with kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
873   hESDmatchedTrackPhiPosTRDout->Sumw2();
874   hESDmatchedTrackPhiPosTRDout->SetLineWidth(1);
875   hESDmatchedTrackPhiPosTRDout->SetMarkerStyle(20);
876   hESDmatchedTrackPhiPosTRDout->SetMarkerSize(0.7);
877   hESDmatchedTrackPhiPosTRDout->SetLineColor(kBlue);
878   hESDmatchedTrackPhiPosTRDout->SetMarkerColor(kBlue);
879   if (fEnableAdvancedCheck)
880   fHpos->AddLast(hESDmatchedTrackPhiPosTRDout);
881
882   //23
883   TH1F* hESDmatchedTrackPhiPosNoTRDout = new TH1F("hESDmatchedTrackPhiPosNoTRDout", "ESDs Pos matched tracks #phi with !kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
884   hESDmatchedTrackPhiPosNoTRDout->Sumw2();
885   hESDmatchedTrackPhiPosNoTRDout->SetLineWidth(1);
886   hESDmatchedTrackPhiPosNoTRDout->SetMarkerStyle(25);
887   hESDmatchedTrackPhiPosNoTRDout->SetMarkerSize(0.7);
888   hESDmatchedTrackPhiPosNoTRDout->SetLineColor(kBlue);
889   hESDmatchedTrackPhiPosNoTRDout->SetMarkerColor(kBlue);
890   if (fEnableAdvancedCheck)
891   fHpos->AddLast(hESDmatchedTrackPhiPosNoTRDout);
892
893   //POS 24
894   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) ; 
895   hTOFmatchedExpTimePiVsPhiTPCPos->Sumw2() ;
896   if (fEnableAdvancedCheck)
897   fHpos->AddLast(hTOFmatchedExpTimePiVsPhiTPCPos) ;
898
899   //POS 25
900   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) ; 
901   hTOFmatchedExpTimeKaVsPhiTPCPos->Sumw2() ;
902   if (fEnableAdvancedCheck)
903   fHpos->AddLast(hTOFmatchedExpTimeKaVsPhiTPCPos) ;
904
905 //----------------------------------------------------------NEGATIVE TRACKS
906   //0
907   TH1F* hTOFmatchedESDtrkLengthNeg  = new TH1F("hTOFmatchedESDtrkLengthNeg", "Matched positive ESDs tracks length; Track length [cm];Counts", 1600, -800., 800) ; 
908   hTOFmatchedESDtrkLengthNeg->Sumw2();
909   hTOFmatchedESDtrkLengthNeg->SetLineColor(kBlue);
910   hTOFmatchedESDtrkLengthNeg->SetMarkerColor(kBlue);
911   hTOFmatchedESDtrkLengthNeg->SetFillColor(kBlue);
912   hTOFmatchedESDtrkLengthNeg->SetDrawOption("BAR"); 
913   if (fEnableAdvancedCheck)
914   fHneg->AddLast(hTOFmatchedESDtrkLengthNeg);
915   //1
916   TH1F* hTOFmatchedESDPNeg  = new TH1F("hTOFmatchedESDPNeg", "TPC-TOF matched positive tracks momentum distribution (GeV/c); p (GeV/c);tracks", 500,0.,5.) ;  
917   hTOFmatchedESDPNeg->Sumw2() ;
918   hTOFmatchedESDPNeg->SetLineColor(kBlue);
919   hTOFmatchedESDPNeg->SetMarkerStyle(20);
920   hTOFmatchedESDPNeg->SetMarkerSize(0.7);
921   hTOFmatchedESDPNeg->SetMarkerColor(kBlue);
922   if (fEnableAdvancedCheck)
923   fHneg->AddLast(hTOFmatchedESDPNeg) ; 
924   //2
925   TH1F* hTOFmatchedESDPtNeg  = new TH1F("hTOFmatchedESDPtNeg", "TPC-TOF positive matched tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500,0.,5.) ;  
926   hTOFmatchedESDPtNeg->Sumw2() ;
927   hTOFmatchedESDPtNeg->SetLineColor(kBlue);
928   hTOFmatchedESDPtNeg->SetMarkerStyle(21);
929   hTOFmatchedESDPtNeg->SetMarkerSize(0.7);
930   hTOFmatchedESDPtNeg->SetMarkerColor(kBlue);
931   if (fEnableAdvancedCheck)
932   fHneg->AddLast(hTOFmatchedESDPtNeg) ; 
933
934   //3
935   TH1F* hTOFmatchedESDetaNeg = new TH1F("hTOFmatchedESDetaNeg", "Matched positive ESD tracks #eta (p_{T} #geq 0.5 GeV/c); eta;Counts", 200, -1., 1.) ; 
936   hTOFmatchedESDetaNeg->Sumw2();
937   hTOFmatchedESDetaNeg->SetLineColor(kBlue);
938   if (fEnableAdvancedCheck)
939   fHneg->AddLast(hTOFmatchedESDetaNeg) ; 
940   //4
941    TH1F* hTOFmatchedESDphiNeg = new TH1F("hTOFmatchedESDphiNeg", "Matched Negitive ESD tracks #phi; #phi (deg);Counts", 72, 0., 360.) ; 
942   hTOFmatchedESDphiNeg->Sumw2();
943   hTOFmatchedESDphiNeg->SetLineColor(kBlue);
944   if (fEnableAdvancedCheck)
945   fHneg->AddLast(hTOFmatchedESDphiNeg) ; 
946
947   //5
948   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) ;  
949   hESDmatchedTrackPtNegTRDout->Sumw2();
950   hESDmatchedTrackPtNegTRDout->SetLineWidth(1);
951   hESDmatchedTrackPtNegTRDout->SetMarkerStyle(20);
952   hESDmatchedTrackPtNegTRDout->SetMarkerSize(0.7);
953   hESDmatchedTrackPtNegTRDout->SetLineColor(kBlue);
954   hESDmatchedTrackPtNegTRDout->SetMarkerColor(kBlue);
955   if (fEnableAdvancedCheck)
956   fHneg->AddLast(hESDmatchedTrackPtNegTRDout);
957
958   //6
959   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) ;  
960   hESDmatchedTrackPtNegNoTRDout->Sumw2();
961   hESDmatchedTrackPtNegNoTRDout->SetLineWidth(1);
962   hESDmatchedTrackPtNegNoTRDout->SetMarkerStyle(25);
963   hESDmatchedTrackPtNegNoTRDout->SetMarkerSize(0.7);
964   hESDmatchedTrackPtNegNoTRDout->SetLineColor(kBlue);
965   hESDmatchedTrackPtNegNoTRDout->SetMarkerColor(kBlue);
966   if (fEnableAdvancedCheck)
967   fHneg->AddLast(hESDmatchedTrackPtNegNoTRDout);
968
969   //7
970   TH1F* hESDprimaryTrackPNeg = new TH1F("hESDprimaryTrackPNeg", "All Neg ESDs tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0., 5.0) ;  
971   hESDprimaryTrackPNeg->Sumw2();
972   hESDprimaryTrackPNeg->SetLineWidth(1);
973   hESDprimaryTrackPNeg->SetMarkerStyle(24);
974   hESDprimaryTrackPNeg->SetMarkerSize(0.7);
975   hESDprimaryTrackPNeg->SetMarkerColor(kBlue);
976   hESDprimaryTrackPNeg->SetLineColor(kBlue);
977   if (fEnableAdvancedCheck)
978   fHneg->AddLast(hESDprimaryTrackPNeg);
979   //8
980   TH1F* hESDprimaryTrackPtNeg = new TH1F("hESDprimaryTrackPtNeg", "ESDs Neg primary tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;  
981   hESDprimaryTrackPtNeg->Sumw2();
982   hESDprimaryTrackPtNeg->SetLineWidth(1);
983   hESDprimaryTrackPtNeg->SetMarkerStyle(25);
984   hESDprimaryTrackPtNeg->SetMarkerSize(0.7);
985   hESDprimaryTrackPtNeg->SetLineColor(kBlue);
986   hESDprimaryTrackPtNeg->SetMarkerColor(kBlue);
987   if (fEnableAdvancedCheck)
988   fHneg->AddLast(hESDprimaryTrackPtNeg);
989   //9
990   TH1F* hTOFprimaryESDetaNeg = new TH1F("hTOFprimaryESDetaNeg", "Primary ESD Neg tracks #eta (p_{T} #geq 0.5 GeV/c); #eta;Counts", 200, -1., 1.) ; 
991   hTOFprimaryESDetaNeg->Sumw2();
992   hTOFprimaryESDetaNeg->SetLineColor(kBlue);
993   if (fEnableAdvancedCheck)
994   fHneg->AddLast(hTOFprimaryESDetaNeg) ; 
995   //10
996   TH1F* hTOFprimaryESDphiNeg = new TH1F("hTOFprimaryESDphiNeg", "Primary ESD Neg tracks #phi;#phi (deg);Counts", 72, 0., 360.) ; 
997   hTOFprimaryESDphiNeg->Sumw2();
998   hTOFprimaryESDphiNeg->SetLineColor(kBlue);
999   if (fEnableAdvancedCheck)
1000   fHneg->AddLast(hTOFprimaryESDphiNeg) ; 
1001
1002  //11
1003   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) ;  
1004   hESDprimaryTrackPtNegTRDout->Sumw2();
1005   hESDprimaryTrackPtNegTRDout->SetLineWidth(1);
1006   hESDprimaryTrackPtNegTRDout->SetMarkerStyle(20);
1007   hESDprimaryTrackPtNegTRDout->SetMarkerSize(0.7);
1008   hESDprimaryTrackPtNegTRDout->SetLineColor(kBlue);
1009   hESDprimaryTrackPtNegTRDout->SetMarkerColor(kBlue);
1010   if (fEnableAdvancedCheck)
1011   fHneg->AddLast(hESDprimaryTrackPtNegTRDout);
1012
1013   //12
1014   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) ;  
1015   hESDprimaryTrackPtNegNoTRDout->Sumw2();
1016   hESDprimaryTrackPtNegNoTRDout->SetLineWidth(1);
1017   hESDprimaryTrackPtNegNoTRDout->SetMarkerStyle(25);
1018   hESDprimaryTrackPtNegNoTRDout->SetMarkerSize(0.7);
1019   hESDprimaryTrackPtNegNoTRDout->SetLineColor(kBlue);
1020   hESDprimaryTrackPtNegNoTRDout->SetMarkerColor(kBlue);
1021   if (fEnableAdvancedCheck)
1022   fHneg->AddLast(hESDprimaryTrackPtNegNoTRDout);
1023
1024   //13
1025   TH1F* hESDprimaryTrackEtaNegTRDout = new TH1F("hESDprimaryTrackEtaNegTRDout", "ESDs Neg primary tracks #eta with kTRDout distribution; #eta;tracks", 200, -1.0, 1.0) ;  
1026   hESDprimaryTrackEtaNegTRDout->Sumw2();
1027   hESDprimaryTrackEtaNegTRDout->SetLineWidth(1);
1028   hESDprimaryTrackEtaNegTRDout->SetMarkerStyle(20);
1029   hESDprimaryTrackEtaNegTRDout->SetMarkerSize(0.7);
1030   hESDprimaryTrackEtaNegTRDout->SetLineColor(kBlue);
1031   hESDprimaryTrackEtaNegTRDout->SetMarkerColor(kBlue);
1032   if (fEnableAdvancedCheck)
1033   fHneg->AddLast(hESDprimaryTrackEtaNegTRDout);
1034
1035   //14
1036   TH1F* hESDprimaryTrackEtaNegNoTRDout = new TH1F("hESDprimaryTrackEtaNegNoTRDout", "ESDs Neg primary tracks #eta with !kTRDout distribution;#eta;tracks", 200, -1.0, 1.0) ;  
1037   hESDprimaryTrackEtaNegNoTRDout->Sumw2();
1038   hESDprimaryTrackEtaNegNoTRDout->SetLineWidth(1);
1039   hESDprimaryTrackEtaNegNoTRDout->SetMarkerStyle(25);
1040   hESDprimaryTrackEtaNegNoTRDout->SetMarkerSize(0.7);
1041   hESDprimaryTrackEtaNegNoTRDout->SetLineColor(kBlue);
1042   hESDprimaryTrackEtaNegNoTRDout->SetMarkerColor(kBlue);
1043   if (fEnableAdvancedCheck)
1044   fHneg->AddLast(hESDprimaryTrackEtaNegNoTRDout);
1045
1046   //15
1047   TH1F* hESDprimaryTrackPhiNegTRDout = new TH1F("hESDprimaryTrackPhiNegTRDout", "ESDs Neg primary tracks #phi with kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
1048   hESDprimaryTrackPhiNegTRDout->Sumw2();
1049   hESDprimaryTrackPhiNegTRDout->SetLineWidth(1);
1050   hESDprimaryTrackPhiNegTRDout->SetMarkerStyle(20);
1051   hESDprimaryTrackPhiNegTRDout->SetMarkerSize(0.7);
1052   hESDprimaryTrackPhiNegTRDout->SetLineColor(kBlue);
1053   hESDprimaryTrackPhiNegTRDout->SetMarkerColor(kBlue);
1054   if (fEnableAdvancedCheck)
1055   fHneg->AddLast(hESDprimaryTrackPhiNegTRDout);
1056
1057   //16
1058   TH1F* hESDprimaryTrackPhiNegNoTRDout = new TH1F("hESDprimaryTrackPhiNegNoTRDout", "ESDs Neg primary tracks #phi with !kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
1059   hESDprimaryTrackPhiNegNoTRDout->Sumw2();
1060   hESDprimaryTrackPhiNegNoTRDout->SetLineWidth(1);
1061   hESDprimaryTrackPhiNegNoTRDout->SetMarkerStyle(25);
1062   hESDprimaryTrackPhiNegNoTRDout->SetMarkerSize(0.7);
1063   hESDprimaryTrackPhiNegNoTRDout->SetLineColor(kBlue);
1064   hESDprimaryTrackPhiNegNoTRDout->SetMarkerColor(kBlue);
1065   if (fEnableAdvancedCheck)
1066   fHneg->AddLast(hESDprimaryTrackPhiNegNoTRDout);
1067
1068   //NEG 17
1069   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) ; 
1070   hTOFmatchedExpTimeProVsPhiNeg->Sumw2() ;
1071   if (fEnableAdvancedCheck)
1072   fHneg->AddLast(hTOFmatchedExpTimeProVsPhiNeg) ;
1073
1074   //NEG 18
1075   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) ; 
1076   hTOFmatchedExpTimeProVsPhiVertexNeg->Sumw2() ;
1077   if (fEnableAdvancedCheck)
1078   fHneg->AddLast(hTOFmatchedExpTimeProVsPhiVertexNeg) ;
1079
1080   //NEG 19
1081   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) ; 
1082   hTOFmatchedExpTimeProVsPhiTPCNeg->Sumw2() ;
1083   if (fEnableAdvancedCheck)
1084   fHneg->AddLast(hTOFmatchedExpTimeProVsPhiTPCNeg) ;
1085
1086
1087   //20
1088   TH1F* hESDmatchedTrackEtaNegTRDout = new TH1F("hESDmatchedTrackEtaNegTRDout", "ESDs Neg matched tracks #eta with kTRDout distribution; #eta;tracks", 200, -1.0, 1.0) ;  
1089   hESDmatchedTrackEtaNegTRDout->Sumw2();
1090   hESDmatchedTrackEtaNegTRDout->SetLineWidth(1);
1091   hESDmatchedTrackEtaNegTRDout->SetMarkerStyle(20);
1092   hESDmatchedTrackEtaNegTRDout->SetMarkerSize(0.7);
1093   hESDmatchedTrackEtaNegTRDout->SetLineColor(kBlue);
1094   hESDmatchedTrackEtaNegTRDout->SetMarkerColor(kBlue);
1095   if (fEnableAdvancedCheck)
1096   fHneg->AddLast(hESDmatchedTrackEtaNegTRDout);
1097
1098   //21
1099   TH1F* hESDmatchedTrackEtaNegNoTRDout = new TH1F("hESDmatchedTrackEtaNegNoTRDout", "ESDs Neg matched tracks #eta with !kTRDout distribution;#eta;tracks", 200, -1.0, 1.0) ;  
1100   hESDmatchedTrackEtaNegNoTRDout->Sumw2();
1101   hESDmatchedTrackEtaNegNoTRDout->SetLineWidth(1);
1102   hESDmatchedTrackEtaNegNoTRDout->SetMarkerStyle(25);
1103   hESDmatchedTrackEtaNegNoTRDout->SetMarkerSize(0.7);
1104   hESDmatchedTrackEtaNegNoTRDout->SetLineColor(kBlue);
1105   hESDmatchedTrackEtaNegNoTRDout->SetMarkerColor(kBlue);
1106   if (fEnableAdvancedCheck)
1107   fHneg->AddLast(hESDmatchedTrackEtaNegNoTRDout);
1108
1109   //22
1110   TH1F* hESDmatchedTrackPhiNegTRDout = new TH1F("hESDmatchedTrackPhiNegTRDout", "ESDs Neg matched tracks #phi with kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
1111   hESDmatchedTrackPhiNegTRDout->Sumw2();
1112   hESDmatchedTrackPhiNegTRDout->SetLineWidth(1);
1113   hESDmatchedTrackPhiNegTRDout->SetMarkerStyle(20);
1114   hESDmatchedTrackPhiNegTRDout->SetMarkerSize(0.7);
1115   hESDmatchedTrackPhiNegTRDout->SetLineColor(kBlue);
1116   hESDmatchedTrackPhiNegTRDout->SetMarkerColor(kBlue);
1117   if (fEnableAdvancedCheck)
1118   fHneg->AddLast(hESDmatchedTrackPhiNegTRDout);
1119
1120   //23
1121   TH1F* hESDmatchedTrackPhiNegNoTRDout = new TH1F("hESDmatchedTrackPhiNegNoTRDout", "ESDs Neg matched tracks #phi with !kTRDout distribution; #phi(deg);tracks", 72, 0., 360.) ;  
1122   hESDmatchedTrackPhiNegNoTRDout->Sumw2();
1123   hESDmatchedTrackPhiNegNoTRDout->SetLineWidth(1);
1124   hESDmatchedTrackPhiNegNoTRDout->SetMarkerStyle(25);
1125   hESDmatchedTrackPhiNegNoTRDout->SetMarkerSize(0.7);
1126   hESDmatchedTrackPhiNegNoTRDout->SetLineColor(kBlue);
1127   hESDmatchedTrackPhiNegNoTRDout->SetMarkerColor(kBlue);
1128   if (fEnableAdvancedCheck)
1129   fHneg->AddLast(hESDmatchedTrackPhiNegNoTRDout);
1130  
1131  //NEG 24
1132   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) ; 
1133   hTOFmatchedExpTimePiVsPhiTPCNeg->Sumw2() ;
1134   if (fEnableAdvancedCheck)
1135   fHneg->AddLast(hTOFmatchedExpTimePiVsPhiTPCNeg) ;
1136
1137   //NEG 25
1138   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) ; 
1139   hTOFmatchedExpTimeKaVsPhiTPCNeg->Sumw2() ;
1140   if (fEnableAdvancedCheck)
1141   fHneg->AddLast(hTOFmatchedExpTimeKaVsPhiTPCNeg) ;
1142
1143   PostData(1, fHlist);
1144   PostData(2, fHlistTimeZero);
1145   PostData(3, fHlistPID);
1146   PostData(4, fHpos);
1147   PostData(5, fHneg);
1148 }
1149 //________________________________________________________________________
1150 void AliAnalysisTaskTOFqa::UserExec(Option_t *) 
1151
1152   /* Main - executed for each event.
1153     It extracts event information and track information after selecting 
1154     primary tracks via standard cuts. */
1155   
1156   AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
1157   if (!esdH) {
1158     Printf("ERROR: Could not get ESDInputHandler");
1159     return;
1160   } else {
1161     fESD = (AliESDEvent*) esdH->GetEvent();
1162   } 
1163   
1164   if (!fESD) {
1165     Printf("ERROR: fESD not available");
1166     return;
1167   }
1168
1169   /* info from V0 detector QA */
1170   AliESDVZERO * vzero = fESD->GetVZEROData();
1171   Float_t V0Atime = vzero->GetV0ATime();
1172   Float_t V0Ctime = vzero->GetV0CTime(); 
1173   ((TH2F*)fHlistTimeZero->At(14))->Fill((V0Atime-V0Ctime)*0.5,(V0Atime+V0Ctime)*0.5);
1174
1175   
1176   /* info from T0 detector QA */
1177   for (Int_t j=0;j<3;j++){
1178     fT0[j]= (Float_t) fESD->GetT0TOF(j);//ps
1179     if (fT0[j]>90000.) fT0[j]=99999.;//fix old default values to the new one
1180   }
1181   Float_t t0cut = 90000.; 
1182   //Float_t t0cut =3 * t0spread; //use this cut to check t0 used in tof response
1183   // if(t0cut < 500) t0cut = 500;
1184   
1185   if(TMath::Abs(fT0[1]) < t0cut && TMath::Abs(fT0[2]) < t0cut ) {
1186     //&& TMath::Abs(fT0[2]-fT0[1]) < 500)  //add this condition to check t0 used in tof response
1187     ((TH1F*)fHlistTimeZero->At(3))->Fill((fT0[2]-fT0[1])*0.5);
1188     ((TH1F*)fHlistTimeZero->At(0))->Fill(fT0[0]);  
1189     ((TH2F*)fHlistTimeZero->At(13))->Fill((fT0[2]-fT0[1])*0.5,(fT0[2]+fT0[1])*0.5);
1190
1191   } 
1192   if(TMath::Abs(fT0[1]) < t0cut){
1193     ((TH1F*)fHlistTimeZero->At(1))->Fill(fT0[1]);   
1194   }
1195   if(TMath::Abs(fT0[2]) < t0cut){
1196     ((TH1F*)fHlistTimeZero->At(2))->Fill(fT0[2]);
1197   }
1198   
1199   /*  event timeZero QA via AliESDpid::SetTOFResponse() */
1200   Double_t timeZero[4]={99999.,99999.,99999.,99999.};
1201   Double_t timeZeroRes[4]={99999.,99999.,99999.,99999.}; 
1202   
1203   for (Int_t j=0;j<4;j++){
1204     fESDpid->SetTOFResponse(fESD, (AliESDpid::EStartTimeType_t) j);//(fill_t0, tof_t0, t0_t0, best_t0)
1205     timeZero[j]=fESDpid->GetTOFResponse().GetStartTime(10.); //timeZero for bin pT>10GeV/c
1206     timeZeroRes[j]=fESDpid->GetTOFResponse().GetStartTimeRes(10.); //timeZero for bin pT>10GeV/c
1207     ((TH1D*)fHlistTimeZero->At(4+j))->Fill(timeZero[j]);
1208     ((TH1D*)fHlistTimeZero->At(8+j))->Fill(timeZeroRes[j]);
1209   }
1210
1211   //re-set response tof_t0 for all other checks
1212   fESDpid->SetTOFResponse(fESD,AliESDpid::kTOF_T0);//(fill_t0, tof_t0, t0_t0, best_t0)
1213   
1214   /* loop over ESD tracks */
1215   fNTOFtracks=0;
1216   // fNPrimaryTracks=0;
1217
1218   for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
1219     AliESDtrack* track = fESD->GetTrack(iTracks);
1220     if (!track) {
1221       Printf("ERROR: Could not receive track %d", iTracks);
1222       continue;
1223     }
1224
1225     //primary tracks selection: kTPCrefit and std cuts
1226     if(!fTrackFilter->IsSelected(track)) continue;
1227     Double_t eta=track->Eta();
1228     if (TMath::Abs(eta)>0.8) continue; //cut for acceptance
1229
1230     Double_t mom=track->P();
1231     Double_t mom2 = mom*mom;
1232     Double_t length=track->GetIntegratedLength();
1233     Double_t pT = track->Pt();
1234     Double_t phi=track->Phi()*TMath::RadToDeg();
1235     track->GetIntegratedTimes(fTrkExpTimes);
1236     
1237     ((TH1F*)fHlist->At(9))->Fill(mom); 
1238     ((TH1F*)fHlist->At(10))->Fill(pT); 
1239     if (pT>=0.5) {
1240       ((TH1F*)fHlist->At(11))->Fill(eta);
1241       ((TH1F*)fHlist->At(12))->Fill(phi);
1242     }
1243     
1244     //evaluate sign  
1245     if (fEnableAdvancedCheck){
1246       if (track->GetSign()>0){
1247         ((TH1F*)fHpos->At(7))->Fill(mom); 
1248         ((TH1F*)fHpos->At(8))->Fill(pT);        
1249         if (pT>=0.5){
1250           ((TH1F*)fHpos->At(9))->Fill(eta);
1251           ((TH1F*)fHpos->At(10))->Fill(phi);
1252         }
1253         if ( (track->IsOn(AliESDtrack::kTRDout)) && (track->IsOn(AliESDtrack::kTPCout)) ) {
1254           ((TH1F*)fHpos->At(11))->Fill(pT);
1255           if (pT>=0.5) {
1256             ((TH1F*)fHpos->At(13))->Fill(eta);
1257             ((TH1F*)fHpos->At(15))->Fill(phi);
1258           }
1259         }
1260         if ((!(track->IsOn(AliESDtrack::kTRDout)))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1261           ((TH1F*)fHpos->At(12))->Fill(pT);
1262           if (pT>=0.5) {
1263             ((TH1F*)fHpos->At(14))->Fill(eta);
1264           ((TH1F*)fHpos->At(16))->Fill(phi);
1265           }
1266         }
1267       } //end positive 
1268       else {
1269         ((TH1F*)fHneg->At(7))->Fill(mom); 
1270         ((TH1F*)fHneg->At(8))->Fill(pT); 
1271         if (pT>=0.5){
1272           ((TH1F*)fHneg->At(9))->Fill(eta);
1273           ((TH1F*)fHneg->At(10))->Fill(phi);            
1274         }
1275         if ((track->IsOn(AliESDtrack::kTRDout))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1276           ((TH1F*)fHneg->At(11))->Fill(pT);
1277           if (pT>0.5) {
1278             ((TH1F*)fHneg->At(13))->Fill(eta);
1279             ((TH1F*)fHneg->At(15))->Fill(phi); 
1280           }
1281         }
1282         if  ((!(track->IsOn(AliESDtrack::kTRDout)))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1283           ((TH1F*)fHneg->At(12))->Fill(pT);
1284           if (pT>0.5){
1285             ((TH1F*)fHneg->At(14))->Fill(eta);
1286             ((TH1F*)fHneg->At(16))->Fill(phi);
1287           }
1288         }
1289       }//end negative
1290     }//end flag advanced check
1291     
1292     //matched tracks selection: kTOFout and kTIME
1293     if ( (track->IsOn(AliESDtrack::kTOFout)) &&
1294          (track->IsOn(AliESDtrack::kTIME)) &&
1295          (track->IsOn(AliESDtrack::kTPCout))  ) {      
1296       
1297       Double_t tofTime=track->GetTOFsignal();//in ps
1298       Double_t tofTimeRaw=track->GetTOFsignalRaw();//in ps
1299       Double_t tofToT=track->GetTOFsignalToT(); //in ps
1300       Int_t channel=track->GetTOFCalChannel(); 
1301       Int_t volId[5]; //(sector, plate,strip,padZ,padX)
1302       AliTOFGeometry::GetVolumeIndices(channel,volId);
1303       
1304       if (pT>=0.3) fNTOFtracks++; //matched counter
1305       Double_t tof= tofTime*1E-3; // ns, average T0 fill subtracted, no info from T0detector     
1306       ((TH1F*)fHlist->At(1))->Fill(tof); //ns
1307       ((TH1F*)fHlist->At(2))->Fill(tofTimeRaw*1E-3); //ns
1308       ((TH1F*)fHlist->At(3))->Fill(tofToT);
1309       ((TH1F*)fHlist->At(4))->Fill(length);  
1310       ((TH1F*)fHlist->At(5))->Fill(mom);
1311       ((TH1F*)fHlist->At(6))->Fill(pT);
1312       if (pT>=0.5){
1313         ((TH1F*)fHlist->At(7))->Fill(eta);
1314         ((TH1F*)fHlist->At(8))->Fill(phi);
1315       }
1316       if (track->GetSign()>0)
1317         ((TH2F*)fHlist->At(13))->Fill(pT,track->GetTOFsignalDx());      
1318       else 
1319         ((TH2F*)fHlist->At(14))->Fill(pT,track->GetTOFsignalDx());
1320       
1321       //evaluate sign
1322       if (fEnableAdvancedCheck){
1323         if (track->GetSign()>0){
1324           ((TH1F*)fHpos->At(0))->Fill(length);  
1325           ((TH1F*)fHpos->At(1))->Fill(mom); 
1326           ((TH1F*)fHpos->At(2))->Fill(pT); 
1327           if (pT>=0.5){
1328             ((TH1F*)fHpos->At(3))->Fill(eta);
1329             ((TH1F*)fHpos->At(4))->Fill(phi);
1330           }     
1331           if ( (track->IsOn(AliESDtrack::kTRDout))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1332             ((TH1F*)fHpos->At(5))->Fill(pT);
1333             if (pT>=0.5){
1334               ((TH1F*)fHpos->At(20))->Fill(eta);
1335               ((TH1F*)fHpos->At(22))->Fill(phi);
1336             }
1337           } 
1338           if ((!(track->IsOn(AliESDtrack::kTRDout)))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1339             ((TH1F*)fHpos->At(6))->Fill(pT);
1340             if (pT>=0.5) {
1341               ((TH1F*)fHpos->At(21))->Fill(eta);
1342               ((TH1F*)fHpos->At(23))->Fill(phi);
1343             }
1344           }
1345         }// END POSITIVE
1346         else {  
1347           ((TH1F*)fHneg->At(0))->Fill(length);  
1348           ((TH1F*)fHneg->At(1))->Fill(mom); 
1349           ((TH1F*)fHneg->At(2))->Fill(pT); 
1350           if (pT>=0.5) {
1351             ((TH1F*)fHneg->At(3))->Fill(eta);
1352             ((TH1F*)fHneg->At(4))->Fill(phi);
1353           }       
1354           if ((track->IsOn(AliESDtrack::kTRDout))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1355             ((TH1F*)fHneg->At(5))->Fill(pT);
1356             if (pT>=0.5) {
1357               ((TH1F*)fHneg->At(20))->Fill(eta);
1358               ((TH1F*)fHneg->At(22))->Fill(phi);            
1359             }
1360           }
1361           if ((!(track->IsOn(AliESDtrack::kTRDout)))  && (track->IsOn(AliESDtrack::kTPCout)) ) {
1362             ((TH1F*)fHneg->At(6))->Fill(pT);
1363             if (pT>=0.5) {
1364               ((TH1F*)fHneg->At(21))->Fill(eta);
1365               ((TH1F*)fHneg->At(23))->Fill(phi);
1366             }
1367           }       
1368         }//end negative
1369       }//end advanced check
1370       //basic PID performance check
1371       if (tof<=0) {
1372         printf("WARNING: track with negative TOF time found! Skipping this track for PID checks\n");
1373         continue;
1374       }
1375       if (mom2==0) {
1376         printf("WARNING: track with negative square momentum found! Skipping this track for PID checks\n");
1377         continue;
1378       }
1379       if (length<=0){
1380         printf("WARNING: track with negative length found!Skipping this track for PID checks\n");
1381         continue;
1382       }
1383       Double_t c=TMath::C()*1.E-9;// m/ns
1384       Double_t mass=0.; //GeV
1385       length =length*0.01; // in meters
1386       tof=tof*c;
1387       Double_t beta=length/tof;
1388       Double_t fact= (tof/length)*(tof/length) -1.;
1389       if(fact<=0) {
1390         mass = -mom*TMath::Sqrt(-fact);
1391       }else{ 
1392         mass = mom*TMath::Sqrt(fact); 
1393       }
1394       ((TH2F*)fHlistPID->At(0))->Fill(mom,beta);
1395       ((TH1F*) fHlistPID->At(1))->Fill(mass);
1396       
1397       //PID sigmas
1398       Bool_t isValidBeta[AliPID::kSPECIES]={0,0,0,0,0};
1399       for (Int_t specie = 0; specie < AliPID::kSPECIES; specie++){
1400         fSigmaSpecie[specie] = fESDpid->GetTOFResponse().GetExpectedSigma(mom, fTrkExpTimes[specie], AliPID::ParticleMass(specie));
1401         beta=1/TMath::Sqrt(1+AliPID::ParticleMass(specie)*AliPID::ParticleMass(specie)/(mom2));
1402         if (beta>0) {
1403           fThExpTimes[specie]=length*1.E3/(beta*c);//ps
1404           isValidBeta[specie]=kTRUE;
1405         } else {
1406           fThExpTimes[specie]=1E-10;
1407           isValidBeta[specie]=kFALSE;
1408         }
1409       }
1410       //here
1411       if (isValidBeta[AliPID::kPion]){
1412         ((TH2F*)fHlistPID->At(2))->Fill((Int_t)GetStripIndex(volId),tofTime-fTrkExpTimes[AliPID::kPion]);//ps
1413         ((TH1F*)fHlistPID->At(3))->Fill(tofTime-fTrkExpTimes[AliPID::kPion]);//ps
1414         ((TH2F*)fHlistPID->At(4))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1415         ((TH1F*)fHlistPID->At(5))->Fill(tofTime-fThExpTimes[AliPID::kPion]);//ps
1416         ((TH2F*)fHlistPID->At(6))->Fill(mom,(tofTime-fThExpTimes[AliPID::kPion]));      
1417         ((TH2F*)fHlistPID->At(7))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kPion])/fSigmaSpecie[AliPID::kPion]);
1418       }
1419       
1420       if (isValidBeta[AliPID::kKaon]){
1421         ((TH1F*)fHlistPID->At(8))->Fill(tofTime-fTrkExpTimes[AliPID::kKaon]);//ps
1422         ((TH2F*)fHlistPID->At(9))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1423         ((TH1F*)fHlistPID->At(10))->Fill(tofTime-fThExpTimes[AliPID::kKaon]);//ps
1424         ((TH2F*)fHlistPID->At(11))->Fill(mom,(tofTime-fThExpTimes[AliPID::kKaon]));
1425         ((TH2F*)fHlistPID->At(12))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kKaon])/fSigmaSpecie[AliPID::kKaon]);
1426       }
1427       if (isValidBeta[AliPID::kProton]){
1428         ((TH1F*)fHlistPID->At(13))->Fill(tofTime-fTrkExpTimes[AliPID::kProton]);//3ps
1429         ((TH2F*)fHlistPID->At(14))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1430         ((TH1F*)fHlistPID->At(15))->Fill(tofTime-fThExpTimes[AliPID::kProton]);//ps
1431         ((TH2F*)fHlistPID->At(16))->Fill(mom,(tofTime-fThExpTimes[AliPID::kProton]));
1432         ((TH2F*)fHlistPID->At(17))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kProton])/fSigmaSpecie[AliPID::kProton]);
1433       }
1434
1435       if (fEnableAdvancedCheck && (pT<1.)) {
1436         Double_t pos[3]={0.,0.,0.};
1437         track->GetXYZAt(378.,5.,pos);
1438         if ((pos[0]==0.)&&(pos[1]==0.)&&(pos[2]==0.))continue;
1439         
1440         Double_t phiTOF=TMath::ATan2(pos[1],pos[0])*TMath::RadToDeg();
1441         if (phiTOF<0) phiTOF+= (2*TMath::Pi()*TMath::RadToDeg());
1442         
1443         if (isValidBeta[AliPID::kProton]){
1444           if (track->GetSign()>0){
1445             ((TH2F*)fHpos->At(17))->Fill(phiTOF,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1446             ((TH2F*)fHpos->At(18))->Fill(phi,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1447           } else {
1448             ((TH2F*)fHneg->At(17))->Fill(phiTOF,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1449             ((TH2F*)fHneg->At(18))->Fill(phi,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1450           }
1451         }
1452         
1453         track->GetOuterXYZ(pos);
1454         Double_t phiOuterTPC=TMath::ATan2(pos[1],pos[0])*TMath::RadToDeg();
1455         if (phiOuterTPC<0) phiOuterTPC+= (2*TMath::Pi()*TMath::RadToDeg());
1456         
1457         if (track->GetSign()>0){
1458           if (isValidBeta[AliPID::kProton])
1459             ((TH2F*)fHpos->At(19))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1460           if (isValidBeta[AliPID::kPion])
1461             ((TH2F*)fHpos->At(24))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kPion]);//ps
1462           if (isValidBeta[AliPID::kKaon])
1463             ((TH2F*)fHpos->At(25))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kKaon]);//ps
1464           
1465           if ((phiOuterTPC<=30) || ((phiOuterTPC>=150)&&(phiOuterTPC<=230)) || (phiOuterTPC>=310) ) { //TRD sectors
1466             if (isValidBeta[AliPID::kPion])
1467               ((TH2F*)fHlistPID->At(18))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1468             if (isValidBeta[AliPID::kKaon])
1469               ((TH2F*)fHlistPID->At(22))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1470             if (isValidBeta[AliPID::kProton])
1471               ((TH2F*)fHlistPID->At(26))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1472           }
1473           if ( ((phiOuterTPC>=50)&&(phiOuterTPC<=130)) || ((phiOuterTPC>=250)&&(phiOuterTPC<=290)) ) {//no TRD sectors
1474             if (isValidBeta[AliPID::kPion])
1475               ((TH2F*)fHlistPID->At(19))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1476             if (isValidBeta[AliPID::kKaon])
1477               ((TH2F*)fHlistPID->At(23))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1478             if (isValidBeta[AliPID::kProton])
1479               ((TH2F*)fHlistPID->At(27))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1480           }
1481         }else{
1482           if (isValidBeta[AliPID::kPion])
1483             ((TH2F*)fHneg->At(24))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kPion]);//ps
1484           if (isValidBeta[AliPID::kKaon])
1485             ((TH2F*)fHneg->At(25))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kKaon]);//ps
1486           if (isValidBeta[AliPID::kProton])
1487             ((TH2F*)fHneg->At(19))->Fill(phiOuterTPC,tofTime-fTrkExpTimes[AliPID::kProton]);//ps
1488           
1489           if ((phiOuterTPC<=30) || ((phiOuterTPC>=150)&&(phiOuterTPC<=230)) || (phiOuterTPC>=310) ) { //TRD sectors
1490             if (isValidBeta[AliPID::kPion])
1491               ((TH2F*)fHlistPID->At(20))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1492             if (isValidBeta[AliPID::kKaon])
1493               ((TH2F*)fHlistPID->At(24))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1494             if (isValidBeta[AliPID::kProton])
1495               ((TH2F*)fHlistPID->At(28))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1496           }
1497           if ( ((phiOuterTPC>=50)&&(phiOuterTPC<=130)) || ((phiOuterTPC>=250)&&(phiOuterTPC<=290)) ) {//no TRD sectors
1498             if (isValidBeta[AliPID::kPion])
1499               ((TH2F*)fHlistPID->At(21))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
1500               if (isValidBeta[AliPID::kKaon])
1501                 ((TH2F*)fHlistPID->At(25))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
1502               if (isValidBeta[AliPID::kProton])
1503                 ((TH2F*)fHlistPID->At(29))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
1504           }
1505         }
1506         
1507       }//end advanced checks && cut on pT for t-texp phi distrib      
1508     }//matched
1509   }//end loop on tracks
1510   //here
1511   ((TH1F*)fHlist->At(0))->Fill(fNTOFtracks) ;
1512   ((TH2F*)fHlistTimeZero->At(12))->Fill(fNTOFtracks,timeZero[AliESDpid::kTOF_T0]);
1513   
1514   PostData(1, fHlist);
1515   PostData(2, fHlistTimeZero);
1516   PostData(3, fHlistPID);
1517   PostData(4, fHpos);
1518   PostData(5, fHneg);
1519   
1520 }      
1521
1522 //________________________________________________________________________
1523 void AliAnalysisTaskTOFqa::Terminate(Option_t *) 
1524 {
1525   //check on output validity
1526   fHlist = dynamic_cast<TList*> (GetOutputData(1));
1527   if (!fHlist || !fHlistTimeZero) {
1528     Printf("ERROR: lists not available");
1529     return;   
1530   }   
1531  
1532 }
1533
1534 //---------------------------------------------------------------
1535 Int_t AliAnalysisTaskTOFqa::GetStripIndex(const Int_t * const in)
1536 {
1537   /* return tof strip index between 0 and 91 */
1538   
1539   Int_t nStripA = AliTOFGeometry::NStripA();
1540   Int_t nStripB = AliTOFGeometry::NStripB();
1541   Int_t nStripC = AliTOFGeometry::NStripC();
1542
1543   Int_t iplate = in[1];
1544   Int_t istrip = in[2];
1545   
1546   Int_t stripOffset = 0;
1547   switch (iplate) {
1548   case 0:
1549     stripOffset = 0;
1550       break;
1551   case 1:
1552     stripOffset = nStripC;
1553     break;
1554   case 2:
1555     stripOffset = nStripC+nStripB;
1556     break;
1557   case 3:
1558     stripOffset = nStripC+nStripB+nStripA;
1559     break;
1560   case 4:
1561     stripOffset = nStripC+nStripB+nStripA+nStripB;
1562     break;
1563   default:
1564     stripOffset=-1;
1565     break;
1566   };
1567   
1568   if (stripOffset<0 || stripOffset>92) return -1;
1569   else 
1570     return (stripOffset+istrip);
1571 }
1572
1573 #endif