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