]>
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" | |
3bcab622 | 15 | #include "AliAODVertex.h" |
c5e33610 | 16 | |
17 | #include "AliMixEventCutObj.h" | |
18 | ||
19 | ClassImp(AliMixEventCutObj) | |
20 | ||
21 | //_________________________________________________________________________________________________ | |
3bcab622 | 22 | AliMixEventCutObj::AliMixEventCutObj(AliMixEventCutObj::EEPAxis_t type, Float_t min, Float_t max, Float_t step, const char *opt) : TObject(), |
b425275c | 23 | fCutType((Int_t)type), |
298831c0 | 24 | fCutOpt(opt), |
b425275c | 25 | fCutMin(min), |
26 | fCutMax(max), | |
27 | fCutStep(step), | |
28 | fCutSmallVal(0), | |
29 | fCurrentVal(min) | |
30 | { | |
31 | // | |
32 | // Default constructor | |
33 | // | |
34 | AliDebug(AliLog::kDebug + 5, "<-"); | |
35 | if (fCutStep < 1e-5) AliError("fCutStep is too small !!! This cut will not work !!!"); | |
36 | AliDebug(AliLog::kDebug + 5, "->"); | |
c5e33610 | 37 | } |
b425275c | 38 | |
c5e33610 | 39 | //_________________________________________________________________________________________________ |
b425275c | 40 | AliMixEventCutObj::AliMixEventCutObj(const AliMixEventCutObj &obj) : TObject(obj), |
41 | fCutType(obj.fCutType), | |
298831c0 | 42 | fCutOpt(obj.fCutOpt), |
b425275c | 43 | fCutMin(obj.fCutMin), |
44 | fCutMax(obj.fCutMax), | |
45 | fCutStep(obj.fCutStep), | |
46 | fCutSmallVal(obj.fCutSmallVal), | |
47 | fCurrentVal(obj.fCurrentVal) | |
48 | { | |
49 | // | |
50 | // Copy constructor | |
51 | // | |
52 | AliDebug(AliLog::kDebug + 5, "<-"); | |
53 | AliDebug(AliLog::kDebug + 5, "->"); | |
c5e33610 | 54 | } |
55 | ||
56 | //_________________________________________________________________________________________________ | |
3bcab622 | 57 | AliMixEventCutObj &AliMixEventCutObj::operator=(const AliMixEventCutObj &obj) |
b425275c | 58 | { |
59 | // | |
60 | // Assigned operator | |
61 | // | |
62 | if (&obj != this) { | |
63 | TObject::operator=(obj); | |
64 | fCutType = obj.fCutType; | |
298831c0 | 65 | fCutOpt = obj.fCutOpt; |
b425275c | 66 | fCutMin = obj.fCutMin; |
67 | fCutMax = obj.fCutMax; | |
68 | fCutStep = obj.fCutStep; | |
69 | fCutSmallVal = obj.fCutSmallVal; | |
70 | fCurrentVal = obj.fCurrentVal; | |
71 | // fNoMore = obj.fNoMore; | |
72 | } | |
73 | return *this; | |
c5e33610 | 74 | } |
b425275c | 75 | |
76 | ||
c5e33610 | 77 | //_________________________________________________________________________________________________ |
b425275c | 78 | void AliMixEventCutObj::Reset() |
79 | { | |
80 | // | |
81 | // Reset cut | |
82 | // | |
83 | AliDebug(AliLog::kDebug + 5, "<-"); | |
84 | fCurrentVal = fCutMin - fCutStep; | |
85 | AliDebug(AliLog::kDebug + 5, "->"); | |
86 | } | |
87 | //_________________________________________________________________________________________________ | |
88 | Bool_t AliMixEventCutObj::HasMore() const | |
89 | { | |
90 | // | |
91 | // Return kTRUE when fCurrentVal is in interval of cut range | |
92 | // | |
93 | return ((fCurrentVal + fCutStep) < fCutMax); | |
c5e33610 | 94 | } |
95 | ||
96 | //_________________________________________________________________________________________________ | |
b425275c | 97 | void AliMixEventCutObj::AddStep() |
98 | { | |
99 | // | |
100 | // Adds step | |
101 | // | |
102 | fCurrentVal += fCutStep; | |
c5e33610 | 103 | } |
104 | ||
105 | //_________________________________________________________________________________________________ | |
b425275c | 106 | void AliMixEventCutObj::Print(const Option_t *) const |
107 | { | |
108 | // | |
109 | // Prints cut information | |
110 | // | |
111 | AliInfo(Form("%s %f %f %f", GetCutName(fCutType), fCutMin, fCutMax, fCutStep)); | |
c5e33610 | 112 | } |
113 | //_________________________________________________________________________________________________ | |
b425275c | 114 | void AliMixEventCutObj::PrintCurrentInterval() |
115 | { | |
116 | // | |
117 | // Prints current cut interval information | |
118 | // | |
119 | AliDebug(AliLog::kDebug, Form("%s <%f,%f>", GetCutName(fCutType), GetMin(), GetMax())); | |
c5e33610 | 120 | } |
121 | ||
122 | //_________________________________________________________________________________________________ | |
b425275c | 123 | Int_t AliMixEventCutObj::GetNumberOfBins() const |
124 | { | |
125 | // | |
126 | // Returns number of bins | |
127 | // | |
128 | if (fCutStep < 1e-5) return -1; | |
129 | return (Int_t)((fCutMax - fCutMin) / fCutStep); | |
c5e33610 | 130 | } |
131 | ||
132 | //_________________________________________________________________________________________________ | |
b425275c | 133 | Int_t AliMixEventCutObj::GetBinNumber(Float_t num) const |
134 | { | |
135 | // | |
136 | // Returns bin (index) number in current cut. | |
137 | // Returns -1 in case of out of range | |
138 | // | |
139 | Int_t binNum = 0; | |
f2db2f8e | 140 | for (Float_t iCurrent = fCutMin; iCurrent < fCutMax; iCurrent += fCutStep) { |
b425275c | 141 | binNum++; |
24dc85b1 | 142 | if ((num >= iCurrent) && (num < iCurrent + fCutStep - fCutSmallVal)) { |
f2db2f8e | 143 | return binNum; |
144 | } | |
b425275c | 145 | } |
146 | return -1; | |
c5e33610 | 147 | } |
148 | ||
149 | //_________________________________________________________________________________________________ | |
b425275c | 150 | Int_t AliMixEventCutObj::GetIndex(AliVEvent *ev) |
151 | { | |
152 | // | |
153 | // Finds bin (index) in current cut from event information. | |
154 | // | |
24dc85b1 | 155 | return GetBinNumber(GetValue(ev)); |
156 | } | |
157 | ||
158 | //_________________________________________________________________________________________________ | |
3bcab622 | 159 | Double_t AliMixEventCutObj::GetValue(AliVEvent *ev) |
24dc85b1 | 160 | { |
161 | // | |
162 | // Returns value from event | |
163 | // | |
164 | ||
b425275c | 165 | AliESDEvent *esd = dynamic_cast<AliESDEvent *>(ev); |
24dc85b1 | 166 | if (esd) return GetValue(esd); |
b425275c | 167 | AliAODEvent *aod = dynamic_cast<AliAODEvent *>(ev); |
24dc85b1 | 168 | if (aod) return GetValue(aod); |
169 | ||
170 | AliFatal("Event is not supported in Event Mixing cuts!!!!"); | |
171 | return -99999; | |
c5e33610 | 172 | } |
173 | ||
174 | //_________________________________________________________________________________________________ | |
3bcab622 | 175 | Double_t AliMixEventCutObj::GetValue(AliESDEvent *ev) |
b425275c | 176 | { |
177 | // | |
24dc85b1 | 178 | // Returns value from esd event |
b425275c | 179 | // |
24dc85b1 | 180 | |
298831c0 | 181 | const AliMultiplicity *multESD = 0; |
182 | ||
b425275c | 183 | switch (fCutType) { |
184 | case kMultiplicity: | |
24dc85b1 | 185 | return (Double_t)ev->GetNumberOfTracks(); |
b425275c | 186 | case kZVertex: |
24dc85b1 | 187 | return ev->GetVertex()->GetZ(); |
b425275c | 188 | case kNumberV0s: |
24dc85b1 | 189 | return ev->GetNumberOfV0s(); |
b425275c | 190 | case kNumberTracklets: |
298831c0 | 191 | multESD = ev->GetMultiplicity(); |
192 | if (multESD) return multESD->GetNumberOfTracklets(); | |
193 | else AliFatal("esd->GetMultiplicity() is null"); | |
194 | break; | |
195 | case kCentrality: | |
196 | AliCentrality *c = ev->GetCentrality(); | |
197 | if (!c) AliFatal("esd->GetCentrality() is null"); | |
198 | if (fCutOpt.IsNull()) AliFatal("fCutOpt is null"); | |
199 | return c->GetCentralityPercentile(fCutOpt.Data()); | |
200 | ||
b425275c | 201 | } |
24dc85b1 | 202 | |
298831c0 | 203 | AliFatal("Mixing Cut TYPE is not supported for ESD"); |
24dc85b1 | 204 | return -99999; |
205 | ||
c5e33610 | 206 | } |
207 | ||
208 | //_________________________________________________________________________________________________ | |
3bcab622 | 209 | Double_t AliMixEventCutObj::GetValue(AliAODEvent *ev) |
b425275c | 210 | { |
211 | // | |
24dc85b1 | 212 | // Returns value from aod event |
b425275c | 213 | // |
3bcab622 | 214 | |
215 | AliAODVertex *v=0; | |
b425275c | 216 | switch (fCutType) { |
217 | case kMultiplicity: | |
24dc85b1 | 218 | return (Double_t) ev->GetNumberOfTracks(); |
b425275c | 219 | case kZVertex: |
3bcab622 | 220 | v = ev->GetVertex(0); |
221 | if (!v) return -99999; | |
24dc85b1 | 222 | return ev->GetVertex(0)->GetZ(); |
3bcab622 | 223 | // if verttex is null return -9999 |
224 | return -99999; | |
b425275c | 225 | case kNumberV0s: |
24dc85b1 | 226 | return ev->GetNumberOfV0s(); |
298831c0 | 227 | case kCentrality: |
228 | AliCentrality *c = ev->GetCentrality(); | |
229 | if (!c) AliFatal("aod->GetCentrality() is null"); | |
230 | if (fCutOpt.IsNull()) AliFatal("fCutOpt is null"); | |
231 | return c->GetCentralityPercentile(fCutOpt.Data()); | |
b425275c | 232 | } |
24dc85b1 | 233 | |
298831c0 | 234 | AliFatal("Mixing Cut TYPE is not supported for AOD"); |
24dc85b1 | 235 | return -99999; |
c5e33610 | 236 | } |
24dc85b1 | 237 | |
c5e33610 | 238 | //_________________________________________________________________________________________________ |
b425275c | 239 | const char *AliMixEventCutObj::GetCutName(Int_t index) const |
c5e33610 | 240 | { |
b425275c | 241 | // |
242 | // Retruns name of cut | |
243 | // | |
244 | ||
245 | if (index < 0) index = fCutType; | |
246 | switch (index) { | |
247 | case kMultiplicity: | |
248 | return "Multiplicity"; | |
249 | case kZVertex: | |
250 | return "ZVertex"; | |
251 | case kNumberV0s: | |
252 | return "NumberV0s"; | |
253 | case kNumberTracklets: | |
254 | return "NumberTracklets"; | |
298831c0 | 255 | case kCentrality: |
256 | return Form("kCentrality[%s]", fCutOpt.Data()); | |
b425275c | 257 | } |
258 | return ""; | |
c5e33610 | 259 | } |
260 | ||
b425275c | 261 | //_________________________________________________________________________________________________ |
262 | void AliMixEventCutObj::SetCurrentValueToIndex(Int_t index) | |
263 | { | |
264 | // | |
265 | // Sets current value to index | |
266 | // | |
267 | for (Int_t i = 0; i < index; i++) AddStep(); | |
268 | } | |
24dc85b1 | 269 | |
270 | //_________________________________________________________________________________________________ | |
3bcab622 | 271 | void AliMixEventCutObj::PrintValues(AliVEvent *main, AliVEvent *mix) |
24dc85b1 | 272 | { |
273 | // | |
274 | // Prints values of both events for current type | |
275 | // | |
276 | AliInfo(Form("name=%s main=%f mix=%f", GetCutName(), GetValue(main), GetValue(mix))); | |
277 | } | |
278 |