]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnCutPIDTPC.cxx
Splitted the PID cuts into three classes for ITS, TPC and TOF, and added the possibil...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutPIDTPC.cxx
1 //
2 // Class AliRsnCutPIDTPC
3 //
4 // General implementation of a single cut strategy, which can be:
5 // - a value contained in a given interval  [--> IsBetween()   ]
6 // - a value equal to a given reference     [--> MatchesValue()]
7 //
8 // In all cases, the reference value(s) is (are) given as data members
9 // and each kind of cut requires a given value type (Int, UInt, Double),
10 // but the cut check procedure is then automatized and chosen thanks to
11 // an enumeration of the implemented cut types.
12 // At the end, the user (or any other point which uses this object) has
13 // to use the method IsSelected() to check if this cut has been passed.
14 //
15 // authors: Martin Vala (martin.vala@cern.ch)
16 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
17 //
18
19 #include <Riostream.h>
20
21 #include "AliESDpid.h"
22 #include "AliTOFT0maker.h"
23 #include "AliTOFcalib.h"
24 #include "AliCDBManager.h"
25 #include "AliITSPIDResponse.h"
26
27 #include "AliRsnEvent.h"
28 #include "AliRsnDaughter.h"
29 #include "AliRsnCutPIDTPC.h"
30
31 ClassImp(AliRsnCutPIDTPC)
32
33 //_________________________________________________________________________________________________
34 AliRsnCutPIDTPC::AliRsnCutPIDTPC
35 (const char *name, AliPID::EParticleType type, Double_t momLimit, Double_t cut1, Double_t cut2) :
36   AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0),
37   fPIDtype(type),
38   fMomentumLimit(momLimit),
39   fLargeCut(TMath::Max(cut1, cut2)),
40   fSmallCut(TMath::Min(cut1, cut2)),
41   fESDpid(),
42   fAODpid()
43 {
44 //
45 // Main constructor.
46 //
47 }
48
49 //_________________________________________________________________________________________________
50 AliRsnCutPIDTPC::AliRsnCutPIDTPC
51 (const AliRsnCutPIDTPC& copy) :
52   AliRsnCut(copy),
53   fPIDtype(copy.fPIDtype),
54   fMomentumLimit(copy.fMomentumLimit),
55   fLargeCut(copy.fLargeCut),
56   fSmallCut(copy.fSmallCut),
57   fESDpid(copy.fESDpid),
58   fAODpid(copy.fAODpid)
59 {
60 //
61 // Copy constructor.
62 //
63 }
64
65 //_________________________________________________________________________________________________
66 AliRsnCutPIDTPC& AliRsnCutPIDTPC::operator=(const AliRsnCutPIDTPC& copy)
67 {
68 //
69 // Assignment operator
70 //
71
72   AliRsnCut::operator=(copy);
73
74   fPIDtype = copy.fPIDtype;
75   fMomentumLimit = copy.fMomentumLimit;
76   fLargeCut = copy.fLargeCut;
77   fSmallCut = copy.fSmallCut;
78   fESDpid = copy.fESDpid;
79   fAODpid = copy.fAODpid;
80   
81   return (*this);
82 }
83
84 //_________________________________________________________________________________________________
85 void AliRsnCutPIDTPC::SetBBParam(Double_t p0, Double_t p1, Double_t p2, Double_t p3, Double_t p4)
86 {
87 //
88 // Properly set the Bethe-Bloch parameters in all places where it is needed.
89 //
90
91   fESDpid.GetTPCResponse().SetBetheBlochParameters(p0, p1, p2, p3, p4);
92   fAODpid.GetTPCResponse().SetBetheBlochParameters(p0, p1, p2, p3, p4);
93 }
94
95 //_________________________________________________________________________________________________
96 Bool_t AliRsnCutPIDTPC::IsSelected(TObject *object)
97 {
98 //
99 // Cut checker.
100 //
101
102   // coherence check
103   if (!TargetOK(object)) return kFALSE;
104   
105   // reject not TPC tracks
106   // status is checked in the same way for all tracks
107   AliVTrack *vtrack = dynamic_cast<AliVTrack*>(fDaughter->GetRef());
108   if (!vtrack)
109   {
110     AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
111     return kFALSE;
112   }
113   ULong_t status = (ULong_t)vtrack->GetStatus();
114   if ((status & AliESDtrack::kTPCin) == 0)
115   {
116     AliDebug(AliLog::kDebug + 2, "Track is not found in TPC");
117     return kFALSE;
118   }
119   
120   // common evaluation variables
121   Double_t mom;
122
123   // retrieve real object type
124   AliESDtrack *esdTrack = fDaughter->GetRefESDtrack();
125   AliAODTrack *aodTrack = fDaughter->GetRefAODtrack();
126   if (esdTrack) 
127   {
128     AliDebug(AliLog::kDebug + 2, "Checking an ESD track");
129     
130     mom = esdTrack->GetInnerParam()->P();
131     
132     AliTPCPIDResponse &tpcrsp = fESDpid.GetTPCResponse();
133     fCutValueD = tpcrsp.GetNumberOfSigmas(mom, esdTrack->GetTPCsignal(), esdTrack->GetTPCsignalN(), fPIDtype);
134   }
135   else if (aodTrack)
136   {
137     AliDebug(AliLog::kDebug + 2, "Checking an AOD track");
138     
139     AliAODPid *pidObj = aodTrack->GetDetPid();
140     mom = pidObj->GetTPCmomentum();
141   
142     fCutValueD = fAODpid.NumberOfSigmasTPC(aodTrack, fPIDtype);
143   }
144   else
145   {
146     AliDebug(AliLog::kDebug + 2, Form("This object is not either an ESD nor AOD track, it is an %s", fDaughter->GetRef()->ClassName()));
147     return kFALSE;
148   }
149   
150   // determine cut range from the momentum
151   if (mom < fMomentumLimit)
152   {
153     fMinD = -fLargeCut;
154     fMaxD =  fLargeCut;
155   }
156   else
157   {
158     fMinD = -fSmallCut;
159     fMaxD =  fSmallCut;
160   }
161   
162   // check the cut using the standard AliRsnCut facilities
163   return OkRangeD();
164 }
165
166 //_________________________________________________________________________________________________
167 void AliRsnCutPIDTPC::Print(const Option_t *) const
168 {
169 //
170 // Print information on this cut
171 //
172
173   AliInfo(Form("Cut name, type                  : %s %s", GetName(), ClassName()));
174   AliInfo(Form("TPC PID cut: limit, large, small: %.3ff %.3ff %.3ff", fMomentumLimit, fLargeCut, fSmallCut));
175 }