fix for bug #70582 (change from L. Molnar)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairDef.cxx
CommitLineData
06351446 1//
e2bafbbc 2// Class AliRsnPairDef
06351446 3//
e2bafbbc 4// Defines a decay channel for a resonance,
5// resulting in a specified PDG code for the mother,
6// and the particle type for the daughters, defined
7// according to the internal PID format of the package
06351446 8//
e2bafbbc 9// author: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
06351446 10//
11
06351446 12#include "AliLog.h"
06351446 13#include "AliRsnPairDef.h"
14
15ClassImp(AliRsnPairDef)
16
17//_____________________________________________________________________________
eb079724 18AliRsnPairDef::AliRsnPairDef() : fMotherMass(0.0), fMotherPDG(0)
06351446 19{
20//
21// Empty constructor.
22// Initializes the data members to default values:
23// - no definition of particles in the pair;
24// - histogram binning undefined.
25// When using this constructor, all analysis elements (particles, histogram)
26// must be defined before starting event processing.
27//
28
e0baff8c 29 Int_t i;
4fbb2459 30 for (i = 0; i < 2; i++) {
e0baff8c 31 fCharge[i] = '0';
32 fMass[i] = 0.0;
5eb970a4 33 fType[i] = AliPID::kUnknown;
e0baff8c 34 }
06351446 35}
36
37//_____________________________________________________________________________
38AliRsnPairDef::AliRsnPairDef
39a3e819 39(Char_t sign1, AliPID::EParticleType type1, Char_t sign2, AliPID::EParticleType type2, Int_t motherPDG, Double_t motherMass) :
40 fMotherMass(motherMass),
41 fMotherPDG(motherPDG)
06351446 42{
43//
44// Constructor with arguments.
45// This constructor allows to define all the working parameters.
46//
47
e0baff8c 48 SetPair(sign1, type1, sign2, type2);
06351446 49}
50
51//_____________________________________________________________________________
aec0ec32 52AliRsnPairDef::AliRsnPairDef
39a3e819 53(AliPID::EParticleType type1, Char_t sign1, AliPID::EParticleType type2, Char_t sign2, Int_t motherPDG, Double_t motherMass) :
54 fMotherMass(motherMass),
55 fMotherPDG(motherPDG)
aec0ec32 56{
57//
58// Constructor with arguments.
59// This constructor allows to define all the working parameters.
60//
61
e0baff8c 62 SetPair(sign1, type1, sign2, type2);
aec0ec32 63}
64
65
66//_____________________________________________________________________________
06351446 67AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef &copy) :
aec0ec32 68 TObject(copy),
eb079724 69 fMotherMass(copy.fMotherMass),
aec0ec32 70 fMotherPDG(copy.fMotherPDG)
06351446 71{
72//
73// Copy constructor with standard behavior
74//
75
e0baff8c 76 SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
06351446 77}
78
79//_____________________________________________________________________________
80const AliRsnPairDef& AliRsnPairDef::operator=(const AliRsnPairDef &copy)
81{
82//
83// Assignment operator with standard behavior.
84//
85
eb079724 86 fMotherMass = copy.fMotherMass;
e0baff8c 87 fMotherPDG = copy.fMotherPDG;
88 SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
06351446 89
e0baff8c 90 return (*this);
06351446 91}
92
93//_____________________________________________________________________________
5eb970a4 94Bool_t AliRsnPairDef::SetPairElement(Int_t i, Char_t charge, AliPID::EParticleType type)
06351446 95{
96//
97// Set one element of the pair
98// and returns warnings if the type is not valid.
99//
5eb970a4 100
101 AliPID pid;
102
4fbb2459 103 if (i < 0 || i > 1) {
e0baff8c 104 AliError("Index out of range");
105 return kFALSE;
106 }
4fbb2459 107 if (charge != '+' && charge != '-') {
1d8bfdee 108 AliError(Form("Character '%c' not recognized as charge sign", charge));
e0baff8c 109 return kFALSE;
110 }
4fbb2459 111 if (type < 0 && type > (Int_t)AliPID::kSPECIES) {
e0baff8c 112 AliError("Type index out of enumeration range");
113 return kFALSE;
114 }
115 fCharge[i] = charge;
116 fType[i] = type;
5eb970a4 117 fMass[i] = pid.ParticleMass(type);
e0baff8c 118
119 return kTRUE;
06351446 120}
121
122//_____________________________________________________________________________
123Bool_t AliRsnPairDef::SetPair
5eb970a4 124(Char_t charge1, AliPID::EParticleType type1, Char_t charge2, AliPID::EParticleType type2)
06351446 125{
126//
127// Set both elements of the pair,
128// returning logical AND of check for each one.
129//
e0baff8c 130 Bool_t part1 = SetPairElement(0, charge1, type1);
131 Bool_t part2 = SetPairElement(1, charge2, type2);
132
133 return (part1 && part2);
06351446 134}
135
136//_____________________________________________________________________________
4fbb2459 137TString AliRsnPairDef::GetPairName() const
aec0ec32 138{
139//
140// Returns a compact string with the name of the pair,
141// to be used for naming objects related to it.
142//
e0baff8c 143
144 TString sName;
5eb970a4 145 sName += AliPID::ParticleShortName(fType[0]);
e0baff8c 146 sName += fCharge[0];
5eb970a4 147 sName += AliPID::ParticleShortName(fType[1]);
e0baff8c 148 sName += fCharge[1];
149
150 return sName;
aec0ec32 151}