]>
Commit | Line | Data |
---|---|---|
1528f6d1 | 1 | #if !defined( __CINT__) || defined(__MAKECINT__) |
2 | ||
3 | #include <exception> | |
4 | #include <iostream> | |
5 | #include "AliLog.h" | |
6 | #include "AliConversionAODBGHandlerRP.h" | |
7 | using namespace std; | |
8 | #endif | |
9 | ||
10 | ||
11 | // Author Daniel Lohner (Daniel.Lohner@cern.ch) | |
12 | ||
13 | ||
14 | ClassImp(AliConversionAODBGHandlerRP); | |
15 | ||
16 | //________________________________________________________________________ | |
17 | AliConversionAODBGHandlerRP::AliConversionAODBGHandlerRP(Bool_t IsHeavyIon,Bool_t UseChargedTrackMult,Int_t NEvents) : TObject(), | |
18 | fIsHeavyIon(IsHeavyIon), | |
19 | fUseChargedTrackMult(UseChargedTrackMult), | |
20 | fNEvents(NEvents), | |
21 | fBGEventCounter(NULL), | |
22 | fNBGEvents(NULL), | |
23 | fNBinsZ(7), | |
24 | fNBinsMultiplicity(5+Int_t(fUseChargedTrackMult)), | |
25 | fBinLimitsArrayZ(NULL), | |
26 | fBinLimitsArrayMultiplicity(NULL), | |
27 | fBGPool(fNBinsZ,AliGammaConversionMultiplicityVector(fNBinsMultiplicity,AliGammaConversionBGEventVector(fNEvents))) | |
28 | { | |
29 | // Vertex Z Binning | |
30 | ||
31 | fBinLimitsArrayZ = new Double_t[fNBinsZ+1]; | |
32 | fBinLimitsArrayZ[0] = -50.00; | |
33 | fBinLimitsArrayZ[1] = -3.375; | |
34 | fBinLimitsArrayZ[2] = -1.605; | |
35 | fBinLimitsArrayZ[3] = -0.225; | |
36 | fBinLimitsArrayZ[4] = 1.065; | |
37 | fBinLimitsArrayZ[5] = 2.445; | |
38 | fBinLimitsArrayZ[6] = 4.245; | |
39 | fBinLimitsArrayZ[7] = 50.00; | |
40 | ||
41 | // MultiplicityBins | |
42 | ||
43 | fBinLimitsArrayMultiplicity= new Double_t[fNBinsMultiplicity+1]; | |
44 | ||
45 | if(fUseChargedTrackMult){ | |
46 | // Use Charged Particle Multiplicity | |
47 | ||
48 | fBinLimitsArrayMultiplicity[0] = 0; | |
49 | fBinLimitsArrayMultiplicity[1] = 8.5; | |
50 | fBinLimitsArrayMultiplicity[2] = 16.5; | |
51 | fBinLimitsArrayMultiplicity[3] = 27.5; | |
52 | fBinLimitsArrayMultiplicity[4] = 41.5; | |
53 | fBinLimitsArrayMultiplicity[5] = 200.; | |
54 | ||
55 | if(fIsHeavyIon){ | |
56 | fBinLimitsArrayMultiplicity[0] = 0; | |
57 | fBinLimitsArrayMultiplicity[1] = 200.; | |
58 | fBinLimitsArrayMultiplicity[2] = 500.; | |
59 | fBinLimitsArrayMultiplicity[3] = 1000.; | |
60 | fBinLimitsArrayMultiplicity[4] = 1500.; | |
61 | fBinLimitsArrayMultiplicity[5] = 5000.; | |
62 | } | |
63 | } | |
64 | else{ | |
65 | // Use V0 Multiplicity | |
66 | ||
67 | fBinLimitsArrayMultiplicity[0] = 2; | |
68 | fBinLimitsArrayMultiplicity[1] = 3; | |
69 | fBinLimitsArrayMultiplicity[2] = 4; | |
70 | fBinLimitsArrayMultiplicity[3] = 5; | |
71 | fBinLimitsArrayMultiplicity[4] = 9999; | |
72 | ||
73 | if(fIsHeavyIon){ | |
74 | fBinLimitsArrayMultiplicity[0] = 2; | |
75 | fBinLimitsArrayMultiplicity[1] = 10; | |
76 | fBinLimitsArrayMultiplicity[2] = 30; | |
77 | fBinLimitsArrayMultiplicity[3] = 50; | |
78 | fBinLimitsArrayMultiplicity[4] = 9999; | |
79 | } | |
80 | } | |
81 | Initialize(); | |
82 | } | |
83 | ||
84 | //________________________________________________________________________ | |
85 | AliConversionAODBGHandlerRP::~AliConversionAODBGHandlerRP() | |
86 | { | |
87 | if(fBinLimitsArrayZ){ | |
88 | delete[] fBinLimitsArrayZ; | |
89 | fBinLimitsArrayZ=0x0;} | |
90 | if(fBinLimitsArrayMultiplicity){ | |
91 | delete[] fBinLimitsArrayMultiplicity; | |
92 | fBinLimitsArrayMultiplicity=0x0;} | |
93 | ||
94 | if(fBGEventCounter){ | |
95 | ||
96 | for(Int_t z=0;z<fNBinsZ;z++){ | |
97 | delete[] fBGEventCounter[z]; | |
98 | } | |
99 | delete[] fBGEventCounter; | |
100 | fBGEventCounter = NULL; | |
101 | } | |
102 | ||
103 | // Delete pool | |
104 | ||
105 | for(Int_t z=0;z<fNBinsZ;z++){ | |
106 | for(Int_t m=0;m<fNBinsMultiplicity;m++){ | |
107 | for(Int_t eventCounter=0;eventCounter<fNBGEvents[z][m]&&eventCounter<fNEvents;eventCounter++){ | |
108 | ||
109 | for(UInt_t d=0;d<fBGPool[z][m][eventCounter].size();d++){ | |
110 | delete (AliAODConversionPhoton*)(fBGPool[z][m][eventCounter][d]); | |
111 | } | |
112 | } | |
113 | } | |
114 | } | |
115 | ||
116 | if(fNBGEvents){ | |
117 | for(Int_t z=0;z<fNBinsZ;z++){ | |
118 | delete[] fNBGEvents[z]; | |
119 | } | |
120 | delete[] fNBGEvents; | |
121 | fNBGEvents = NULL; | |
122 | } | |
123 | ||
124 | } | |
125 | ||
126 | //________________________________________________________________________ | |
127 | void AliConversionAODBGHandlerRP::Initialize(){ | |
128 | ||
129 | // Counter | |
130 | ||
131 | if(fBGEventCounter == NULL){ | |
132 | fBGEventCounter= new Int_t*[fNBinsZ]; | |
133 | } | |
134 | for(Int_t z=0;z<fNBinsZ;z++){ | |
135 | fBGEventCounter[z]=new Int_t[fNBinsMultiplicity]; | |
136 | } | |
137 | ||
138 | for(Int_t z=0;z<fNBinsZ;z++){ | |
139 | for(Int_t m=0;m<fNBinsMultiplicity;m++){ | |
140 | fBGEventCounter[z][m]=0; | |
141 | } | |
142 | } | |
143 | ||
144 | if(fNBGEvents == NULL){ | |
145 | fNBGEvents= new Int_t*[fNBinsZ]; | |
146 | } | |
147 | for(Int_t z=0;z<fNBinsZ;z++){ | |
148 | fNBGEvents[z]=new Int_t[fNBinsMultiplicity]; | |
149 | } | |
150 | for(Int_t z=0;z<fNBinsZ;z++){ | |
151 | for(Int_t m=0;m<fNBinsMultiplicity;m++){ | |
152 | fNBGEvents[z][m]=0; | |
153 | } | |
154 | } | |
155 | } | |
156 | ||
157 | //------------------------------------------------------------- | |
158 | ||
159 | Int_t AliConversionAODBGHandlerRP::GetZBinIndex(Double_t zvalue) const{ | |
160 | ||
161 | if(zvalue<=fBinLimitsArrayZ[0]){ | |
162 | return -1; | |
163 | } | |
164 | ||
165 | if(fNBinsZ<2){return 0;} | |
166 | ||
167 | for(Int_t i=0; i<fNBinsZ ;i++){ | |
168 | if(zvalue >= fBinLimitsArrayZ[i] && zvalue <= fBinLimitsArrayZ[i+1]){ | |
169 | return i; | |
170 | } | |
171 | } | |
172 | return -1; | |
173 | } | |
174 | //------------------------------------------------------------- | |
175 | Int_t AliConversionAODBGHandlerRP::GetMultiplicityBinIndex(Int_t multiplicity) const{ | |
176 | if(fNBinsMultiplicity<2){ | |
177 | return 0; | |
178 | } | |
179 | ||
180 | for(Int_t i=0; i<fNBinsMultiplicity ;i++){ | |
181 | if(multiplicity >= fBinLimitsArrayMultiplicity[i] && multiplicity < fBinLimitsArrayMultiplicity[i+1]){ | |
182 | return i; | |
183 | } | |
184 | } | |
185 | return -1; | |
186 | } | |
187 | ||
188 | //------------------------------------------------------------- | |
189 | Bool_t AliConversionAODBGHandlerRP::FindBins(TObjArray * const eventGammas,AliVEvent *fInputEvent,Int_t &zbin,Int_t &mbin){ | |
190 | Double_t vertexz=fInputEvent->GetPrimaryVertex()->GetZ(); | |
191 | zbin = GetZBinIndex(vertexz); | |
192 | ||
193 | Int_t multiplicity=0; | |
194 | if(fUseChargedTrackMult){ | |
195 | multiplicity=fInputEvent->GetNumberOfTracks(); | |
196 | } | |
197 | else{ | |
198 | multiplicity=eventGammas->GetEntries(); | |
199 | } | |
200 | mbin = GetMultiplicityBinIndex(multiplicity); | |
201 | ||
202 | if(zbin<fNBinsZ&&mbin<fNBinsMultiplicity){ | |
203 | if(zbin>=0&&mbin>=0){ | |
204 | return kTRUE; | |
205 | } | |
206 | } | |
207 | //cout<<Form("Requested BG pool does not exist: z %i m %i",zbin,mbin)<<endl; | |
208 | return kFALSE; | |
209 | } | |
e5b6e8a6 | 210 | //------------------------------------------------------------- |
211 | Bool_t AliConversionAODBGHandlerRP::FindBins(TList * const eventGammas,AliVEvent *fInputEvent,Int_t &zbin,Int_t &mbin){ | |
212 | Double_t vertexz=fInputEvent->GetPrimaryVertex()->GetZ(); | |
213 | zbin = GetZBinIndex(vertexz); | |
214 | ||
215 | Int_t multiplicity=0; | |
216 | if(fUseChargedTrackMult){ | |
217 | multiplicity=fInputEvent->GetNumberOfTracks(); | |
218 | } | |
219 | else{ | |
220 | multiplicity=eventGammas->GetEntries(); | |
221 | } | |
222 | mbin = GetMultiplicityBinIndex(multiplicity); | |
223 | ||
224 | if(zbin<fNBinsZ&&mbin<fNBinsMultiplicity){ | |
225 | if(zbin>=0&&mbin>=0){ | |
226 | return kTRUE; | |
227 | } | |
228 | } | |
229 | //cout<<Form("Requested BG pool does not exist: z %i m %i",zbin,mbin)<<endl; | |
230 | return kFALSE; | |
231 | } | |
1528f6d1 | 232 | |
233 | ||
234 | //------------------------------------------------------------- | |
235 | void AliConversionAODBGHandlerRP::AddEvent(TObjArray * const eventGammas,AliVEvent *fInputEvent){ | |
236 | ||
237 | if(eventGammas->GetEntriesFast()==0)return; | |
238 | ||
239 | Int_t z; | |
240 | Int_t m; | |
241 | if(FindBins(eventGammas,fInputEvent,z,m)){ | |
242 | ||
243 | ||
244 | // If Event Stack is full, replace the first entry (First in first out) | |
245 | if(fBGEventCounter[z][m] >= fNEvents){ | |
246 | fBGEventCounter[z][m]=0; | |
247 | } | |
248 | ||
249 | // Update number of Events stored | |
250 | if(fNBGEvents[z][m] < fNEvents){ | |
251 | fNBGEvents[z][m]++; | |
252 | } | |
253 | ||
254 | Int_t eventCounter=fBGEventCounter[z][m]; | |
255 | ||
256 | //clear the vector for old gammas | |
257 | for(UInt_t d=0;d<fBGPool[z][m][eventCounter].size();d++){ | |
258 | delete (AliAODConversionPhoton*)(fBGPool[z][m][eventCounter][d]); | |
259 | } | |
260 | ||
261 | fBGPool[z][m][eventCounter].clear(); | |
262 | ||
263 | // add the gammas to the vector | |
264 | ||
265 | for(Int_t i=0; i< eventGammas->GetEntriesFast();i++){ | |
266 | fBGPool[z][m][eventCounter].push_back(new AliAODConversionPhoton(*(AliAODConversionPhoton*)(eventGammas->At(i)))); | |
267 | } | |
268 | ||
269 | fBGEventCounter[z][m]++; | |
270 | } | |
271 | } | |
e5b6e8a6 | 272 | //------------------------------------------------------------- |
273 | void AliConversionAODBGHandlerRP::AddEvent(TList * const eventGammas,AliVEvent *fInputEvent){ | |
274 | if(eventGammas->GetEntries()==0)return; | |
275 | ||
276 | Int_t z; | |
277 | Int_t m; | |
278 | if(FindBins(eventGammas,fInputEvent,z,m)){ | |
279 | ||
280 | ||
281 | // If Event Stack is full, replace the first entry (First in first out) | |
282 | if(fBGEventCounter[z][m] >= fNEvents){ | |
283 | fBGEventCounter[z][m]=0; | |
284 | } | |
285 | ||
286 | // Update number of Events stored | |
287 | if(fNBGEvents[z][m] < fNEvents){ | |
288 | fNBGEvents[z][m]++; | |
289 | } | |
290 | ||
291 | Int_t eventCounter=fBGEventCounter[z][m]; | |
292 | ||
293 | //clear the vector for old gammas | |
294 | for(UInt_t d=0;d<fBGPool[z][m][eventCounter].size();d++){ | |
295 | delete (AliAODConversionPhoton*)(fBGPool[z][m][eventCounter][d]); | |
296 | } | |
297 | ||
298 | fBGPool[z][m][eventCounter].clear(); | |
299 | ||
300 | // add the gammas to the vector | |
301 | ||
302 | for(Int_t i=0; i< eventGammas->GetEntries();i++){ | |
303 | fBGPool[z][m][eventCounter].push_back(new AliAODConversionPhoton(*(AliAODConversionPhoton*)(eventGammas->At(i)))); | |
304 | } | |
305 | ||
306 | fBGEventCounter[z][m]++; | |
307 | } | |
308 | } | |
1528f6d1 | 309 | |
310 | //------------------------------------------------------------- | |
311 | AliGammaConversionPhotonVector* AliConversionAODBGHandlerRP::GetBGGoodGammas(TObjArray * const eventGammas,AliVEvent *fInputEvent,Int_t event){ | |
312 | Int_t zbin; | |
313 | Int_t mbin; | |
314 | if(FindBins(eventGammas,fInputEvent,zbin,mbin)){ | |
315 | return &(fBGPool[zbin][mbin][event]); | |
316 | } | |
317 | return NULL; | |
318 | } | |
e5b6e8a6 | 319 | //------------------------------------------------------------- |
320 | AliGammaConversionPhotonVector* AliConversionAODBGHandlerRP::GetBGGoodGammas(TList * const eventGammas,AliVEvent *fInputEvent,Int_t event){ | |
321 | Int_t zbin; | |
322 | Int_t mbin; | |
323 | if(FindBins(eventGammas,fInputEvent,zbin,mbin)){ | |
324 | return &(fBGPool[zbin][mbin][event]); | |
325 | } | |
326 | return NULL; | |
327 | } | |
1528f6d1 | 328 | |
329 | //------------------------------------------------------------- | |
330 | Int_t AliConversionAODBGHandlerRP::GetNBGEvents(TObjArray * const eventGammas,AliVEvent *fInputEvent){ | |
331 | Int_t zbin; | |
332 | Int_t mbin; | |
333 | if(FindBins(eventGammas,fInputEvent,zbin,mbin)){ | |
334 | return fNBGEvents[zbin][mbin]; | |
335 | } | |
336 | return 0; | |
337 | } | |
e5b6e8a6 | 338 | //------------------------------------------------------------- |
339 | Int_t AliConversionAODBGHandlerRP::GetNBGEvents(TList * const eventGammas,AliVEvent *fInputEvent){ | |
340 | Int_t zbin; | |
341 | Int_t mbin; | |
342 | if(FindBins(eventGammas,fInputEvent,zbin,mbin)){ | |
343 | return fNBGEvents[zbin][mbin]; | |
344 | } | |
345 | return 0; | |
346 | } | |
1528f6d1 | 347 |