]>
Commit | Line | Data |
---|---|---|
2eedd4ed | 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 | AliConversionAODBGHandlerRP::AliConversionAODBGHandlerRP() : | |
17 | fNEvents(20), | |
18 | fBGEventCounter(NULL), | |
19 | fNBGEvents(NULL), | |
20 | fNBinsZ(7), | |
21 | fNBinsCentrality(6), | |
22 | fNBinsRP(6), | |
23 | fBinLimitsArrayZ(NULL), | |
24 | fBinLimitsArrayCentrality(NULL), | |
25 | fBinLimitsArrayRP(NULL), | |
26 | fBGEvents(fNBinsRP,AliGammaConversionVertexPositionVector(fNBinsZ,AliGammaConversionCentralityVector(fNBinsCentrality,AliGammaConversionBGEventVector(fNEvents)))) | |
27 | { | |
28 | // Default Constructor | |
29 | ||
30 | // CentralityBins | |
31 | fBinLimitsArrayCentrality= new Double_t[fNBinsCentrality+1]; | |
32 | ||
33 | fBinLimitsArrayCentrality[0] = 0; | |
34 | fBinLimitsArrayCentrality[1] = 5; | |
35 | fBinLimitsArrayCentrality[2] = 10; | |
36 | fBinLimitsArrayCentrality[3] = 20; | |
37 | fBinLimitsArrayCentrality[4] = 40; | |
38 | fBinLimitsArrayCentrality[5] = 60; | |
39 | fBinLimitsArrayCentrality[6] = 90; | |
40 | ||
41 | // Vertex Z Binning | |
42 | ||
43 | fBinLimitsArrayZ = new Double_t[fNBinsZ+1]; | |
44 | ||
45 | fBinLimitsArrayZ[0] = -10; | |
46 | fBinLimitsArrayZ[1] = -5.4; | |
47 | fBinLimitsArrayZ[2] = -2.8; | |
48 | fBinLimitsArrayZ[3] = -0.6; | |
49 | fBinLimitsArrayZ[4] = 1.4; | |
50 | fBinLimitsArrayZ[5] = 3.5; | |
51 | fBinLimitsArrayZ[6] = 6.1; | |
52 | fBinLimitsArrayZ[7] = 10; | |
53 | ||
54 | // Initialize | |
55 | ||
56 | Initialize(); | |
57 | ||
58 | } | |
59 | ||
60 | AliConversionAODBGHandlerRP::AliConversionAODBGHandlerRP(Int_t NEvents,Int_t NBinsZ,Double_t *BinLimitsZ,Int_t NBinsCentrality,Double_t *BinLimitsCentrality,Int_t NBinsRP) : | |
61 | fNEvents(NEvents), | |
62 | fBGEventCounter(NULL), | |
63 | fNBGEvents(NULL), | |
64 | fNBinsZ(NBinsZ), | |
65 | fNBinsCentrality(NBinsCentrality), | |
66 | fNBinsRP(NBinsRP), | |
67 | fBinLimitsArrayZ(BinLimitsZ), | |
68 | fBinLimitsArrayCentrality(BinLimitsCentrality), | |
69 | fBinLimitsArrayRP(NULL), | |
70 | fBGEvents(fNBinsRP,AliGammaConversionVertexPositionVector(fNBinsZ,AliGammaConversionCentralityVector(fNBinsCentrality,AliGammaConversionBGEventVector(fNEvents)))) | |
71 | { | |
72 | Initialize(); | |
73 | } | |
74 | ||
75 | ||
76 | AliConversionAODBGHandlerRP::~AliConversionAODBGHandlerRP() | |
77 | { | |
78 | if(fBinLimitsArrayZ){ | |
79 | delete[] fBinLimitsArrayZ; | |
80 | fBinLimitsArrayZ=0x0;} | |
81 | if(fBinLimitsArrayCentrality){ | |
82 | delete[] fBinLimitsArrayCentrality; | |
83 | fBinLimitsArrayCentrality=0x0;} | |
84 | if(fBinLimitsArrayRP){ | |
85 | delete[] fBinLimitsArrayRP; | |
86 | fBinLimitsArrayRP=0x0;} | |
87 | ||
88 | if(fBGEventCounter){ | |
89 | ||
90 | for(Int_t psi=0;psi<fNBinsRP;psi++){ | |
91 | for(Int_t z=0;z<fNBinsZ;z++){ | |
92 | delete[] fBGEventCounter[psi][z]; | |
93 | } | |
94 | delete[] fBGEventCounter[psi]; | |
95 | } | |
96 | delete[] fBGEventCounter; | |
97 | fBGEventCounter = NULL; | |
98 | } | |
99 | ||
100 | // Delete pool | |
101 | ||
102 | for(Int_t psi=0;psi<fNBinsRP;psi++){ | |
103 | for(Int_t z=0;z<fNBinsZ;z++){ | |
104 | for(Int_t m=0;m<fNBinsCentrality;m++){ | |
105 | for(Int_t eventCounter=0;eventCounter<fNBGEvents[psi][z][m]&&eventCounter<fNEvents;eventCounter++){ | |
106 | ||
107 | for(UInt_t d=0;d<fBGEvents[psi][z][m][eventCounter].size();d++){ | |
108 | delete (AliAODConversionPhoton*)(fBGEvents[psi][z][m][eventCounter][d]); | |
109 | } | |
110 | } | |
111 | } | |
112 | } | |
113 | } | |
114 | ||
115 | if(fNBGEvents){ | |
116 | for(Int_t psi=0;psi<fNBinsRP;psi++){ | |
117 | for(Int_t z=0;z<fNBinsZ;z++){ | |
118 | delete[] fNBGEvents[psi][z]; | |
119 | } | |
120 | delete[] fNBGEvents[psi]; | |
121 | } | |
122 | delete[] fNBGEvents; | |
123 | fNBGEvents = NULL; | |
124 | } | |
125 | ||
126 | ||
127 | } | |
128 | ||
129 | ||
130 | void AliConversionAODBGHandlerRP::Initialize(){ | |
131 | ||
132 | // RP Binning | |
133 | ||
134 | fBinLimitsArrayRP=new Double_t[fNBinsRP+1]; | |
135 | ||
136 | for(Int_t i=0;i<fNBinsRP+1;i++){ | |
137 | fBinLimitsArrayRP[i] = i*TMath::Pi()/fNBinsRP; | |
138 | } | |
139 | ||
140 | // Counter | |
141 | ||
142 | if(fBGEventCounter == NULL){ | |
143 | fBGEventCounter= new Int_t**[fNBinsRP]; | |
144 | } | |
145 | for(Int_t psi=0;psi<fNBinsRP;psi++){ | |
146 | fBGEventCounter[psi]= new Int_t*[fNBinsZ]; | |
147 | ||
148 | for(Int_t z=0;z<fNBinsZ;z++){ | |
149 | fBGEventCounter[psi][z]=new Int_t[fNBinsCentrality]; | |
150 | } | |
151 | } | |
152 | for(Int_t psi=0;psi<fNBinsRP;psi++){ | |
153 | for(Int_t z=0;z<fNBinsZ;z++){ | |
154 | for(Int_t m=0;m<fNBinsCentrality;m++){ | |
155 | fBGEventCounter[psi][z][m]=0; | |
156 | } | |
157 | } | |
158 | } | |
159 | ||
160 | ||
161 | if(fNBGEvents == NULL){ | |
162 | fNBGEvents= new Int_t**[fNBinsRP]; | |
163 | } | |
164 | for(Int_t psi=0;psi<fNBinsRP;psi++){ | |
165 | fNBGEvents[psi]= new Int_t*[fNBinsZ]; | |
166 | ||
167 | for(Int_t z=0;z<fNBinsZ;z++){ | |
168 | fNBGEvents[psi][z]=new Int_t[fNBinsCentrality]; | |
169 | } | |
170 | } | |
171 | for(Int_t psi=0;psi<fNBinsRP;psi++){ | |
172 | for(Int_t z=0;z<fNBinsZ;z++){ | |
173 | for(Int_t m=0;m<fNBinsCentrality;m++){ | |
174 | fNBGEvents[psi][z][m]=0; | |
175 | } | |
176 | } | |
177 | } | |
178 | ||
179 | } | |
180 | ||
181 | //------------------------------------------------------------- | |
182 | ||
183 | Int_t AliConversionAODBGHandlerRP::GetZBinIndex(Double_t zvalue) const{ | |
184 | // see header file for documantation | |
185 | if(fNBinsZ<2 || zvalue<=fBinLimitsArrayZ[0]){ | |
186 | return 0; | |
187 | } | |
188 | ||
189 | for(Int_t i=0; i<fNBinsZ ;i++){ | |
190 | if(zvalue >= fBinLimitsArrayZ[i] && zvalue <= fBinLimitsArrayZ[i+1]){ | |
191 | return i; | |
192 | } | |
193 | } | |
194 | return -1; | |
195 | } | |
196 | //------------------------------------------------------------- | |
197 | Int_t AliConversionAODBGHandlerRP::GetCentralityBinIndex(Int_t multiplicity) const{ | |
198 | if(fNBinsCentrality<2){ | |
199 | return 0; | |
200 | } | |
201 | ||
202 | for(Int_t i=0; i<fNBinsCentrality ;i++){ | |
203 | if(multiplicity >= fBinLimitsArrayCentrality[i] && multiplicity < fBinLimitsArrayCentrality[i+1]){ | |
204 | return i; | |
205 | } | |
206 | } | |
207 | return -1; | |
208 | } | |
209 | ||
210 | //------------------------------------------------------------- | |
211 | ||
212 | Int_t AliConversionAODBGHandlerRP::GetRPBinIndex(Double_t psivalue) const{ | |
213 | ||
214 | if(fNBinsRP<2 || psivalue<=fBinLimitsArrayRP[0]){ | |
215 | return 0; | |
216 | } | |
217 | ||
218 | for(Int_t i=0; i<fNBinsRP ;i++){ | |
219 | if(psivalue >= fBinLimitsArrayRP[i] && psivalue <= fBinLimitsArrayRP[i+1]){ | |
220 | return i; | |
221 | } | |
222 | } | |
223 | return -1; | |
224 | } | |
225 | ||
226 | ||
227 | //------------------------------------------------------------- | |
228 | void AliConversionAODBGHandlerRP::AddEvent(TClonesArray * const eventGammas,Double_t psivalue,Double_t zvalue, Int_t multiplicity){ | |
229 | ||
230 | ||
231 | Int_t z = GetZBinIndex(zvalue); | |
232 | Int_t m = GetCentralityBinIndex(multiplicity); | |
233 | Int_t psi=GetRPBinIndex(psivalue); | |
234 | ||
235 | // If Event Stack is full, replace the first entry (First in first out) | |
236 | if(fBGEventCounter[psi][z][m] >= fNEvents){ | |
237 | fBGEventCounter[psi][z][m]=0; | |
238 | } | |
239 | ||
240 | // Update number of Events stored | |
241 | if(fNBGEvents[psi][z][m] < fNEvents){ | |
242 | fNBGEvents[psi][z][m]++; | |
243 | } | |
244 | ||
245 | ||
246 | Int_t eventCounter=fBGEventCounter[psi][z][m]; | |
247 | ||
248 | //clear the vector for old gammas | |
249 | for(UInt_t d=0;d<fBGEvents[psi][z][m][eventCounter].size();d++){ | |
250 | delete (AliAODConversionPhoton*)(fBGEvents[psi][z][m][eventCounter][d]); | |
251 | } | |
252 | ||
253 | fBGEvents[psi][z][m][eventCounter].clear(); | |
254 | ||
255 | ||
256 | // add the gammas to the vector | |
257 | ||
258 | for(Int_t i=0; i< eventGammas->GetEntriesFast();i++){ | |
259 | fBGEvents[psi][z][m][eventCounter].push_back(new AliAODConversionPhoton(*(AliAODConversionPhoton*)(eventGammas->At(i)))); | |
260 | } | |
261 | ||
262 | fBGEventCounter[psi][z][m]++; | |
263 | ||
264 | ||
265 | } | |
266 | ||
267 | //------------------------------------------------------------- | |
268 | AliGammaConversionPhotonVector* AliConversionAODBGHandlerRP::GetBGGoodGammas(Int_t psi,Int_t zbin, Int_t mbin, Int_t event){ | |
269 | //see headerfile for documentation | |
270 | return &(fBGEvents[psi][zbin][mbin][event]); | |
271 | } | |
272 |