reverted change 49142 (wrong header)
[u/mrichter/AliRoot.git] / PWG1 / TOF / AliAnalysisTaskTOFqa.cxx
CommitLineData
aac12889 1/* created by fbellini@cern.ch on 14/09/2010 */
a5427fbf 2/* last modified by fbellini on 08/03/2010 */
aac12889 3
4
5#ifndef ALIANALYSISTASKTOFQA_CXX
6#define ALIANALYSISTASKTOFQA_CXX
7
8#include "TChain.h"
9#include "TTree.h"
10#include "TH1F.h"
11#include "TH2F.h"
12#include "TCanvas.h"
aac12889 13#include "AliAnalysisTaskSE.h"
14#include "AliAnalysisManager.h"
15#include "AliESDEvent.h"
16#include "AliESDInputHandler.h"
e866f574 17#include "AliESDpid.h"
aac12889 18#include "AliAnalysisTaskTOFqa.h"
19#include "AliAnalysisFilter.h"
20#include "AliESDtrackCuts.h"
aac12889 21#include "AliLog.h"
aac12889 22#include "AliTOFRawStream.h"
23#include "AliTOFGeometry.h"
24
25ClassImp(AliAnalysisTaskTOFqa)
26
27//________________________________________________________________________
28AliAnalysisTaskTOFqa::AliAnalysisTaskTOFqa() :
111b2155 29 fRunNumber(0),
aac12889 30 fESD(0x0),
31 fTrackFilter(0x0),
32 fVertex(0x0),
a5427fbf 33 fESDpid(0x0),
aac12889 34 fNTOFtracks(0),
e866f574 35// fNPrimaryTracks(0),
aac12889 36 fHlist(0x0),
e866f574 37 fHlistTimeZero(0x0),
38 fHlistPID(0x0)
aac12889 39 {
40 // Default constructor
e866f574 41 fESDpid=new AliESDpid();
42 for (Int_t j=0;j<3;j++ ) {
43 if (j<3) fT0[j]=0.0;
44 fSigmaSpecie[j]=0.0;
45 fTrkExpTimes[j]=0.0;
46 fThExpTimes[j]=0.0;
47 }
48 }
aac12889 49//________________________________________________________________________
50AliAnalysisTaskTOFqa::AliAnalysisTaskTOFqa(const char *name) :
51 AliAnalysisTaskSE(name),
111b2155 52 fRunNumber(0),
aac12889 53 fESD(0x0),
54 fTrackFilter(0x0),
55 fVertex(0x0),
a5427fbf 56 fESDpid(0x0),
aac12889 57 fNTOFtracks(0),
e866f574 58 // fNPrimaryTracks(0),
aac12889 59 fHlist(0x0),
e866f574 60 fHlistTimeZero(0),
61 fHlistPID(0x0)
aac12889 62 {
63 // Constructor
64 // Define input and output slots here
65 Info("AliAnalysisTaskTOFqa","Calling Constructor");
66
e866f574 67 fESDpid=new AliESDpid();
68 for (Int_t j=0;j<5;j++ ) {
69 if (j<3) fT0[j]=0.0;
70 fSigmaSpecie[j]=0.0;
71 fTrkExpTimes[j]=0.0;
72 fThExpTimes[j]=0.0;
73 }
aac12889 74 // Input slot #0 works with a TChain
75 DefineInput(0, TChain::Class());
76
77 // Output slot #0 writes into a TH1 container
78 // Output slot #1 writes into a user defined container
79 DefineOutput(1, TList::Class());
80 DefineOutput(2, TList::Class());
e866f574 81 DefineOutput(3, TList::Class());
aac12889 82 }
83
84//________________________________________________________________________
85AliAnalysisTaskTOFqa::AliAnalysisTaskTOFqa(const AliAnalysisTaskTOFqa& copy)
86: AliAnalysisTaskSE(),
87 fRunNumber(copy.fRunNumber),
88 fESD(copy.fESD),
89 fTrackFilter(copy.fTrackFilter),
90 fVertex(copy.fVertex),
a5427fbf 91 fESDpid(0x0),
aac12889 92 fNTOFtracks(copy.fNTOFtracks),
e866f574 93 //fNPrimaryTracks(copy.fNPrimaryTracks),
aac12889 94 fHlist(copy.fHlist),
e866f574 95 fHlistTimeZero(copy.fHlistTimeZero),
96 fHlistPID(copy.fHlistPID)
aac12889 97{
98 // Copy constructor
e866f574 99 for (Int_t j=0;j<5;j++ ) {
100 if (j<3) fT0[j]=copy.fT0[j];
101 fSigmaSpecie[j]=copy.fSigmaSpecie[j];
102 fTrkExpTimes[j]=copy.fTrkExpTimes[j];
103 fThExpTimes[j]=copy.fThExpTimes[j];
104 }
105 fESDpid=copy.fESDpid;
106
aac12889 107}
108
109//___________________________________________________________________________
110AliAnalysisTaskTOFqa& AliAnalysisTaskTOFqa::operator=(const AliAnalysisTaskTOFqa& copy)
111{
112 //
113 // Assignment operator
114 //
115 if (this!=&copy) {
116 AliAnalysisTaskSE::operator=(copy) ;
117 fRunNumber=copy.fRunNumber;
118 fESD=copy.fESD;
119 fTrackFilter=copy.fTrackFilter;
120 fVertex=copy.fVertex;
e866f574 121 fESDpid=copy.fESDpid;
aac12889 122 fNTOFtracks=copy.fNTOFtracks;
e866f574 123 //fNPrimaryTracks=copy.fNPrimaryTracks;
124 for (Int_t j=0;j<5;j++ ) {
125 if (j<3) fT0[j]=copy.fT0[j];
126 fSigmaSpecie[j]=copy.fSigmaSpecie[j];
127 fTrkExpTimes[j]=copy.fTrkExpTimes[j];
128 fThExpTimes[j]=copy.fThExpTimes[j];
129 }
aac12889 130 fHlist=copy.fHlist;
e866f574 131 fHlistTimeZero=copy.fHlistTimeZero;
132 fHlistPID=copy.fHlistPID;
aac12889 133 }
134 return *this;
135}
136
137//___________________________________________________________________________
138AliAnalysisTaskTOFqa::~AliAnalysisTaskTOFqa() {
139 //
140 //destructor
141 //
142
143 Info("~AliAnalysisTaskTOFqa","Calling Destructor");
e866f574 144 if (fESDpid) delete fESDpid;
aac12889 145 if (fVertex) delete fVertex;
146 if (fTrackFilter) delete fTrackFilter;
aac12889 147 if (fHlist) {
148 delete fHlist;
149 fHlist = 0;
150 }
e866f574 151 if (fHlistTimeZero) {
152 delete fHlistTimeZero;
153 fHlistTimeZero = 0;
154 }
155 if (fHlistPID){
156 delete fHlistPID;
157 fHlistPID = 0;
aac12889 158 }
159}
160
aac12889 161//________________________________________________________________________
162void AliAnalysisTaskTOFqa::UserCreateOutputObjects()
163{
164 //Defines output objects and histograms
165 Info("CreateOutputObjects","CreateOutputObjects (TList) of task %s", GetName());
166 OpenFile(1);
167 if (!fHlist) fHlist = new TList();
111b2155 168 fHlist->SetOwner(kTRUE);
e866f574 169 if (!fHlistTimeZero) fHlistTimeZero = new TList();
170 fHlistTimeZero->SetOwner(kTRUE);
171 if (!fHlistPID) fHlistPID = new TList();
172 fHlistPID->SetOwner(kTRUE);
173
174//0
175 TH1I* hTOFmatchedESDperEvt = new TH1I("hTOFmatchedPerEvt", "Matched TOF tracks per event (|#eta| #leq 0.9 and pT #geq 0.3 GeV/c);TOF-matched ESD tracks;Events", 100, 0, 100) ;
176 hTOFmatchedESDperEvt->Sumw2() ;
aac12889 177 hTOFmatchedESDperEvt->SetLineWidth(2);
178 hTOFmatchedESDperEvt->SetLineColor(kBlue);
e866f574 179 hTOFmatchedESDperEvt->SetMarkerStyle(20);
180 hTOFmatchedESDperEvt->SetMarkerSize(0.8);
181 hTOFmatchedESDperEvt->SetMarkerColor(kBlue);
aac12889 182 fHlist->AddLast(hTOFmatchedESDperEvt) ;
183 //1
184 TH1F* hTOFmatchedESDtime = new TH1F("hTOFmatchedESDtime", "Matched ESDs tracks: TOF Time spectrum; t [ns];Counts", 250, 0., 610. ) ;
e866f574 185 hTOFmatchedESDtime->Sumw2() ;
aac12889 186 hTOFmatchedESDtime->SetLineWidth(2);
187 hTOFmatchedESDtime->SetLineColor(kBlue);
188 hTOFmatchedESDtime->SetFillColor(kBlue);
e866f574 189 hTOFmatchedESDtime->SetDrawOption("BAR");
aac12889 190 fHlist->AddLast(hTOFmatchedESDtime) ;
191 //2
192 TH1F* hTOFmatchedESDrawTime = new TH1F("hTOFmatchedESDrawTime", "Matched ESDs tracks: TOF raw Time spectrum;t_{raw} [ns];Counts", 250, 0., 610.) ;
e866f574 193 hTOFmatchedESDrawTime->Sumw2() ;
aac12889 194 hTOFmatchedESDrawTime->SetLineWidth(2);
e866f574 195 hTOFmatchedESDrawTime->SetLineColor(kAzure+2);
196 hTOFmatchedESDrawTime->SetFillColor(kAzure+2);
197 hTOFmatchedESDrawTime->SetDrawOption("BAR");
aac12889 198 fHlist->AddLast(hTOFmatchedESDrawTime) ;
199 //3
200 TH1F* hTOFmatchedESDToT = new TH1F("hTOFmatchedESDToT", "Matched ESDs tracks: TOF ToT spectrum; ToT [ns];Counts",100, 0., 48.8) ;
e866f574 201 hTOFmatchedESDToT->Sumw2() ;
202 hTOFmatchedESDToT->SetLineColor(kOrange+1);
203 hTOFmatchedESDToT->SetMarkerColor(kOrange+1);
204 hTOFmatchedESDToT->SetFillColor(kOrange+1);
205 hTOFmatchedESDToT->SetDrawOption("BAR");
aac12889 206 fHlist->AddLast(hTOFmatchedESDToT) ;
207 //4
e866f574 208 TH1F* hTOFmatchedESDtrkLength = new TH1F("hTOFmatchedESDtrkLength", "Matched ESDs tracks length; Track length [cm];Counts", 1200, -400., 800) ;
209 hTOFmatchedESDtrkLength->Sumw2();
210 hTOFmatchedESDtrkLength->SetLineColor(kViolet-3);
211 hTOFmatchedESDtrkLength->SetMarkerColor(kViolet-3);
212 hTOFmatchedESDtrkLength->SetFillColor(kViolet-3);
213 hTOFmatchedESDtrkLength->SetDrawOption("BAR");
214 fHlist->AddLast(hTOFmatchedESDtrkLength);
215 //5
216 TH1F* hTOFmatchedESDP = new TH1F("hTOFmatchedESDP", "TPC-TOF matched tracks momentum distribution (GeV/c); p (GeV/c);tracks", 500,0.,5.) ;
217 hTOFmatchedESDP->Sumw2() ;
aac12889 218 hTOFmatchedESDP->SetLineColor(kBlue);
e866f574 219 hTOFmatchedESDP->SetMarkerStyle(20);
220 hTOFmatchedESDP->SetMarkerSize(0.7);
aac12889 221 hTOFmatchedESDP->SetMarkerColor(kBlue);
222 fHlist->AddLast(hTOFmatchedESDP) ;
e866f574 223 //6
aac12889 224 TH1F* hTOFmatchedESDPt = new TH1F("hTOFmatchedESDPt", "TPC-TOF matched tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500,0.,5.) ;
e866f574 225 hTOFmatchedESDPt->Sumw2() ;
aac12889 226 hTOFmatchedESDPt->SetLineColor(kBlue);
e866f574 227 hTOFmatchedESDPt->SetMarkerStyle(21);
228 hTOFmatchedESDPt->SetMarkerSize(0.7);
aac12889 229 hTOFmatchedESDPt->SetMarkerColor(kBlue);
230 fHlist->AddLast(hTOFmatchedESDPt) ;
e866f574 231
aac12889 232 //7
e866f574 233 TH1F* hTOFmatchedESDeta = new TH1F("hTOFmatchedESDeta", "Matched ESDtracks #eta (p_{T} #geq 0.5 GeV/c); #eta;Counts", 200, -1., 1.) ;
234 hTOFmatchedESDeta->Sumw2();
235 hTOFmatchedESDeta->SetLineColor(kBlue);
236 fHlist->AddLast(hTOFmatchedESDeta) ;
aac12889 237 //8
e866f574 238 TH1F* hTOFmatchedESDphi = new TH1F("hTOFmatchedESDphi", "Matched ESDtracks #phi; #phi (deg);Counts", 72, 0., 365.) ;
239 hTOFmatchedESDphi->Sumw2();
240 hTOFmatchedESDphi->SetLineColor(kBlue);
241 fHlist->AddLast(hTOFmatchedESDphi) ;
242
243 //9
244 TH1F* hESDprimaryTrackP = new TH1F("hESDprimaryTrackP", "All ESDs tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0., 5.0) ;
245 hESDprimaryTrackP->Sumw2();
aac12889 246 hESDprimaryTrackP->SetLineWidth(1);
e866f574 247 hESDprimaryTrackP->SetMarkerStyle(24);
248 hESDprimaryTrackP->SetMarkerSize(0.7);
249 hESDprimaryTrackP->SetMarkerColor(kRed);
250 hESDprimaryTrackP->SetLineColor(kRed);
aac12889 251 fHlist->AddLast(hESDprimaryTrackP);
e866f574 252 //10
253 TH1F* hESDprimaryTrackPt = new TH1F("hESDprimaryTrackPt", "ESDs primary tracks p_{T} distribution (GeV/c); p_{T}(GeV/c);tracks", 500, 0.0, 5.0) ;
254 hESDprimaryTrackPt->Sumw2();
aac12889 255 hESDprimaryTrackPt->SetLineWidth(1);
e866f574 256 hESDprimaryTrackPt->SetMarkerStyle(25);
257 hESDprimaryTrackPt->SetMarkerSize(0.7);
258 hESDprimaryTrackPt->SetLineColor(kRed);
259 hESDprimaryTrackPt->SetMarkerColor(kRed);
aac12889 260 fHlist->AddLast(hESDprimaryTrackPt);
aac12889 261 //11
e866f574 262 TH1F* hTOFprimaryESDeta = new TH1F("hTOFprimaryESDeta", "Primary ESDtracks #eta (p_{T} #geq 0.5 GeV/c); #eta;Counts",200, -1., 1.) ;
263 hTOFprimaryESDeta->Sumw2();
264 hTOFprimaryESDeta->SetLineColor(kRed);
aac12889 265 fHlist->AddLast(hTOFprimaryESDeta) ;
266 //12
e866f574 267 TH1F* hTOFprimaryESDphi = new TH1F("hTOFprimaryESDphi", "Primary ESDtracks #phi;#phi (deg);Counts", 72, 0., 360.) ;
268 hTOFprimaryESDphi->Sumw2();
269 hTOFprimaryESDphi->SetLineColor(kRed);
aac12889 270 fHlist->AddLast(hTOFprimaryESDphi) ;
e866f574 271 //13
272 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.) ;
273 hTOFmatchedDxVsPtPos->Sumw2();
274 fHlist->AddLast(hTOFmatchedDxVsPtPos) ;
275 //14
276 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.) ;
277 hTOFmatchedDxVsPtNeg->Sumw2();
278 fHlist->AddLast(hTOFmatchedDxVsPtNeg) ;
279
280 //15
281 TH2F* hTOFmatchedDzVsStrip = new TH2F("hTOFmatchedDzVsStrip", "Dz vs strip; strip (#eta); Dz [cm]; hits", 92,0.,92.,200, -10., 10.) ;
282 hTOFmatchedDzVsStrip->Sumw2();
283 fHlist->AddLast(hTOFmatchedDzVsStrip) ;
284
285 //----------------------------------------------timeZero QA plots
286 //TimeZero 0
287 TH1D* hEventT0DetAND = new TH1D("hEventT0DetAND", "Event timeZero from T0AC detector ; t0 [ps]; events", 1000, -25000., 25000. ) ;
288 hEventT0DetAND->Sumw2() ;
aac12889 289 hEventT0DetAND->SetLineWidth(2);
290 hEventT0DetAND->SetLineColor(kRed);
291 hEventT0DetAND->SetFillColor(kRed);
e866f574 292 fHlistTimeZero->AddLast(hEventT0DetAND) ;
aac12889 293
e866f574 294 //TImeZero 1
295 TH1D* hEventT0DetA = new TH1D("hEventT0DetA", "Event timeZero from T0A detector; t0 [ps]; events", 1000, -25000., 25000. ) ;
296 hEventT0DetA->Sumw2() ;
aac12889 297 hEventT0DetA->SetLineWidth(2);
298 hEventT0DetA->SetLineColor(kBlue);
299 hEventT0DetA->SetFillColor(kBlue);
e866f574 300 fHlistTimeZero->AddLast(hEventT0DetA) ;
aac12889 301
e866f574 302 //TImeZero 2
303 TH1D* hEventT0DetC = new TH1D("hEventT0DetC", "Event timeZero from T0C detector; t0 [ps]; events", 1000, -25000., 25000.) ;
304 hEventT0DetC->Sumw2() ;
aac12889 305 hEventT0DetC->SetLineWidth(2);
306 hEventT0DetC->SetLineColor(kGreen);
307 hEventT0DetC->SetFillColor(kGreen);
e866f574 308 fHlistTimeZero->AddLast(hEventT0DetC);
309
310 //TimeZero 3
311 TH1F* hT0DetRes = new TH1F("hT0DetRes", "T0 detector (T0A-T0C)/2; (T0A-T0C)/2 [ps]; events", 200, -500.,500. ) ;
312 hT0DetRes->Sumw2() ;
313 hT0DetRes->SetMarkerStyle(24);
314 hT0DetRes->SetMarkerSize(0.7);
315 hT0DetRes->SetMarkerColor(kMagenta+2);
316 hT0DetRes->SetLineColor(kMagenta+2);
317 hT0DetRes->SetFillColor(kMagenta+2);
318 fHlistTimeZero->AddLast(hT0DetRes) ;
319
320 //timeZero 4
321 TH1F* hT0fill = new TH1F("hT0fill", "Event timeZero of fill; t0 [ps]; events", 1000, -25000., 25000. ) ;
322 hT0fill->Sumw2() ;
323 hT0fill->SetMarkerStyle(20);
324 hT0fill->SetMarkerColor(kBlack);
325 hT0fill->SetLineColor(kBlack);
326 fHlistTimeZero->AddLast(hT0fill) ;
327
328 //TimeZero 5
329 TH1F* hT0TOF = new TH1F("hT0TOF", "Event timeZero estimated by TOF; t0 [ps]; events", 1000, -25000., 25000. ) ;
330 hT0TOF->Sumw2() ;
331 hT0TOF->SetMarkerStyle(20);
332 hT0TOF->SetMarkerColor(kBlue);
333 hT0TOF->SetLineColor(kBlue);
334 hT0TOF->SetFillColor(kBlue);
335 fHlistTimeZero->AddLast(hT0TOF) ;
336
337
338 //timeZero 6
339 TH1F* hT0T0 = new TH1F("hT0T0", "Event timeZero measured by T0 detector (best between AC, A, C); t0 [ps]; events", 1000, -25000.,25000. ) ;
340 hT0T0->Sumw2() ;
341 hT0T0->SetMarkerStyle(20);
342 hT0T0->SetMarkerColor(kGreen+1);
343 hT0T0->SetLineColor(kGreen+1);
344 hT0T0->SetFillColor(kGreen+1);
345 fHlistTimeZero->AddLast(hT0T0) ;
346
347 //timeZero 7
348 TH1F* hT0best = new TH1F("hT0best", "Event timeZero estimated as T0best; t0 [ps]; events", 1000, -25000.,25000. ) ;
349 hT0best->Sumw2() ;
350 hT0best->SetMarkerStyle(20);
351 hT0best->SetMarkerColor(kRed);
352 hT0best->SetLineColor(kRed);
353 hT0best->SetFillColor(kRed);
354 fHlistTimeZero->AddLast(hT0best) ;
355
356 //TimeZero 8
357 TH1F* hT0fillRes = new TH1F("hT0fillRes", "Resolution of fillT0; #sigma_{bestT0} [ps];events", 250, 0.,250. ) ;
358 hT0fillRes->Sumw2() ;
359 hT0fillRes->SetMarkerStyle(21);
360 hT0fillRes->SetMarkerColor(kBlack);
361 hT0fillRes->SetLineColor(kBlack);
362 hT0fillRes->SetFillColor(kBlack);
363 fHlistTimeZero->AddLast(hT0fillRes) ;
aac12889 364
e866f574 365 //TimeZero 9
366 TH1F* hT0TOFRes = new TH1F("hT0TOFRes", "Resolution of timeZero from TOF; #sigma_{TOFT0} [ps];events", 250, 0.,250. ) ;
367 hT0TOFRes->Sumw2() ;
368 hT0TOFRes->SetLineWidth(1);
369 hT0TOFRes->SetMarkerStyle(21);
370 hT0TOFRes->SetMarkerColor(kBlue);
371 hT0TOFRes->SetLineColor(kBlue);
372 hT0TOFRes->SetFillColor(kBlue);
373 fHlistTimeZero->AddLast(hT0TOFRes) ;
aac12889 374
e866f574 375 //TimeZero 10
376 TH1F* hT0T0res = new TH1F("hT0T0res", "Resolution of timeZero from T0;#sigma_{T0T0} [ps];events", 250, -0., 250. ) ;
377 hT0T0res->Sumw2() ;
378 hT0T0res->SetMarkerStyle(21);
379 hT0T0res->SetMarkerColor(kGreen+1);
380 hT0T0res->SetLineColor(kGreen+1);
381 hT0T0res->SetFillColor(kGreen+1);
382 fHlistTimeZero->AddLast(hT0T0res) ;
383
384 //TimeZero 11
385 TH1F* hT0bestRes = new TH1F("hT0bestRes", "Resolution of bestT0; #sigma_{bestT0} [ps];events", 250, 0.,250. ) ;
386 hT0bestRes->Sumw2() ;
387 hT0fillRes->SetMarkerStyle(21);
388 hT0fillRes->SetMarkerColor(kRed);
389 hT0fillRes->SetLineColor(kRed);
390 hT0fillRes->SetFillColor(kRed);
391 fHlistTimeZero->AddLast(hT0bestRes) ;
392
393 //timeZero 12
394 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. ) ;
395 hT0TOFvsNtrk->Sumw2() ;
396 fHlistTimeZero->AddLast(hT0TOFvsNtrk) ;
397
398//--------------------------------------------- TOF PID QA plots
399 //PID 0
400 TH2F* hTOFmatchedESDpVsBeta = new TH2F("hTOFmatchedESDpVsBeta", "Matched ESDs tracks beta vs. p; p(GeV/c); beta", 500, 0.0, 5.0, 150,0., 1.5) ;
401 fHlistPID->AddLast(hTOFmatchedESDpVsBeta);
111b2155 402
e866f574 403 //PID 1
404 TH1F* hTOFmatchedMass= new TH1F("hTOFmatchedMass","Matched ESD tracks mass distribution - (L>0); M (GeV/c^{2}); entries", 500,0., 5. );
405 hTOFmatchedMass->Sumw2();
406 hTOFmatchedMass->SetLineWidth(2);
407 hTOFmatchedMass->SetLineColor(kBlue);
408 hTOFmatchedMass->SetLineColor(kBlue);
409 fHlistPID->AddLast(hTOFmatchedMass);
410
411 //PID 2
412 TH2F* hTOFmatchedExpTimePiVsEta = new TH2F("hTOFmatchedExpTimePiVsEta", "ESDs t_{TOF}-t_{#pi,exp} (from tracking); strip (#eta); t_{TOF}-t_{#pi,exp} [ps]",92,0,92,2000, -5000., 5000. ) ;
413 hTOFmatchedExpTimePiVsEta->Sumw2() ;
414 fHlistPID->AddLast(hTOFmatchedExpTimePiVsEta) ;
415
416 //PID 3
417 TH1F* hTOFmatchedExpTimePi = new TH1F("hTOFmatchedExpTimePi", "ESDs t_{TOF}-t_{#pi,exp} (from tracking); t_{TOF}-t_{#pi,exp} [ps];Counts",5000, -25000., 25000. ) ;
418 hTOFmatchedExpTimePi->Sumw2() ;
419 hTOFmatchedExpTimePi->SetLineWidth(1);
420 hTOFmatchedExpTimePi->SetLineColor(kRed);
421 hTOFmatchedExpTimePi->SetMarkerStyle(20);
422 hTOFmatchedExpTimePi->SetMarkerSize(0.8);
423 hTOFmatchedExpTimePi->SetMarkerColor(kRed);
424 fHlistPID->AddLast(hTOFmatchedExpTimePi) ;
425
426 //PID 4
427 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.,1000, -25000., 25000. ) ;
428 hTOFmatchedExpTimePiVsP->Sumw2() ;
429 fHlistPID->AddLast(hTOFmatchedExpTimePiVsP) ;
430
431 //PID 5
432 TH1F* hTOFtheoreticalExpTimePi = new TH1F("hTOFtheoreticalExpTimePi", "ESDs t_{TOF}-t_{#pi,exp} (theoretical); t_{TOF}-t_{#pi,exp} [ps];Counts", 5000, -25000., 25000. ) ;
433 hTOFtheoreticalExpTimePi->Sumw2() ;
434 hTOFtheoreticalExpTimePi->SetLineWidth(1);
435 hTOFtheoreticalExpTimePi->SetLineColor(kRed);
436 hTOFtheoreticalExpTimePi->SetMarkerStyle(24);
437 hTOFtheoreticalExpTimePi->SetMarkerSize(0.8);
438 hTOFtheoreticalExpTimePi->SetMarkerColor(kRed);
439 fHlistPID->AddLast(hTOFtheoreticalExpTimePi) ;
440
441 //PID 6
442 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.,1000, -25000., 25000. ) ;
443 hTOFtheoreticalExpTimePiVsP->Sumw2() ;
444 fHlistPID->AddLast(hTOFtheoreticalExpTimePiVsP) ;
445
446 //PID 7
447 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. ) ;
448 hTOFExpSigmaPi->Sumw2() ;
449 fHlistPID->AddLast(hTOFExpSigmaPi) ;
450
451 //PID 8
452 TH1F* hTOFmatchedExpTimeKa = new TH1F("hTOFmatchedExpTimeKa", "ESDs t_{TOF}-t_{K,exp} (from tracking); t_{TOF}-t_{K,exp} [ps];Counts", 500, -5000., 5000. ) ;
453 hTOFmatchedExpTimeKa->Sumw2() ;
454 hTOFmatchedExpTimeKa->SetLineWidth(1);
455 hTOFmatchedExpTimeKa->SetLineColor(kBlue);
456 hTOFmatchedExpTimeKa->SetMarkerStyle(21);
457 hTOFmatchedExpTimeKa->SetMarkerSize(0.8);
458 hTOFmatchedExpTimeKa->SetMarkerColor(kBlue);
459 fHlistPID->AddLast(hTOFmatchedExpTimeKa);
460
461 //PID 9
462 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.,1000, -25000., 25000. ) ;
463 hTOFmatchedExpTimeKaVsP->Sumw2() ;
464 fHlistPID->AddLast(hTOFmatchedExpTimeKaVsP) ;
465
466 //PID 10
467 TH1F* hTOFtheoreticalExpTimeKa = new TH1F("hTOFtheoreticalExpTimeKa", "ESDs t_{TOF}-t_{K,exp} (theoretical); t_{TOF}-t_{K,exp} [ps];Counts", 5000, -25000., 25000. ) ;
468 hTOFtheoreticalExpTimeKa->Sumw2() ;
469 hTOFtheoreticalExpTimeKa->SetLineWidth(1);
470 hTOFtheoreticalExpTimeKa->SetLineColor(kBlue);
471 hTOFtheoreticalExpTimeKa->SetMarkerStyle(24);
472 hTOFtheoreticalExpTimeKa->SetMarkerSize(0.8);
473 hTOFtheoreticalExpTimeKa->SetMarkerColor(kBlue);
474 fHlistPID->AddLast(hTOFtheoreticalExpTimeKa) ;
475
476 //PID 11
477 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.,1000, -25000., 25000. ) ;
478 hTOFtheoreticalExpTimeKaVsP->Sumw2() ;
479 fHlistPID->AddLast(hTOFtheoreticalExpTimeKaVsP) ;
480
481 //PID 12
482 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. ) ;
483 hTOFExpSigmaKa->Sumw2() ;
484 fHlistPID->AddLast(hTOFExpSigmaKa) ;
485
486 //PID 13
487 TH1F* hTOFmatchedExpTimePro = new TH1F("hTOFmatchedExpTimePro", "ESDs t_{TOF}-t_{p,exp} (from tracking); t_{TOF}-t_{p,exp} [ps];Counts", 500, -5000., 5000. ) ;
488 hTOFmatchedExpTimePro->Sumw2() ;
489 hTOFmatchedExpTimePro->SetLineWidth(1);
490 hTOFmatchedExpTimePro->SetLineColor(kGreen+1);
491 hTOFmatchedExpTimePro->SetMarkerStyle(22);
492 hTOFmatchedExpTimePro->SetMarkerSize(0.8);
493 hTOFmatchedExpTimePro->SetMarkerColor(kGreen+1);
494 fHlistPID->AddLast(hTOFmatchedExpTimePro) ;
495
496 //PID 14
497 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.,1000, -25000., 25000. ) ;
498 hTOFmatchedExpTimeProVsP->Sumw2() ;
499 fHlistPID->AddLast(hTOFmatchedExpTimeProVsP) ;
500
501 //PID 15
502 TH1F* hTOFtheoreticalExpTimePro = new TH1F("hTOFtheoreticalExpTimePro", "ESDs t_{TOF}-t_{p,exp} (theoretical); t_{TOF}-t_{p,exp} [ps];Counts", 500, -5000., 5000. ) ;
503 hTOFtheoreticalExpTimePro->Sumw2() ;
504 hTOFtheoreticalExpTimePro->SetLineWidth(1);
505 hTOFtheoreticalExpTimePro->SetLineColor(kGreen+1);
506 hTOFtheoreticalExpTimePro->SetMarkerStyle(26);
507 hTOFtheoreticalExpTimePro->SetMarkerSize(0.8);
508 hTOFtheoreticalExpTimePro->SetMarkerColor(kGreen+1);
509 fHlistPID->AddLast(hTOFtheoreticalExpTimePro) ;
510
511 //PID 16
512 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.,1000, -25000., 25000. ) ;
513 hTOFtheoreticalExpTimeProVsP->Sumw2() ;
514 fHlistPID->AddLast(hTOFtheoreticalExpTimeProVsP) ;
515
516 //PID 17
517 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. ) ;
518 hTOFExpSigmaPro->Sumw2() ;
519 fHlistPID->AddLast(hTOFExpSigmaPro) ;
520
111b2155 521 PostData(1, fHlist);
e866f574 522 PostData(2, fHlistTimeZero);
523 PostData(3, fHlistPID);
524
aac12889 525}
526//________________________________________________________________________
527void AliAnalysisTaskTOFqa::UserExec(Option_t *)
528{
529 /* Main - executed for each event.
530 It extracts event information and track information after selecting
531 primary tracks via standard cuts. */
111b2155 532
533 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
534 if (!esdH) {
535 Printf("ERROR: Could not get ESDInputHandler");
536 return;
537 } else {
538 fESD = (AliESDEvent*) esdH->GetEvent();
539 }
540
aac12889 541 if (!fESD) {
542 Printf("ERROR: fESD not available");
543 return;
544 }
545
e866f574 546 /* info from T0 detector QA */
547 for (Int_t j=0;j<3;j++){
548 fT0[j]= (Float_t) fESD->GetT0TOF(j);//ps
549 if (fT0[j]>90000.) fT0[j]=99999.;//fix old default values to the new one
550 }
551 Float_t t0cut = 90000.;
552 //Float_t t0cut =3 * t0spread; //use this cut to check t0 used in tof response
553 // if(t0cut < 500) t0cut = 500;
aac12889 554
e866f574 555 if(TMath::Abs(fT0[1]) < t0cut && TMath::Abs(fT0[2]) < t0cut ) {
556 //&& TMath::Abs(fT0[2]-fT0[1]) < 500) //add this condition to check t0 used in tof response
557 ((TH1F*)fHlistTimeZero->At(3))->Fill((fT0[2]-fT0[1])*0.5);
558 ((TH1F*)fHlistTimeZero->At(0))->Fill(fT0[0]);
559 }
560 if(TMath::Abs(fT0[1]) < t0cut){
561 ((TH1F*)fHlistTimeZero->At(1))->Fill(fT0[1]);
562 }
563 if(TMath::Abs(fT0[2]) < t0cut){
564 ((TH1F*)fHlistTimeZero->At(2))->Fill(fT0[2]);
565 }
566
567 /* event timeZero QA via AliESDpid::SetTOFResponse() */
568 Double_t timeZero[4]={99999.,99999.,99999.,99999.};
569 Double_t timeZeroRes[4]={99999.,99999.,99999.,99999.};
570
571 for (Int_t j=0;j<4;j++){
572 fESDpid->SetTOFResponse(fESD, (AliESDpid::EStartTimeType_t) j);//(fill_t0, tof_t0, t0_t0, best_t0)
573 timeZero[j]=fESDpid->GetTOFResponse().GetStartTime(10.); //timeZero for bin pT>10GeV/c
574 timeZeroRes[j]=fESDpid->GetTOFResponse().GetStartTimeRes(10.); //timeZero for bin pT>10GeV/c
575 ((TH1D*)fHlistTimeZero->At(4+j))->Fill(timeZero[j]);
576 ((TH1D*)fHlistTimeZero->At(8+j))->Fill(timeZeroRes[j]);
577 }
578
579
580 /* loop over ESD tracks */
581 fNTOFtracks=0;
582 // fNPrimaryTracks=0;
583
aac12889 584 for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
585 AliESDtrack* track = fESD->GetTrack(iTracks);
586 if (!track) {
587 Printf("ERROR: Could not receive track %d", iTracks);
588 continue;
589 }
590
591 //primary tracks selection: kTPCrefit and std cuts
592 if(!fTrackFilter->IsSelected(track)) continue;
aac12889 593 Double_t eta=track->Eta();
e866f574 594 if (TMath::Abs(eta)>0.9) continue; //cut for acceptance
595
596 Double_t mom=track->P();
597 Double_t mom2 = mom*mom;
598 Double_t length=track->GetIntegratedLength();
599 Double_t pT = track->Pt();
600 Double_t phi=track->Phi()*TMath::RadToDeg();
601 track->GetIntegratedTimes(fTrkExpTimes);
602
603 ((TH1F*)fHlist->At(9))->Fill(mom);
604 ((TH1F*)fHlist->At(10))->Fill(pT);
605 if (pT>=0.5)
aac12889 606 ((TH1F*)fHlist->At(11))->Fill(eta);
e866f574 607 ((TH1F*)fHlist->At(12))->Fill(phi);
608
609 //matched tracks selection: kTOFout and kTIME
610 if ((track->GetStatus() & AliESDtrack::kTOFout) &&
611 (track->GetStatus() & AliESDtrack::kTIME)) {
aac12889 612
e866f574 613 Double_t tofTime=track->GetTOFsignal();//in ps
614 Double_t tofTimeRaw=track->GetTOFsignalRaw();//in ps
615 Double_t tofToT=track->GetTOFsignalToT(); //in ps
616 Int_t channel=track->GetTOFCalChannel();
617 Int_t volId[5]; //(sector, plate,strip,padZ,padX)
618 AliTOFGeometry::GetVolumeIndices(channel,volId);
619
620 if (pT>=0.3) fNTOFtracks++; //matched counter
621 Double_t tof= tofTime*1E-3; // ns, average T0 fill subtracted, no info from T0detector
622 ((TH1F*)fHlist->At(1))->Fill(tof); //ns
623 ((TH1F*)fHlist->At(2))->Fill(tofTimeRaw*1E-3); //ns
624 ((TH1F*)fHlist->At(3))->Fill(tofToT);
625 ((TH1F*)fHlist->At(4))->Fill(length);
626 ((TH1F*)fHlist->At(5))->Fill(mom);
627 ((TH1F*)fHlist->At(6))->Fill(pT);
628 if (pT>=0.5)
629 ((TH1F*)fHlist->At(7))->Fill(eta);
630 ((TH1F*)fHlist->At(8))->Fill(phi);
631 if (track->GetSign()>0)
632 ((TH2F*)fHlist->At(13))->Fill(pT,track->GetTOFsignalDx());
633 else ((TH2F*)fHlist->At(14))->Fill(pT,track->GetTOFsignalDx());
634 ((TH2F*)fHlist->At(15))->Fill((Int_t)GetStripIndex(volId),track->GetTOFsignalDz());
635
636 //basic PID performance check
637 Double_t c=TMath::C()*1.E-9;// m/ns
638 Double_t mass=0.; //GeV
639 length =length*0.01; // in meters
640 tof=tof*c;
a5427fbf 641 Double_t beta= length/tof;
e866f574 642 Double_t fact= (tof/length)*(tof/length) -1.;
643 if(fact<=0) {
644 mass = -mom*TMath::Sqrt(-fact);
645 }else{
646 mass = mom*TMath::Sqrt(fact);
647 }
648 ((TH2F*)fHlistPID->At(0))->Fill(mom,beta);
649 ((TH1F*) fHlistPID->At(1))->Fill(mass);
650
651 //PID sigmas
652 for (Int_t specie = 0; specie < AliPID::kSPECIES; specie++){
653 fSigmaSpecie[specie] = fESDpid->GetTOFResponse().GetExpectedSigma(mom, fTrkExpTimes[specie], AliPID::ParticleMass(specie));
654 beta=1/TMath::Sqrt(1+AliPID::ParticleMass(specie)*AliPID::ParticleMass(specie)/(mom2));
a5427fbf 655 fThExpTimes[specie]=length*1.E3/(beta*c);//ps
e866f574 656 }
a5427fbf 657 ((TH2F*)fHlistPID->At(2))->Fill((Int_t)GetStripIndex(volId),tofTime-fTrkExpTimes[AliPID::kPion]);//ps
658
659 ((TH1F*)fHlistPID->At(3))->Fill(tofTime-fTrkExpTimes[AliPID::kPion]);//ps
660 ((TH2F*)fHlistPID->At(4))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kPion]));
661 ((TH1F*)fHlistPID->At(5))->Fill(tofTime-fThExpTimes[AliPID::kPion]);//ps
662 ((TH2F*)fHlistPID->At(6))->Fill(mom,(tofTime-fThExpTimes[AliPID::kPion]));
663 ((TH2F*)fHlistPID->At(7))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kPion])/fSigmaSpecie[AliPID::kPion]);
664
665 ((TH1F*)fHlistPID->At(8))->Fill(tofTime-fTrkExpTimes[AliPID::kKaon]);//ps
666 ((TH2F*)fHlistPID->At(9))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kKaon]));
667 ((TH1F*)fHlistPID->At(10))->Fill(tofTime-fThExpTimes[AliPID::kKaon]);//ps
668 ((TH2F*)fHlistPID->At(11))->Fill(mom,(tofTime-fThExpTimes[AliPID::kKaon]));
669 ((TH2F*)fHlistPID->At(12))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kKaon])/fSigmaSpecie[AliPID::kKaon]);
e866f574 670
a5427fbf 671 ((TH1F*)fHlistPID->At(13))->Fill(tofTime-fTrkExpTimes[AliPID::kProton]);//ps
672 ((TH2F*)fHlistPID->At(14))->Fill(mom,(tofTime-fTrkExpTimes[AliPID::kProton]));
673 ((TH1F*)fHlistPID->At(15))->Fill(tofTime-fThExpTimes[AliPID::kProton]);//ps
674 ((TH2F*)fHlistPID->At(16))->Fill(mom,(tofTime-fThExpTimes[AliPID::kProton]));
675 ((TH2F*)fHlistPID->At(17))->Fill(pT,(tofTime-fTrkExpTimes[AliPID::kProton])/fSigmaSpecie[AliPID::kProton]);
e866f574 676
677 }//matched
aac12889 678 }//end loop on tracks
e866f574 679
aac12889 680 ((TH1F*)fHlist->At(0))->Fill(fNTOFtracks) ;
e866f574 681 ((TH2F*)fHlistTimeZero->At(12))->Fill(fNTOFtracks,timeZero[AliESDpid::kTOF_T0]);
aac12889 682
aac12889 683 PostData(1, fHlist);
e866f574 684 PostData(2, fHlistTimeZero);
685 PostData(3, fHlistPID);
686
aac12889 687
688}
689
690//________________________________________________________________________
691void AliAnalysisTaskTOFqa::Terminate(Option_t *)
692{
693 //check on output validity
694 fHlist = dynamic_cast<TList*> (GetOutputData(1));
e866f574 695 if (!fHlist || !fHlistTimeZero) {
aac12889 696 Printf("ERROR: lists not available");
697 return;
698 }
699
700}
701
702//---------------------------------------------------------------
703Int_t AliAnalysisTaskTOFqa::GetStripIndex(const Int_t * const in)
704{
705 /* return tof strip index between 0 and 91 */
706
707 Int_t nStripA = AliTOFGeometry::NStripA();
708 Int_t nStripB = AliTOFGeometry::NStripB();
709 Int_t nStripC = AliTOFGeometry::NStripC();
710
711 Int_t iplate = in[1];
712 Int_t istrip = in[2];
713
714 Int_t stripOffset = 0;
715 switch (iplate) {
716 case 0:
717 stripOffset = 0;
718 break;
719 case 1:
720 stripOffset = nStripC;
721 break;
722 case 2:
723 stripOffset = nStripC+nStripB;
724 break;
725 case 3:
726 stripOffset = nStripC+nStripB+nStripA;
727 break;
728 case 4:
729 stripOffset = nStripC+nStripB+nStripA+nStripB;
730 break;
731 default:
732 stripOffset=-1;
733 break;
734 };
735
736 if (stripOffset<0 || stripOffset>92) return -1;
737 else
738 return (stripOffset+istrip);
739}
740
741#endif