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