]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/RESONANCES/AliRsnValueDaughter.cxx
Fix for MC in AddTask for Sigma* pp analysis (M.Venaruzzo)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnValueDaughter.cxx
CommitLineData
2895972e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16////////////////////////////////////////////////////////////////////////////////
17//
18// This class contains all code which is used to compute any of the values
19// which can be of interest within a resonance analysis. Besides the obvious
20// invariant mass, it allows to compute other utility values on all possible
21// targets, in order to allow a wide spectrum of binning and checks.
22// When needed, this object can also define a binning in the variable which
23// it is required to compute, which is used for initializing axes of output
24// histograms (see AliRsnFunction).
25// The value computation requires this object to be passed the object whose
26// informations will be used. This object can be of any allowed input type
27// (track, Daughter, event), then this class must inherit from AliRsnTarget.
28// Then, when value computation is attempted, a check on target type is done
29// and computation is successful only if expected target matches that of the
30// passed object.
31// In some cases, the value computation can require a support external object,
32// which must then be passed to this class. It can be of any type inheriting
33// from TObject.
34//
35// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
36// M. Vala (martin.vala@cern.ch)
37//
38////////////////////////////////////////////////////////////////////////////////
39
b63357a0 40#include <Riostream.h>
2895972e 41#include "AliVVertex.h"
42#include "AliMultiplicity.h"
43#include "AliESDtrackCuts.h"
44#include "AliESDpid.h"
45#include "AliAODPid.h"
46#include "AliCentrality.h"
47#include "AliESDUtils.h"
b63357a0 48#include "AliPIDResponse.h"
2895972e 49
50#include "AliRsnEvent.h"
51#include "AliRsnDaughter.h"
52#include "AliRsnMother.h"
53#include "AliRsnDaughterDef.h"
54#include "AliRsnDaughterDef.h"
55
56#include "AliRsnValueDaughter.h"
57
58ClassImp(AliRsnValueDaughter)
59
60//_____________________________________________________________________________
61AliRsnValueDaughter::AliRsnValueDaughter(const char *name, EType type) :
62 AliRsnValue(name, AliRsnTarget::kDaughter),
63 fType(type)
64{
65//
66// Constructor
67//
68}
69
70//_____________________________________________________________________________
61f275d1 71AliRsnValueDaughter::AliRsnValueDaughter(const AliRsnValueDaughter &copy) :
2895972e 72 AliRsnValue(copy),
73 fType(copy.fType)
74{
75//
76// Copy constructor
77//
78}
79
80//_____________________________________________________________________________
61f275d1 81AliRsnValueDaughter &AliRsnValueDaughter::operator=(const AliRsnValueDaughter &copy)
2895972e 82{
83//
84// Assignment operator.
85// Works like copy constructor.
86//
87
88 AliRsnValue::operator=(copy);
e6f3a909 89 if (this == &copy)
61f275d1 90 return *this;
2895972e 91 fType = copy.fType;
61f275d1 92
2895972e 93 return (*this);
94}
95
96//_____________________________________________________________________________
61f275d1 97const char *AliRsnValueDaughter::GetTypeName() const
2895972e 98{
99//
100// This method returns a string to give a name to each possible
101// computation value.
102//
103
104 switch (fType) {
b63357a0 105 case kP: return "SingleTrackPtot";
106 case kPt: return "SingleTrackPt";
107 case kPtpc: return "SingleTrackPtpc";
108 case kEta: return "SingleTrackEta";
b154f736 109 case kMass: return "SingleTrackMass";
b63357a0 110 case kITSsignal: return "SingleTrackITSsignal";
111 case kTPCsignal: return "SingleTrackTPCsignal";
112 case kTOFsignal: return "SingleTrackTOFsignal";
52e6652d 113 case kTPCnsigmaPi: return "SingleTrackTPCnsigmaPion";
114 case kTPCnsigmaK: return "SingleTrackTPCnsigmaKaon";
115 case kTPCnsigmaP: return "SingleTrackTPCnsigmaProton";
b63357a0 116 case kTOFnsigmaPi: return "SingleTrackTOFnsigmaPion";
117 case kTOFnsigmaK: return "SingleTrackTOFnsigmaKaon";
118 case kTOFnsigmaP: return "SingleTrackTOFnsigmaProton";
119 default: return "Undefined";
2895972e 120 }
121}
122
123//_____________________________________________________________________________
124Bool_t AliRsnValueDaughter::Eval(TObject *object)
125{
126//
127// Evaluation of the required value.
128// Checks that the passed object is of the right type
129// and if this check is successful, computes the required value.
130// The output of the function tells if computing was successful,
131// and the values must be taken with GetValue().
132//
61f275d1 133
134 // coherence check, which also casts object
2895972e 135 // to AliRsnTarget data members and returns kFALSE
136 // in case the object is NULL
137 if (!TargetOK(object)) return kFALSE;
138
139 // set a reference to the mother momentum
b63357a0 140 AliVParticle *ref = fDaughter->GetRef();
141 AliVParticle *refMC = fDaughter->GetRefMC();
2895972e 142 AliVTrack *track = fDaughter->Ref2Vtrack();
b63357a0 143 if (fUseMCInfo && !refMC) {
144 AliError("No MC");
145 return kFALSE;
146 }
147 if (!fUseMCInfo && !ref) {
148 AliError("No DATA");
149 return kFALSE;
150 }
61f275d1 151
2895972e 152 // compute value depending on types in the enumeration
153 // if the type does not match any available choice, or if
154 // the computation is not doable due to any problem
155 // (not initialized support object, wrong values, risk of floating point errors)
156 // the method returng kFALSE and sets the computed value to a meaningless number
157 switch (fType) {
158 case kP:
b63357a0 159 fComputedValue = (fUseMCInfo ? refMC->P() : ref->P());
2895972e 160 return kTRUE;
161 case kPt:
b63357a0 162 fComputedValue = (fUseMCInfo ? refMC->Pt() : ref->Pt());
2895972e 163 return kTRUE;
164 case kEta:
b63357a0 165 fComputedValue = (fUseMCInfo ? refMC->Eta() : ref->Eta());
2895972e 166 return kTRUE;
b154f736 167 case kMass:
e6952ec7 168 fComputedValue = (fUseMCInfo ? refMC->M() : ref->M());
b154f736 169 return kTRUE;
2895972e 170 case kPtpc:
171 if (track) {
172 fComputedValue = track->GetTPCmomentum();
173 return kTRUE;
174 } else {
175 AliWarning("Cannot get TPC momentum for non-track object");
176 fComputedValue = 0.0;
177 return kFALSE;
178 }
179 case kITSsignal:
180 if (track) {
181 fComputedValue = track->GetITSsignal();
182 return kTRUE;
183 } else {
184 AliWarning("Cannot get ITS signal for non-track object");
185 fComputedValue = 0.0;
186 return kFALSE;
187 }
188 case kTPCsignal:
189 if (track) {
190 fComputedValue = track->GetTPCsignal();
191 return kTRUE;
192 } else {
193 AliWarning("Cannot get TPC signal for non-track object");
194 fComputedValue = 0.0;
195 return kFALSE;
196 }
197 case kTOFsignal:
198 if (track) {
199 fComputedValue = track->GetTOFsignal();
200 return kTRUE;
201 } else {
202 AliWarning("Cannot get TOF signal for non-track object");
203 fComputedValue = 0.0;
204 return kFALSE;
205 }
52e6652d 206 case kTPCnsigmaPi:
207 if (track) {
208 AliPIDResponse *pid = fEvent->GetPIDResponse();
209 fComputedValue = pid->NumberOfSigmasTPC(track, AliPID::kPion);
210 return kTRUE;
211 } else {
212 AliWarning("Cannot get TOF signal for non-track object");
213 fComputedValue = 0.0;
214 return kFALSE;
215 }
216 case kTPCnsigmaK:
217 if (track) {
218 AliPIDResponse *pid = fEvent->GetPIDResponse();
219 fComputedValue = pid->NumberOfSigmasTPC(track, AliPID::kKaon);
220 return kTRUE;
221 } else {
222 AliWarning("Cannot get TOF signal for non-track object");
223 fComputedValue = 0.0;
224 return kFALSE;
225 }
226 case kTPCnsigmaP:
227 if (track) {
228 AliPIDResponse *pid = fEvent->GetPIDResponse();
229 fComputedValue = pid->NumberOfSigmasTPC(track, AliPID::kProton);
230 return kTRUE;
231 } else {
232 AliWarning("Cannot get TOF signal for non-track object");
233 fComputedValue = 0.0;
234 return kFALSE;
235 }
b63357a0 236 case kTOFnsigmaPi:
237 if (track) {
238 AliPIDResponse *pid = fEvent->GetPIDResponse();
239 fComputedValue = pid->NumberOfSigmasTOF(track, AliPID::kPion);
240 return kTRUE;
241 } else {
242 AliWarning("Cannot get TOF signal for non-track object");
243 fComputedValue = 0.0;
244 return kFALSE;
245 }
246 case kTOFnsigmaK:
247 if (track) {
248 AliPIDResponse *pid = fEvent->GetPIDResponse();
249 fComputedValue = pid->NumberOfSigmasTOF(track, AliPID::kKaon);
250 return kTRUE;
251 } else {
252 AliWarning("Cannot get TOF signal for non-track object");
253 fComputedValue = 0.0;
254 return kFALSE;
255 }
256 case kTOFnsigmaP:
257 if (track) {
258 AliPIDResponse *pid = fEvent->GetPIDResponse();
259 fComputedValue = pid->NumberOfSigmasTOF(track, AliPID::kProton);
260 return kTRUE;
261 } else {
262 AliWarning("Cannot get TOF signal for non-track object");
263 fComputedValue = 0.0;
264 return kFALSE;
265 }
a83bcf6e 266 case kNITSclusters:
267 if (track) {
e6952ec7 268 AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
269 if (trackESD) {
270 fComputedValue = trackESD->GetITSclusters(0);
271 } else {
272 fComputedValue = ((AliAODTrack *)track)->GetITSNcls();
273 }
a83bcf6e 274 return kTRUE;
275 } else {
276 AliWarning("Cannot get n ITS clusters for non-track object");
277 fComputedValue = 0.0;
278 return kFALSE;
279 }
280 case kNTPCclusters:
281 if (track) {
e6952ec7 282 AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
283 if (trackESD) {
284 fComputedValue = trackESD->GetTPCclusters(0);
285 } else {
286 fComputedValue = ((AliAODTrack *)track)->GetTPCNcls();
287 }
a83bcf6e 288 return kTRUE;
289 } else {
290 AliWarning("Cannot get n TPC clusters for non-track object");
291 fComputedValue = 0.0;
292 return kFALSE;
293 }
294 case kITSchi2:
295 if (track) {
e6952ec7 296 AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
297 if (trackESD) {
298 UShort_t nClustersITS = trackESD->GetITSclusters(0);
299 fComputedValue = trackESD->GetITSchi2()/Float_t(nClustersITS);
300 } else {
301 fComputedValue = ((AliAODTrack *)track)->Chi2perNDF();
302 }
a83bcf6e 303 return kTRUE;
304 } else {
305 AliWarning("Cannot get ITS chi^2 for non-track object");
306 fComputedValue = 0.0;
307 return kFALSE;
308 }
309 case kTPCchi2:
310 if (track) {
e6952ec7 311 AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
312 if (trackESD) {
313 UShort_t nClustersTPC = trackESD->GetTPCclusters(0);
314 fComputedValue = trackESD->GetTPCchi2()/Float_t(nClustersTPC);
315 } else {
316 fComputedValue = ((AliAODTrack *)track)->Chi2perNDF();
317 }
a83bcf6e 318 return kTRUE;
319 } else {
320 AliWarning("Cannot get TPC chi^2 for non-track object");
321 fComputedValue = 0.0;
322 return kFALSE;
323 }
3d0e1672 324 case kDCAXY:
325 if (track) {
e6952ec7 326 AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
327 if (trackESD) {
328 Float_t b[2], bCov[3];
329 trackESD->GetImpactParameters(b, bCov);
330 fComputedValue = b[0];
331 } else {
332 Double_t b[2]= {-999,-999}, cov[3];
333 AliAODVertex *vertex = fEvent->GetRefAOD()->GetPrimaryVertex();
334 if(vertex) {
335 track->PropagateToDCA(vertex, fEvent->GetRefAOD()->GetMagneticField(),kVeryBig, b, cov);
336 fComputedValue = b[0];
337 } else {
338 fComputedValue = -999;
339 }
340 }
3d0e1672 341 return kTRUE;
342 } else {
343 AliWarning("Cannot get TPC chi^2 for non-track object");
344 fComputedValue = 0.0;
345 return kFALSE;
346 }
347 case kDCAZ:
348 if (track) {
e6952ec7 349 AliESDtrack *trackESD = dynamic_cast<AliESDtrack *>(track);
350 if (trackESD) {
351 Float_t b[2], bCov[3];
352 trackESD->GetImpactParameters(b, bCov);
353 fComputedValue = b[1];
354 } else {
355 Double_t b[2]= {-999,-999}, cov[3];
356 AliAODVertex *vertex = fEvent->GetRefAOD()->GetPrimaryVertex();
357 if(vertex) {
358 track->PropagateToDCA(vertex, fEvent->GetRefAOD()->GetMagneticField(),kVeryBig, b, cov);
359 fComputedValue = b[1];
360 } else {
361 fComputedValue = -999;
362 }
3d0e1672 363
e6952ec7 364 }
3d0e1672 365 return kTRUE;
366 } else {
367 AliWarning("Cannot get TPC chi^2 for non-track object");
368 fComputedValue = 0.0;
369 return kFALSE;
370 }
2895972e 371 default:
372 AliError(Form("[%s] Invalid value type for this computation", GetName()));
373 return kFALSE;
374 }
375}