]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/EventMixing/AliMixEventCutObj.cxx
loading also TRD alignment objects
[u/mrichter/AliRoot.git] / ANALYSIS / EventMixing / AliMixEventCutObj.cxx
CommitLineData
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
18ClassImp(AliMixEventCutObj)
19
20//_________________________________________________________________________________________________
21AliMixEventCutObj::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 38AliMixEventCutObj::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 54AliMixEventCutObj& 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 74void AliMixEventCutObj::Reset()
75{
76 //
77 // Reset cut
78 //
79 AliDebug(AliLog::kDebug + 5, "<-");
80 fCurrentVal = fCutMin - fCutStep;
81 AliDebug(AliLog::kDebug + 5, "->");
82}
83//_________________________________________________________________________________________________
84Bool_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 93void AliMixEventCutObj::AddStep()
94{
95 //
96 // Adds step
97 //
98 fCurrentVal += fCutStep;
c5e33610 99}
100
101//_________________________________________________________________________________________________
b425275c 102void 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 110void 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 119Int_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 129Int_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;
f2db2f8e 136 for (Float_t iCurrent = fCutMin; iCurrent < fCutMax; iCurrent += fCutStep) {
b425275c 137 binNum++;
24dc85b1 138 if ((num >= iCurrent) && (num < iCurrent + fCutStep - fCutSmallVal)) {
f2db2f8e 139 return binNum;
140 }
b425275c 141 }
142 return -1;
c5e33610 143}
144
145//_________________________________________________________________________________________________
b425275c 146Int_t AliMixEventCutObj::GetIndex(AliVEvent *ev)
147{
148 //
149 // Finds bin (index) in current cut from event information.
150 //
24dc85b1 151 return GetBinNumber(GetValue(ev));
152}
153
154//_________________________________________________________________________________________________
155Double_t AliMixEventCutObj::GetValue(AliVEvent* ev)
156{
157 //
158 // Returns value from event
159 //
160
b425275c 161 AliESDEvent *esd = dynamic_cast<AliESDEvent *>(ev);
24dc85b1 162 if (esd) return GetValue(esd);
b425275c 163 AliAODEvent *aod = dynamic_cast<AliAODEvent *>(ev);
24dc85b1 164 if (aod) return GetValue(aod);
165
166 AliFatal("Event is not supported in Event Mixing cuts!!!!");
167 return -99999;
c5e33610 168}
169
170//_________________________________________________________________________________________________
24dc85b1 171Double_t AliMixEventCutObj::GetValue(AliESDEvent* ev)
b425275c 172{
173 //
24dc85b1 174 // Returns value from esd event
b425275c 175 //
24dc85b1 176
b425275c 177 switch (fCutType) {
178 case kMultiplicity:
24dc85b1 179 return (Double_t)ev->GetNumberOfTracks();
b425275c 180 case kZVertex:
24dc85b1 181 return ev->GetVertex()->GetZ();
b425275c 182 case kNumberV0s:
24dc85b1 183 return ev->GetNumberOfV0s();
b425275c 184 case kNumberTracklets:
185 const AliMultiplicity *multESD = ev->GetMultiplicity();
24dc85b1 186 return multESD->GetNumberOfTracklets();
b425275c 187 }
24dc85b1 188
189 AliFatal("Mixing Cut TYPE is not supported");
190 return -99999;
191
c5e33610 192}
193
194//_________________________________________________________________________________________________
24dc85b1 195Double_t AliMixEventCutObj::GetValue(AliAODEvent* ev)
b425275c 196{
197 //
24dc85b1 198 // Returns value from aod event
b425275c 199 //
200 switch (fCutType) {
201 case kMultiplicity:
24dc85b1 202 return (Double_t) ev->GetNumberOfTracks();
b425275c 203 case kZVertex:
24dc85b1 204 return ev->GetVertex(0)->GetZ();
b425275c 205 case kNumberV0s:
24dc85b1 206 return ev->GetNumberOfV0s();
b425275c 207 }
24dc85b1 208
209 AliFatal("Mixing Cut TYPE is not supported");
210 return -99999;
c5e33610 211}
24dc85b1 212
c5e33610 213//_________________________________________________________________________________________________
b425275c 214const char *AliMixEventCutObj::GetCutName(Int_t index) const
c5e33610 215{
b425275c 216 //
217 // Retruns name of cut
218 //
219
220 if (index < 0) index = fCutType;
221 switch (index) {
222 case kMultiplicity:
223 return "Multiplicity";
224 case kZVertex:
225 return "ZVertex";
226 case kNumberV0s:
227 return "NumberV0s";
228 case kNumberTracklets:
229 return "NumberTracklets";
230 }
231 return "";
c5e33610 232}
233
b425275c 234//_________________________________________________________________________________________________
235void AliMixEventCutObj::SetCurrentValueToIndex(Int_t index)
236{
237 //
238 // Sets current value to index
239 //
240 for (Int_t i = 0; i < index; i++) AddStep();
241}
24dc85b1 242
243//_________________________________________________________________________________________________
244void AliMixEventCutObj::PrintValues(AliVEvent* main, AliVEvent* mix)
245{
246 //
247 // Prints values of both events for current type
248 //
249 AliInfo(Form("name=%s main=%f mix=%f", GetCutName(), GetValue(main), GetValue(mix)));
250}
251