]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPairDef.cxx
New classes required for revision of package
[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 <Riostream.h>
13
14 #include "AliLog.h"
15 #include "AliRsnDaughter.h"
16 #include "AliRsnPairDef.h"
17
18 ClassImp(AliRsnPairDef)
19
20 //_____________________________________________________________________________
21 AliRsnPairDef::AliRsnPairDef() : fMotherPDG(0)
22 {
23 //
24 // Empty constructor.
25 // Initializes the data members to default values:
26 //  - no definition of particles in the pair;
27 //  - histogram binning undefined.
28 // When using this constructor, all analysis elements (particles, histogram)
29 // must be defined before starting event processing.
30 //
31
32   Int_t i;
33   for (i = 0; i < 2; i++)
34   {
35     fCharge[i] = '0';
36     fMass[i] = 0.0;
37     fType[i] = AliPID::kUnknown;
38   }
39 }
40
41 //_____________________________________________________________________________
42 AliRsnPairDef::AliRsnPairDef
43 (Char_t sign1, AliPID::EParticleType type1, Char_t sign2, AliPID::EParticleType type2, Int_t motherPDG) :
44     fMotherPDG(motherPDG)
45 {
46 //
47 // Constructor with arguments.
48 // This constructor allows to define all the working parameters.
49 //
50
51   SetPair(sign1, type1, sign2, type2);
52 }
53
54 //_____________________________________________________________________________
55 AliRsnPairDef::AliRsnPairDef
56 (AliPID::EParticleType type1, Char_t sign1, AliPID::EParticleType type2, Char_t sign2, Int_t motherPDG) :
57     fMotherPDG(motherPDG)
58 {
59 //
60 // Constructor with arguments.
61 // This constructor allows to define all the working parameters.
62 //
63
64   SetPair(sign1, type1, sign2, type2);
65 }
66
67
68 //_____________________________________________________________________________
69 AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef &copy) :
70     TObject(copy),
71     fMotherPDG(copy.fMotherPDG)
72 {
73 //
74 // Copy constructor with standard behavior
75 //
76
77   SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
78 }
79
80 //_____________________________________________________________________________
81 const AliRsnPairDef& AliRsnPairDef::operator=(const AliRsnPairDef &copy)
82 {
83 //
84 // Assignment operator with standard behavior.
85 //
86
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   {
105     AliError("Index out of range");
106     return kFALSE;
107   }
108   if (charge != '+' && charge != '-')
109   {
110     AliError(Form("Character '%c' not recognized as charge sign"));
111     return kFALSE;
112   }
113   if (type < 0 && type > (Int_t)AliPID::kSPECIES)
114   {
115     AliError("Type index out of enumeration range");
116     return kFALSE;
117   }
118   fCharge[i] = charge;
119   fType[i] = type;
120   fMass[i] = pid.ParticleMass(type);
121
122   return kTRUE;
123 }
124
125 //_____________________________________________________________________________
126 Bool_t AliRsnPairDef::SetPair
127 (Char_t charge1, AliPID::EParticleType type1, Char_t charge2, AliPID::EParticleType type2)
128 {
129 //
130 // Set both elements of the pair,
131 // returning logical AND of check for each one.
132 //
133   Bool_t part1 = SetPairElement(0, charge1, type1);
134   Bool_t part2 = SetPairElement(1, charge2, type2);
135
136   return (part1 && part2);
137 }
138
139 //_____________________________________________________________________________
140 TString AliRsnPairDef::GetPairName()
141 {
142 //
143 // Returns a compact string with the name of the pair,
144 // to be used for naming objects related to it.
145 //
146
147   TString sName;
148   sName += AliPID::ParticleShortName(fType[0]);
149   sName += fCharge[0];
150   sName += AliPID::ParticleShortName(fType[1]);
151   sName += fCharge[1];
152
153   return sName;
154 }