]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnMother.cxx
Added cut for checking multiplicity and done some adaptments for AOD analysis with...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnMother.cxx
1 //
2 // Class AliRsnMother
3 //
4 // Implementation of a pair of tracks, for several purposes
5 // - computing the total 4-momentum & inv. mass for output histos filling
6 // - evaluating cut checks on the pair of particles
7 // - evaluating any kind of kinematic value over their sum
8 //
9 // authors: Martin Vala (martin.vala@cern.ch)
10 //          Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
11 //
12 #include <Riostream.h>
13 #include <TVector3.h>
14 #include "AliAODMCParticle.h"
15 #include "AliMCParticle.h"
16 #include "AliRsnDaughter.h"
17 #include "AliRsnPairDef.h"
18 #include "AliRsnMother.h"
19
20 ClassImp(AliRsnMother)
21
22 //_____________________________________________________________________________
23 AliRsnMother::AliRsnMother() : 
24   fUseMC(kFALSE),
25   fDefaultMass(0.0),
26   fSum(),
27   fSumMC(),
28   fRef(),
29   fRefMC()
30 {
31 //
32 // Constructor.
33 // Initializes all variables to meaningless values.
34 //
35
36   Int_t i;
37   for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
38 }
39
40 //_____________________________________________________________________________
41 AliRsnMother::AliRsnMother(const AliRsnMother &obj) : 
42   TObject(obj), 
43   fUseMC(obj.fUseMC),
44   fDefaultMass(obj.fDefaultMass),
45   fSum(obj.fSum),
46   fSumMC(obj.fSumMC),
47   fRef(obj.fRef),
48   fRefMC(obj.fRefMC)
49 {
50 //
51 // Copy constructor.
52 // Initializes all variables to copy values.
53 // Does not duplicate pointers.
54 //
55
56   Int_t i;
57   for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
58 }
59
60 //_____________________________________________________________________________
61 AliRsnMother& AliRsnMother::operator=(const AliRsnMother &obj)
62 {
63 //
64 // Assignment operator.
65 // Initializes all variables to copy values.
66 // Does not duplicate pointers.
67 //
68
69   Int_t i;
70   
71   fDefaultMass = obj.fDefaultMass;
72   fSum = obj.fSum;
73   fRef = obj.fRef;
74   fSumMC = obj.fSumMC;
75   fRefMC = obj.fRefMC;
76   
77   for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
78
79   return (*this);
80 }
81
82 //_____________________________________________________________________________
83 AliRsnMother::~AliRsnMother()
84 {
85 //
86 // Desctructor.
87 // Does nothing, since pointers are not created in this class.
88 //
89 }
90
91 //_____________________________________________________________________________
92 Int_t AliRsnMother::CommonMother(Int_t &m0, Int_t &m1) const
93 {
94 //
95 // Checks if the two tracks in the pair have the same mother.
96 // This can be known if MC info is present.
97 // If the mother label is the same, rhe PDG code of the mother is returned,
98 // otherwise the method returns 0.
99 // In the two arguments passed by reference, the mothers of the two daghters are stored
100 //
101
102   // if MC info is not available, the pairs is not true by default
103   if (!fDaughter[0]->GetRefMC() || !fDaughter[1]->GetRefMC()) 
104   {
105     AliInfo("Cannot know if the pairs is true or not because MC Info is not present");
106     return 0;
107   }
108
109   // check that labels are the same
110   m0 = -1;
111   m1 = -2;
112   if (fDaughter[0]->IsESD() && fDaughter[1]->IsESD() )
113   {
114     if (fDaughter[0]->GetRefMCESD() && fDaughter[1]->GetRefMCESD())
115     {
116       m0 = fDaughter[0]->GetRefMCESD()->Particle()->GetFirstMother();
117       m1 = fDaughter[1]->GetRefMCESD()->Particle()->GetFirstMother();
118     }
119   }
120   if (fDaughter[0]->IsAOD() && fDaughter[1]->IsAOD())
121   {
122     if (fDaughter[0]->GetRefMCAOD() && fDaughter[1]->GetRefMCAOD())
123     {
124       m0 = fDaughter[0]->GetRefMCAOD()->GetMother();
125       m1 = fDaughter[1]->GetRefMCAOD()->GetMother();
126     }
127   }
128   if (m0 != m1) return 0;
129
130   // if we reach this point, the two tracks have the same mother
131   // let's check now the PDG code of this common mother
132   return TMath::Abs(fDaughter[0]->GetMotherPDG());
133 }
134
135 //_____________________________________________________________________________
136 void AliRsnMother::SetDaughters
137 (AliRsnDaughter *d0, Double_t mass0, AliRsnDaughter *d1, Double_t mass1)
138 {
139 //
140 // Sets the pair defined in this usind tso passed daughters and two masses
141 // which will be assigned to them, in order to recompute their 4-momenta
142 // and sum them into the datamembers of this object.
143 //
144
145   if (d0) fDaughter[0] = d0;
146   if (d1) fDaughter[1] = d1;
147   
148   if (!d0 || !d1) return;
149   
150   fDaughter[0]->SetMass(mass0);
151   fDaughter[1]->SetMass(mass1);
152   
153   fSum   = fDaughter[0]->P(kFALSE) + fDaughter[1]->P(kFALSE);
154   fSumMC = fDaughter[0]->P(kTRUE)  + fDaughter[1]->P(kTRUE);
155   
156   fRef  .SetXYZM(fSum  .X(), fSum  .Y(), fSum  .Z(), fDefaultMass);
157   fRefMC.SetXYZM(fSumMC.X(), fSumMC.Y(), fSumMC.Z(), fDefaultMass);
158 }
159
160 //_____________________________________________________________________________
161 void AliRsnMother::ResetPair()
162 {
163 //
164 // Resets the mother, nullifying all data members
165 //
166
167   Int_t i;
168   for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
169   
170   fSum  .SetXYZM(0.0, 0.0, 0.0, 0.0);
171   fRef  .SetXYZM(0.0, 0.0, 0.0, 0.0);
172   fSumMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
173   fRefMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
174 }
175
176 //_____________________________________________________________________________
177 Double_t AliRsnMother::CosThetaStar(Bool_t first, Bool_t useMC)
178 {
179   TLorentzVector mother    = (useMC ? fSumMC : fSum);
180   TLorentzVector daughter0 = (first ? fDaughter[0]->P() : fDaughter[1]->P());
181   TLorentzVector daughter1 = (first ? fDaughter[1]->P() : fDaughter[0]->P());
182   TVector3 momentumM          (mother.Vect());
183   //cout << mother.Vect().X() << ' ' << mother.Vect().Y() << ' ' << mother.Vect().Z() << endl;
184   TVector3 normal             (mother.Y()/momentumM.Mag(), -mother.X()/momentumM.Mag(), 0.0);
185   //cout << momentumM.Mag() << ' ' << normal.X() << ' ' << normal.Y() << ' ' << normal.Z() << endl;
186
187 // Computes first the invariant mass of the mother
188
189   Double_t mass0            = fDaughter[0]->P().M();
190   Double_t mass1            = fDaughter[1]->P().M();
191   Double_t p0               = daughter0.Vect().Mag();
192   Double_t p1               = daughter1.Vect().Mag();
193   Double_t E0               = TMath::Sqrt(mass0*mass0+p0*p0);
194   Double_t E1               = TMath::Sqrt(mass1*mass1+p1*p1);
195   Double_t MotherMass       = TMath::Sqrt((E0+E1)*(E0+E1)-(p0*p0+2.0*daughter0.Vect().Dot(daughter1.Vect())+p1*p1));
196   MotherMass = fSum.M();
197
198 // Computes components of beta
199
200   Double_t betaX = -mother.X()/mother.E(); //TMath::Sqrt(momentumM.Mag()*momentumM.Mag()+MotherMass*MotherMass);
201   Double_t betaY = -mother.Y()/mother.E(); //TMath::Sqrt(momentumM.Mag()*momentumM.Mag()+MotherMass*MotherMass);
202   Double_t betaZ = -mother.Z()/mother.E(); //TMath::Sqrt(momentumM.Mag()*momentumM.Mag()+MotherMass*MotherMass);
203
204 // Computes Lorentz transformation of the momentum of the first daughter
205 // into the rest frame of the mother and theta*
206   //cout << "Beta = " << betaX << ' ' << betaY << ' ' << betaZ << endl;
207
208   daughter0.Boost(betaX,betaY,betaZ);
209   TVector3 momentumD = daughter0.Vect();
210
211   Double_t cosThetaStar = normal.Dot(momentumD)/momentumD.Mag();
212
213   return cosThetaStar;
214
215 }
216
217 //_____________________________________________________________________________
218 void AliRsnMother::PrintInfo(const Option_t * /*option*/) const
219 {
220 //
221 // Print some info of the pair.
222 // The options are passed to the AliRsnDaughter::Print() method
223 //
224
225   AliInfo("======== BEGIN PAIR INFO ===========");
226   AliInfo("Track #1");
227   fDaughter[0]->Print();
228   AliInfo("Track #2");
229   fDaughter[1]->Print();
230   AliInfo("========= END PAIR INFO ===========");
231 }
232
233 //_____________________________________________________________________________
234 Bool_t AliRsnMother::CheckPair() const
235 {
236 //
237 // Checks that the pair is well initialized:
238 // - both daughters are good pointers
239 // - if MC is required, both daughters have a MC reference
240 //
241
242   if (!fDaughter[0] || !fDaughter[1]) 
243   {
244     AliError("One of the two tracks is NULL in this pair!");
245     return kFALSE;
246   }
247   
248   if (fUseMC)
249   {
250     if (fDaughter[0]->GetRefMC() == 0x0 || fDaughter[1]->GetRefMC() == 0x0)
251     {
252       AliError("Required MC info but not all MC refs are available");
253       return kFALSE;
254     }
255   }
256   
257   return kTRUE;
258 }
259
260 //_____________________________________________________________________________
261 Bool_t AliRsnMother::MatchesDef(AliRsnPairDef *def)
262 {
263 //
264 // Checks if the daughters, in any order, do match a given decay channel,
265 // using the specified identification method, which can be the 'true' one
266 // or the 'realistic' one only.
267 //
268
269   if (!def) return kFALSE;
270   if (!fDaughter[0]->GetRefMC()) return kFALSE;
271   if (!fDaughter[1]->GetRefMC()) return kFALSE;
272
273   Bool_t decayMatch = kFALSE;
274   Int_t  pdg[2], ref[2];
275   pdg[0] = fDaughter[0]->GetPDG();
276   pdg[1] = fDaughter[1]->GetPDG();
277   ref[0] = TMath::Abs(AliPID::ParticleCode(def->GetPID(0)));
278   ref[1] = TMath::Abs(AliPID::ParticleCode(def->GetPID(1)));
279
280   // check #1:
281   // if first member of pairDef has same sign as first member of this,
282   // daughter[0] perfect PID must match first member of pairDef
283   // daughter[1] perfect PID must march second member of pairDef
284   if (fDaughter[0]->IsSign(def->GetCharge(0)) && fDaughter[1]->IsSign(def->GetCharge(1))) 
285   {
286     decayMatch = (pdg[0] == ref[0] && pdg[1] == ref[1]);
287   }
288
289   // check #2:
290   // if first member of pairDef has same sign as second member of this,
291   // daughter[0] perfect PID must match second member of pairDef
292   // daughter[1] perfect PID must march first member of pairDef
293   if (fDaughter[1]->IsSign(def->GetCharge(0)) && fDaughter[0]->IsSign(def->GetCharge(1))) 
294   {
295     decayMatch = (pdg[0] == ref[1] && pdg[1] == ref[0]);
296   }
297
298   return (decayMatch && (CommonMother() == def->GetMotherPDG()));
299 }