]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnMother.cxx
Major upgrade to the package, in order to speed-up the execution and remove some...
[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 "AliRsnDaughter.h"
14 #include "AliRsnPairDef.h"
15 #include "AliRsnMother.h"
16
17 ClassImp(AliRsnMother)
18
19 //_____________________________________________________________________________
20 AliRsnMother::AliRsnMother() : 
21   fUseMC(kFALSE),
22   fDefaultMass(0.0),
23   fSum(),
24   fSumMC(),
25   fRef(),
26   fRefMC()
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 //_____________________________________________________________________________
38 AliRsnMother::AliRsnMother(const AliRsnMother &obj) : 
39   TObject(obj), 
40   fUseMC(obj.fUseMC),
41   fDefaultMass(obj.fDefaultMass),
42   fSum(obj.fSum),
43   fSumMC(obj.fSumMC),
44   fRef(obj.fRef),
45   fRefMC(obj.fRefMC)
46 {
47 //
48 // Copy constructor.
49 // Initializes all variables to copy values.
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 // Initializes all variables to copy values.
63 // Does not duplicate pointers.
64 //
65
66   Int_t i;
67   
68   fDefaultMass = obj.fDefaultMass;
69   fSum = obj.fSum;
70   fRef = obj.fRef;
71   fSumMC = obj.fSumMC;
72   fRefMC = obj.fRefMC;
73   
74   for (i = 0; i < 2; i++) fDaughter[i] = obj.fDaughter[i];
75
76   return (*this);
77 }
78
79 //_____________________________________________________________________________
80 AliRsnMother::~AliRsnMother()
81 {
82 //
83 // Desctructor.
84 // Does nothing, since pointers are not created in this class.
85 //
86 }
87
88 //_____________________________________________________________________________
89 Int_t AliRsnMother::CommonMother() const
90 {
91 //
92 // Checks if the two tracks in the pair have the same mother.
93 // This can be known if MC info is present.
94 // If the mother label is the same, rhe PDG code of the mother is returned,
95 // otherwise the method returns 0.
96 //
97
98   // if MC info is not available, the pairs is not true by default
99   if (!fDaughter[0]->GetRefMC() || !fDaughter[1]->GetRefMC()) 
100   {
101     AliInfo("Cannot know if the pairs is true or not because MC Info is not present");
102     return 0;
103   }
104
105   // check that labels are the same
106   if (fDaughter[0]->GetParticle()->GetFirstMother() != fDaughter[1]->GetParticle()->GetFirstMother())
107     return 0;
108
109   // if we reach this point, the two tracks have the same mother
110   // let's check now the PDG code of this common mother
111   return TMath::Abs(fDaughter[0]->GetMotherPDG());
112 }
113
114 //_____________________________________________________________________________
115 void AliRsnMother::SetDaughters
116 (AliRsnDaughter *d0, Double_t mass0, AliRsnDaughter *d1, Double_t mass1)
117 {
118 //
119 // Sets the pair defined in this usind tso passed daughters and two masses
120 // which will be assigned to them, in order to recompute their 4-momenta
121 // and sum them into the datamembers of this object.
122 //
123
124   if (d0) fDaughter[0] = d0;
125   if (d1) fDaughter[1] = d1;
126   
127   if (!d0 || !d1) return;
128   
129   fDaughter[0]->SetMass(mass0);
130   fDaughter[1]->SetMass(mass1);
131   
132   fSum   = fDaughter[0]->P(kFALSE) + fDaughter[1]->P(kFALSE);
133   fSumMC = fDaughter[0]->P(kTRUE)  + fDaughter[1]->P(kTRUE);
134   
135   fRef  .SetXYZM(fSum  .X(), fSum  .Y(), fSum  .Z(), fDefaultMass);
136   fRefMC.SetXYZM(fSumMC.X(), fSumMC.Y(), fSumMC.Z(), fDefaultMass);
137 }
138
139 //_____________________________________________________________________________
140 void AliRsnMother::ResetPair()
141 {
142 //
143 // Resets the mother, nullifying all data members
144 //
145
146   Int_t i;
147   for (i = 0; i < 2; i++) fDaughter[i] = 0x0;
148   
149   fSum  .SetXYZM(0.0, 0.0, 0.0, 0.0);
150   fRef  .SetXYZM(0.0, 0.0, 0.0, 0.0);
151   fSumMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
152   fRefMC.SetXYZM(0.0, 0.0, 0.0, 0.0);
153 }
154
155 //_____________________________________________________________________________
156 void AliRsnMother::PrintInfo(const Option_t * /*option*/) const
157 {
158 //
159 // Print some info of the pair.
160 // The options are passed to the AliRsnDaughter::Print() method
161 //
162
163   AliInfo("======== BEGIN PAIR INFO ===========");
164   AliInfo("Track #1");
165   fDaughter[0]->Print();
166   AliInfo("Track #2");
167   fDaughter[1]->Print();
168   AliInfo("========= END PAIR INFO ===========");
169 }
170
171 //_____________________________________________________________________________
172 Bool_t AliRsnMother::CheckPair() const
173 {
174 //
175 // Checks that the pair is well initialized:
176 // - both daughters are good pointers
177 // - if MC is required, both daughters have a MC reference
178 //
179
180   if (!fDaughter[0] || !fDaughter[1]) 
181   {
182     AliError("One of the two tracks is NULL in this pair!");
183     return kFALSE;
184   }
185   
186   if (fUseMC)
187   {
188     if (fDaughter[0]->GetRefMC() == 0x0 || fDaughter[1]->GetRefMC() == 0x0)
189     {
190       AliError("Required MC info but not all MC refs are available");
191       return kFALSE;
192     }
193   }
194   
195   return kTRUE;
196 }
197
198 //_____________________________________________________________________________
199 Bool_t AliRsnMother::MatchesDef(AliRsnPairDef *def)
200 {
201 //
202 // Checks if the daughters, in any order, do match a given decay channel,
203 // using the specified identification method, which can be the 'true' one
204 // or the 'realistic' one only.
205 //
206
207   if (!def) return kFALSE;
208   if (!fDaughter[0]->GetRefMC()) return kFALSE;
209   if (!fDaughter[1]->GetRefMC()) return kFALSE;
210
211   Bool_t decayMatch = kFALSE;
212   Int_t  pdg[2], ref[2];
213   pdg[0] = fDaughter[0]->GetRefMC()->Particle()->GetPdgCode();
214   pdg[1] = fDaughter[1]->GetRefMC()->Particle()->GetPdgCode();
215   ref[0] = TMath::Abs(AliPID::ParticleCode(def->GetPID(0)));
216   ref[1] = TMath::Abs(AliPID::ParticleCode(def->GetPID(1)));
217
218   // check #1:
219   // if first member of pairDef has same sign as first member of this,
220   // daughter[0] perfect PID must match first member of pairDef
221   // daughter[1] perfect PID must march second member of pairDef
222   if (fDaughter[0]->IsSign(def->GetCharge(0)) && fDaughter[1]->IsSign(def->GetCharge(1))) 
223   {
224     decayMatch = (pdg[0] == ref[0] && pdg[1] == ref[1]);
225   }
226
227   // check #2:
228   // if first member of pairDef has same sign as second member of this,
229   // daughter[0] perfect PID must match second member of pairDef
230   // daughter[1] perfect PID must march first member of pairDef
231   if (fDaughter[1]->IsSign(def->GetCharge(0)) && fDaughter[0]->IsSign(def->GetCharge(1))) 
232   {
233     decayMatch = (pdg[0] == ref[1] && pdg[1] == ref[0]);
234   }
235
236   return (decayMatch && (CommonMother() == def->GetMotherPDG()));
237 }