]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnDaughter.cxx
Update macros
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.cxx
1 //
2 // Class AliRsnDaughter
3 //
4 // Interface to candidate daughters of a resonance (tracks).
5 // Points to the source of information, which is generally an AliVParticle-derived object
6 // and contains few internal data-members to store "on fly" some important information
7 // for the computations required during resonance analysis.
8 // It contains a useful TLorentzVector data-member which, provided that a meaningful mass was assigned,
9 // eases a lot the computation of invariant masses from summing up several of these objects.
10 //
11 // authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
12 //          M. Vala (martin.vala@cern.ch)
13 //
14
15 #include <TParticle.h>
16 #include "AliAODVertex.h"
17 #include "AliRsnDaughter.h"
18
19 ClassImp(AliRsnDaughter)
20
21 //_____________________________________________________________________________
22 AliRsnDaughter::AliRsnDaughter() :
23   fOK(kFALSE),
24   fLabel(-1),
25   fMotherPDG(0),
26   fPrec(0.0, 0.0, 0.0, 0.0),
27   fPsim(0.0, 0.0, 0.0, 0.0),
28   fRef(0x0),
29   fRefMC(0x0)
30 {
31 //
32 // Default constructor.
33 //
34 }
35
36 //_____________________________________________________________________________
37 AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) :
38   TObject(copy),
39   fOK(copy.fOK),
40   fLabel(copy.fLabel),
41   fMotherPDG(copy.fMotherPDG),
42   fPrec(copy.fPrec),
43   fPsim(copy.fPsim),
44   fRef(copy.fRef),
45   fRefMC(copy.fRefMC)
46 {
47 //
48 // Copy constructor.
49 // Pointers are NOT duplicated, since they don't come from a 'new'
50 // statement, but from just referencing something in the data source.
51 //
52 }
53
54 //_____________________________________________________________________________
55 AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter &copy)
56 {
57 //
58 // Assignment operator.
59 // Pointers are NOT duplicated, since they don't come from a 'new'
60 // statement, but from just referencing something in the data source.
61 //
62
63   fOK        = copy.fOK;
64   fLabel     = copy.fLabel;
65   fMotherPDG = copy.fMotherPDG;
66   fPrec      = copy.fPrec;
67   fPsim      = copy.fPsim;
68   fRef       = copy.fRef;
69   fRefMC     = copy.fRefMC;
70
71   return (*this);
72 }
73
74 //_____________________________________________________________________________
75 void AliRsnDaughter::Reset()
76 {
77 //
78 // Reset this track to meaningless values and to a 'bad' status.
79 // After this has been done, this object should not be used
80 // for analysis unless initialized properly.
81 //
82
83   fOK        = kFALSE;
84   fLabel     = -1;
85   fMotherPDG = 0;
86   fRef       = 0x0;
87   fRefMC     = 0x0;
88   
89   fPrec.SetXYZM(0.0, 0.0, 0.0, 0.0);
90   fPsim.SetXYZM(0.0, 0.0, 0.0, 0.0);
91 }
92
93 //_____________________________________________________________________________
94 Int_t AliRsnDaughter::GetPDG(Bool_t abs)
95 {
96 //
97 // Return the PDG code of the particle from MC ref (if any).
98 // If argument is kTRUE, returns its absolute value.
99 //
100
101   Int_t pdg = 0;
102
103   // ESD
104   AliMCParticle *esd = GetRefMCESD();
105   if (esd) pdg = esd->Particle()->GetPdgCode();
106   
107   // AOD
108   AliAODMCParticle *aod = GetRefMCAOD();
109   if (aod) pdg = aod->GetPdgCode();
110   
111   // abs value if required
112   if (abs) pdg = TMath::Abs(pdg);
113   return pdg;
114 }
115
116 //_____________________________________________________________________________
117 Int_t AliRsnDaughter::GetID()
118 {
119 //
120 // Return reference index, using the "GetID" method
121 // of the possible source object.
122 // In case of V0s, since this method is unsuccessful, return the label.
123 //
124
125   // ESD tracks
126   AliESDtrack *esd = GetRefESDtrack();
127   if (esd) return esd->GetID();
128
129   // AOD tracks
130   AliAODTrack *aod = GetRefAODtrack();
131   if (aod) return aod->GetID();
132
133   // whatever else
134   return GetLabel();
135 }
136
137 //_____________________________________________________________________________
138 Bool_t AliRsnDaughter::HasFlag(ULong_t flag)
139 {
140 //
141 // Checks that the 'status' flag of the source object has one or 
142 // a combination of status flags specified in argument.
143 // Works only with track-like objects, irrespectively if they
144 // are ESD or AOD tracks, since it refers to their AliVTrack base class.
145 //
146
147   AliVTrack *track  = dynamic_cast<AliVTrack*>(fRef);
148   if (!track) return kFALSE;
149   
150   ULong_t status = (ULong_t)track->GetStatus();
151   
152   return ((status & flag) != 0);
153 }
154
155 //_____________________________________________________________________________
156 Bool_t AliRsnDaughter::SetMass(Double_t mass)
157 {
158 //
159 // Assign a mass hypothesis to the track.
160 // This causes the 4-momentum data members to be initialized
161 // using the momenta of referenced tracks/v0s and this mass.
162 // This step is fundamental for the following of the analysis.
163 // Of course, this operation is successful only if the mass is
164 // a meaningful positive number, and the pointers are properly initialized.
165 //
166
167   if (mass < 0.) return kFALSE;
168   
169   if (fRef)   fPrec.SetXYZM(fRef  ->Px(), fRef  ->Py(), fRef  ->Pz(), mass);
170   if (fRefMC) fPsim.SetXYZM(fRefMC->Px(), fRefMC->Py(), fRefMC->Pz(), mass);
171   
172   return kTRUE;
173 }
174
175 //_____________________________________________________________________________
176 Bool_t AliRsnDaughter::IsKinkDaughter()
177 {
178 //
179 // Checks if this track is a kink daughter.
180 // this information is important for some cuts, in some cases
181 // and it is retrieved differently from ESDs and AODs, so
182 // this is done here in order to have a unique outcome.
183 //
184
185   AliESDtrack *etrack = GetRefESDtrack();
186   AliAODTrack *atrack = GetRefAODtrack();
187   
188   if (etrack)
189   {
190     return (etrack->GetKinkIndex(0) > 0);
191   }
192   else if (atrack)
193   {
194     AliAODVertex *vertex = atrack->GetProdVertex();
195     if (vertex) if (vertex->GetType() == AliAODVertex::kKink) return kTRUE;
196   }
197   
198   return kFALSE;
199 }