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