]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnDaughter.cxx
Introduce a limit on the gain factor (Raphaelle)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.cxx
CommitLineData
7356f978 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////////////////////////////////////////////////////////////////////////////////
e2bafbbc 17//
7356f978 18// This class works as generic interface to each candidate resonance daughter.
19// Its main purpose is to provide a unique reference which includes all the
20// facilities available in the AliVParticle generic base class, plus all info
21// which could be needed during analysis, which are not in AliVParticle but
22// need to be accessed from ESD or AOD objects, usually in different ways.
23// When MC is available, AliRsnDaughter matches each reconstructed object with
24// its corresponding MC particle.
25//
26// Currently, this interface can point to all kinds of single-particle object
27// which one can have in the reconstructed event: charged tracks, V0s and
28// cascades. It is care of the user to treat each of them in the correct way,
29// regarding cuts, functions to be computed, etc.
06351446 30//
7356f978 31// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
32// M. Vala (martin.vala@cern.ch)
e2bafbbc 33//
7356f978 34////////////////////////////////////////////////////////////////////////////////
7c2974c8 35
a62a2d82 36#include <TParticle.h>
7356f978 37#include <TDatabasePDG.h>
5eb970a4 38#include "AliAODVertex.h"
5f1c287d 39
a62a2d82 40#include "AliRsnDaughter.h"
41
42ClassImp(AliRsnDaughter)
43
7c2974c8 44//_____________________________________________________________________________
2dab9030 45AliRsnDaughter::AliRsnDaughter() :
2a1c7696 46 fOK(kFALSE),
47 fLabel(-1),
48 fMotherPDG(0),
5f1c287d 49 fRsnID(-1),
2a1c7696 50 fPrec(0.0, 0.0, 0.0, 0.0),
51 fPsim(0.0, 0.0, 0.0, 0.0),
52 fRef(0x0),
53 fRefMC(0x0)
2f769150 54{
06351446 55//
a62a2d82 56// Default constructor.
5f1c287d 57// Initializes all data members to the same values
58// Which will be given by Reset() method.
06351446 59//
7c2974c8 60}
61
62//_____________________________________________________________________________
63AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) :
2a1c7696 64 TObject(copy),
65 fOK(copy.fOK),
66 fLabel(copy.fLabel),
67 fMotherPDG(copy.fMotherPDG),
5f1c287d 68 fRsnID(copy.fRsnID),
2a1c7696 69 fPrec(copy.fPrec),
70 fPsim(copy.fPsim),
71 fRef(copy.fRef),
72 fRefMC(copy.fRefMC)
7c2974c8 73{
06351446 74//
7c2974c8 75// Copy constructor.
2dab9030 76// Pointers are NOT duplicated, since they don't come from a 'new'
77// statement, but from just referencing something in the data source.
06351446 78//
7c2974c8 79}
80
7c2974c8 81//_____________________________________________________________________________
82AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter &copy)
83{
06351446 84//
7c2974c8 85// Assignment operator.
2dab9030 86// Pointers are NOT duplicated, since they don't come from a 'new'
87// statement, but from just referencing something in the data source.
06351446 88//
89
2a1c7696 90 fOK = copy.fOK;
91 fLabel = copy.fLabel;
92 fMotherPDG = copy.fMotherPDG;
5f1c287d 93 fRsnID = copy.fRsnID;
2a1c7696 94 fPrec = copy.fPrec;
95 fPsim = copy.fPsim;
96 fRef = copy.fRef;
97 fRefMC = copy.fRefMC;
aec0ec32 98
2a1c7696 99 return (*this);
7c2974c8 100}
101
5f1c287d 102//_____________________________________________________________________________
103void AliRsnDaughter::SetRef(AliVParticle *p)
104{
105//
106// Set the pointer to reference VParticle
107// and copies its momentum in the 4-vector.
108// Mass is assigned by SetMass().
109//
110
111 fRef = p;
112 if (p) fPrec.SetXYZT(p->Px(), p->Py(), p->Pz(), 0.0);
113 else fPrec.SetXYZT(0.0, 0.0, 0.0, 0.0);
114}
115
116//_____________________________________________________________________________
117void AliRsnDaughter::SetRefMC(AliVParticle *p)
118{
119//
120// Set the pointer to reference MonteCarlo VParticle
121// and copies its momentum in the 4-vector.
122// Mass is assigned by SetMass().
123//
124
125 fRefMC = p;
126 if (p) fPsim.SetXYZT(p->Px(), p->Py(), p->Pz(), 0.0);
127 else fPrec.SetXYZT(0.0, 0.0, 0.0, 0.0);
128}
129
5eb970a4 130//_____________________________________________________________________________
131void AliRsnDaughter::Reset()
132{
133//
2dab9030 134// Reset this track to meaningless values and to a 'bad' status.
135// After this has been done, this object should not be used
136// for analysis unless initialized properly.
5eb970a4 137//
138
2a1c7696 139 fOK = kFALSE;
140 fLabel = -1;
5f1c287d 141 fMotherPDG = 0;
142 fRsnID = -1;
2a1c7696 143
5f1c287d 144 SetRef(NULL);
145 SetRefMC(NULL);
e2bafbbc 146}
147
5f1c287d 148
7c2974c8 149//_____________________________________________________________________________
a378358c 150Int_t AliRsnDaughter::GetPDG(Bool_t abs)
4c2fda1e 151{
06351446 152//
a378358c 153// Return the PDG code of the particle from MC ref (if any).
154// If argument is kTRUE, returns its absolute value.
06351446 155//
7c2974c8 156
2a1c7696 157 Int_t pdg = 0;
7356f978 158 if (!fRefMC) return pdg;
2a1c7696 159
160 // ESD
161 AliMCParticle *esd = GetRefMCESD();
162 if (esd) pdg = esd->Particle()->GetPdgCode();
163
164 // AOD
165 AliAODMCParticle *aod = GetRefMCAOD();
166 if (aod) pdg = aod->GetPdgCode();
ec927a7d 167
2a1c7696 168 // abs value if required
169 if (abs) pdg = TMath::Abs(pdg);
170 return pdg;
ec927a7d 171}
172
7c2974c8 173//_____________________________________________________________________________
a378358c 174Int_t AliRsnDaughter::GetID()
4fbb2459 175{
06351446 176//
2dab9030 177// Return reference index, using the "GetID" method
178// of the possible source object.
5f1c287d 179// When this method is unsuccessful (e.g.: V0s), return the label.
06351446 180//
4fbb2459 181
2a1c7696 182 // ESD tracks
183 AliESDtrack *esd = GetRefESDtrack();
184 if (esd) return esd->GetID();
5eb970a4 185
2a1c7696 186 // AOD tracks
187 AliAODTrack *aod = GetRefAODtrack();
188 if (aod) return aod->GetID();
2dab9030 189
2a1c7696 190 // whatever else
191 return GetLabel();
e2bafbbc 192}
4fbb2459 193
2dab9030 194//_____________________________________________________________________________
195Bool_t AliRsnDaughter::SetMass(Double_t mass)
196{
197//
d0282f3d 198// Assign a mass hypothesis to the track.
5f1c287d 199// This causes the 4-momentum data members to be re-initialized
a378358c 200// using the momenta of referenced tracks/v0s and this mass.
d0282f3d 201// This step is fundamental for the following of the analysis.
2dab9030 202//
203
2a1c7696 204 if (mass < 0.) return kFALSE;
205
206 if (fRef) fPrec.SetXYZM(fRef ->Px(), fRef ->Py(), fRef ->Pz(), mass);
207 if (fRefMC) fPsim.SetXYZM(fRefMC->Px(), fRefMC->Py(), fRefMC->Pz(), mass);
208
209 return kTRUE;
4fbb2459 210}
32992791 211
212//_____________________________________________________________________________
213Bool_t AliRsnDaughter::IsKinkDaughter()
214{
215//
216// Checks if this track is a kink daughter.
217// this information is important for some cuts, in some cases
218// and it is retrieved differently from ESDs and AODs, so
219// this is done here in order to have a unique outcome.
220//
221
2a1c7696 222 AliESDtrack *etrack = GetRefESDtrack();
223 AliAODTrack *atrack = GetRefAODtrack();
224
225 if (etrack) {
226 return (etrack->GetKinkIndex(0) > 0);
227 } else if (atrack) {
228 AliAODVertex *vertex = atrack->GetProdVertex();
229 if (vertex) if (vertex->GetType() == AliAODVertex::kKink) return kTRUE;
230 }
231
232 return kFALSE;
32992791 233}
7356f978 234
235//______________________________________________________________________________
236AliRsnDaughter::ERefType AliRsnDaughter::RefType(ESpecies species)
237{
238//
239// Returns the expected object type for a candidate daughter
240// of the given species.
241//
242
243 switch (species) {
244 case kElectron:
245 case kMuon:
246 case kPion:
247 case kKaon:
248 case kProton:
249 return kTrack;
250 case kKaon0:
251 case kLambda:
252 return kV0;
253 case kXi:
254 case kOmega:
255 return kCascade;
256 default:
257 return kNoType;
258 }
259}
260
261//______________________________________________________________________________
262const char* AliRsnDaughter::SpeciesName(ESpecies species)
263{
264//
265// Return a string with the short name of the particle
266//
267
268 switch (species) {
269 case kElectron: return "E";
270 case kMuon: return "Mu";
271 case kPion: return "Pi";
272 case kKaon: return "K";
273 case kProton: return "P";
274 case kKaon0: return "K0s";
275 case kLambda: return "Lambda";
276 case kXi: return "Xi";
277 case kOmega: return "Omega";
278 default: return "Undef";
279 }
280}
281
282//______________________________________________________________________________
283Int_t AliRsnDaughter::SpeciesPDG(ESpecies species)
284{
285//
286// Return the PDG code of a particle species (abs value)
287//
288
289 switch (species) {
290 case kElectron: return 11;
291 case kMuon: return 13;
292 case kPion: return 211;
293 case kKaon: return 321;
294 case kProton: return 2212;
295 case kKaon0: return 310;
296 case kLambda: return 3122;
297 case kXi: return 3312;
298 case kOmega: return 3334;
299 default: return 0;
300 }
301}
302
303//______________________________________________________________________________
304Double_t AliRsnDaughter::SpeciesMass(ESpecies species)
305{
306//
307// Return the mass of a particle species
308//
309
310 TDatabasePDG *db = TDatabasePDG::Instance();
311 TParticlePDG *part = 0x0;
312
313 Int_t pdg = SpeciesPDG(species);
314 if (pdg) {
315 part = db->GetParticle(pdg);
316 return part->Mass();
317 }
318 else
319 return 0.0;
320}
321
322//______________________________________________________________________________
323EPARTYPE AliRsnDaughter::ToAliPID(ESpecies species)
324{
325//
326// Convert an enum element from this object
327// into the enumeration of AliPID.
328// If no match are cound 'kUnknown' is returned.
329//
330
331 switch (species) {
332 case kElectron: return AliPID::kElectron;
333 case kMuon: return AliPID::kMuon;
334 case kPion: return AliPID::kPion;
335 case kKaon: return AliPID::kKaon;
336 case kProton: return AliPID::kProton;
337 case kKaon0: return AliPID::kKaon0;
338 default: return AliPID::kUnknown;
339 }
340}
341
342//______________________________________________________________________________
343AliRsnDaughter::ESpecies AliRsnDaughter::FromAliPID(EPARTYPE pid)
344{
345//
346// Convert an enum element from AliPID
347// into the enumeration of this object.
348// If no match are cound 'kUnknown' is returned.
349//
350
351 switch (pid) {
352 case AliPID::kElectron: return kElectron;
353 case AliPID::kMuon: return kMuon;
354 case AliPID::kPion: return kPion;
355 case AliPID::kKaon: return kKaon;
356 case AliPID::kProton: return kProton;
357 case AliPID::kKaon0: return kKaon0;
358 default: return kUnknown;
359 }
360}