1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //=========================================================================
17 // Class AliRsnDaughter
20 // Light-weight 'track' object into an internal format used
21 // for further steps of resonance analysis.
22 // Provides converters from all kinds of input track type
24 // Contains also a facility to compute invariant mass of a pair.
26 // author: A. Pulvirenti --- email: alberto.pulvirenti@ct.infn.it
27 //=========================================================================
29 #include <Riostream.h>
31 #include <TParticle.h>
35 #include "AliESDtrack.h"
36 #include "AliAODTrack.h"
37 #include "AliMCParticle.h"
39 #include "AliRsnPID.h"
40 #include "AliRsnMCInfo.h"
41 #include "AliRsnDaughter.h"
43 ClassImp(AliRsnDaughter)
45 //_____________________________________________________________________________
46 AliRsnDaughter::AliRsnDaughter() :
52 fPIDType(AliRsnPID::kUnknown),
57 // Default constructor.
58 // Initializes all data-members with meaningless values.
62 for (i = 0; i < AliRsnPID::kSpecies; i++) {
72 //_____________________________________________________________________________
73 AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter ©) :
77 fCharge(copy.fCharge),
79 fPIDType(copy.fPIDType),
88 for (i = 0; i < AliRsnPID::kSpecies; i++) {
93 fPIDWeight[i] = copy.fPIDWeight[i];
94 fPIDProb[i] = copy.fPIDProb[i];
97 // initialize particle object
98 // only if it is present in the template object
99 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
102 //_____________________________________________________________________________
103 AliRsnDaughter::AliRsnDaughter(AliESDtrack *track, Bool_t useTPC) :
109 fPIDType(AliRsnPID::kUnknown),
114 // Constructor to get data from an ESD track.
118 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
119 Adopt(track, useTPC);
122 //_____________________________________________________________________________
123 AliRsnDaughter::AliRsnDaughter(AliAODTrack *track) :
129 fPIDType(AliRsnPID::kUnknown),
134 // Constructor to get data from an AOD track.
138 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
142 //_____________________________________________________________________________
143 AliRsnDaughter::AliRsnDaughter(AliMCParticle *track) :
149 fPIDType(AliRsnPID::kUnknown),
154 // Constructor to get data from an MC track.
158 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
162 //_____________________________________________________________________________
163 AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter ©)
166 // Assignment operator.
167 // Works like the copy constructor and returns a reference
168 // to the initialized object for which it is called.
171 fIndex = copy.fIndex;
172 fLabel = copy.fLabel;
173 fCharge = copy.fCharge;
174 fFlags = copy.fFlags;
177 for (i = 0; i < AliRsnPID::kSpecies; i++) {
182 fPIDWeight[i] = copy.fPIDWeight[i];
183 fPIDProb[i] = copy.fPIDProb[i];
186 fPIDType = copy.fPIDType;
189 // initialize particle object
190 // only if it is present in the template object;
191 // otherwise, it is just cleared and not replaced with anything
196 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
201 //_____________________________________________________________________________
202 AliRsnDaughter::~AliRsnDaughter()
214 //_____________________________________________________________________________
215 void AliRsnDaughter::SetPIDWeight(Int_t i, Double_t value)
218 // I the argument 'i' is in the correct range,
219 // sets the i-th PID weight to 'value'
222 if (i >= 0 && i < AliRsnPID::kSpecies) fPIDWeight[i] = value;
224 AliError(Form("Cannot set a weight related to slot %d", i));
228 //_____________________________________________________________________________
229 void AliRsnDaughter::SetPIDProb(Int_t i, Double_t value)
232 // I the argument 'i' is in the correct range,
233 // sets the i-th PID probability to 'value'
236 if (i >= 0 && i < AliRsnPID::kSpecies) fPIDProb[i] = value;
238 AliError(Form("Cannot set a weight related to slot %d", i));
242 //_____________________________________________________________________________
243 void AliRsnDaughter::SetPIDWeights(const Double_t *pid)
246 // Sets ALL PID weights at once.
247 // The passed array is supposed to have at least as many
248 // slots as the number of allowed particle species.
252 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDWeight[i] = pid[i];
256 //_____________________________________________________________________________
257 Bool_t AliRsnDaughter::Adopt(AliESDtrack* esdTrack, Bool_t useTPCInnerParam)
260 // Copies data from an AliESDtrack into "this":
263 // - point of closest approach to primary vertex
265 // In case of errors returns kFALSE, otherwise kTRUE.
269 AliError("Passed NULL object: nothing done");
273 // copy momentum and vertex
274 if (!useTPCInnerParam) {
275 esdTrack->GetPxPyPz(fP);
276 esdTrack->GetXYZ(fV);
279 if (!esdTrack->GetTPCInnerParam()) return kFALSE;
280 esdTrack->GetTPCInnerParam()->GetPxPyPz(fP);
281 esdTrack->GetTPCInnerParam()->GetXYZ(fV);
287 if (!useTPCInnerParam) {
288 esdTrack->GetESDpid(pid);
291 esdTrack->GetTPCpid(pid);
293 for (i = 0; i < 5; i++) fPIDWeight[i] = pid[i];
296 fFlags = esdTrack->GetStatus();
299 fCharge = (Short_t)esdTrack->Charge();
305 //_____________________________________________________________________________
306 Bool_t AliRsnDaughter::Adopt(AliAODTrack* aodTrack)
309 // Copies data from an AliAODtrack into "this":
312 // - point of closest approach to primary vertex
314 // In case of errors returns kFALSE, otherwise kTRUE.
318 AliError("Passed NULL object: nothing done");
322 // copy momentum and vertex
323 fP[0] = aodTrack->Px();
324 fP[1] = aodTrack->Py();
325 fP[2] = aodTrack->Pz();
326 fV[0] = aodTrack->Xv();
327 fV[1] = aodTrack->Yv();
328 fV[2] = aodTrack->Zv();
332 for (i = 0; i < 5; i++) fPIDWeight[i] = aodTrack->PID()[i];
335 fCharge = aodTrack->Charge();
341 //_____________________________________________________________________________
342 Bool_t AliRsnDaughter::Adopt(AliMCParticle *mcParticle)
345 // Copies data from a MCParticle into "this":
348 // - point of closest approach to primary vertex
352 // In case of errors returns kFALSE, otherwise kTRUE.
356 AliError("Passed NULL object: nothing done");
360 // retrieve the TParticle object from the argument
361 TParticle *particle = mcParticle->Particle();
363 AliError("AliMCParticle::Particle() returned NULL");
367 // copy momentum and vertex
368 fP[0] = particle->Px();
369 fP[1] = particle->Py();
370 fP[2] = particle->Pz();
371 fV[0] = particle->Vx();
372 fV[1] = particle->Vy();
373 fV[2] = particle->Vz();
375 // recognize charge sign from PDG code sign
376 Int_t pdg = particle->GetPdgCode();
377 Int_t absPDG = TMath::Abs(pdg);
379 if (pdg > 0) fCharge = -1; else fCharge = 1;
381 else if (absPDG < 3000) {
382 if (pdg > 0) fCharge = 1; else fCharge = -1;
389 // identify track perfectly using PDG code
390 fPIDType = AliRsnPID::InternalType(pdg);
391 fMass = AliRsnPID::ParticleMass(fPIDType);
393 // flags and PID weights make no sense with MC tracks
395 for (pdg = 0; pdg < AliRsnPID::kSpecies; pdg++) fPIDWeight[pdg] = 0.0;
396 fPIDWeight[fPIDType] = 1.0;
398 // copy other MC info (mother PDG code cannot be retrieved here)
399 InitMCInfo(particle);
404 //_____________________________________________________________________________
405 void AliRsnDaughter::Print(Option_t *option) const
408 // Prints the values of data members, using the options:
410 // - V --> DCA vertex
411 // - C --> electric charge
413 // - I --> identification (PID, probability and mass)
414 // - W --> PID weights
415 // - M --> Montecarlo (from AliRsnMCInfo)
416 // - ALL --> All oprions switched on
418 // Index and label are printed by default.
424 cout << ".......Index : " << fIndex << endl;
425 cout << ".......Label : " << fLabel << endl;
427 if (opt.Contains("P") || opt.Contains("ALL")) {
428 cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
430 if (opt.Contains("V") || opt.Contains("ALL")) {
431 cout << ".......Vx, Vy, Vz : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
433 if (opt.Contains("C") || opt.Contains("ALL")) {
434 cout << ".......Charge : " << fCharge << endl;
436 if (opt.Contains("F") || opt.Contains("ALL")) {
437 cout << ".......Flags : " << fFlags << endl;
439 if (opt.Contains("I") || opt.Contains("ALL")) {
440 cout << ".......PID : " << AliRsnPID::ParticleName(fPIDType) << endl;
441 if (fPIDType > 0 && fPIDType < AliRsnPID::kSpecies) {
442 cout << ".......PID probability : " << fPIDProb[fPIDType] << endl;
444 cout << ".......Mass : " << fMass << endl;
446 if (opt.Contains("W") || opt.Contains("ALL")) {
447 cout << ".......Weights : ";
449 for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[i] << ' ';
452 if (opt.Contains("M") || opt.Contains("ALL")) {
454 cout << ".......PDG code : " << fMCInfo->PDG() << endl;
455 cout << ".......Mother (label) : " << fMCInfo->Mother() << endl;
456 cout << ".......Mother (PDG code): " << fMCInfo->MotherPDG() << endl;
459 cout << ".......MC info not present" << endl;
464 //_____________________________________________________________________________
465 void AliRsnDaughter::InitMCInfo()
468 // Initializes the particle object with default constructor.
471 fMCInfo = new AliRsnMCInfo;
474 //_____________________________________________________________________________
475 Bool_t AliRsnDaughter::InitMCInfo(TParticle *particle)
478 // Copies data from an MC particle into the object which
479 // contains all MC details taken from kinematics info.
480 // If requested by second argument, momentum and vertex
481 // of the Particle are copied into the 'fP' and 'fV'
482 // data members, to simulate a perfect reconstruction.
483 // If something goes wrong, returns kFALSE,
484 // otherwise returns kTRUE.
487 // retrieve the TParticle object pointed by this MC track
489 AliError("Passed NULL particle object");
493 // initialize object if not initialized yet
494 if (fMCInfo) delete fMCInfo;
495 fMCInfo = new AliRsnMCInfo;
496 fMCInfo->Adopt(particle);
501 //_____________________________________________________________________________
502 Bool_t AliRsnDaughter::InitMCInfo(AliMCParticle *mcParticle)
505 // Copies data from an MC particle into the object which
506 // contains all MC details taken from kinematics info.
507 // If requested by second argument, momentum and vertex
508 // of the Particle are copied into the 'fP' and 'fV'
509 // data members, to simulate a perfect reconstruction.
510 // If something goes wrong, returns kFALSE,
511 // otherwise returns kTRUE.
514 // retrieve the TParticle object pointed by this MC track
515 TParticle *particle = mcParticle->Particle();
516 return InitMCInfo(particle);