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