]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnValuePID.cxx
New values and cuts
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnValuePID.cxx
1 #include <Riostream.h>
2
3 #include "AliVTrack.h"
4 #include "AliESDtrack.h"
5 #include "AliAODTrack.h"
6
7 #include "AliPIDResponse.h"
8 #include "AliAnalysisManager.h"
9 #include "AliInputEventHandler.h"
10
11
12 #include "AliRsnValuePID.h"
13
14 ClassImp(AliRsnValuePID)
15
16 //__________________________________________________________________________________________________
17 AliRsnValuePID::AliRsnValuePID() :
18    AliRsnValue(),
19    fSpecies(AliPID::kUnknown),
20    fValuePID(kValues),
21    fPID(0x0)
22 {
23 //
24 // Dummy constructor
25 //
26
27    Int_t i;
28    for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0;
29    
30    SetTargetType(AliRsnTarget::kDaughter);
31 }
32
33 //__________________________________________________________________________________________________
34 AliRsnValuePID::AliRsnValuePID
35 (const char *name, EValuePID type, AliPID::EParticleType species, Int_t nbins, Double_t min, Double_t max) :
36    AliRsnValue(name, nbins, min, max),
37    fSpecies(species),
38    fValuePID(type),
39    fPID(0x0)
40 {
41 //
42 // Constructor 1 (fixed bins with number of bins, or no bins)
43 //
44
45    Int_t i;
46    for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0;
47    
48    SetTargetType(AliRsnTarget::kDaughter);
49 }
50
51 //__________________________________________________________________________________________________
52 AliRsnValuePID::AliRsnValuePID
53 (const char *name, EValuePID type, AliPID::EParticleType species, Double_t min, Double_t max, Double_t step) :
54    AliRsnValue(name, min, max, step),
55    fSpecies(species),
56    fValuePID(type),
57    fPID(0x0)
58 {
59 //
60 // Constructor 2 (fixed bins with step)
61 //
62
63    Int_t i;
64    for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0;
65    
66    SetTargetType(AliRsnTarget::kDaughter);
67 }
68
69 //__________________________________________________________________________________________________
70 AliRsnValuePID::AliRsnValuePID
71 (const char *name, EValuePID type, AliPID::EParticleType species, Int_t nbins, Double_t *array) :
72    AliRsnValue(name, nbins, array),
73    fSpecies(species),
74    fValuePID(type),
75    fPID(0x0)
76 {
77 //
78 // Constructor 3 (variable bins)
79 //
80    
81    Int_t i;
82    for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0;
83    
84    SetTargetType(AliRsnTarget::kDaughter);
85 }
86
87 //__________________________________________________________________________________________________
88 AliRsnValuePID::AliRsnValuePID(const AliRsnValuePID& copy) :
89    AliRsnValue(copy),
90    fSpecies(copy.fSpecies),
91    fValuePID(copy.fValuePID),
92    fPID(copy.fPID)
93 {
94 //
95 // Copy constructor
96 //
97
98    Int_t i;
99    for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0;
100 }
101
102 //__________________________________________________________________________________________________
103 AliRsnValuePID& AliRsnValuePID::operator=(const AliRsnValuePID& copy)
104 {
105 //
106 // Assignment operator
107 //
108
109    AliRsnValue::operator=(copy);
110    
111    fValuePID = copy.fValuePID;
112    fSpecies = copy.fSpecies;
113    fPID = copy.fPID;
114    
115    Int_t i;
116    for (i = 0; i < AliPID::kSPECIES; i++) fTOFtimes[i] = fTOFsigma[i] = 0.0;
117    
118    return (*this);
119 }
120
121 //__________________________________________________________________________________________________
122 Bool_t AliRsnValuePID::Eval(TObject *object, Bool_t)
123 {
124 //
125 // Evaluation function
126 //
127
128    if (fValuePID != kITSsignal && fValuePID != kTPCsignal && !fPID) InitializePID();
129    if (!fPID) {
130       AliError("PID not correctly initialized");
131       fComputedValue = 0.0;
132       return kFALSE;
133    }
134    if (!TargetOK(object)) return kFALSE;
135    
136    AliVTrack *vtrack = fDaughter->GetRefVtrack();
137    
138    switch (fValuePID) {
139       case kITSsignal:
140          fComputedValue = vtrack->GetITSsignal();
141          return kTRUE;
142       case kITSnsigma:
143          fComputedValue = fPID->NumberOfSigmasITS(vtrack, fSpecies);
144          return kTRUE;
145       case kTPCsignal:
146          fComputedValue = vtrack->GetTPCsignal();
147          return kTRUE;
148       case kTPCnsigma:
149          fComputedValue = fPID->NumberOfSigmasTPC(vtrack, fSpecies);
150          return kTRUE;
151       case kTOFsignal:
152          if (!TOFComputations(vtrack)) return kFALSE;
153          fComputedValue = (vtrack->GetTOFsignal() - fPID->GetTOFResponse().GetStartTime(vtrack->P()));
154          return kTRUE;
155       case kTOFnsigma:
156          if (!TOFComputations(vtrack)) return kFALSE;
157          fComputedValue = fPID->NumberOfSigmasTOF(vtrack, fSpecies);
158          return kTRUE;
159       case kTOFtime:
160          if (!TOFComputations(vtrack)) return kFALSE;
161          fComputedValue = fTOFtimes[(Int_t)fSpecies];
162          return kTRUE;
163       case kTOFsigma:
164          if (!TOFComputations(vtrack)) return kFALSE;
165          fComputedValue = fTOFsigma[(Int_t)fSpecies];
166          return kTRUE;
167       default:
168          AliError("Unrecognized option");
169          fComputedValue = 0.0;
170          return kFALSE;
171    }
172 }
173
174 //__________________________________________________________________________________________________
175 void AliRsnValuePID::Print(Option_t *) const
176 {
177 //
178 // Printout
179 //
180
181    AliRsnValue::Print();
182 }
183
184 //__________________________________________________________________________________________________
185 void AliRsnValuePID::InitializePID()
186 {
187 //
188 // Initialize PID object
189 //
190
191    AliAnalysisManager   *man = AliAnalysisManager::GetAnalysisManager();
192    AliInputEventHandler *inh = (AliInputEventHandler*)man->GetInputEventHandler();
193    
194    fPID = inh->GetPIDResponse();
195 }
196
197 //__________________________________________________________________________________________________
198 Bool_t AliRsnValuePID::TOFComputations(AliVTrack *vtrack)
199 {
200 //
201 // Make TOF computations
202 //
203
204    if (vtrack->InheritsFrom(AliESDtrack::Class())) {
205       AliESDtrack *track = (AliESDtrack*)vtrack;
206       track->GetIntegratedTimes(fTOFtimes);
207       Int_t i;
208       for (i = 0; i < AliPID::kSPECIES; i++) {
209          fTOFsigma[i] = fPID->GetTOFResponse().GetExpectedSigma(track->GetP(), fTOFtimes[i], AliPID::ParticleMass(i));
210       }
211       return kTRUE;
212    } else if (vtrack->InheritsFrom(AliAODTrack::Class())) {
213       AliAODTrack *track = (AliAODTrack*)vtrack;
214       AliAODPid *pidObj = track->GetDetPid();
215       if (!pidObj) return kFALSE;
216       pidObj->GetIntegratedTimes(fTOFtimes);
217       pidObj->GetTOFpidResolution(fTOFsigma);
218       return kTRUE;
219    } else {
220       return kFALSE;
221    }
222 }
223