]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnMother.cxx
New values and cuts
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnMother.cxx
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 ////////////////////////////////////////////////////////////////////////////////
17 //
18 //  This class implements a candidate resonance. It has two pointers to its
19 //  two candidate daughters, whose 4-momenta are combined to obtain the mother
20 //  invariant mass and other kinematical quantities.
21 //  This class contains also some methods used to compute kinematical relations
22 //  between the candidate resonance and other particles.
23 //
24 //  authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
25 //           M. Vala (martin.vala@cern.ch)
26 //
27 ////////////////////////////////////////////////////////////////////////////////
28
29 #include <Riostream.h>
30 #include <TVector3.h>
31
32 #include "AliAODMCParticle.h"
33 #include "AliMCParticle.h"
34 #include "AliRsnDaughter.h"
35 #include "AliRsnEvent.h"
36
37 #include "AliRsnMother.h"
38
39 ClassImp(AliRsnMother)
40
41 //_____________________________________________________________________________
42 AliRsnMother::AliRsnMother(const AliRsnMother &obj) :
43    TObject(obj),
44    fRefEvent(obj.fRefEvent),
45    fSum(obj.fSum),
46    fSumMC(obj.fSumMC)
47 {
48 //
49 // Copy constructor.
50 // Does not duplicate pointers.
51 //
52
53    Int_t i;
54    for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
55 }
56
57 //_____________________________________________________________________________
58 AliRsnMother& AliRsnMother::operator=(const AliRsnMother &obj)
59 {
60 //
61 // Assignment operator.
62 // Does not duplicate pointers.
63 //
64
65    Int_t i;
66
67    fSum = obj.fSum;
68    fSumMC = obj.fSumMC;
69
70    for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
71    
72    fRefEvent = obj.fRefEvent;
73
74    return (*this);
75 }
76
77 //_____________________________________________________________________________
78 AliRsnMother::~AliRsnMother()
79 {
80 //
81 // Desctructor.
82 // Does nothing, since pointers are not created in this class.
83 //
84 }
85
86 //_____________________________________________________________________________
87 Int_t AliRsnMother::CommonMother(Int_t &m0, Int_t &m1) const
88 {
89 //
90 // If MC info is available, checks if the two tracks in the pair have the same mother.
91 // If the mother label is the same, the function returns the PDG code of mother,
92 // otherwise it returns 0.
93 // The two arguments passed by reference contain the GEANT labels of the mother
94 // of the two particles to which the two daughters point. This is for being able 
95 // to check if they are really coming from a resonance (indexes >= 0) or not.
96 //
97
98    // if MC info is not available, the check can't be done
99    if (!fDaughter[0]->GetRefMC() || !fDaughter[1]->GetRefMC()) {
100       AliDebug(AliLog::kDebug, "MC Info absent --> cannot check common mother");
101       return 0;
102    }
103
104    // check that labels are the same
105    m0 = -1;
106    m1 = -2;
107    if (fDaughter[0]->IsESD() && fDaughter[1]->IsESD()) {
108       if (fDaughter[0]->GetRefMCESD() && fDaughter[1]->GetRefMCESD()) {
109          m0 = fDaughter[0]->GetRefMCESD()->Particle()->GetFirstMother();
110          m1 = fDaughter[1]->GetRefMCESD()->Particle()->GetFirstMother();
111       }
112    }
113    if (fDaughter[0]->IsAOD() && fDaughter[1]->IsAOD()) {
114       if (fDaughter[0]->GetRefMCAOD() && fDaughter[1]->GetRefMCAOD()) {
115          m0 = fDaughter[0]->GetRefMCAOD()->GetMother();
116          m1 = fDaughter[1]->GetRefMCAOD()->GetMother();
117       }
118    }
119    
120    // decide the answer depending on the two mother labels
121    if (m0 != m1) 
122       return 0;
123    else
124       return TMath::Abs(fDaughter[0]->GetMotherPDG());
125 }
126
127 //_____________________________________________________________________________
128 void AliRsnMother::ComputeSum(Double_t mass0, Double_t mass1)
129 {
130 //
131 // Sets the masses for the 4-momenta of the daughters and then
132 // sums them, taking into account that the space part is set to
133 // each of them when the reference object is set (see AliRsnDaughter::SetRef)
134 //
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, zeroing all data members.
148 //
149
150    Int_t i;
151    for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
152    fRefEvent = 0x0;
153
154    fSum  .SetXYZM(0.0, 0.0, 0.0, 0.0);
155    fSumMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
156 }
157
158 //_____________________________________________________________________________
159 Double_t AliRsnMother::AngleTo(AliRsnDaughter *track, Bool_t mc)
160 {
161 //
162 // Compute the angle betwee this and the passed object
163 // if second argument is kTRUE, use MC values.
164 //
165
166    TLorentzVector &me = (mc ? fSumMC : fSum);
167    TLorentzVector &he = track->P(mc);
168    
169    return me.Angle(he.Vect());
170 }
171
172 //_____________________________________________________________________________
173 Double_t AliRsnMother::AngleToLeading(Bool_t &success)
174 {
175 //
176 // Compute the angle betwee this and the leading particls
177 // of the reference event (if this was set properly).
178 // In case one of the two daughters is the leading, return
179 // a meaningless value, in order to skip this pair.
180 // if second argument is kTRUE, use MC values.
181 //
182
183    if (!fRefEvent) {
184       success = kFALSE;
185       return -99.0;
186    }
187    
188    Int_t id1 = fDaughter[0]->GetID();
189    Int_t id2 = fDaughter[1]->GetID();
190    Int_t idL = fRefEvent->GetLeadingParticleID();
191    
192    if (id1 == idL || id2 == idL) {
193       success = kFALSE;
194       return -99.0;
195    }
196    
197    AliRsnDaughter leading = fRefEvent->GetDaughter(idL);
198    AliVParticle  *ref     = leading.GetRef();
199    Double_t       angle   = ref->Phi() - fSum.Phi();
200    
201    //return angle w.r.t. leading particle in the range -pi/2, 3/2pi
202    while (angle >= 1.5 * TMath::Pi()) angle -= 2 * TMath::Pi();
203    while (angle < -0.5 * TMath::Pi()) angle += 2 * TMath::Pi();
204    success = kTRUE;
205    
206    return angle;
207 }
208
209 //_____________________________________________________________________________
210 Double_t AliRsnMother::CosThetaStar(Bool_t first, Bool_t useMC)
211 {
212 //
213 // Computes the cosine of theta*, which is the angle of one of the daughters
214 // with respect to the total momentum of the resonance, in its rest frame.
215 // The arguments are needed to choose which of the daughters one want to use
216 // and if reconstructed or MC momentum must be used.
217 // [Contribution from Z. Feckova]
218 //
219
220    TLorentzVector mother    = (useMC ? fSumMC : fSum);
221    TLorentzVector daughter0 = (first ? fDaughter[0]->P(useMC) : fDaughter[1]->P(useMC));
222    TLorentzVector daughter1 = (first ? fDaughter[1]->P(useMC) : fDaughter[0]->P(useMC));
223    TVector3 momentumM(mother.Vect());
224    TVector3 normal(mother.Y() / momentumM.Mag(), -mother.X() / momentumM.Mag(), 0.0);
225
226    // Computes first the invariant mass of the mother
227    Double_t mass0      = fDaughter[0]->P(useMC).M();
228    Double_t mass1      = fDaughter[1]->P(useMC).M();
229    Double_t p0         = daughter0.Vect().Mag();
230    Double_t p1         = daughter1.Vect().Mag();
231    Double_t E0         = TMath::Sqrt(mass0 * mass0 + p0 * p0);
232    Double_t E1         = TMath::Sqrt(mass1 * mass1 + p1 * p1);
233    Double_t MotherMass = TMath::Sqrt((E0 + E1) * (E0 + E1) - (p0 * p0 + 2.0 * daughter0.Vect().Dot(daughter1.Vect()) + p1 * p1));
234    MotherMass = fSum.M();
235
236    // Computes components of beta
237    Double_t betaX = -mother.X() / mother.E();
238    Double_t betaY = -mother.Y() / mother.E();
239    Double_t betaZ = -mother.Z() / mother.E();
240
241    // Computes Lorentz transformation of the momentum of the first daughter
242    // into the rest frame of the mother and theta*
243    daughter0.Boost(betaX, betaY, betaZ);
244    TVector3 momentumD = daughter0.Vect();
245
246    Double_t cosThetaStar = normal.Dot(momentumD) / momentumD.Mag();
247
248    return cosThetaStar;
249 }
250
251 //_____________________________________________________________________________
252 void AliRsnMother::PrintInfo(const Option_t * /*option*/) const
253 {
254 //
255 // Print some info of the pair.
256 // The options are passed to the AliRsnDaughter::Print() method
257 //
258
259    AliInfo("======== BEGIN PAIR INFO ===========");
260    AliInfo("Track #1");
261    fDaughter[0]->Print();
262    AliInfo("Track #2");
263    fDaughter[1]->Print();
264    AliInfo("========= END PAIR INFO ===========");
265 }
266
267 //_____________________________________________________________________________
268 Bool_t AliRsnMother::CheckPair(Bool_t checkMC) const
269 {
270 //
271 // Checks that the pair is well initialized:
272 // - both daughters are good pointers
273 // - if MC is required, both daughters have a MC reference
274 //
275
276    if (!fDaughter[0] || !fDaughter[1]) {
277       AliError("One of the two tracks is NULL in this pair!");
278       return kFALSE;
279    }
280
281    if (checkMC) {
282       if (fDaughter[0]->GetRefMC() == 0x0 || fDaughter[1]->GetRefMC() == 0x0) {
283          AliError("Required MC info but not all MC refs are available");
284          return kFALSE;
285       }
286    }
287
288    return kTRUE;
289 }