]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnDaughter.cxx
Package upgrade.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.cxx
CommitLineData
a62a2d82 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
7c2974c8 15
06351446 16//=========================================================================
17// Class AliRsnDaughter
18//
19//
7c2974c8 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
23// (ESD, AOD and MC).
24// Contains also a facility to compute invariant mass of a pair.
25//
26// author: A. Pulvirenti --- email: alberto.pulvirenti@ct.infn.it
06351446 27//=========================================================================
7c2974c8 28
29#include <Riostream.h>
a62a2d82 30
a62a2d82 31#include <TParticle.h>
4c2fda1e 32#include <TString.h>
a62a2d82 33
c37c6481 34#include "AliLog.h"
a62a2d82 35#include "AliESDtrack.h"
7c2974c8 36#include "AliAODTrack.h"
37#include "AliMCParticle.h"
38
39#include "AliRsnPID.h"
06351446 40#include "AliRsnMCInfo.h"
a62a2d82 41#include "AliRsnDaughter.h"
42
43ClassImp(AliRsnDaughter)
44
7c2974c8 45//_____________________________________________________________________________
c37c6481 46AliRsnDaughter::AliRsnDaughter() :
7c2974c8 47 AliVParticle(),
48 fIndex(-1),
c37c6481 49 fLabel(-1),
7c2974c8 50 fCharge(0),
51 fFlags(0),
52 fPIDType(AliRsnPID::kUnknown),
7c2974c8 53 fMass(0.0),
06351446 54 fMCInfo(0x0)
2f769150 55{
06351446 56//
a62a2d82 57// Default constructor.
7c2974c8 58// Initializes all data-members with meaningless values.
06351446 59//
7c2974c8 60
61 Int_t i;
62 for (i = 0; i < AliRsnPID::kSpecies; i++) {
63 if (i < 3) {
64 fP[i] = 0.0;
65 fV[i] = 0.0;
66 }
67 fPIDWeight[i] = 0.0;
06351446 68 fPIDProb[i] = 0.0;
7c2974c8 69 }
70}
71
72//_____________________________________________________________________________
73AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) :
74 AliVParticle(copy),
75 fIndex(copy.fIndex),
76 fLabel(copy.fLabel),
77 fCharge(copy.fCharge),
78 fFlags(copy.fFlags),
79 fPIDType(copy.fPIDType),
7c2974c8 80 fMass(copy.fMass),
06351446 81 fMCInfo(0x0)
7c2974c8 82{
06351446 83//
7c2974c8 84// Copy constructor.
06351446 85//
7c2974c8 86
87 Int_t i;
88 for (i = 0; i < AliRsnPID::kSpecies; i++) {
89 if (i < 3) {
90 fP[i] = copy.fP[i];
91 fV[i] = copy.fV[i];
92 }
93 fPIDWeight[i] = copy.fPIDWeight[i];
06351446 94 fPIDProb[i] = copy.fPIDProb[i];
7c2974c8 95 }
96
06351446 97 // initialize particle object
7c2974c8 98 // only if it is present in the template object
06351446 99 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
7c2974c8 100}
101
102//_____________________________________________________________________________
06351446 103AliRsnDaughter::AliRsnDaughter(AliESDtrack *track, Bool_t useTPC) :
7c2974c8 104 AliVParticle(),
105 fIndex(-1),
106 fLabel(-1),
107 fCharge(0),
108 fFlags(0),
109 fPIDType(AliRsnPID::kUnknown),
c37c6481 110 fMass(0.0),
06351446 111 fMCInfo(0x0)
2f769150 112{
06351446 113//
7c2974c8 114// Constructor to get data from an ESD track.
06351446 115//
7c2974c8 116
06351446 117 Int_t i;
118 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
119 Adopt(track, useTPC);
7c2974c8 120}
121
122//_____________________________________________________________________________
123AliRsnDaughter::AliRsnDaughter(AliAODTrack *track) :
124 AliVParticle(),
125 fIndex(-1),
126 fLabel(-1),
127 fCharge(0),
128 fFlags(0),
129 fPIDType(AliRsnPID::kUnknown),
7c2974c8 130 fMass(0.0),
06351446 131 fMCInfo(0x0)
2f769150 132{
06351446 133//
7c2974c8 134// Constructor to get data from an AOD track.
06351446 135//
7c2974c8 136
06351446 137 Int_t i;
138 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
7c2974c8 139 Adopt(track);
a62a2d82 140}
7c2974c8 141
142//_____________________________________________________________________________
143AliRsnDaughter::AliRsnDaughter(AliMCParticle *track) :
144 AliVParticle(),
145 fIndex(-1),
146 fLabel(-1),
147 fCharge(0),
148 fFlags(0),
149 fPIDType(AliRsnPID::kUnknown),
7c2974c8 150 fMass(0.0),
06351446 151 fMCInfo(0x0)
2f769150 152{
06351446 153//
7c2974c8 154// Constructor to get data from an MC track.
06351446 155//
7c2974c8 156
06351446 157 Int_t i;
158 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
7c2974c8 159 Adopt(track);
160}
161
162//_____________________________________________________________________________
163AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter &copy)
164{
06351446 165//
7c2974c8 166// Assignment operator.
167// Works like the copy constructor and returns a reference
168// to the initialized object for which it is called.
06351446 169//
170
7c2974c8 171 fIndex = copy.fIndex;
172 fLabel = copy.fLabel;
173 fCharge = copy.fCharge;
174 fFlags = copy.fFlags;
175
176 Int_t i;
177 for (i = 0; i < AliRsnPID::kSpecies; i++) {
178 if (i < 3) {
179 fP[i] = copy.fP[i];
180 fV[i] = copy.fV[i];
181 }
182 fPIDWeight[i] = copy.fPIDWeight[i];
06351446 183 fPIDProb[i] = copy.fPIDProb[i];
7c2974c8 184 }
06351446 185
7c2974c8 186 fPIDType = copy.fPIDType;
7c2974c8 187 fMass = copy.fMass;
06351446 188
189 // initialize particle object
7c2974c8 190 // only if it is present in the template object;
191 // otherwise, it is just cleared and not replaced with anything
06351446 192 if (fMCInfo) {
193 delete fMCInfo;
194 fMCInfo = 0x0;
7c2974c8 195 }
06351446 196 if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
7c2974c8 197
198 return (*this);
199}
200
201//_____________________________________________________________________________
202AliRsnDaughter::~AliRsnDaughter()
203{
06351446 204//
7c2974c8 205// Destructor
06351446 206//
7c2974c8 207
06351446 208 if (fMCInfo) {
209 delete fMCInfo;
210 fMCInfo = 0;
7c2974c8 211 }
212}
213
214//_____________________________________________________________________________
215void AliRsnDaughter::SetPIDWeight(Int_t i, Double_t value)
216{
06351446 217//
7c2974c8 218// I the argument 'i' is in the correct range,
219// sets the i-th PID weight to 'value'
06351446 220//
7c2974c8 221
222 if (i >= 0 && i < AliRsnPID::kSpecies) fPIDWeight[i] = value;
223 else {
224 AliError(Form("Cannot set a weight related to slot %d", i));
225 }
226}
227
06351446 228//_____________________________________________________________________________
229void AliRsnDaughter::SetPIDProb(Int_t i, Double_t value)
230{
231//
232// I the argument 'i' is in the correct range,
233// sets the i-th PID probability to 'value'
234//
235
236 if (i >= 0 && i < AliRsnPID::kSpecies) fPIDProb[i] = value;
237 else {
238 AliError(Form("Cannot set a weight related to slot %d", i));
239 }
240}
7c2974c8 241
242//_____________________________________________________________________________
243void AliRsnDaughter::SetPIDWeights(const Double_t *pid)
244{
06351446 245//
7c2974c8 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.
06351446 249//
7c2974c8 250
251 Int_t i;
252 for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDWeight[i] = pid[i];
253}
254
255
256//_____________________________________________________________________________
06351446 257Bool_t AliRsnDaughter::Adopt(AliESDtrack* esdTrack, Bool_t useTPCInnerParam)
7c2974c8 258{
06351446 259//
7c2974c8 260// Copies data from an AliESDtrack into "this":
261// - charge sign
262// - momentum
263// - point of closest approach to primary vertex
264// - ESD pid weights
265// In case of errors returns kFALSE, otherwise kTRUE.
06351446 266//
7c2974c8 267
268 if (!esdTrack) {
269 AliError("Passed NULL object: nothing done");
270 return kFALSE;
271 }
06351446 272
7c2974c8 273 // copy momentum and vertex
06351446 274 if (!useTPCInnerParam) {
275 esdTrack->GetPxPyPz(fP);
276 esdTrack->GetXYZ(fV);
277 }
278 else {
279 if (!esdTrack->GetTPCInnerParam()) return kFALSE;
280 esdTrack->GetTPCInnerParam()->GetPxPyPz(fP);
281 esdTrack->GetTPCInnerParam()->GetXYZ(fV);
282 }
7c2974c8 283
284 // copy PID weights
285 Int_t i;
286 Double_t pid[5];
06351446 287 if (!useTPCInnerParam) {
288 esdTrack->GetESDpid(pid);
289 }
290 else {
291 esdTrack->GetTPCpid(pid);
292 }
7c2974c8 293 for (i = 0; i < 5; i++) fPIDWeight[i] = pid[i];
06351446 294
7c2974c8 295 // copy flags
296 fFlags = esdTrack->GetStatus();
06351446 297
7c2974c8 298 // copy charge sign
299 fCharge = (Short_t)esdTrack->Charge();
06351446 300
7c2974c8 301 return kTRUE;
302}
303
304
305//_____________________________________________________________________________
306Bool_t AliRsnDaughter::Adopt(AliAODTrack* aodTrack)
307{
06351446 308//
7c2974c8 309// Copies data from an AliAODtrack into "this":
310// - charge sign
311// - momentum
312// - point of closest approach to primary vertex
313// - ESD pid weights
314// In case of errors returns kFALSE, otherwise kTRUE.
06351446 315//
7c2974c8 316
317 if (!aodTrack) {
318 AliError("Passed NULL object: nothing done");
319 return kFALSE;
320 }
06351446 321
7c2974c8 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();
06351446 329
7c2974c8 330 // copy PID weights
331 Int_t i;
332 for (i = 0; i < 5; i++) fPIDWeight[i] = aodTrack->PID()[i];
06351446 333
7c2974c8 334 // copy sign
335 fCharge = aodTrack->Charge();
336
337 return kTRUE;
338}
339
340
341//_____________________________________________________________________________
342Bool_t AliRsnDaughter::Adopt(AliMCParticle *mcParticle)
343{
06351446 344//
7c2974c8 345// Copies data from a MCParticle into "this":
346// - charge sign
347// - momentum
348// - point of closest approach to primary vertex
349// - ESD pid weights
350// - true PDG code
351// - mother
352// In case of errors returns kFALSE, otherwise kTRUE.
06351446 353//
7c2974c8 354
355 if (!mcParticle) {
356 AliError("Passed NULL object: nothing done");
357 return kFALSE;
358 }
06351446 359
7c2974c8 360 // retrieve the TParticle object from the argument
361 TParticle *particle = mcParticle->Particle();
362 if (!particle) {
363 AliError("AliMCParticle::Particle() returned NULL");
364 return kFALSE;
365 }
06351446 366
7c2974c8 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();
06351446 374
7c2974c8 375 // recognize charge sign from PDG code sign
376 Int_t pdg = particle->GetPdgCode();
377 Int_t absPDG = TMath::Abs(pdg);
378 if (absPDG <= 15) {
379 if (pdg > 0) fCharge = -1; else fCharge = 1;
380 }
381 else if (absPDG < 3000) {
382 if (pdg > 0) fCharge = 1; else fCharge = -1;
383 }
384 else {
385 fCharge = 0;
386 return kFALSE;
387 }
06351446 388
7c2974c8 389 // identify track perfectly using PDG code
390 fPIDType = AliRsnPID::InternalType(pdg);
7c2974c8 391 fMass = AliRsnPID::ParticleMass(fPIDType);
06351446 392
7c2974c8 393 // flags and PID weights make no sense with MC tracks
394 fFlags = 0;
395 for (pdg = 0; pdg < AliRsnPID::kSpecies; pdg++) fPIDWeight[pdg] = 0.0;
396 fPIDWeight[fPIDType] = 1.0;
06351446 397
7c2974c8 398 // copy other MC info (mother PDG code cannot be retrieved here)
06351446 399 InitMCInfo(particle);
7c2974c8 400
401 return kTRUE;
a62a2d82 402}
7c2974c8 403
404//_____________________________________________________________________________
4c2fda1e 405void AliRsnDaughter::Print(Option_t *option) const
406{
06351446 407//
7c2974c8 408// Prints the values of data members, using the options:
409// - P --> momentum
410// - V --> DCA vertex
411// - C --> electric charge
412// - F --> flags
413// - I --> identification (PID, probability and mass)
414// - W --> PID weights
06351446 415// - M --> Montecarlo (from AliRsnMCInfo)
7c2974c8 416// - ALL --> All oprions switched on
4c2fda1e 417//
7c2974c8 418// Index and label are printed by default.
06351446 419//
4c2fda1e 420
7c2974c8 421 TString opt(option);
422 opt.ToUpper();
06351446 423
7c2974c8 424 cout << ".......Index : " << fIndex << endl;
425 cout << ".......Label : " << fLabel << endl;
06351446 426
7c2974c8 427 if (opt.Contains("P") || opt.Contains("ALL")) {
428 cout << ".......Px, Py, Pz, Pt : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
429 }
430 if (opt.Contains("V") || opt.Contains("ALL")) {
431 cout << ".......Vx, Vy, Vz : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
432 }
433 if (opt.Contains("C") || opt.Contains("ALL")) {
434 cout << ".......Charge : " << fCharge << endl;
435 }
436 if (opt.Contains("F") || opt.Contains("ALL")) {
437 cout << ".......Flags : " << fFlags << endl;
438 }
439 if (opt.Contains("I") || opt.Contains("ALL")) {
440 cout << ".......PID : " << AliRsnPID::ParticleName(fPIDType) << endl;
06351446 441 if (fPIDType > 0 && fPIDType < AliRsnPID::kSpecies) {
442 cout << ".......PID probability : " << fPIDProb[fPIDType] << endl;
443 }
7c2974c8 444 cout << ".......Mass : " << fMass << endl;
445 }
446 if (opt.Contains("W") || opt.Contains("ALL")) {
447 cout << ".......Weights : ";
448 Int_t i;
449 for (i = 0; i < AliRsnPID::kSpecies; i++) cout << fPIDWeight[i] << ' ';
450 cout << endl;
451 }
452 if (opt.Contains("M") || opt.Contains("ALL")) {
06351446 453 if (fMCInfo) {
454 cout << ".......PDG code : " << fMCInfo->PDG() << endl;
455 cout << ".......Mother (label) : " << fMCInfo->Mother() << endl;
456 cout << ".......Mother (PDG code): " << fMCInfo->MotherPDG() << endl;
7c2974c8 457 }
458 else {
459 cout << ".......MC info not present" << endl;
460 }
461 }
4c2fda1e 462}
7c2974c8 463
7c2974c8 464//_____________________________________________________________________________
06351446 465void AliRsnDaughter::InitMCInfo()
2f769150 466{
06351446 467//
7c2974c8 468// Initializes the particle object with default constructor.
06351446 469//
7c2974c8 470
06351446 471 fMCInfo = new AliRsnMCInfo;
7c2974c8 472}
473
474//_____________________________________________________________________________
06351446 475Bool_t AliRsnDaughter::InitMCInfo(TParticle *particle)
7c2974c8 476{
06351446 477//
7c2974c8 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.
06351446 483// If something goes wrong, returns kFALSE,
7c2974c8 484// otherwise returns kTRUE.
06351446 485//
7c2974c8 486
487 // retrieve the TParticle object pointed by this MC track
488 if (!particle) {
489 AliError("Passed NULL particle object");
490 return kFALSE;
491 }
06351446 492
7c2974c8 493 // initialize object if not initialized yet
06351446 494 if (fMCInfo) delete fMCInfo;
495 fMCInfo = new AliRsnMCInfo;
496 fMCInfo->Adopt(particle);
7c2974c8 497
498 return kTRUE;
499}
500
7c2974c8 501//_____________________________________________________________________________
06351446 502Bool_t AliRsnDaughter::InitMCInfo(AliMCParticle *mcParticle)
7c2974c8 503{
06351446 504//
7c2974c8 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.
06351446 510// If something goes wrong, returns kFALSE,
7c2974c8 511// otherwise returns kTRUE.
06351446 512//
7c2974c8 513
514 // retrieve the TParticle object pointed by this MC track
515 TParticle *particle = mcParticle->Particle();
06351446 516 return InitMCInfo(particle);
a62a2d82 517}