]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/RESONANCES/AliRsnCutPIDNSigma.h
Lego_train macros update (M.Vala)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnCutPIDNSigma.h
1 #ifndef ALIRSNCUTPIDNSIGMA_H
2 #define ALIRSNCUTPIDNSIGMA_H
3
4 //
5 // Class for n-sigma PID cuts.
6 // ---
7 // Requires:
8 //
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>
15 #include <TClonesArray.h>
16
17 #include "AliPID.h"
18 #include "AliESDtrack.h"
19
20 #include "AliRsnCut.h"
21
22 class AliVTrack;
23 class AliPIDResponse;
24
25 class AliRsnCutPIDNSigma : public AliRsnCut {
26 public:
27
28    enum EDetector {
29       kITS,
30       kTPC,
31       kTOF,
32       kDetectors
33    };
34
35    //
36    // This allows to define several intervals
37    //
38    class AliRsnPIDRange : public TObject {
39    public:
40
41       AliRsnPIDRange(Double_t nsigma, Double_t pmin, Double_t pmax)
42          : fPMin(pmin), fPMax(pmax), fNSigmaCut(nsigma) { }
43
44       Double_t &PMin()      {return fPMin;}
45       Double_t &PMax()      {return fPMax;}
46       Double_t &NSigmaCut() {return fNSigmaCut;}
47
48       Bool_t IsInRange(Double_t mom)  {return (mom >= fPMin && mom <= fPMax);}
49       Bool_t CutPass(Double_t nsigma) {return (nsigma <= fNSigmaCut);}
50
51    private:
52
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
56
57       ClassDef(AliRsnCutPIDNSigma::AliRsnPIDRange,1)
58    };
59
60    AliRsnCutPIDNSigma();
61    AliRsnCutPIDNSigma(const char *name, AliPID::EParticleType species, EDetector det);
62    AliRsnCutPIDNSigma(const AliRsnCutPIDNSigma &copy);
63    AliRsnCutPIDNSigma &operator=(const AliRsnCutPIDNSigma &copy);
64    virtual ~AliRsnCutPIDNSigma() { }
65
66    void             SetSpecies(AliPID::EParticleType type)        {fSpecies = type;}
67    void             SetDetector(EDetector det)                    {fDetector = det;}
68    void             SetRejectUnmatched(Bool_t yn = kTRUE)         {fRejectUnmatched = yn;}
69
70    AliPIDResponse  *MyPID()                                       {return fMyPID;}
71    void             InitMyPID(Bool_t isMC, Bool_t isESD);
72
73    void             SinglePIDRange(Double_t nsigma);
74    void             AddPIDRange(Double_t nsigma, Double_t pmin = 0.0, Double_t pmax = 1E20);
75
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;
80
81    virtual Bool_t   IsSelected(TObject *object);
82    virtual void     Print(const Option_t *option = "") const;
83
84 private:
85
86    AliPID::EParticleType   fSpecies;         //  particle species
87    EDetector               fDetector;        //  detector used for PID
88    Bool_t                  fRejectUnmatched; //  tracks not matched to this detector do pass the cut?
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
93
94    ClassDef(AliRsnCutPIDNSigma, 1)
95 };
96
97 inline Bool_t AliRsnCutPIDNSigma::MatchITS(const AliVTrack *vtrack) const
98 {
99 //
100 // Checks if the track has the status flags required for an ITS standalone track
101 //
102
103    if ((vtrack->GetStatus() & AliESDtrack::kITSin)  == 0) return kFALSE;
104    if ((vtrack->GetStatus() & AliESDtrack::kITSpid) == 0) return kFALSE;
105
106    return kTRUE;
107 }
108
109 inline Bool_t AliRsnCutPIDNSigma::MatchTPC(const AliVTrack *vtrack) const
110 {
111 //
112 // Checks if the track has the status flags required for a TPC track
113 //
114
115    if ((vtrack->GetStatus() & AliESDtrack::kTPCin) == 0) return kFALSE;
116
117    return kTRUE;
118 }
119
120 inline Bool_t AliRsnCutPIDNSigma::MatchTOF(const AliVTrack *vtrack) const
121 {
122 //
123 // Checks if the track has the status flags required for an ITS standalone track
124 //
125
126    if ((vtrack->GetStatus() & AliESDtrack::kTOFout) == 0) return kFALSE;
127    if ((vtrack->GetStatus() & AliESDtrack::kTIME)   == 0) return kFALSE;
128
129    return kTRUE;
130 }
131
132 inline 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
147 inline 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();
154
155    new (fRanges[n]) AliRsnPIDRange(nsigma, pmin, pmax);
156 }
157
158 inline void AliRsnCutPIDNSigma::SinglePIDRange(Double_t nsigma)
159 {
160 //
161 // Clear all slots and sets a unique one
162 //
163
164    fRanges.Delete();
165
166    new (fRanges[0]) AliRsnPIDRange(nsigma, 0.0, 1E20);
167 }
168
169 #endif