]>
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 | // | |
7 | // authors: | |
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(), | |
22 | fCutType((Short_t)type), | |
23 | fCutMin(min), | |
24 | fCutMax(max), | |
25 | fCutStep(step), | |
26 | fCutSmallVal((max - min) / (step*1e6)), | |
27 | fCurrentVal(min), | |
28 | fNoMore(kFALSE) { | |
29 | // | |
30 | // Default constructor. | |
31 | // | |
32 | ||
33 | AliDebug(AliLog::kDebug + 2, "<-"); | |
34 | ||
35 | AliDebug(AliLog::kDebug + 2, "->"); | |
36 | } | |
37 | //_________________________________________________________________________________________________ | |
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 | fNoMore(obj.fNoMore) { | |
46 | // | |
47 | // Copy constructor. | |
48 | // | |
49 | } | |
50 | ||
51 | //_________________________________________________________________________________________________ | |
52 | void AliMixEventCutObj::Reset() { | |
53 | // | |
54 | // Reset cut. | |
55 | // | |
56 | ||
57 | AliDebug(AliLog::kDebug + 2, "<-"); | |
58 | fCurrentVal = fCutMin - fCutStep; | |
59 | fNoMore = kFALSE; | |
60 | AliDebug(AliLog::kDebug + 2, "->"); | |
61 | } | |
62 | //_________________________________________________________________________________________________ | |
63 | Bool_t AliMixEventCutObj::HasMore() const { | |
64 | // | |
65 | // Return kTRUE when fCurrentVal is in interval of cut range | |
66 | // | |
67 | ||
68 | return ((fCurrentVal + fCutStep) < fCutMax); | |
69 | } | |
70 | ||
71 | //_________________________________________________________________________________________________ | |
72 | void AliMixEventCutObj::AddStep() { | |
73 | // | |
74 | // Adds step | |
75 | // | |
76 | ||
77 | fCurrentVal += fCutStep; | |
78 | } | |
79 | ||
80 | //_________________________________________________________________________________________________ | |
81 | void AliMixEventCutObj::Print(const Option_t *) const { | |
82 | // | |
83 | // Prints cut information | |
84 | // | |
85 | ||
86 | AliInfo(Form("%d %f %f %f", fCutType, fCutMin, fCutMax, fCutStep)); | |
87 | } | |
88 | //_________________________________________________________________________________________________ | |
89 | void AliMixEventCutObj::PrintCurrentInterval() { | |
90 | // | |
91 | // Prints current cut interval information | |
92 | // | |
93 | ||
94 | AliInfo(Form("%s <%f,%f>", GetNameOfCut(fCutType), GetMin(), GetMax())); | |
95 | } | |
96 | ||
97 | //_________________________________________________________________________________________________ | |
98 | Int_t AliMixEventCutObj::GetNumberOfBins() const { | |
99 | // | |
100 | // Returns number of bins | |
101 | // | |
102 | ||
103 | if (!fCutStep) return -1; | |
104 | return (Int_t)((fCutMax -fCutMin) / fCutStep); | |
105 | } | |
106 | ||
107 | //_________________________________________________________________________________________________ | |
108 | Int_t AliMixEventCutObj::GetBinNumber(Float_t num) const { | |
109 | // | |
110 | // Returns bin (index) number in current cut. | |
111 | // Returns -1 in case of out of range | |
112 | // | |
113 | ||
114 | Int_t binNum = 0; | |
115 | for (Float_t i = fCutMin;i <= fCutMax - fCutSmallVal;i += fCutStep) { | |
116 | binNum++; | |
117 | if ((num >= i) && (num <= i + fCutStep - fCutSmallVal)) return binNum; | |
118 | ||
119 | } | |
120 | return -1; | |
121 | } | |
122 | ||
123 | //_________________________________________________________________________________________________ | |
124 | Int_t AliMixEventCutObj::GetIndex(AliVEvent* ev) { | |
125 | // | |
126 | // Finds bin (index) in current cut from event information. | |
127 | // | |
128 | ||
129 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(ev); | |
130 | if (esd) return GetIndex(esd); | |
131 | AliAODEvent *aod = dynamic_cast<AliAODEvent*>(ev); | |
132 | if (aod) return GetIndex(aod); | |
133 | return -1; | |
134 | } | |
135 | ||
136 | //_________________________________________________________________________________________________ | |
137 | Int_t AliMixEventCutObj::GetIndex(AliESDEvent* ev) { | |
138 | // | |
139 | // Finds bin (index) in current cut from ESD event information. | |
140 | // | |
141 | switch (fCutType) { | |
142 | case kMultiplicity: | |
143 | return GetBinNumber((Float_t)ev->GetNumberOfTracks()); | |
144 | case kZVertex: | |
145 | return GetBinNumber(ev->GetVertex()->GetZ()); | |
146 | case kNumberV0s: | |
147 | return GetBinNumber(ev->GetNumberOfV0s()); | |
148 | case kNumberTracklets: | |
149 | const AliMultiplicity* multESD = ev->GetMultiplicity(); | |
150 | return GetBinNumber(multESD->GetNumberOfTracklets()); | |
151 | } | |
152 | return -1; | |
153 | } | |
154 | ||
155 | //_________________________________________________________________________________________________ | |
156 | Int_t AliMixEventCutObj::GetIndex(AliAODEvent* ev) { | |
157 | // | |
158 | // Finds bin (index) in current cut from AOD event information. | |
159 | // | |
160 | switch (fCutType) { | |
161 | case kMultiplicity: | |
162 | return GetBinNumber((Float_t)ev->GetNumberOfTracks()); | |
163 | case kZVertex: | |
164 | return GetBinNumber(ev->GetVertex(0)->GetZ()); | |
165 | case kNumberV0s: | |
166 | return GetBinNumber(ev->GetNumberOfV0s()); | |
167 | } | |
168 | return -1; | |
169 | } | |
170 | //_________________________________________________________________________________________________ | |
171 | const char* AliMixEventCutObj::GetNameOfCut(Short_t index) const | |
172 | { | |
173 | // | |
174 | // Retruns name of cut | |
175 | // | |
176 | switch ((Int_t)index) { | |
177 | case kMultiplicity: | |
178 | return "Multiplicity"; | |
179 | case kZVertex: | |
180 | return "ZVertex"; | |
181 | case kNumberV0s: | |
182 | return "NumberV0s"; | |
183 | case kNumberTracklets: | |
184 | return "NumberTracklets"; | |
185 | } | |
186 | return ""; | |
187 | } | |
188 |