]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnDaughter.cxx
few modifications on package, waiting for AOD compliance corrections
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.cxx
CommitLineData
e2bafbbc 1//
06351446 2// Class AliRsnDaughter
3//
e0baff8c 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.
06351446 7//
e0baff8c 8// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
9// M. Vala (martin.vala@cern.ch)
e2bafbbc 10//
7c2974c8 11
12#include <Riostream.h>
a62a2d82 13
a62a2d82 14#include <TParticle.h>
4c2fda1e 15#include <TString.h>
a62a2d82 16
c37c6481 17#include "AliLog.h"
a62a2d82 18#include "AliESDtrack.h"
7c2974c8 19#include "AliAODTrack.h"
20#include "AliMCParticle.h"
21
61f55b30 22#include "AliRsnPIDDefESD.h"
06351446 23#include "AliRsnMCInfo.h"
a62a2d82 24#include "AliRsnDaughter.h"
25
26ClassImp(AliRsnDaughter)
27
61f55b30 28AliRsnDaughter::EPIDMethod AliRsnDaughter::fgPIDMethod = AliRsnDaughter::kRealistic;
e2bafbbc 29
7c2974c8 30//_____________________________________________________________________________
c37c6481 31AliRsnDaughter::AliRsnDaughter() :
61f55b30 32 AliVParticle(),
33 fIndex(-1),
34 fLabel(-1),
35 fCharge(0),
36 fFlags(0),
37 fKink(0),
38 fMass(0.0),
39 fChi2(0.0),
40 fNSigmaToVertex(-1.0),
41 fITSnum(0),
42 fTPCnum(0),
43 fRealisticPID(AliRsnPID::kUnknown),
44 fMCInfo(0x0)
2f769150 45{
06351446 46//
a62a2d82 47// Default constructor.
7c2974c8 48// Initializes all data-members with meaningless values.
06351446 49//
7c2974c8 50
aec0ec32 51 Int_t i;
52 for (i = 0; i < AliRsnPID::kSpecies; i++)
53 {
54 if (i < 3)
55 {
56 fP[i] = 0.0;
57 fV[i] = 0.0;
7c2974c8 58 }
aec0ec32 59 fPIDWeight[i] = 0.0;
60 fPIDProb[i] = 0.0;
61 }
7c2974c8 62}
63
64//_____________________________________________________________________________
65AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) :
61f55b30 66 AliVParticle(copy),
67 fIndex(copy.fIndex),
68 fLabel(copy.fLabel),
69 fCharge(copy.fCharge),
70 fFlags(copy.fFlags),
71 fKink(copy.fKink),
72 fMass(copy.fMass),
73 fChi2(copy.fChi2),
74 fNSigmaToVertex(copy.fNSigmaToVertex),
75 fITSnum(copy.fITSnum),
76 fTPCnum(copy.fTPCnum),
77 fRealisticPID(copy.fRealisticPID),
78 fMCInfo(0x0)
7c2974c8 79{
06351446 80//
7c2974c8 81// Copy constructor.
06351446 82//
7c2974c8 83
aec0ec32 84 Int_t i;
85 for (i = 0; i < AliRsnPID::kSpecies; i++)
86 {
87 if (i < 3)
88 {
89 fP[i] = copy.fP[i];
90 fV[i] = copy.fV[i];
7c2974c8 91 }
aec0ec32 92 fPIDWeight[i] = copy.fPIDWeight[i];
93 fPIDProb[i] = copy.fPIDProb[i];
94 }
7c2974c8 95
aec0ec32 96 // initialize particle object
97 // only if it is present in the template object
98 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
7c2974c8 99}
100
7c2974c8 101//_____________________________________________________________________________
102AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter &copy)
103{
06351446 104//
7c2974c8 105// Assignment operator.
106// Works like the copy constructor and returns a reference
107// to the initialized object for which it is called.
06351446 108//
109
aec0ec32 110 fIndex = copy.fIndex;
111 fLabel = copy.fLabel;
112 fCharge = copy.fCharge;
113 fFlags = copy.fFlags;
e0baff8c 114 fKink = copy.fKink;
115 fChi2 = copy.fChi2;
116 fNSigmaToVertex = copy.fNSigmaToVertex;
117 fITSnum = copy.fITSnum;
118 fTPCnum = copy.fTPCnum;
06351446 119
aec0ec32 120 Int_t i;
121 for (i = 0; i < AliRsnPID::kSpecies; i++)
122 {
123 if (i < 3)
124 {
125 fP[i] = copy.fP[i];
126 fV[i] = copy.fV[i];
7c2974c8 127 }
aec0ec32 128 fPIDWeight[i] = copy.fPIDWeight[i];
129 fPIDProb[i] = copy.fPIDProb[i];
130 }
131
132 fMass = copy.fMass;
133 fRealisticPID = copy.fRealisticPID;
134
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
138 if (fMCInfo)
139 {
140 delete fMCInfo;
141 fMCInfo = 0x0;
142 }
143 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
144
145 return (*this);
7c2974c8 146}
147
148//_____________________________________________________________________________
149AliRsnDaughter::~AliRsnDaughter()
150{
06351446 151//
7c2974c8 152// Destructor
06351446 153//
7c2974c8 154
aec0ec32 155 if (fMCInfo)
156 {
157 delete fMCInfo;
158 fMCInfo = 0;
159 }
7c2974c8 160}
161
e0baff8c 162//_____________________________________________________________________________
61f55b30 163void AliRsnDaughter::RotateP(Double_t angle, Bool_t isDegrees)
e0baff8c 164{
165//
61f55b30 166// Rotate the transverse momentum by an angle (in DEGREES)
167// around Z axis (does not change the Z component)
e0baff8c 168//
169
61f55b30 170 if (isDegrees) angle *= TMath::DegToRad();
171
e0baff8c 172 Double_t s = TMath::Sin(angle);
173 Double_t c = TMath::Cos(angle);
174 Double_t xx = fP[0];
175 fP[0] = c*xx - s*fP[1];
176 fP[1] = s*xx + c*fP[1];
177}
178
78b94cbd 179//_____________________________________________________________________________
61f55b30 180Double_t AliRsnDaughter::AngleTo(AliRsnDaughter *d, Bool_t outInDegrees)
78b94cbd 181{
182//
61f55b30 183// Compute angle between the vector momentum of this
78b94cbd 184// and the one of argument.
185//
186
187 Double_t arg, dot, ptot2 = P2() * d->P2();
61f55b30 188
78b94cbd 189 if(ptot2 <= 0) {
190 return 0.0;
191 }
192 else {
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;
61f55b30 197 if (outInDegrees) return TMath::ACos(arg) * TMath::RadToDeg();
198 else return TMath::ACos(arg);
aec0ec32 199 }
7c2974c8 200}
201
06351446 202//_____________________________________________________________________________
e343e521 203void AliRsnDaughter::RealisticPID()
06351446 204{
205//
e2bafbbc 206// Assign realistic PID from largest probability
06351446 207//
208
aec0ec32 209 Int_t i, imax = 0;
210 Double_t pmax = fPIDProb[0];
211
212 // search for maximum
213 for (i = 1; i < AliRsnPID::kSpecies; i++)
214 {
215 if (fPIDProb[i] > pmax)
216 {
217 imax = i;
218 pmax = fPIDProb[i];
06351446 219 }
aec0ec32 220 }
221
222 fRealisticPID = (AliRsnPID::EType)imax;
06351446 223}
7c2974c8 224
225//_____________________________________________________________________________
aec0ec32 226AliRsnPID::EType AliRsnDaughter::PIDType(Double_t &prob) const
7c2974c8 227{
06351446 228//
e2bafbbc 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.
232//
233
aec0ec32 234 switch (fgPIDMethod)
235 {
236 case kNoPID:
237 AliWarning("Requested a PIDtype call in NoPID mode");
61f55b30 238 prob = 1.0;
aec0ec32 239 return AliRsnPID::kUnknown;
240 case kPerfect:
61f55b30 241 prob = 1.0;
aec0ec32 242 if (fMCInfo) return AliRsnPID::InternalType(fMCInfo->PDG());
243 else return AliRsnPID::kUnknown;
244 default:
61f55b30 245 if (fRealisticPID >= 0 && fRealisticPID < AliRsnPID::kSpecies)
aec0ec32 246 {
247 prob = fPIDProb[fRealisticPID];
248 return fRealisticPID;
249 }
250 else
251 {
252 prob = 1.0;
253 return AliRsnPID::kUnknown;
254 }
255 }
e2bafbbc 256}
257
7c2974c8 258//_____________________________________________________________________________
4c2fda1e 259void AliRsnDaughter::Print(Option_t *option) const
260{
06351446 261//
7c2974c8 262// Prints the values of data members, using the options:
263// - P --> momentum
264// - V --> DCA vertex
265// - C --> electric charge
266// - F --> flags
267// - I --> identification (PID, probability and mass)
268// - W --> PID weights
06351446 269// - M --> Montecarlo (from AliRsnMCInfo)
e2bafbbc 270// - L --> index & label
0ef90328 271// - A --> angles
7c2974c8 272// - ALL --> All oprions switched on
4c2fda1e 273//
7c2974c8 274// Index and label are printed by default.
06351446 275//
4c2fda1e 276
aec0ec32 277 TString opt(option);
278 opt.ToUpper();
279
280 if (opt.Contains("L") || opt.Contains("ALL"))
281 {
282 cout << ".......Index : " << fIndex << endl;
283 cout << ".......Label : " << fLabel << endl;
284 }
285 if (opt.Contains("P") || opt.Contains("ALL"))
286 {
287 cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
288 }
0ef90328 289 if (opt.Contains("A") || opt.Contains("ALL"))
290 {
291 cout << ".......Phi, Theta : " << Phi() << ' ' << Theta() << endl;
292 }
aec0ec32 293 if (opt.Contains("V") || opt.Contains("ALL"))
294 {
295 cout << ".......Vx, Vy, Vz : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
296 }
297 if (opt.Contains("I") || opt.Contains("ALL"))
298 {
299 AliRsnPID::EType type;
300 Double_t prob;
301 type = PIDType(prob);
302 cout << ".......PID & prob : " << AliRsnPID::ParticleName(type) << ' ' << prob << endl;
303 }
304 if (opt.Contains("C") || opt.Contains("ALL"))
305 {
306 cout << ".......Charge : " << fCharge << endl;
307 }
308 if (opt.Contains("F") || opt.Contains("ALL"))
309 {
310 cout << ".......Flags : " << fFlags << endl;
311 }
312 if (opt.Contains("W") || opt.Contains("ALL"))
313 {
314 cout << ".......Weights : ";
315 Int_t i;
316 for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[i] << ' ';
317 cout << endl;
318 }
319 if (opt.Contains("M") || opt.Contains("ALL"))
320 {
321 if (fMCInfo)
322 {
323 cout << ".......PDG code : " << fMCInfo->PDG() << endl;
324 cout << ".......Mother (label) : " << fMCInfo->Mother() << endl;
325 cout << ".......Mother (PDG code): " << fMCInfo->MotherPDG() << endl;
7c2974c8 326 }
aec0ec32 327 else
328 {
329 cout << ".......MC info not present" << endl;
7c2974c8 330 }
aec0ec32 331 }
4c2fda1e 332}
7c2974c8 333
7c2974c8 334//_____________________________________________________________________________
06351446 335void AliRsnDaughter::InitMCInfo()
2f769150 336{
06351446 337//
7c2974c8 338// Initializes the particle object with default constructor.
06351446 339//
7c2974c8 340
aec0ec32 341 fMCInfo = new AliRsnMCInfo;
7c2974c8 342}
343
344//_____________________________________________________________________________
06351446 345Bool_t AliRsnDaughter::InitMCInfo(TParticle *particle)
7c2974c8 346{
06351446 347//
7c2974c8 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.
06351446 353// If something goes wrong, returns kFALSE,
7c2974c8 354// otherwise returns kTRUE.
06351446 355//
7c2974c8 356
aec0ec32 357 // retrieve the TParticle object pointed by this MC track
358 if (!particle)
359 {
360 AliError("Passed NULL particle object");
361 return kFALSE;
362 }
06351446 363
aec0ec32 364 // initialize object if not initialized yet
365 if (fMCInfo) delete fMCInfo;
366 fMCInfo = new AliRsnMCInfo;
367 fMCInfo->Adopt(particle);
7c2974c8 368
aec0ec32 369 return kTRUE;
7c2974c8 370}
371
e2bafbbc 372//_____________________________________________________________________________
373Int_t AliRsnDaughter::Compare(const TObject* obj) const
374{
375//
376// Compare two tracks with respect to their transverse momentum.
aec0ec32 377// Citation from ROOT reference:
378// "Must return -1 if this is smaller than obj, 0 if objects are equal
e2bafbbc 379// and 1 if this is larger than obj".
380//
381
aec0ec32 382 AliRsnDaughter *that = (AliRsnDaughter*)obj;
383 if (Pt() < that->Pt()) return 1;
384 else if (Pt() > that->Pt()) return -1;
385 else return 0;
e2bafbbc 386}