2 // Class AliMixEventCutObj
4 // AliMixEventCutObj object contains information about one cut on for event mixing
5 // used by AliMixEventPool class
8 // Martin Vala (martin.vala@cern.ch)
12 #include "AliESDEvent.h"
13 #include "AliAODEvent.h"
14 #include "AliMultiplicity.h"
15 #include "AliAODVertex.h"
16 #include "AliEventplane.h"
18 #include "AliMixEventCutObj.h"
20 ClassImp(AliMixEventCutObj)
22 //_________________________________________________________________________________________________
23 AliMixEventCutObj::AliMixEventCutObj(AliMixEventCutObj::EEPAxis_t type, Float_t min, Float_t max, Float_t step, const char *opt) : TObject(),
24 fCutType((Int_t)type),
33 // Default constructor
35 AliDebug(AliLog::kDebug + 5, "<-");
36 if (fCutStep < 1e-5) AliError("fCutStep is too small !!! This cut will not work !!!");
37 AliDebug(AliLog::kDebug + 5, "->");
40 //_________________________________________________________________________________________________
41 AliMixEventCutObj::AliMixEventCutObj(const AliMixEventCutObj &obj) : TObject(obj),
42 fCutType(obj.fCutType),
46 fCutStep(obj.fCutStep),
47 fCutSmallVal(obj.fCutSmallVal),
48 fCurrentVal(obj.fCurrentVal)
53 AliDebug(AliLog::kDebug + 5, "<-");
54 AliDebug(AliLog::kDebug + 5, "->");
57 //_________________________________________________________________________________________________
58 AliMixEventCutObj &AliMixEventCutObj::operator=(const AliMixEventCutObj &obj)
64 TObject::operator=(obj);
65 fCutType = obj.fCutType;
66 fCutOpt = obj.fCutOpt;
67 fCutMin = obj.fCutMin;
68 fCutMax = obj.fCutMax;
69 fCutStep = obj.fCutStep;
70 fCutSmallVal = obj.fCutSmallVal;
71 fCurrentVal = obj.fCurrentVal;
72 // fNoMore = obj.fNoMore;
78 //_________________________________________________________________________________________________
79 void AliMixEventCutObj::Reset()
84 AliDebug(AliLog::kDebug + 5, "<-");
85 fCurrentVal = fCutMin - fCutStep;
86 AliDebug(AliLog::kDebug + 5, "->");
88 //_________________________________________________________________________________________________
89 Bool_t AliMixEventCutObj::HasMore() const
92 // Return kTRUE when fCurrentVal is in interval of cut range
94 return ((fCurrentVal + fCutStep) < fCutMax);
97 //_________________________________________________________________________________________________
98 void AliMixEventCutObj::AddStep()
103 fCurrentVal += fCutStep;
106 //_________________________________________________________________________________________________
107 void AliMixEventCutObj::Print(const Option_t *) const
110 // Prints cut information
112 AliInfo(Form("%s %f %f %f", GetCutName(fCutType), fCutMin, fCutMax, fCutStep));
114 //_________________________________________________________________________________________________
115 void AliMixEventCutObj::PrintCurrentInterval()
118 // Prints current cut interval information
120 AliDebug(AliLog::kDebug, Form("%s <%f,%f>", GetCutName(fCutType), GetCurrentMin(), GetCurrentMax()));
123 //_________________________________________________________________________________________________
124 Int_t AliMixEventCutObj::GetNumberOfBins() const
127 // Returns number of bins
129 if (fCutStep < 1e-5) return -1;
130 return (Int_t)((fCutMax - fCutMin) / fCutStep);
133 //_________________________________________________________________________________________________
134 Int_t AliMixEventCutObj::GetBinNumber(Float_t num) const
137 // Returns bin (index) number in current cut.
138 // Returns -1 in case of out of range
141 for (Float_t iCurrent = fCutMin; iCurrent < fCutMax; iCurrent += fCutStep) {
143 if ((num >= iCurrent) && (num < iCurrent + fCutStep - fCutSmallVal)) {
150 //_________________________________________________________________________________________________
151 Int_t AliMixEventCutObj::GetIndex(AliVEvent *ev)
154 // Finds bin (index) in current cut from event information.
156 return GetBinNumber(GetValue(ev));
159 //_________________________________________________________________________________________________
160 Double_t AliMixEventCutObj::GetValue(AliVEvent *ev)
163 // Returns value from event
166 AliESDEvent *esd = dynamic_cast<AliESDEvent *>(ev);
167 if (esd) return GetValue(esd);
168 AliAODEvent *aod = dynamic_cast<AliAODEvent *>(ev);
169 if (aod) return GetValue(aod);
171 AliFatal("Event is not supported in Event Mixing cuts!!!!");
175 //_________________________________________________________________________________________________
176 Double_t AliMixEventCutObj::GetValue(AliESDEvent *ev)
179 // Returns value from esd event
182 const AliMultiplicity *multESD = 0;
186 return (Double_t)ev->GetNumberOfTracks();
188 return ev->GetVertex()->GetZ();
190 return ev->GetNumberOfV0s();
191 case kNumberTracklets:
192 multESD = ev->GetMultiplicity();
193 if (multESD) return multESD->GetNumberOfTracklets();
194 else AliFatal("esd->GetMultiplicity() is null");
198 AliCentrality *c = ev->GetCentrality();
199 if (!c) AliFatal("esd->GetCentrality() is null");
200 return c->GetCentralityPercentile(fCutOpt.Data());
204 AliEventplane *evtPlane = ev->GetEventplane();
205 if (!evtPlane) evtPlane = new AliEventplane();
206 Double_t val = evtPlane->GetEventplane("V0",ev,fCutOpt.Atoi());
207 if (!ev->GetEventplane()) delete evtPlane;
212 AliEventplane *evtPlane = ev->GetEventplane();
213 if (!evtPlane) evtPlane = new AliEventplane();
214 Double_t val = evtPlane->GetEventplane("V0A",ev,fCutOpt.Atoi());
215 if (!ev->GetEventplane()) delete evtPlane;
220 AliEventplane *evtPlane = ev->GetEventplane();
221 if (!evtPlane) evtPlane = new AliEventplane();
222 Double_t val = evtPlane->GetEventplane("V0C",ev,fCutOpt.Atoi());
223 if (!ev->GetEventplane()) delete evtPlane;
228 AliFatal("Mixing Cut TYPE is not supported for ESD");
233 //_________________________________________________________________________________________________
234 Double_t AliMixEventCutObj::GetValue(AliAODEvent *ev)
237 // Returns value from aod event
243 return (Double_t) ev->GetNumberOfTracks();
245 v = ev->GetVertex(0);
246 if (!v) return -99999;
247 return ev->GetVertex(0)->GetZ();
248 // if verttex is null return -9999
251 return ev->GetNumberOfV0s();
254 AliCentrality *c = ev->GetCentrality();
255 if (!c) AliFatal("esd->GetCentrality() is null");
256 return c->GetCentralityPercentile(fCutOpt.Data());
260 AliEventplane *evtPlane = ev->GetEventplane();
261 if (!evtPlane) evtPlane = new AliEventplane();
262 Double_t val = evtPlane->GetEventplane("V0A",ev,fCutOpt.Atoi());
263 if (!ev->GetEventplane()) delete evtPlane;
268 AliEventplane *evtPlane = ev->GetEventplane();
269 if (!evtPlane) evtPlane = new AliEventplane();
270 Double_t val = evtPlane->GetEventplane("V0A",ev,fCutOpt.Atoi());
271 if (!ev->GetEventplane()) delete evtPlane;
276 AliEventplane *evtPlane = ev->GetEventplane();
277 if (!evtPlane) evtPlane = new AliEventplane();
278 Double_t val = evtPlane->GetEventplane("V0C",ev,fCutOpt.Atoi());
279 if (!ev->GetEventplane()) delete evtPlane;
284 AliFatal("Mixing Cut TYPE is not supported for AOD");
288 //_________________________________________________________________________________________________
289 const char *AliMixEventCutObj::GetCutName(Int_t index) const
292 // Retruns name of cut
295 if (index < 0) index = fCutType;
298 return "Multiplicity";
303 case kNumberTracklets:
304 return "NumberTracklets";
306 return Form("kCentrality[%s]", fCutOpt.Data());
308 return Form("EventPlane[%s]", fCutOpt.Data());
310 return Form("EventPlaneV0A[%s]", fCutOpt.Data());
312 return Form("EventPlaneV0A[%s]", fCutOpt.Data());
317 //_________________________________________________________________________________________________
318 void AliMixEventCutObj::SetCurrentValueToIndex(Int_t index)
321 // Sets current value to index
324 fCurrentVal = fCutMin;
325 for (Int_t i = 0; i < index-1; i++) AddStep();
328 //_________________________________________________________________________________________________
329 void AliMixEventCutObj::PrintValues(AliVEvent *main, AliVEvent *mix)
332 // Prints values of both events for current type
334 AliInfo(Form("name=%s main=%f mix=%f", GetCutName(), GetValue(main), GetValue(mix)));
337 //_________________________________________________________________________________________________
338 Bool_t AliMixEventCutObj::IsValid()
341 // Check if cut is valid
347 if (fCutOpt.IsNull()) {
348 AliError("fCutOpt is null");
355 if (fCutOpt.IsNull()) {
356 AliError("fCutOpt is null");
359 if (!fCutOpt.IsDigit()) {
360 AliError("fCutOpt is not a digit string");
367 if (fCutOpt.IsNull()) {
368 AliError("fCutOpt is null");
371 if (!fCutOpt.IsDigit()) {
372 AliError("fCutOpt is not a digit string");
379 if (fCutOpt.IsNull()) {
380 AliError("fCutOpt is null");
383 if (!fCutOpt.IsDigit()) {
384 AliError("fCutOpt is not a digit string");