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 fAssignedPID(AliRsnPID::kUnknown),
44 fRealisticPID(AliRsnPID::kUnknown),
48 // Default constructor.
49 // Initializes all data-members with meaningless values.
53 for (i = 0; i < AliRsnPID::kSpecies; i++)
65 //_____________________________________________________________________________
66 AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter ©) :
70 fCharge(copy.fCharge),
75 fNSigmaToVertex(copy.fNSigmaToVertex),
76 fITSnum(copy.fITSnum),
77 fTPCnum(copy.fTPCnum),
78 fAssignedPID(copy.fAssignedPID),
79 fRealisticPID(copy.fRealisticPID),
87 for (i = 0; i < AliRsnPID::kSpecies; i++)
94 fPIDWeight[i] = copy.fPIDWeight[i];
95 fPIDProb[i] = copy.fPIDProb[i];
98 // initialize particle object
99 // only if it is present in the template object
100 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
103 //_____________________________________________________________________________
104 AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter ©)
107 // Assignment operator.
108 // Works like the copy constructor and returns a reference
109 // to the initialized object for which it is called.
112 fIndex = copy.fIndex;
113 fLabel = copy.fLabel;
114 fCharge = copy.fCharge;
115 fFlags = copy.fFlags;
118 fNSigmaToVertex = copy.fNSigmaToVertex;
119 fITSnum = copy.fITSnum;
120 fTPCnum = copy.fTPCnum;
123 for (i = 0; i < AliRsnPID::kSpecies; i++)
130 fPIDWeight[i] = copy.fPIDWeight[i];
131 fPIDProb[i] = copy.fPIDProb[i];
135 fAssignedPID = copy.fAssignedPID;
136 fRealisticPID = copy.fRealisticPID;
138 // initialize particle object
139 // only if it is present in the template object;
140 // otherwise, it is just cleared and not replaced with anything
146 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
151 //_____________________________________________________________________________
152 AliRsnDaughter::~AliRsnDaughter()
165 //_____________________________________________________________________________
166 void AliRsnDaughter::RotateP(Double_t angle, Bool_t isDegrees)
169 // Rotate the transverse momentum by an angle (in DEGREES)
170 // around Z axis (does not change the Z component)
173 if (isDegrees) angle *= TMath::DegToRad();
175 Double_t s = TMath::Sin(angle);
176 Double_t c = TMath::Cos(angle);
178 fP[0] = c*xx - s*fP[1];
179 fP[1] = s*xx + c*fP[1];
182 //_____________________________________________________________________________
183 Double_t AliRsnDaughter::AngleTo(AliRsnDaughter *d, Bool_t outInDegrees)
186 // Compute angle between the vector momentum of this
187 // and the one of argument.
190 Double_t arg, dot, ptot2 = P2() * d->P2();
196 dot = Px()*d->Px() + Py()*d->Py() + Pz()*d->Pz();
197 arg = dot / TMath::Sqrt(ptot2);
198 if (arg > 1.0) arg = 1.0;
199 if (arg < -1.0) arg = -1.0;
200 if (outInDegrees) return TMath::ACos(arg) * TMath::RadToDeg();
201 else return TMath::ACos(arg);
205 //_____________________________________________________________________________
206 void AliRsnDaughter::RealisticPID()
209 // Assign realistic PID from largest probability
213 Double_t pmax = fPIDProb[0];
215 // search for maximum
216 for (i = 1; i < AliRsnPID::kSpecies; i++)
218 if (fPIDProb[i] > pmax)
225 fRealisticPID = (AliRsnPID::EType)imax;
228 //_____________________________________________________________________________
229 AliRsnPID::EType AliRsnDaughter::PIDType(Double_t &prob) const
232 // Return the PID type according to the selected method
233 // in the argument passed by reference, the probability is stored.
234 // It will be realistic for realistic PID and 1 for perfect PID.
240 AliWarning("Requested a PIDtype call in NoPID mode");
242 return AliRsnPID::kUnknown;
245 if (fMCInfo) return AliRsnPID::InternalType(fMCInfo->PDG());
246 else return AliRsnPID::kUnknown;
248 if (fRealisticPID >= 0 && fRealisticPID < AliRsnPID::kSpecies)
250 prob = fPIDProb[fRealisticPID];
251 return fRealisticPID;
256 return AliRsnPID::kUnknown;
261 //_____________________________________________________________________________
262 void AliRsnDaughter::Print(Option_t *option) const
265 // Prints the values of data members, using the options:
267 // - V --> DCA vertex
268 // - C --> electric charge
270 // - I --> identification (PID, probability and mass)
271 // - W --> PID weights
272 // - M --> Montecarlo (from AliRsnMCInfo)
273 // - L --> index & label
275 // - ALL --> All oprions switched on
277 // Index and label are printed by default.
283 if (opt.Contains("L") || opt.Contains("ALL"))
285 cout << ".......Index : " << fIndex << endl;
286 cout << ".......Label : " << fLabel << endl;
288 if (opt.Contains("P") || opt.Contains("ALL"))
290 cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
292 if (opt.Contains("A") || opt.Contains("ALL"))
294 cout << ".......Phi, Theta : " << Phi() << ' ' << Theta() << endl;
296 if (opt.Contains("V") || opt.Contains("ALL"))
298 cout << ".......Vx, Vy, Vz : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
300 if (opt.Contains("I") || opt.Contains("ALL"))
302 AliRsnPID::EType type;
304 type = PIDType(prob);
305 cout << ".......PID & prob : " << AliRsnPID::ParticleName(type) << ' ' << prob << endl;
307 if (opt.Contains("C") || opt.Contains("ALL"))
309 cout << ".......Charge : " << fCharge << endl;
311 if (opt.Contains("F") || opt.Contains("ALL"))
313 cout << ".......Flags : " << fFlags << endl;
315 if (opt.Contains("W") || opt.Contains("ALL"))
317 cout << ".......Weights : ";
319 for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[i] << ' ';
322 if (opt.Contains("M") || opt.Contains("ALL"))
326 cout << ".......PDG code : " << fMCInfo->PDG() << endl;
327 cout << ".......Mother (label) : " << fMCInfo->Mother() << endl;
328 cout << ".......Mother (PDG code): " << fMCInfo->MotherPDG() << endl;
332 cout << ".......MC info not present" << endl;
337 //_____________________________________________________________________________
338 void AliRsnDaughter::InitMCInfo()
341 // Initializes the particle object with default constructor.
344 fMCInfo = new AliRsnMCInfo;
347 //_____________________________________________________________________________
348 Bool_t AliRsnDaughter::InitMCInfo(TParticle *particle)
351 // Copies data from an MC particle into the object which
352 // contains all MC details taken from kinematics info.
353 // If requested by second argument, momentum and vertex
354 // of the Particle are copied into the 'fP' and 'fV'
355 // data members, to simulate a perfect reconstruction.
356 // If something goes wrong, returns kFALSE,
357 // otherwise returns kTRUE.
360 // retrieve the TParticle object pointed by this MC track
363 AliError("Passed NULL particle object");
367 // initialize object if not initialized yet
368 if (fMCInfo) delete fMCInfo;
369 fMCInfo = new AliRsnMCInfo;
370 fMCInfo->Adopt(particle);
375 //_____________________________________________________________________________
376 Int_t AliRsnDaughter::Compare(const TObject* obj) const
379 // Compare two tracks with respect to their transverse momentum.
380 // Citation from ROOT reference:
381 // "Must return -1 if this is smaller than obj, 0 if objects are equal
382 // and 1 if this is larger than obj".
385 AliRsnDaughter *that = (AliRsnDaughter*)obj;
386 if (Pt() < that->Pt()) return 1;
387 else if (Pt() > that->Pt()) return -1;