]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnMother.cxx
Removed the 'useMC' data member which is never used along the class. In the only...
[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
13 #include <Riostream.h>
14 #include <TVector3.h>
15
16 #include "AliAODMCParticle.h"
17 #include "AliMCParticle.h"
18 #include "AliRsnDaughter.h"
19 #include "AliRsnPairDef.h"
20 #include "AliRsnMother.h"
21
22 ClassImp(AliRsnMother)
23
24 //_____________________________________________________________________________
25 AliRsnMother::AliRsnMother() :
26    fSum(),
27    fSumMC()
28 {
29 //
30 // Constructor.
31 // Initializes all variables to meaningless values.
32 //
33
34    Int_t i;
35    for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
36 }
37
38 //_____________________________________________________________________________
39 AliRsnMother::AliRsnMother(const AliRsnMother &obj) :
40    TObject(obj),
41    fSum(obj.fSum),
42    fSumMC(obj.fSumMC)
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 //_____________________________________________________________________________
55 AliRsnMother& 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
65    fSum = obj.fSum;
66    fSumMC = obj.fSumMC;
67
68    for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
69
70    return (*this);
71 }
72
73 //_____________________________________________________________________________
74 AliRsnMother::~AliRsnMother()
75 {
76 //
77 // Desctructor.
78 // Does nothing, since pointers are not created in this class.
79 //
80 }
81
82 //_____________________________________________________________________________
83 Int_t AliRsnMother::CommonMother(Int_t &m0, Int_t &m1) const
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.
90 // In the two arguments passed by reference, the mothers of the two daghters are stored
91 //
92
93    // if MC info is not available, the pair is not true by default
94    if (!fDaughter[0]->GetRefMC() || !fDaughter[1]->GetRefMC()) {
95       AliWarning("Cannot know if the pairs is true or not because MC Info is not present");
96       return 0;
97    }
98
99    // check that labels are the same
100    m0 = -1;
101    m1 = -2;
102    if (fDaughter[0]->IsESD() && fDaughter[1]->IsESD()) {
103       if (fDaughter[0]->GetRefMCESD() && fDaughter[1]->GetRefMCESD()) {
104          m0 = fDaughter[0]->GetRefMCESD()->Particle()->GetFirstMother();
105          m1 = fDaughter[1]->GetRefMCESD()->Particle()->GetFirstMother();
106       }
107    }
108    if (fDaughter[0]->IsAOD() && fDaughter[1]->IsAOD()) {
109       if (fDaughter[0]->GetRefMCAOD() && fDaughter[1]->GetRefMCAOD()) {
110          m0 = fDaughter[0]->GetRefMCAOD()->GetMother();
111          m1 = fDaughter[1]->GetRefMCAOD()->GetMother();
112       }
113    }
114    if (m0 != m1) return 0;
115
116    // if we reach this point, the two tracks have the same mother
117    // let's check now the PDG code of this common mother
118    return TMath::Abs(fDaughter[0]->GetMotherPDG());
119 }
120
121 //_____________________________________________________________________________
122 void AliRsnMother::SetDaughters
123 (AliRsnDaughter *d0, Double_t mass0, AliRsnDaughter *d1, Double_t mass1)
124 {
125 //
126 // Sets the pair defined in this usind tso passed daughters and two masses
127 // which will be assigned to them, in order to recompute their 4-momenta
128 // and sum them into the datamembers of this object.
129 //
130
131    if (d0) fDaughter[0] = d0;
132    if (d1) fDaughter[1] = d1;
133
134    if (!d0 || !d1) return;
135
136    fDaughter[0]->SetMass(mass0);
137    fDaughter[1]->SetMass(mass1);
138
139    fSum   = fDaughter[0]->Prec() + fDaughter[1]->Prec();
140    fSumMC = fDaughter[0]->Psim() + fDaughter[1]->Psim();
141 }
142
143 //_____________________________________________________________________________
144 void AliRsnMother::ResetPair()
145 {
146 //
147 // Resets the mother, nullifying all data members
148 //
149
150    Int_t i;
151    for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
152
153    fSum  .SetXYZM(0.0, 0.0, 0.0, 0.0);
154    fSumMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
155 }
156
157 //_____________________________________________________________________________
158 Double_t AliRsnMother::CosThetaStar(Bool_t first, Bool_t useMC)
159 {
160    TLorentzVector mother    = (useMC ? fSumMC : fSum);
161    TLorentzVector daughter0 = (first ? fDaughter[0]->P(useMC) : fDaughter[1]->P(useMC));
162    TLorentzVector daughter1 = (first ? fDaughter[1]->P(useMC) : fDaughter[0]->P(useMC));
163    TVector3 momentumM(mother.Vect());
164    TVector3 normal(mother.Y() / momentumM.Mag(), -mother.X() / momentumM.Mag(), 0.0);
165
166    // Computes first the invariant mass of the mother
167    Double_t mass0            = fDaughter[0]->P(useMC).M();
168    Double_t mass1            = fDaughter[1]->P(useMC).M();
169    Double_t p0               = daughter0.Vect().Mag();
170    Double_t p1               = daughter1.Vect().Mag();
171    Double_t E0               = TMath::Sqrt(mass0 * mass0 + p0 * p0);
172    Double_t E1               = TMath::Sqrt(mass1 * mass1 + p1 * p1);
173    Double_t MotherMass       = TMath::Sqrt((E0 + E1) * (E0 + E1) - (p0 * p0 + 2.0 * daughter0.Vect().Dot(daughter1.Vect()) + p1 * p1));
174    MotherMass = fSum.M();
175
176    // Computes components of beta
177    Double_t betaX = -mother.X() / mother.E();
178    Double_t betaY = -mother.Y() / mother.E();
179    Double_t betaZ = -mother.Z() / mother.E();
180
181    // Computes Lorentz transformation of the momentum of the first daughter
182    // into the rest frame of the mother and theta*
183    daughter0.Boost(betaX, betaY, betaZ);
184    TVector3 momentumD = daughter0.Vect();
185
186    Double_t cosThetaStar = normal.Dot(momentumD) / momentumD.Mag();
187
188    return cosThetaStar;
189 }
190
191 //_____________________________________________________________________________
192 void AliRsnMother::PrintInfo(const Option_t * /*option*/) const
193 {
194 //
195 // Print some info of the pair.
196 // The options are passed to the AliRsnDaughter::Print() method
197 //
198
199    AliInfo("======== BEGIN PAIR INFO ===========");
200    AliInfo("Track #1");
201    fDaughter[0]->Print();
202    AliInfo("Track #2");
203    fDaughter[1]->Print();
204    AliInfo("========= END PAIR INFO ===========");
205 }
206
207 //_____________________________________________________________________________
208 Bool_t AliRsnMother::CheckPair(Bool_t checkMC) const
209 {
210 //
211 // Checks that the pair is well initialized:
212 // - both daughters are good pointers
213 // - if MC is required, both daughters have a MC reference
214 //
215
216    if (!fDaughter[0] || !fDaughter[1]) {
217       AliError("One of the two tracks is NULL in this pair!");
218       return kFALSE;
219    }
220
221    if (checkMC) {
222       if (fDaughter[0]->GetRefMC() == 0x0 || fDaughter[1]->GetRefMC() == 0x0) {
223          AliError("Required MC info but not all MC refs are available");
224          return kFALSE;
225       }
226    }
227
228    return kTRUE;
229 }