]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnDaughterDef.cxx
Fixed bug in AliRsnPair::Fill()
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughterDef.cxx
1 //
2 // Class AliRsnDaughterDef
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 "AliPID.h"
14 #include "AliRsnDaughterDef.h"
15
16 ClassImp(AliRsnDaughterDef)
17
18
19 //_____________________________________________________________________________
20 AliRsnDaughterDef::AliRsnDaughterDef() :
21    fMass(0.0),
22    fCharge(0),
23    fPID(AliPID::kUnknown),
24    fDaughterType(AliRsnDaughter::kNoType)
25 {
26 //
27 // Constructor.
28 // This version of constructor leaves all undefined,
29 // and all daughters will be accepted.
30 //
31 }
32
33 //_____________________________________________________________________________
34 AliRsnDaughterDef::AliRsnDaughterDef(AliPID::EParticleType type, Char_t sign) :
35    fMass(0.0),
36    fCharge(sign),
37    fPID(type),
38    fDaughterType(AliRsnDaughter::kNoType)
39 {
40 //
41 // Constructor.
42 // This version of constructor initializes the PID type
43 // and the charge (optional, leave its default to include both),
44 // and calls 'SetDaughter()' to assign the object type accordingly.
45 //
46
47    SetDaughter(type, sign);
48 }
49
50 //_____________________________________________________________________________
51 AliRsnDaughterDef::AliRsnDaughterDef(AliRsnDaughter::ERefType refType, Char_t sign) :
52    fMass(0.0),
53    fCharge(sign),
54    fPID(AliPID::kUnknown),
55    fDaughterType(refType)
56 {
57 //
58 // Constructor.
59 // This version of constructor initialized the object type
60 // and the charge (optiona, leave its defaul to include both),
61 // and sets the PID type undefined.
62 //
63 }
64
65 //_____________________________________________________________________________
66 AliRsnDaughterDef::AliRsnDaughterDef(const AliRsnDaughterDef &copy) :
67    TObject(copy),
68    fMass(copy.fMass),
69    fCharge(copy.fCharge),
70    fPID(copy.fPID),
71    fDaughterType(copy.fDaughterType)
72 {
73 //
74 // Copy constructor with standard behavior
75 //
76 }
77
78 //_____________________________________________________________________________
79 const AliRsnDaughterDef& AliRsnDaughterDef::operator=(const AliRsnDaughterDef &copy)
80 {
81 //
82 // Assignment operator with standard behavior.
83 //
84
85    fMass = copy.fMass;
86    fCharge = copy.fCharge;
87    fPID = copy.fPID;
88    fDaughterType = copy.fDaughterType;
89
90    return (*this);
91 }
92
93 //_____________________________________________________________________________
94 Bool_t AliRsnDaughterDef::SetDaughter(AliPID::EParticleType type, Char_t charge)
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    // charge and type come from arguments
104    fCharge = charge;
105    fPID    = type;
106    
107    // mass is assigned by AliPID, if possible
108    fMass = 0.0;
109    if ((Int_t)type >= 0 && (Int_t)type < AliPID::kSPECIESN)
110       fMass = pid.ParticleMass(type);
111    
112    // object type is determined by type itself
113    if ((Int_t)type >= 0 && (Int_t)type < AliPID::kSPECIES) 
114       fDaughterType = AliRsnDaughter::kTrack;
115    else if (type == AliPID::kKaon0) {
116       fDaughterType = AliRsnDaughter::kV0;
117       fCharge = '0';
118    }
119    else
120       fDaughterType = AliRsnDaughter::kNoType;
121
122    return kTRUE;
123 }
124
125 //_____________________________________________________________________________
126 Bool_t AliRsnDaughterDef::MatchesDaughter(AliRsnDaughter *checked, Bool_t truePID)
127 {
128 //
129 // Checks if the argument matches the definitions here.
130 // If second argument is kTRUE and checked daughter has MC,
131 // check also that the particle species is correct.
132 //
133
134    // charge matching:
135    // if charge was set to '+', '-' or '0'
136    // the checked daughter charge must match that defined in the settings
137    // otherwise no specific charge requirement was done
138    Bool_t chargeMatch = kTRUE;
139    switch (fCharge) {
140       case '+':
141          chargeMatch = checked->IsPos();
142          break;
143       case '-': 
144          chargeMatch = checked->IsNeg();
145          break;
146       case '0': 
147          chargeMatch = checked->IsNeutral();
148          break;
149       default : 
150          chargeMatch = kTRUE;
151    }
152    
153    // object type matching
154    Bool_t objMatch = kTRUE;
155    if (fDaughterType != AliRsnDaughter::kNoType)
156       objMatch = (checked->RefType() == fDaughterType);
157       
158    // particle type matching (only if MC is available and second arg is true)
159    Bool_t pidMatch = kTRUE;
160    if (truePID && fPID != AliPID::kUnknown && checked->GetRefMC())
161       pidMatch = (AliPID::ParticleCode(fPID) == checked->GetPDG());
162       
163    // return the AND of all
164    return (chargeMatch && objMatch && pidMatch);
165 }