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 // *** AliRsnDaughter ****
18 // ***********************
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
28 #include <Riostream.h>
30 #include <TParticle.h>
34 #include "AliESDtrack.h"
35 #include "AliAODTrack.h"
36 #include "AliMCParticle.h"
38 #include "AliRsnPID.h"
39 #include "AliRsnParticle.h"
40 #include "AliRsnDaughter.h"
42 ClassImp(AliRsnDaughter)
44 //_____________________________________________________________________________
45 AliRsnDaughter::AliRsnDaughter() :
51 fPIDType(AliRsnPID::kUnknown),
56 //=========================================================
57 // Default constructor.
58 // Initializes all data-members with meaningless values.
59 //=========================================================
62 for (i = 0; i < AliRsnPID::kSpecies; i++) {
71 //_____________________________________________________________________________
72 AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter ©) :
76 fCharge(copy.fCharge),
78 fPIDType(copy.fPIDType),
79 fPIDProb(copy.fPIDProb),
83 //=========================================================
85 //=========================================================
88 for (i = 0; i < AliRsnPID::kSpecies; i++) {
93 fPIDWeight[i] = copy.fPIDWeight[i];
96 // initialize particle object
97 // only if it is present in the template object
98 if (copy.fParticle) fParticle = new AliRsnParticle(*(copy.fParticle));
101 //_____________________________________________________________________________
102 AliRsnDaughter::AliRsnDaughter(AliESDtrack *track) :
108 fPIDType(AliRsnPID::kUnknown),
113 //=========================================================
114 // Constructor to get data from an ESD track.
115 //=========================================================
120 //_____________________________________________________________________________
121 AliRsnDaughter::AliRsnDaughter(AliAODTrack *track) :
127 fPIDType(AliRsnPID::kUnknown),
132 //=========================================================
133 // Constructor to get data from an AOD track.
134 //=========================================================
139 //_____________________________________________________________________________
140 AliRsnDaughter::AliRsnDaughter(AliMCParticle *track) :
146 fPIDType(AliRsnPID::kUnknown),
151 //=========================================================
152 // Constructor to get data from an MC track.
153 //=========================================================
158 //_____________________________________________________________________________
159 AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter ©)
161 //=========================================================
162 // Assignment operator.
163 // Works like the copy constructor and returns a reference
164 // to the initialized object for which it is called.
165 //=========================================================
167 fIndex = copy.fIndex;
168 fLabel = copy.fLabel;
169 fCharge = copy.fCharge;
170 fFlags = copy.fFlags;
173 for (i = 0; i < AliRsnPID::kSpecies; i++) {
178 fPIDWeight[i] = copy.fPIDWeight[i];
181 fPIDType = copy.fPIDType;
182 fPIDProb = copy.fPIDProb;
185 // initialize particle object
186 // only if it is present in the template object;
187 // otherwise, it is just cleared and not replaced with anything
192 if (copy.fParticle) fParticle = new AliRsnParticle(*(copy.fParticle));
197 //_____________________________________________________________________________
198 AliRsnDaughter::~AliRsnDaughter()
200 //=========================================================
202 //=========================================================
210 //_____________________________________________________________________________
211 void AliRsnDaughter::SetPIDWeight(Int_t i, Double_t value)
213 //=========================================================
214 // I the argument 'i' is in the correct range,
215 // sets the i-th PID weight to 'value'
216 //=========================================================
218 if (i >= 0 && i < AliRsnPID::kSpecies) fPIDWeight[i] = value;
220 AliError(Form("Cannot set a weight related to slot %d", i));
225 //_____________________________________________________________________________
226 void AliRsnDaughter::SetPIDWeights(const Double_t *pid)
228 //=========================================================
229 // Sets ALL PID weights at once.
230 // The passed array is supposed to have at least as many
231 // slots as the number of allowed particle species.
232 //=========================================================
235 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDWeight[i] = pid[i];
239 //_____________________________________________________________________________
240 Bool_t AliRsnDaughter::Adopt(AliESDtrack* esdTrack)
242 //=========================================================
243 // Copies data from an AliESDtrack into "this":
246 // - point of closest approach to primary vertex
248 // In case of errors returns kFALSE, otherwise kTRUE.
249 //=========================================================
252 AliError("Passed NULL object: nothing done");
256 // copy momentum and vertex
257 esdTrack->GetPxPyPz(fP);
258 esdTrack->GetXYZ(fV);
263 esdTrack->GetESDpid(pid);
264 for (i = 0; i < 5; i++) fPIDWeight[i] = pid[i];
267 fFlags = esdTrack->GetStatus();
270 fCharge = (Short_t)esdTrack->Charge();
276 //_____________________________________________________________________________
277 Bool_t AliRsnDaughter::Adopt(AliAODTrack* aodTrack)
279 //=========================================================
280 // Copies data from an AliAODtrack into "this":
283 // - point of closest approach to primary vertex
285 // In case of errors returns kFALSE, otherwise kTRUE.
286 //=========================================================
289 AliError("Passed NULL object: nothing done");
293 // copy momentum and vertex
294 fP[0] = aodTrack->Px();
295 fP[1] = aodTrack->Py();
296 fP[2] = aodTrack->Pz();
297 fV[0] = aodTrack->Xv();
298 fV[1] = aodTrack->Yv();
299 fV[2] = aodTrack->Zv();
303 for (i = 0; i < 5; i++) fPIDWeight[i] = aodTrack->PID()[i];
306 fCharge = aodTrack->Charge();
312 //_____________________________________________________________________________
313 Bool_t AliRsnDaughter::Adopt(AliMCParticle *mcParticle)
315 //=========================================================
316 // Copies data from a MCParticle into "this":
319 // - point of closest approach to primary vertex
323 // In case of errors returns kFALSE, otherwise kTRUE.
324 //=========================================================
327 AliError("Passed NULL object: nothing done");
331 // retrieve the TParticle object from the argument
332 TParticle *particle = mcParticle->Particle();
334 AliError("AliMCParticle::Particle() returned NULL");
338 // copy momentum and vertex
339 fP[0] = particle->Px();
340 fP[1] = particle->Py();
341 fP[2] = particle->Pz();
342 fV[0] = particle->Vx();
343 fV[1] = particle->Vy();
344 fV[2] = particle->Vz();
346 // recognize charge sign from PDG code sign
347 Int_t pdg = particle->GetPdgCode();
348 Int_t absPDG = TMath::Abs(pdg);
350 if (pdg > 0) fCharge = -1; else fCharge = 1;
352 else if (absPDG < 3000) {
353 if (pdg > 0) fCharge = 1; else fCharge = -1;
360 // identify track perfectly using PDG code
361 fPIDType = AliRsnPID::InternalType(pdg);
363 fMass = AliRsnPID::ParticleMass(fPIDType);
365 // flags and PID weights make no sense with MC tracks
367 for (pdg = 0; pdg < AliRsnPID::kSpecies; pdg++) fPIDWeight[pdg] = 0.0;
368 fPIDWeight[fPIDType] = 1.0;
370 // copy other MC info (mother PDG code cannot be retrieved here)
371 InitParticle(particle);
376 //_____________________________________________________________________________
377 void AliRsnDaughter::Print(Option_t *option) const
379 //=========================================================
380 // Prints the values of data members, using the options:
382 // - V --> DCA vertex
383 // - C --> electric charge
385 // - I --> identification (PID, probability and mass)
386 // - W --> PID weights
387 // - M --> Montecarlo (from AliRsnParticle)
388 // - ALL --> All oprions switched on
390 // Index and label are printed by default.
391 //=========================================================
396 cout << ".......Index : " << fIndex << endl;
397 cout << ".......Label : " << fLabel << endl;
399 if (opt.Contains("P") || opt.Contains("ALL")) {
400 cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
402 if (opt.Contains("V") || opt.Contains("ALL")) {
403 cout << ".......Vx, Vy, Vz : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
405 if (opt.Contains("C") || opt.Contains("ALL")) {
406 cout << ".......Charge : " << fCharge << endl;
408 if (opt.Contains("F") || opt.Contains("ALL")) {
409 cout << ".......Flags : " << fFlags << endl;
411 if (opt.Contains("I") || opt.Contains("ALL")) {
412 cout << ".......PID : " << AliRsnPID::ParticleName(fPIDType) << endl;
413 cout << ".......PID probability : " << fPIDProb << endl;
414 cout << ".......Mass : " << fMass << endl;
416 if (opt.Contains("W") || opt.Contains("ALL")) {
417 cout << ".......Weights : ";
419 for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[i] << ' ';
422 if (opt.Contains("M") || opt.Contains("ALL")) {
424 cout << ".......PDG code : " << fParticle->PDG() << endl;
425 cout << ".......Mother (label) : " << fParticle->Mother() << endl;
426 cout << ".......Mother (PDG code): " << fParticle->MotherPDG() << endl;
429 cout << ".......MC info not present" << endl;
435 //_____________________________________________________________________________
436 AliRsnDaughter AliRsnDaughter::Sum(AliRsnDaughter t1, AliRsnDaughter t2)
438 //=========================================================
439 // Creates an AliRsnDaughter object composing momenta
440 // of the particles passed as arguments.
441 // The vector momentum of the returned object is
442 // the sum of the ones of the arguments.
443 // The mass of the object is set to the invariant mass
444 // computed from the relativistic sum of the 4-momenta
445 // of the two arguments.
446 // Finally, if both arguments have the same 'fMother'
447 // (when this MC information is available), it is set
448 // also as the 'fMother' of the returned object, together
449 // with its PDG code.
450 //=========================================================
452 // create a 'default' new AliRsnDaughter
455 // define the momentum of the sum as the
456 // relativistic sum of 4-momenta of arguments
457 Double_t etot = t1.E() + t2.E();
458 Double_t pxTot = t1.Px() + t2.Px();
459 Double_t pyTot = t1.Py() + t2.Py();
460 Double_t pzTot = t1.Pz() + t2.Pz();
461 Double_t mass = TMath::Sqrt(etot*etot - pxTot*pxTot - pyTot*pyTot - pzTot*pzTot);
463 out.SetP(pxTot, pyTot, pzTot);
465 // if both arguments have MC info, it is used here
466 // to check if they (in the truth MC) are daughters
467 // of the same resonance and, if this is the case,
468 // details of that resonance are set into the
469 // 'fParticle' object of the sum
471 if (t1.GetParticle() && t2.GetParticle()) {
473 mum1 = t1.GetParticle()->Mother();
474 mum2 = t2.GetParticle()->Mother();
475 if (mum1 == mum2 && mum1 >= 0) {
477 out.GetParticle()->SetPDG(t1.GetParticle()->MotherPDG());
485 //_____________________________________________________________________________
486 void AliRsnDaughter::InitParticle()
488 //=========================================================
489 // Initializes the particle object with default constructor.
490 //=========================================================
492 fParticle = new AliRsnParticle;
495 //_____________________________________________________________________________
496 Bool_t AliRsnDaughter::InitParticle(TParticle *particle)
498 //=========================================================
499 // Copies data from an MC particle into the object which
500 // contains all MC details taken from kinematics info.
501 // If requested by second argument, momentum and vertex
502 // of the Particle are copied into the 'fP' and 'fV'
503 // data members, to simulate a perfect reconstruction.
504 // If something goes wrong, returns kFALSE,
505 // otherwise returns kTRUE.
506 //=========================================================
508 // retrieve the TParticle object pointed by this MC track
510 AliError("Passed NULL particle object");
514 // initialize object if not initialized yet
515 if (fParticle) delete fParticle;
516 fParticle = new AliRsnParticle;
517 fParticle->Adopt(particle);
523 //_____________________________________________________________________________
524 Bool_t AliRsnDaughter::InitParticle(AliMCParticle *mcParticle)
526 //=========================================================
527 // Copies data from an MC particle into the object which
528 // contains all MC details taken from kinematics info.
529 // If requested by second argument, momentum and vertex
530 // of the Particle are copied into the 'fP' and 'fV'
531 // data members, to simulate a perfect reconstruction.
532 // If something goes wrong, returns kFALSE,
533 // otherwise returns kTRUE.
534 //=========================================================
536 // retrieve the TParticle object pointed by this MC track
537 TParticle *particle = mcParticle->Particle();
538 return InitParticle(particle);