]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/RESONANCES/AliRsnCutPIDNSigma.h
Migration of PWG2/RESONANCES -> PWGLF/RESONANCES
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutPIDNSigma.h
CommitLineData
c865cb1d 1#ifndef ALIRSNCUTPIDNSIGMA_H
2#define ALIRSNCUTPIDNSIGMA_H
3
4//
64129b35 5// Class for n-sigma PID cuts.
6// ---
7// Requires:
c865cb1d 8//
64129b35 9// 1) the used detector, chosen from an enumeration
10// 2) the reference charged particle species, chosen from AliPID enumeration
11// 3) a momentum range: outside it, the cut is never passed
12//
13
14#include <TMath.h>
b6ab153d 15#include <TClonesArray.h>
c865cb1d 16
17#include "AliPID.h"
b6ab153d 18#include "AliESDtrack.h"
c865cb1d 19
20#include "AliRsnCut.h"
21
f34f960b 22class AliVTrack;
c865cb1d 23class AliPIDResponse;
24
25class AliRsnCutPIDNSigma : public AliRsnCut {
26public:
27
28 enum EDetector {
29 kITS,
30 kTPC,
31 kTOF,
32 kDetectors
33 };
61f275d1 34
b6ab153d 35 //
36 // This allows to define several intervals
37 //
38 class AliRsnPIDRange : public TObject {
39 public:
61f275d1 40
b6ab153d 41 AliRsnPIDRange(Double_t nsigma, Double_t pmin, Double_t pmax)
42 : fPMin(pmin), fPMax(pmax), fNSigmaCut(nsigma) { }
61f275d1 43
44 Double_t &PMin() {return fPMin;}
45 Double_t &PMax() {return fPMax;}
46 Double_t &NSigmaCut() {return fNSigmaCut;}
47
b6ab153d 48 Bool_t IsInRange(Double_t mom) {return (mom >= fPMin && mom <= fPMax);}
49 Bool_t CutPass(Double_t nsigma) {return (nsigma <= fNSigmaCut);}
61f275d1 50
b6ab153d 51 private:
61f275d1 52
b6ab153d 53 Double_t fPMin; // lower bound of momentum range
54 Double_t fPMax; // upper bound of momentum range
55 Double_t fNSigmaCut; // cut in number of sigmas
61f275d1 56
b6ab153d 57 ClassDef(AliRsnCutPIDNSigma::AliRsnPIDRange,1)
58 };
c865cb1d 59
64129b35 60 AliRsnCutPIDNSigma();
b6ab153d 61 AliRsnCutPIDNSigma(const char *name, AliPID::EParticleType species, EDetector det);
61f275d1 62 AliRsnCutPIDNSigma(const AliRsnCutPIDNSigma &copy);
63 AliRsnCutPIDNSigma &operator=(const AliRsnCutPIDNSigma &copy);
c865cb1d 64 virtual ~AliRsnCutPIDNSigma() { }
65
c865cb1d 66 void SetSpecies(AliPID::EParticleType type) {fSpecies = type;}
64129b35 67 void SetDetector(EDetector det) {fDetector = det;}
68 void SetRejectUnmatched(Bool_t yn = kTRUE) {fRejectUnmatched = yn;}
61f275d1 69
b6ab153d 70 AliPIDResponse *MyPID() {return fMyPID;}
71 void InitMyPID(Bool_t isMC, Bool_t isESD);
61f275d1 72
b6ab153d 73 void SinglePIDRange(Double_t nsigma);
74 void AddPIDRange(Double_t nsigma, Double_t pmin = 0.0, Double_t pmax = 1E20);
61f275d1 75
b6ab153d 76 Bool_t MatchITS(const AliVTrack *vtrack) const;
77 Bool_t MatchTPC(const AliVTrack *vtrack) const;
78 Bool_t MatchTOF(const AliVTrack *vtrack) const;
79 Bool_t MatchDetector(const AliVTrack *vtrack) const;
61f275d1 80
c865cb1d 81 virtual Bool_t IsSelected(TObject *object);
82 virtual void Print(const Option_t *option = "") const;
83
84private:
85
86 AliPID::EParticleType fSpecies; // particle species
87 EDetector fDetector; // detector used for PID
c865cb1d 88 Bool_t fRejectUnmatched; // tracks not matched to this detector do pass the cut?
b6ab153d 89 Double_t fTrackNSigma; //! tmp track number of sigmas w.r. to chosen detector
90 Double_t fTrackMom; //! track reference momentum
91 AliPIDResponse *fMyPID; // PID response object to be configured manyally
92 TClonesArray fRanges; // collection of ranges
c865cb1d 93
94 ClassDef(AliRsnCutPIDNSigma, 1)
95};
96
b6ab153d 97inline Bool_t AliRsnCutPIDNSigma::MatchITS(const AliVTrack *vtrack) const
c865cb1d 98{
99//
100// Checks if the track has the status flags required for an ITS standalone track
101//
102
f34f960b 103 if ((vtrack->GetStatus() & AliESDtrack::kITSin) == 0) return kFALSE;
104 if ((vtrack->GetStatus() & AliESDtrack::kITSpid) == 0) return kFALSE;
c865cb1d 105
f34f960b 106 return kTRUE;
c865cb1d 107}
108
b6ab153d 109inline Bool_t AliRsnCutPIDNSigma::MatchTPC(const AliVTrack *vtrack) const
c865cb1d 110{
111//
112// Checks if the track has the status flags required for a TPC track
113//
114
f34f960b 115 if ((vtrack->GetStatus() & AliESDtrack::kTPCin) == 0) return kFALSE;
61f275d1 116
f34f960b 117 return kTRUE;
c865cb1d 118}
119
b6ab153d 120inline Bool_t AliRsnCutPIDNSigma::MatchTOF(const AliVTrack *vtrack) const
c865cb1d 121{
122//
123// Checks if the track has the status flags required for an ITS standalone track
124//
125
f34f960b 126 if ((vtrack->GetStatus() & AliESDtrack::kTOFout) == 0) return kFALSE;
127 if ((vtrack->GetStatus() & AliESDtrack::kTIME) == 0) return kFALSE;
c865cb1d 128
f34f960b 129 return kTRUE;
c865cb1d 130}
131
b6ab153d 132inline Bool_t AliRsnCutPIDNSigma::MatchDetector(const AliVTrack *vtrack) const
133{
134//
135// Checks if the track has matched the required detector.
136// If no valid detector is specified, kFALSE is always returned.
137//
138
139 switch (fDetector) {
140 case kITS: return MatchITS(vtrack);
141 case kTPC: return MatchTPC(vtrack);
142 case kTOF: return MatchTOF(vtrack);
143 default : return kFALSE;
144 }
145}
146
147inline void AliRsnCutPIDNSigma::AddPIDRange(Double_t nsigma, Double_t pmin, Double_t pmax)
148{
149//
150// Add a new slot for checking PID
151//
152
153 Int_t n = fRanges.GetEntries();
61f275d1 154
b6ab153d 155 new (fRanges[n]) AliRsnPIDRange(nsigma, pmin, pmax);
156}
157
158inline void AliRsnCutPIDNSigma::SinglePIDRange(Double_t nsigma)
159{
160//
161// Clear all slots and sets a unique one
162//
163
164 fRanges.Delete();
61f275d1 165
b6ab153d 166 new (fRanges[0]) AliRsnPIDRange(nsigma, 0.0, 1E20);
167}
168
c865cb1d 169#endif