2 // Class AliRsnDaughter
4 // Light-weight AOD object which contains all required track details
5 // which are used for resonance analysis.
6 // Provides converters from all kinds of input track type: ESD, AOD and MC.
8 // authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
9 // M. Vala (martin.vala@cern.ch)
12 #include <Riostream.h>
14 #include <TParticle.h>
18 #include "AliESDtrack.h"
19 #include "AliAODTrack.h"
20 #include "AliMCParticle.h"
22 #include "AliRsnPIDDefESD.h"
23 #include "AliRsnMCInfo.h"
24 #include "AliRsnDaughter.h"
26 ClassImp(AliRsnDaughter)
28 AliRsnDaughter::EPIDMethod AliRsnDaughter::fgPIDMethod = AliRsnDaughter::kRealistic;
30 //_____________________________________________________________________________
31 AliRsnDaughter::AliRsnDaughter() :
40 fNSigmaToVertex(-1.0),
43 fRealisticPID(AliRsnPID::kUnknown),
47 // Default constructor.
48 // Initializes all data-members with meaningless values.
52 for (i = 0; i < AliRsnPID::kSpecies; i++)
64 //_____________________________________________________________________________
65 AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter ©) :
69 fCharge(copy.fCharge),
74 fNSigmaToVertex(copy.fNSigmaToVertex),
75 fITSnum(copy.fITSnum),
76 fTPCnum(copy.fTPCnum),
77 fRealisticPID(copy.fRealisticPID),
85 for (i = 0; i < AliRsnPID::kSpecies; i++)
92 fPIDWeight[i] = copy.fPIDWeight[i];
93 fPIDProb[i] = copy.fPIDProb[i];
96 // initialize particle object
97 // only if it is present in the template object
98 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
101 //_____________________________________________________________________________
102 AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter ©)
105 // Assignment operator.
106 // Works like the copy constructor and returns a reference
107 // to the initialized object for which it is called.
110 fIndex = copy.fIndex;
111 fLabel = copy.fLabel;
112 fCharge = copy.fCharge;
113 fFlags = copy.fFlags;
116 fNSigmaToVertex = copy.fNSigmaToVertex;
117 fITSnum = copy.fITSnum;
118 fTPCnum = copy.fTPCnum;
121 for (i = 0; i < AliRsnPID::kSpecies; i++)
128 fPIDWeight[i] = copy.fPIDWeight[i];
129 fPIDProb[i] = copy.fPIDProb[i];
133 fRealisticPID = copy.fRealisticPID;
135 // initialize particle object
136 // only if it is present in the template object;
137 // otherwise, it is just cleared and not replaced with anything
143 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
148 //_____________________________________________________________________________
149 AliRsnDaughter::~AliRsnDaughter()
162 //_____________________________________________________________________________
163 void AliRsnDaughter::RotateP(Double_t angle, Bool_t isDegrees)
166 // Rotate the transverse momentum by an angle (in DEGREES)
167 // around Z axis (does not change the Z component)
170 if (isDegrees) angle *= TMath::DegToRad();
172 Double_t s = TMath::Sin(angle);
173 Double_t c = TMath::Cos(angle);
175 fP[0] = c*xx - s*fP[1];
176 fP[1] = s*xx + c*fP[1];
179 //_____________________________________________________________________________
180 Double_t AliRsnDaughter::AngleTo(AliRsnDaughter *d, Bool_t outInDegrees)
183 // Compute angle between the vector momentum of this
184 // and the one of argument.
187 Double_t arg, dot, ptot2 = P2() * d->P2();
193 dot = Px()*d->Px() + Py()*d->Py() + Pz()*d->Pz();
194 arg = dot / TMath::Sqrt(ptot2);
195 if (arg > 1.0) arg = 1.0;
196 if (arg < -1.0) arg = -1.0;
197 if (outInDegrees) return TMath::ACos(arg) * TMath::RadToDeg();
198 else return TMath::ACos(arg);
202 //_____________________________________________________________________________
203 void AliRsnDaughter::AssignRealisticPID()
206 // Assign realistic PID from largest probability
210 Double_t pmax = fPIDProb[0];
212 // search for maximum
213 for (i = 1; i < AliRsnPID::kSpecies; i++)
215 if (fPIDProb[i] > pmax)
222 fRealisticPID = (AliRsnPID::EType)imax;
225 //_____________________________________________________________________________
226 AliRsnPID::EType AliRsnDaughter::PIDType(Double_t &prob) const
229 // Return the PID type according to the selected method
230 // in the argument passed by reference, the probability is stored.
231 // It will be realistic for realistic PID and 1 for perfect PID.
237 AliWarning("Requested a PIDtype call in NoPID mode");
239 return AliRsnPID::kUnknown;
242 if (fMCInfo) return AliRsnPID::InternalType(fMCInfo->PDG());
243 else return AliRsnPID::kUnknown;
245 if (fRealisticPID >= 0 && fRealisticPID < AliRsnPID::kSpecies)
247 prob = fPIDProb[fRealisticPID];
248 return fRealisticPID;
253 return AliRsnPID::kUnknown;
258 //_____________________________________________________________________________
259 void AliRsnDaughter::Print(Option_t *option) const
262 // Prints the values of data members, using the options:
264 // - V --> DCA vertex
265 // - C --> electric charge
267 // - I --> identification (PID, probability and mass)
268 // - W --> PID weights
269 // - M --> Montecarlo (from AliRsnMCInfo)
270 // - L --> index & label
272 // - ALL --> All oprions switched on
274 // Index and label are printed by default.
280 if (opt.Contains("L") || opt.Contains("ALL"))
282 cout << ".......Index : " << fIndex << endl;
283 cout << ".......Label : " << fLabel << endl;
285 if (opt.Contains("P") || opt.Contains("ALL"))
287 cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
289 if (opt.Contains("A") || opt.Contains("ALL"))
291 cout << ".......Phi, Theta : " << Phi() << ' ' << Theta() << endl;
293 if (opt.Contains("V") || opt.Contains("ALL"))
295 cout << ".......Vx, Vy, Vz : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
297 if (opt.Contains("I") || opt.Contains("ALL"))
299 AliRsnPID::EType type;
301 type = PIDType(prob);
302 cout << ".......PID & prob : " << AliRsnPID::ParticleName(type) << ' ' << prob << endl;
304 if (opt.Contains("C") || opt.Contains("ALL"))
306 cout << ".......Charge : " << fCharge << endl;
308 if (opt.Contains("F") || opt.Contains("ALL"))
310 cout << ".......Flags : " << fFlags << endl;
312 if (opt.Contains("W") || opt.Contains("ALL"))
314 cout << ".......Weights : ";
316 for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[i] << ' ';
319 if (opt.Contains("M") || opt.Contains("ALL"))
323 cout << ".......PDG code : " << fMCInfo->PDG() << endl;
324 cout << ".......Mother (label) : " << fMCInfo->Mother() << endl;
325 cout << ".......Mother (PDG code): " << fMCInfo->MotherPDG() << endl;
329 cout << ".......MC info not present" << endl;
334 //_____________________________________________________________________________
335 void AliRsnDaughter::InitMCInfo()
338 // Initializes the particle object with default constructor.
341 fMCInfo = new AliRsnMCInfo;
344 //_____________________________________________________________________________
345 Bool_t AliRsnDaughter::InitMCInfo(TParticle *particle)
348 // Copies data from an MC particle into the object which
349 // contains all MC details taken from kinematics info.
350 // If requested by second argument, momentum and vertex
351 // of the Particle are copied into the 'fP' and 'fV'
352 // data members, to simulate a perfect reconstruction.
353 // If something goes wrong, returns kFALSE,
354 // otherwise returns kTRUE.
357 // retrieve the TParticle object pointed by this MC track
360 AliError("Passed NULL particle object");
364 // initialize object if not initialized yet
365 if (fMCInfo) delete fMCInfo;
366 fMCInfo = new AliRsnMCInfo;
367 fMCInfo->Adopt(particle);
372 //_____________________________________________________________________________
373 Int_t AliRsnDaughter::Compare(const TObject* obj) const
376 // Compare two tracks with respect to their transverse momentum.
377 // Citation from ROOT reference:
378 // "Must return -1 if this is smaller than obj, 0 if objects are equal
379 // and 1 if this is larger than obj".
382 AliRsnDaughter *that = (AliRsnDaughter*)obj;
383 if (Pt() < that->Pt()) return 1;
384 else if (Pt() > that->Pt()) return -1;