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