]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPairDef.cxx
fixed warnings
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairDef.cxx
1 //
2 // Class AliRsnPairDef
3 //
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
8 //
9 // author: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
10 //
11
12 #include "AliLog.h"
13 #include "AliRsnPairDef.h"
14
15 ClassImp(AliRsnPairDef)
16
17 //_____________________________________________________________________________
18 AliRsnPairDef::AliRsnPairDef() : fMotherMass(0.0), fMotherPDG(0)
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
29   Int_t i;
30   for (i = 0; i < 2; i++) {
31     fCharge[i] = '0';
32     fMass[i] = 0.0;
33     fType[i] = AliPID::kUnknown;
34   }
35 }
36
37 //_____________________________________________________________________________
38 AliRsnPairDef::AliRsnPairDef
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)
42 {
43 //
44 // Constructor with arguments.
45 // This constructor allows to define all the working parameters.
46 //
47
48   SetPair(sign1, type1, sign2, type2);
49 }
50
51 //_____________________________________________________________________________
52 AliRsnPairDef::AliRsnPairDef
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)
56 {
57 //
58 // Constructor with arguments.
59 // This constructor allows to define all the working parameters.
60 //
61
62   SetPair(sign1, type1, sign2, type2);
63 }
64
65
66 //_____________________________________________________________________________
67 AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef &copy) :
68     TObject(copy),
69     fMotherMass(copy.fMotherMass),
70     fMotherPDG(copy.fMotherPDG)
71 {
72 //
73 // Copy constructor with standard behavior
74 //
75
76   SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
77 }
78
79 //_____________________________________________________________________________
80 const AliRsnPairDef& AliRsnPairDef::operator=(const AliRsnPairDef &copy)
81 {
82 //
83 // Assignment operator with standard behavior.
84 //
85
86   fMotherMass = copy.fMotherMass;
87   fMotherPDG = copy.fMotherPDG;
88   SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
89
90   return (*this);
91 }
92
93 //_____________________________________________________________________________
94 Bool_t AliRsnPairDef::SetPairElement(Int_t i, Char_t charge, AliPID::EParticleType type)
95 {
96 //
97 // Set one element of the pair
98 // and returns warnings if the type is not valid.
99 //
100
101   AliPID pid;
102
103   if (i < 0 || i > 1) {
104     AliError("Index out of range");
105     return kFALSE;
106   }
107   if (charge != '+' && charge != '-') {
108     AliError(Form("Character '%c' not recognized as charge sign", charge));
109     return kFALSE;
110   }
111   if (type < 0 && type > (Int_t)AliPID::kSPECIES) {
112     AliError("Type index out of enumeration range");
113     return kFALSE;
114   }
115   fCharge[i] = charge;
116   fType[i] = type;
117   fMass[i] = pid.ParticleMass(type);
118
119   return kTRUE;
120 }
121
122 //_____________________________________________________________________________
123 Bool_t AliRsnPairDef::SetPair
124 (Char_t charge1, AliPID::EParticleType type1, Char_t charge2, AliPID::EParticleType type2)
125 {
126 //
127 // Set both elements of the pair,
128 // returning logical AND of check for each one.
129 //
130   Bool_t part1 = SetPairElement(0, charge1, type1);
131   Bool_t part2 = SetPairElement(1, charge2, type2);
132
133   return (part1 && part2);
134 }
135
136 //_____________________________________________________________________________
137 TString AliRsnPairDef::GetPairName() const
138 {
139 //
140 // Returns a compact string with the name of the pair,
141 // to be used for naming objects related to it.
142 //
143
144   TString sName;
145   sName += AliPID::ParticleShortName(fType[0]);
146   sName += fCharge[0];
147   sName += AliPID::ParticleShortName(fType[1]);
148   sName += fCharge[1];
149
150   return sName;
151 }