]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/Correlations/DPhi/DiHadronPID/AliAODTrackCutsDiHadronPID.h
DiHadronPID task update (Misha.Veldhoen@cern.ch)
[u/mrichter/AliRoot.git] / PWGCF / Correlations / DPhi / DiHadronPID / AliAODTrackCutsDiHadronPID.h
CommitLineData
6788af99 1#ifndef ALIAODTRACKCUTSDIHADRONPID_H
2#define ALIAODTRACKCUTSDIHADRONPID_H
3
4#include "TFormula.h"
5#include "TH1F.h"
6#include "TH2F.h"
7#include "TH3F.h"
8#include "TList.h"
9
10class AliAODTrackCutsDiHadronPID : public TNamed
11
12{
13
14public:
15 enum HistoClass {kAllCharged = 0, kPositive = 1, kNegative = 2,
16 kAllPion = 3, kPosPion = 4, kNegPion = 5,
17 kAllKaon = 6, kPosKaon = 7, kNegKaon = 8,
18 kAllProton = 9, kPosProton = 10, kNegProton = 11};
19
20public:
21 AliAODTrackCutsDiHadronPID(); // Default Constructor
22 AliAODTrackCutsDiHadronPID(const char* name); // Named Constructor
23 virtual ~AliAODTrackCutsDiHadronPID(); // Destructor
24 virtual Long64_t Merge(TCollection* list); // Merger
25
26// -------------------------------------------------------------------------
27// Interface, methods used to get information about the track cuts, and to
28// retrieve filled histograms.
29// -------------------------------------------------------------------------
30
31public:
32 void PrintCuts(); // Gives an overview of the cuts.
33
34// Return the list of QA histos
35 TList* GetListOfDataQAHistos() const{
36 if (fDataTrackQAHistos) {return fDataTrackQAHistos;}
37 else return 0x0;
38 }
39 TList* GetListOfPrimRecMCTrackQAHistos() const{
40 if (fPrimRecMCTrackQAHistos) {return fPrimRecMCTrackQAHistos;}
41 else return 0x0;
42 }
43 TList* GetListOfPrimGenMCTrackQAHistos() const {
44 if (fPrimGenMCTrackQAHistos) {return fPrimGenMCTrackQAHistos;}
45 else return 0x0;
46 }
47 TList* GetListOfSecRecMCTrackQAHistos() const {
48 if (fSecRecMCTrackQAHistos) return fSecRecMCTrackQAHistos;
49 else return 0x0;
50 }
51 TList* GetListOfSecGenMCTrackQAHistos() const {
52 if (fSecGenMCTrackQAHistos) return fSecGenMCTrackQAHistos;
53 else return 0x0;
54 }
55
56// Note that the PID histograms have in principle a different number of pT bins.
57// FIXME: This is not very nice...
58 Int_t GetNPtBins() const {return fNPtBins;}
59 Int_t GetNPtBinsPID(Int_t ptclass = -1) const {
60 // if class = -1, then return the sum.
61 if (ptclass == -1) {
62 Int_t nptbinspid = 0;
63 for (Int_t iPtClass = 0; iPtClass < 5; iPtClass++) {
64 nptbinspid += fNPtBinsPID[iPtClass];
65 }
66 return nptbinspid;
67 } else if (ptclass >= 0 && ptclass < 5) {
68 return fNPtBinsPID[ptclass];
69 } else {return -999;}
70 }
71
72// Returns the Pt axis for PID and other histograms.
73 Double_t* GetPtAxis() {return fPtAxis;}
74 Float_t* GetPtAxisPID() const {
75 const Int_t nptbinspid = GetNPtBinsPID();
76 Float_t* ptaxis = new Float_t[nptbinspid];
77 for (Int_t iPtBin = 0; iPtBin < nptbinspid; iPtBin++) {
78 ptaxis[iPtBin] = GetPtMinPID(iPtBin + 1);
79 }
80 ptaxis[nptbinspid] = GetPtMaxPID(nptbinspid);
81 return ptaxis;
82 }
83
84// Return data histogram with a specific name. Since the histograms are not streamed, and only the
85// TList containing them is, we have to retrieve them from the list.
86 TObject* GetHistData(const char* name) const {return fDataTrackQAHistos->FindObject(name);}
87 TObject* GetHistPrimRecMC(const char* name) const {return fPrimRecMCTrackQAHistos->FindObject(name);}
88 TObject* GetHistPrimGenMC(const char* name) const {return fPrimGenMCTrackQAHistos->FindObject(name);}
89 TObject* GetHistSecRecMC(const char* name) const {return fSecRecMCTrackQAHistos->FindObject(name);}
90 TObject* GetHistSecGenMC(const char* name) const {return fSecGenMCTrackQAHistos->FindObject(name);}
91
92// Since we will often want to have TOF histograms, here are a few methods which return the
93// appropriate projections. The class does not own these projections, and the user must take care of them.
94 TH1F* GetHistDataTOFProjection(Int_t charge, Int_t species, Int_t ptbin);
95 TH1F* GetHistDataTOFMismatch(Int_t charge, Int_t species, Int_t ptbin);
96 Double_t GetPtMinPID(Int_t bin) const {
97 Int_t ptclass = GetPtClass(bin);
98 Int_t bininptclass = GetBinInPtClass(bin);
99 Double_t minpt = fPtBoundaryPID[ptclass];
100 Double_t maxpt = fPtBoundaryPID[ptclass+1];
101 Double_t ptres = (maxpt - minpt)/((Double_t)fNPtBinsPID[ptclass]);
102 return (minpt + ptres * ((Double_t)(bininptclass - 1)) );
103 }
104 Double_t GetPtMaxPID(Int_t bin) const {
105 Int_t ptclass = GetPtClass(bin);
106 Int_t bininptclass = GetBinInPtClass(bin);
107 Double_t minpt = fPtBoundaryPID[ptclass];
108 Double_t maxpt = fPtBoundaryPID[ptclass+1];
109 Double_t ptres = (maxpt - minpt)/((Double_t)fNPtBinsPID[ptclass]);
110 return (minpt + ptres * ((Double_t)(bininptclass)) );
111 }
112 Double_t GetPtClassMin(Int_t ptclass) const {
113 if (ptclass >= 0 && ptclass < 5) {
114 return fPtBoundaryPID[ptclass];
115 } else {return -999;}
116 }
117 Double_t GetPtClassMax(Int_t ptclass) const {
118 if (ptclass >= 0 && ptclass < 5) {
119 return fPtBoundaryPID[ptclass+1];
120 } else {return -999;}
121 }
122
123 Double_t GetPtBinWidthPID(Int_t bin) const {return (GetPtMaxPID(bin) - GetPtMinPID(bin)); }
124
125// BE CAREFUL! Following methods do not apply to the ptaxis of the PID histograms! For that, call
126// the GetPtMinPID and GetPtMaxPID methods.
127 Double_t GetPtMin(Int_t bin) const {
128 if ((bin < 1) || (bin > fNPtBins + 1)) {cout<<"Bin is out of range..."<<endl; return -999.;}
129 else {return fPtAxis[bin - 1];}
130 }
131 Double_t GetPtMax(Int_t bin) const {
132 if ((bin < 1) || (bin > fNPtBins + 1)) {cout<<"Bin is out of range..."<<endl; return -999.;}
133 else {return fPtAxis[bin];}
134 }
135 Double_t GetPtBinWidth(Int_t bin) const {return (GetPtMax(bin) - GetPtMin(bin)); }
136
137 Int_t GetNTOFbins(Int_t ptclass, Int_t species) const {return fTOFbins[ptclass][species];}
138 Double_t GetTOFmin(Int_t ptclass, Int_t species) const {return fTOFLowerBound[ptclass][species];}
139 Double_t GetTOFmax(Int_t ptclass, Int_t species) const {return fTOFUpperBound[ptclass][species];}
140
141 Int_t GetNTPCbins(Int_t ptclass, Int_t species) const {return fTPCbins[ptclass][species];}
142 Double_t GetTPCmin(Int_t ptclass, Int_t species) const {return fTPCLowerBound[ptclass][species];}
143 Double_t GetTPCmax(Int_t ptclass, Int_t species) const {return fTPCUpperBound[ptclass][species];}
144
145// Getters (Cuts)
146 UInt_t GetFilterMask() const {return fFilterMask;}
147 Double_t GetMaxEta() const {return fMaxEta;}
148 ULong_t GetDemandedFlags() const {return fDemandedFlags;}
149 TFormula* GetPtDeptDCACutFormula() const {return fPtDeptDCAxyCutFormula;}
150 Double_t GetDCAzCut() const {return fDCAzCut;}
151 UInt_t GetMinSPDHitsForPtDeptDCACut() const {return fMinSPDHitsForPtDeptDCAcut;}
152
153// Getters (Settings)
154 Bool_t GetIsMC() const {return fIsMC;}
155
156 Int_t GetDebugLevel() const {return fDebug;}
157
158// -------------------------------------------------------------------------
159// Methods used to configure the track cuts object, to be called at
160// initialization, i.e., before the object is added to an analysis task.
161// -------------------------------------------------------------------------
162
163public:
164
165// Request Certain QA histograms being filled.
166 Bool_t RequestQAHistos(Int_t histoclass, Bool_t Enable3DSpectra = kFALSE, Bool_t EnablePIDHistos = kFALSE) {
167 if ((histoclass > -1) && (histoclass < 12)) {
168 fHistRequested[histoclass] = kTRUE;
169 f3DSpectraEnabeled[histoclass] = Enable3DSpectra;
170 fPIDHistosEnabeled[histoclass] = EnablePIDHistos;
171 //cout<<"histoclass: "<<histoclass<<" requested: "<<fHistRequested[histoclass]<<endl;
172 return kTRUE;
173 } else {
174 return kFALSE;
175 }
176 }
177
178// Setters (Cuts)
179 void SetPtRange(Double_t minpt, Double_t maxpt) {
180 fMinPt = minpt;
181 fMaxPt = maxpt;
182 fTestPt = kTRUE;
183 }
184 void SetFilterMask(UInt_t filtermask) {
185 fFilterMask = filtermask;
186 fTestFilterMask = kTRUE;
187 }
188 void SetMaxEta(Double_t maxeta) {
189 fMaxEta = maxeta;
190 fTestMaxEta = kTRUE;
191 }
192 void SetMaxRapidity(Double_t maxrapidity) {
193 fMaxRapidity = maxrapidity;
194 fTestMaxRapidity = kTRUE;
195 }
196 void SetDemandNoMismatch() {
197 fTestTOFmismatch = kTRUE;
198 }
199 void SetDemandFlags(ULong_t demandedflags) {
200 fDemandedFlags = demandedflags;
201 fTestFlags = kTRUE;
202 }
203 void SetPtDeptDCACut(TFormula* DCAxyCutFormula, Double_t DCAzCut, UInt_t MinSPDHits = 1) {
204 fPtDeptDCAxyCutFormula = DCAxyCutFormula;
205 fDCAzCut = DCAzCut;
206 fMinSPDHitsForPtDeptDCAcut = MinSPDHits;
207 fTestPtDeptDCAcut = kTRUE;
208 }
209
210// Setters (Settings)
211 void SetIsMC(Bool_t ismc = kTRUE) {fIsMC = ismc;}
212
213 void SetDebugLevel(Int_t debuglevel) {fDebug = debuglevel;}
214
215// -------------------------------------------------------------------------
216// Methods called by the analysis task.
217// -------------------------------------------------------------------------
218
219public:
220
221// These two functions signal the beginning and the end of a new event.
222 void StartNewEvent(); // Some things are set to zero.
223 void EventIsDone(Bool_t IsMC); // Some final histograms are filled.
224 void CreateHistos(); // Should be called by the UserCreateOutput() function of the analysis task.
225
226// Is Selected, for different types of tracks.
227 Bool_t IsSelectedData(AliTrackDiHadronPID* track, Double_t randomhittime = -1.e20);
228 Bool_t IsSelectedGeneratedMC(AliAODMCParticle* particle);
229 Bool_t IsSelectedReconstructedMC(AliTrackDiHadronPID* track);
230
231// -------------------------------------------------------------------------
232// Internal methods.
233// -------------------------------------------------------------------------
234
235public:
236
237// For PID histograms we have a certain number of bins in pT, spread out over five
238// large histograms, i.e., one for the lowest pT, and the biggest range in TOF/TPC,
239// one for the higher pT and smaller range in TOF/TPC, etc. The following methods
240// are a mapping between the total pT bin (what the user uses), and the pt bin
241// within one of the five histograms (what's used internally)
242 Int_t GetPtClass(const Int_t ptbin) const {
243
244 // Returns a number [0..4]
245 Int_t currentptclass = 0;
246 Int_t currentptbin = fNPtBinsPID[0];
247 while (currentptbin < ptbin) {
248 currentptclass++;
249 if (currentptclass == 5) {break;}
250 currentptbin += fNPtBinsPID[currentptclass];
251 }
252 if (currentptclass == 5) {cout<<"GetPtClass -> ptbin out of range!"<<endl; return -1;}
253 return currentptclass;
254 }
255 Int_t GetBinInPtClass(const Int_t ptbin) const {
256
257 // Returns a number [1..Nbins]
258 Int_t ptclass = GetPtClass(ptbin);
259 if (ptclass == -1) {return -1;}
260
261 Int_t ptbinout = ptbin;
262 for (Int_t iPtClass = 0; iPtClass < ptclass; iPtClass++) {ptbinout -= fNPtBinsPID[iPtClass];}
263
264 return ptbinout;
265
266 }
267
268private:
269
270// Checks, return kTRUE if track passes the cut.
271 Bool_t CheckPt(Double_t pt) const {
272 if (!fTestPt) return kTRUE;
273 if ((pt > fMinPt) && (pt < fMaxPt)) return kTRUE;
274 return kFALSE;
275 }
276 Bool_t CheckMaxEta(Double_t eta) const {
277 if (!fTestMaxEta) return kTRUE; // Accepted if there is no check on this parameter.
278 if (TMath::Abs(eta) < fMaxEta) return kTRUE;
279 return kFALSE;
280 }
281 Bool_t CheckRapidity(Double_t rap) const {
282 if (!fTestMaxRapidity) return kTRUE;
283 if (TMath::Abs(rap) < fMaxRapidity) return kTRUE;
284 return kFALSE;
285 }
286 Bool_t CheckFilterMask(UInt_t filtermap) const {
287 if (!fTestFilterMask) return kTRUE;
288 if ((fFilterMask & filtermap) == fFilterMask) return kTRUE;
289 return kFALSE;
290 }
291 Bool_t CheckFlags(ULong_t flags) const {
292 if (!fTestFlags) return kTRUE;
293 if ((flags & fDemandedFlags) == fDemandedFlags) return kTRUE;
294 return kFALSE;
295 }
296 Bool_t CheckTOFmismatch(Bool_t ismismatch) const {
297 if (!fTestTOFmismatch) return kTRUE; // if we're not cutting on mismatch, then it's accepted.
298 if (!ismismatch) return kTRUE; // so if the track is not a mismatch, then it is accepted.
299 return kFALSE; // if it is a mismatch, then it's not accepted.
300 }
301 Bool_t CheckPtDeptDCACut(Double_t dcaz, Double_t dcaxy, Double_t pt, UInt_t SPDhits) const {
302 if (!fTestPtDeptDCAcut) return kTRUE;
303 if (SPDhits < fMinSPDHitsForPtDeptDCAcut) return kTRUE; // If there are not enough SPD hits to do the cut.
304 if ((dcaz < fDCAzCut) && (dcaxy < fPtDeptDCAxyCutFormula->Eval(pt))) return kTRUE;
305 return kFALSE;
306 }
307
308// Filling QA histograms.
309 Bool_t FillDataHistos(Int_t histoclass, AliTrackDiHadronPID* track);
310 Bool_t FillTOFMismatchHistos(Int_t histoclass, AliTrackDiHadronPID* track, Double_t randomhittime);
311 Bool_t FillGenMCHistos(Int_t histoclass, AliAODMCParticle* particle);
312 Bool_t FillRecMCHistos(Int_t histoclass, AliTrackDiHadronPID* track);
313
314// Initializing QA histograms.
315 Bool_t InitializeDataHistos(Int_t histoclass);
316 Bool_t InitializeGenMCHistos(Int_t histoclass);
317 Bool_t InitializeRecMCHistos(Int_t histoclass);
318
319 void InitializeDefaultHistoNamesAndAxes();
320
321 TH1F* InitializePtSpectrum(const char* name, Int_t histoclass);
322 TH1F* InitializeNTracksHisto(const char* name, Int_t histoclass);
323 TH1F* InitializeDCAxyHisto(const char* name, Int_t histoclass);
324 TH1F* InitializeDCAzHisto(const char* name, Int_t histoclass);
325 TH3F* InitializeAcceptanceHisto(const char* /*name*/, Int_t /*histoclass*/); // TO BE IMPLEMENTED.
326 TH2F* InitializeDCASpectrum(const char* name, Int_t histoclass);
327
328
329 TH3F* InitializePIDHisto(const char* name, Int_t histoclass, Int_t expspecies, Int_t ptclass);
330 TH2F* InitializeTOFMismatchHisto(const char* name, Int_t histoclass, Int_t expspecies, Int_t ptclass);
331
332// -------------------------------------------------------------------------
333// Data members.
334// -------------------------------------------------------------------------
335
336private:
337// Track Cuts
338 Double_t fMinPt;
339 Double_t fMaxPt;
340 UInt_t fFilterMask; // FilterMask to-be-checked.
341 Double_t fMaxEta; // Max Eta of the track.
342 Double_t fMaxRapidity; // Rapidity cut (only done for PID plots!!)
343 ULong_t fDemandedFlags; // Flags demanded on the track.
344 UInt_t fMinSPDHitsForPtDeptDCAcut; // Required number of SPD hits for performing Pt-Dept DCA cut.
345 TFormula* fPtDeptDCAxyCutFormula; // Formula for the Pt-Dept DCA cut.
346 Double_t fDCAzCut; // Max z at DCA.
347
348// Settings
349 Bool_t fIsMC; // Is the current event MC or not.
350
351// Requested Histograms;
352 Bool_t fHistRequested[12]; //
353 Bool_t f3DSpectraEnabeled[12]; //
354 Bool_t fPIDHistosEnabeled[12]; //
355
356// Which Track Cuts will be tested.
357 Bool_t fTestPt; //
358 Bool_t fTestFilterMask; //
359 Bool_t fTestMaxEta; //
360 Bool_t fTestMaxRapidity; //
361 Bool_t fTestFlags; //
362 Bool_t fTestTOFmismatch; //
363 Bool_t fTestPtDeptDCAcut; //
364
365// QA histograms for Data.
366 TList* fDataTrackQAHistos; //
367 TH1F* fHistDataPt[3]; //! Pt distribution of tracks passing this cut.
368 TH1F* fHistDataNTracks[3]; //! Number of tracks passing the cut per event (filling by EventIsDone()).
369 TH1F* fHistDataDCAxy[3]; //! DCA_{xy} distribution.
370 TH1F* fHistDataDCAz[3]; //! DCA_{z} distribution
371 TH2F* fHistDataDCAxyOneSigma[12]; //! DCA_{xy} distribution of particles as identified by 1 sigma method.
372 Int_t fNTracks[3]; //! Number of tracks
373
374 TH3F* fHistDataPID[3][3][5]; //! TPC/TOF v.s. pT, [charge][mass assumption][ptclass]
375 TH2F* fHistTOFMismatch[3][3][5]; //! TOF Mismatch histograms, [charge][mass assumption][ptclass]
376
377// QA histograms for Primary Reconstructed MC tracks.
378 TList* fPrimRecMCTrackQAHistos; //
379 TH1F* fHistPrimRecMCPt[12]; //! Pt distribution of reconstructed MC track passing this cut.
380 TH1F* fHistPrimRecNTracks[12]; //!
381 TH2F* fHistPrimRecMCDCA[12]; //! DCA_xy distribution of reconstructed MC track passing this cut.
382
383// QA histograms for Primary Generated MC particles.
384 TList* fPrimGenMCTrackQAHistos; //
385 TH1F* fHistPrimGenMCPt[12]; //! Pt distribution of generated MC particles passing this cut.
386
387// QA histograms for Secondary Reconstructed MC tracks.
388 TList* fSecRecMCTrackQAHistos; //
389 TH1F* fHistSecRecMCPt[12]; //! Pt distribution of reconstructed MC track passing this cut.
390 TH2F* fHistSecRecMCDCAMat[12]; //! DCA_xy distribution of material decay particles.
391 TH2F* fHistSecRecMCDCAWeak[12]; //! DCA_xy distribution of weak decay.
392
393// QA histograms for Secondary Generated MC particles.
394 TList* fSecGenMCTrackQAHistos; //
395 TH1F* fHistSecGenMCPt[12]; //! Pt distribution of generated MC particles passing this cut.
396
397// Binning of all the histograms.
398 Double_t fPtAxis[47]; // Pt axis used in all histograms, except PID and Mismatch histograms.
399 Int_t fNPtBins; // Number of bins in the pt-axis.
400
401 Double_t fPtBoundaryPID[6]; // There are five different PID histo's. This array gives the pT range of these histograms.
402 Int_t fNPtBinsPID[5]; // This array gives the number of pT bins for each of these histograms.
403
404 Double_t fTOFLowerBound[5][3]; // These arrays give the lower and upper bound of the TOF axes,
405 Double_t fTOFUpperBound[5][3]; // for each species, as well as the number of bins. The numbers
406 Int_t fTOFbins[5][3]; // size of the array is [ptrange][species].
407
408 Double_t fTPCLowerBound[5][3]; // The same, but now for TPC.
409 Double_t fTPCUpperBound[5][3];
410 Int_t fTPCbins[5][3];
411
412// Naming conventions of the histograms.
413 TString fHistoName[12]; // Names of the histogram classes.
414 TString fHistoLatex[12]; // Names of the histogram classes in LaTeX.
415 TString fParticleName[3]; // Names of the particles (Pion, Kaon, Proton)
416 TString fPtClassName[5]; // Names of the ptclasses (should only be for internal use)
417
418 Int_t fDebug; // Debug flag.
419
420 ClassDef(AliAODTrackCutsDiHadronPID,4);
421
422};
423
424#endif