]>
Commit | Line | Data |
---|---|---|
c5e33610 | 1 | // |
2 | // Class AliMixEventCutObj | |
3 | // | |
4 | // AliMixEventCutObj object contains information about one cut on for event mixing | |
5 | // used by AliMixEventPool class | |
6 | // | |
b425275c | 7 | // authors: |
c5e33610 | 8 | // Martin Vala (martin.vala@cern.ch) |
9 | // | |
10 | ||
11 | #include "AliLog.h" | |
12 | #include "AliESDEvent.h" | |
13 | #include "AliAODEvent.h" | |
14 | #include "AliMultiplicity.h" | |
15 | ||
16 | #include "AliMixEventCutObj.h" | |
17 | ||
18 | ClassImp(AliMixEventCutObj) | |
19 | ||
20 | //_________________________________________________________________________________________________ | |
21 | AliMixEventCutObj::AliMixEventCutObj(EEPAxis_t type, Float_t min, Float_t max, Float_t step) : TObject(), | |
b425275c | 22 | fCutType((Int_t)type), |
23 | fCutMin(min), | |
24 | fCutMax(max), | |
25 | fCutStep(step), | |
26 | fCutSmallVal(0), | |
27 | fCurrentVal(min) | |
28 | { | |
29 | // | |
30 | // Default constructor | |
31 | // | |
32 | AliDebug(AliLog::kDebug + 5, "<-"); | |
33 | if (fCutStep < 1e-5) AliError("fCutStep is too small !!! This cut will not work !!!"); | |
34 | AliDebug(AliLog::kDebug + 5, "->"); | |
c5e33610 | 35 | } |
b425275c | 36 | |
c5e33610 | 37 | //_________________________________________________________________________________________________ |
b425275c | 38 | AliMixEventCutObj::AliMixEventCutObj(const AliMixEventCutObj &obj) : TObject(obj), |
39 | fCutType(obj.fCutType), | |
40 | fCutMin(obj.fCutMin), | |
41 | fCutMax(obj.fCutMax), | |
42 | fCutStep(obj.fCutStep), | |
43 | fCutSmallVal(obj.fCutSmallVal), | |
44 | fCurrentVal(obj.fCurrentVal) | |
45 | { | |
46 | // | |
47 | // Copy constructor | |
48 | // | |
49 | AliDebug(AliLog::kDebug + 5, "<-"); | |
50 | AliDebug(AliLog::kDebug + 5, "->"); | |
c5e33610 | 51 | } |
52 | ||
53 | //_________________________________________________________________________________________________ | |
b425275c | 54 | AliMixEventCutObj& AliMixEventCutObj::operator=(const AliMixEventCutObj& obj) |
55 | { | |
56 | // | |
57 | // Assigned operator | |
58 | // | |
59 | if (&obj != this) { | |
60 | TObject::operator=(obj); | |
61 | fCutType = obj.fCutType; | |
62 | fCutMin = obj.fCutMin; | |
63 | fCutMax = obj.fCutMax; | |
64 | fCutStep = obj.fCutStep; | |
65 | fCutSmallVal = obj.fCutSmallVal; | |
66 | fCurrentVal = obj.fCurrentVal; | |
67 | // fNoMore = obj.fNoMore; | |
68 | } | |
69 | return *this; | |
c5e33610 | 70 | } |
b425275c | 71 | |
72 | ||
c5e33610 | 73 | //_________________________________________________________________________________________________ |
b425275c | 74 | void AliMixEventCutObj::Reset() |
75 | { | |
76 | // | |
77 | // Reset cut | |
78 | // | |
79 | AliDebug(AliLog::kDebug + 5, "<-"); | |
80 | fCurrentVal = fCutMin - fCutStep; | |
81 | AliDebug(AliLog::kDebug + 5, "->"); | |
82 | } | |
83 | //_________________________________________________________________________________________________ | |
84 | Bool_t AliMixEventCutObj::HasMore() const | |
85 | { | |
86 | // | |
87 | // Return kTRUE when fCurrentVal is in interval of cut range | |
88 | // | |
89 | return ((fCurrentVal + fCutStep) < fCutMax); | |
c5e33610 | 90 | } |
91 | ||
92 | //_________________________________________________________________________________________________ | |
b425275c | 93 | void AliMixEventCutObj::AddStep() |
94 | { | |
95 | // | |
96 | // Adds step | |
97 | // | |
98 | fCurrentVal += fCutStep; | |
c5e33610 | 99 | } |
100 | ||
101 | //_________________________________________________________________________________________________ | |
b425275c | 102 | void AliMixEventCutObj::Print(const Option_t *) const |
103 | { | |
104 | // | |
105 | // Prints cut information | |
106 | // | |
107 | AliInfo(Form("%s %f %f %f", GetCutName(fCutType), fCutMin, fCutMax, fCutStep)); | |
c5e33610 | 108 | } |
109 | //_________________________________________________________________________________________________ | |
b425275c | 110 | void AliMixEventCutObj::PrintCurrentInterval() |
111 | { | |
112 | // | |
113 | // Prints current cut interval information | |
114 | // | |
115 | AliDebug(AliLog::kDebug, Form("%s <%f,%f>", GetCutName(fCutType), GetMin(), GetMax())); | |
c5e33610 | 116 | } |
117 | ||
118 | //_________________________________________________________________________________________________ | |
b425275c | 119 | Int_t AliMixEventCutObj::GetNumberOfBins() const |
120 | { | |
121 | // | |
122 | // Returns number of bins | |
123 | // | |
124 | if (fCutStep < 1e-5) return -1; | |
125 | return (Int_t)((fCutMax - fCutMin) / fCutStep); | |
c5e33610 | 126 | } |
127 | ||
128 | //_________________________________________________________________________________________________ | |
b425275c | 129 | Int_t AliMixEventCutObj::GetBinNumber(Float_t num) const |
130 | { | |
131 | // | |
132 | // Returns bin (index) number in current cut. | |
133 | // Returns -1 in case of out of range | |
134 | // | |
135 | Int_t binNum = 0; | |
136 | for (Float_t i = fCutMin; i <= fCutMax - fCutSmallVal; i += fCutStep) { | |
137 | binNum++; | |
138 | if ((num >= i) && (num <= i + fCutStep - fCutSmallVal)) return binNum; | |
139 | } | |
140 | return -1; | |
c5e33610 | 141 | } |
142 | ||
143 | //_________________________________________________________________________________________________ | |
b425275c | 144 | Int_t AliMixEventCutObj::GetIndex(AliVEvent *ev) |
145 | { | |
146 | // | |
147 | // Finds bin (index) in current cut from event information. | |
148 | // | |
149 | AliESDEvent *esd = dynamic_cast<AliESDEvent *>(ev); | |
150 | if (esd) return GetIndex(esd); | |
151 | AliAODEvent *aod = dynamic_cast<AliAODEvent *>(ev); | |
152 | if (aod) return GetIndex(aod); | |
153 | return -1; | |
c5e33610 | 154 | } |
155 | ||
156 | //_________________________________________________________________________________________________ | |
b425275c | 157 | Int_t AliMixEventCutObj::GetIndex(AliESDEvent *ev) |
158 | { | |
159 | // | |
160 | // Finds bin (index) in current cut from ESD event information. | |
161 | // | |
162 | switch (fCutType) { | |
163 | case kMultiplicity: | |
164 | return GetBinNumber((Float_t)ev->GetNumberOfTracks()); | |
165 | case kZVertex: | |
166 | return GetBinNumber(ev->GetVertex()->GetZ()); | |
167 | case kNumberV0s: | |
168 | return GetBinNumber(ev->GetNumberOfV0s()); | |
169 | case kNumberTracklets: | |
170 | const AliMultiplicity *multESD = ev->GetMultiplicity(); | |
171 | return GetBinNumber(multESD->GetNumberOfTracklets()); | |
172 | } | |
173 | return -1; | |
c5e33610 | 174 | } |
175 | ||
176 | //_________________________________________________________________________________________________ | |
b425275c | 177 | Int_t AliMixEventCutObj::GetIndex(AliAODEvent *ev) |
178 | { | |
179 | // | |
180 | // Finds bin (index) in current cut from AOD event information. | |
181 | // | |
182 | switch (fCutType) { | |
183 | case kMultiplicity: | |
184 | return GetBinNumber((Float_t)ev->GetNumberOfTracks()); | |
185 | case kZVertex: | |
186 | return GetBinNumber(ev->GetVertex(0)->GetZ()); | |
187 | case kNumberV0s: | |
188 | return GetBinNumber(ev->GetNumberOfV0s()); | |
189 | } | |
190 | return -1; | |
c5e33610 | 191 | } |
192 | //_________________________________________________________________________________________________ | |
b425275c | 193 | const char *AliMixEventCutObj::GetCutName(Int_t index) const |
c5e33610 | 194 | { |
b425275c | 195 | // |
196 | // Retruns name of cut | |
197 | // | |
198 | ||
199 | if (index < 0) index = fCutType; | |
200 | switch (index) { | |
201 | case kMultiplicity: | |
202 | return "Multiplicity"; | |
203 | case kZVertex: | |
204 | return "ZVertex"; | |
205 | case kNumberV0s: | |
206 | return "NumberV0s"; | |
207 | case kNumberTracklets: | |
208 | return "NumberTracklets"; | |
209 | } | |
210 | return ""; | |
c5e33610 | 211 | } |
212 | ||
b425275c | 213 | //_________________________________________________________________________________________________ |
214 | void AliMixEventCutObj::SetCurrentValueToIndex(Int_t index) | |
215 | { | |
216 | // | |
217 | // Sets current value to index | |
218 | // | |
219 | for (Int_t i = 0; i < index; i++) AddStep(); | |
220 | } |