]>
Commit | Line | Data |
---|---|---|
5e55d806 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: Ana Marin, Kathrin Koch, Kenneth Aamodt * | |
5 | * Version 1.0 * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | //////////////////////////////////////////////// | |
17 | //--------------------------------------------- | |
18 | // Class for handling of background calculation | |
19 | //--------------------------------------------- | |
20 | //////////////////////////////////////////////// | |
21 | ||
22 | #include "AliGammaConversionBGHandler.h" | |
23 | #include "AliKFParticle.h" | |
24 | #include "AliAnalysisTaskGammaConversion.h" | |
25 | ||
26 | using namespace std; | |
27 | ||
28 | ClassImp(AliGammaConversionBGHandler) | |
29 | ||
30 | AliGammaConversionBGHandler::AliGammaConversionBGHandler() : | |
31 | TObject(), | |
32 | fNEvents(10), | |
33 | fBGEventCounter(NULL), | |
7f3c7cc6 | 34 | fBGEventENegCounter(NULL), |
5e55d806 | 35 | fNBinsZ(0), |
36 | fNBinsMultiplicity(0), | |
37 | fBinLimitsArrayZ(NULL), | |
38 | fBinLimitsArrayMultiplicity(NULL), | |
7f3c7cc6 | 39 | fBGEvents(), |
40 | fBGEventsENeg() | |
5e55d806 | 41 | { |
42 | // constructor | |
43 | } | |
44 | ||
45 | AliGammaConversionBGHandler::AliGammaConversionBGHandler(UInt_t binsZ,UInt_t binsMultiplicity,UInt_t nEvents) : | |
46 | TObject(), | |
47 | fNEvents(nEvents), | |
48 | fBGEventCounter(NULL), | |
7f3c7cc6 | 49 | fBGEventENegCounter(NULL), |
5e55d806 | 50 | fNBinsZ(binsZ), |
51 | fNBinsMultiplicity(binsMultiplicity), | |
52 | fBinLimitsArrayZ(NULL), | |
53 | fBinLimitsArrayMultiplicity(NULL), | |
7f3c7cc6 | 54 | fBGEvents(binsZ,AliGammaConversionMultipicityVector(binsMultiplicity,AliGammaConversionBGEventVector(nEvents))), |
55 | fBGEventsENeg(binsZ,AliGammaConversionMultipicityVector(binsMultiplicity,AliGammaConversionBGEventVector(nEvents))) | |
5e55d806 | 56 | { |
57 | // constructor | |
58 | } | |
59 | ||
60 | AliGammaConversionBGHandler::AliGammaConversionBGHandler(const AliGammaConversionBGHandler & original) : | |
61 | TObject(original), | |
62 | fNEvents(original.fNEvents), | |
63 | fBGEventCounter(original.fBGEventCounter), | |
7f3c7cc6 | 64 | fBGEventENegCounter(original.fBGEventENegCounter), |
5e55d806 | 65 | fNBinsZ(original.fNBinsZ), |
66 | fNBinsMultiplicity(original.fNBinsMultiplicity), | |
67 | fBinLimitsArrayZ(original.fBinLimitsArrayZ), | |
68 | fBinLimitsArrayMultiplicity(original.fBinLimitsArrayMultiplicity), | |
7f3c7cc6 | 69 | fBGEvents(original.fBGEvents), |
70 | fBGEventsENeg(original.fBGEventsENeg) | |
5e55d806 | 71 | { |
72 | //copy constructor | |
73 | } | |
74 | ||
75 | AliGammaConversionBGHandler & AliGammaConversionBGHandler::operator = (const AliGammaConversionBGHandler & /*source*/) | |
76 | { | |
77 | // assignment operator | |
78 | return *this; | |
79 | } | |
80 | ||
81 | AliGammaConversionBGHandler::~AliGammaConversionBGHandler(){ | |
82 | ||
83 | //Kenneth remember to clear memory!!!!!!!!!!!!!!!!!!!!! | |
84 | if(fBGEventCounter){ | |
85 | for(Int_t z=0;z<fNBinsZ;z++){ | |
86 | delete[] fBGEventCounter[z]; | |
87 | } | |
88 | delete[] fBGEventCounter; | |
89 | fBGEventCounter = NULL; | |
90 | } | |
7f3c7cc6 | 91 | if(fBGEventENegCounter){ |
92 | for(Int_t z=0;z<fNBinsZ;z++){ | |
93 | delete[] fBGEventENegCounter[z]; | |
94 | } | |
95 | delete[] fBGEventENegCounter; | |
96 | fBGEventENegCounter = NULL; | |
97 | } | |
98 | ||
5e55d806 | 99 | if(fBinLimitsArrayZ){ |
100 | delete[] fBinLimitsArrayZ; | |
101 | } | |
102 | ||
103 | if(fBinLimitsArrayMultiplicity){ | |
104 | delete[] fBinLimitsArrayMultiplicity; | |
105 | } | |
106 | } | |
107 | ||
037dc2db | 108 | void AliGammaConversionBGHandler::Initialize(Double_t * const zBinLimitsArray, Double_t * const multiplicityBinLimitsArray){ |
5e55d806 | 109 | // see header file for documantation |
110 | ||
111 | if(zBinLimitsArray){ | |
112 | fBinLimitsArrayZ = zBinLimitsArray; | |
113 | } | |
114 | else{ | |
115 | //Print warning | |
116 | } | |
117 | ||
118 | if(multiplicityBinLimitsArray){ | |
119 | fBinLimitsArrayMultiplicity = multiplicityBinLimitsArray ; | |
120 | } | |
121 | else{ | |
122 | //Print warning | |
123 | } | |
63e16c52 | 124 | if(fBGEventCounter == NULL){ |
125 | fBGEventCounter= new Int_t*[fNBinsZ]; | |
126 | } | |
5e55d806 | 127 | for(Int_t z=0;z<fNBinsZ;z++){ |
128 | fBGEventCounter[z]=new Int_t[fNBinsMultiplicity]; | |
129 | } | |
037dc2db | 130 | |
131 | for(Int_t z=0;z<fNBinsZ;z++){ | |
132 | for(Int_t m=0;m<fNBinsMultiplicity;m++){ | |
133 | fBGEventCounter[z][m]=0; | |
134 | } | |
135 | } | |
136 | ||
7f3c7cc6 | 137 | if( fBGEventENegCounter == NULL){ |
138 | fBGEventENegCounter = new Int_t*[fNBinsZ]; | |
139 | } | |
140 | for(Int_t z=0; z < fNBinsZ; z++){ | |
141 | fBGEventENegCounter[z] = new Int_t[fNBinsMultiplicity]; | |
142 | } | |
143 | for(Int_t z=0;z<fNBinsZ;z++){ | |
144 | for(Int_t m=0;m<fNBinsMultiplicity; m++){ | |
145 | fBGEventENegCounter[z][m] = 0; | |
146 | } | |
147 | } | |
148 | ||
5e55d806 | 149 | } |
150 | ||
037dc2db | 151 | Int_t AliGammaConversionBGHandler::GetZBinIndex(Double_t zvalue) const{ |
5e55d806 | 152 | // see header file for documantation |
153 | if(fNBinsZ<2 || zvalue<=fBinLimitsArrayZ[0]){ | |
154 | return 0; | |
155 | } | |
156 | ||
157 | for(Int_t i=0; i<fNBinsZ-1 ;i++){ | |
158 | if(zvalue >= fBinLimitsArrayZ[i] && zvalue <= fBinLimitsArrayZ[i+1]){ | |
159 | return i; | |
160 | } | |
161 | } | |
162 | return fNBinsZ-1; | |
163 | } | |
164 | ||
037dc2db | 165 | Int_t AliGammaConversionBGHandler::GetMultiplicityBinIndex(Int_t multiplicity) const{ |
5e55d806 | 166 | // see header file for documantation |
167 | if(fNBinsMultiplicity<2){ | |
168 | return 0; | |
169 | } | |
170 | ||
171 | for(Int_t i=0; i<fNBinsMultiplicity-1 ;i++){ | |
172 | if(multiplicity > fBinLimitsArrayMultiplicity[i] && multiplicity < fBinLimitsArrayMultiplicity[i+1]){ | |
173 | return i; | |
174 | } | |
175 | } | |
176 | return fNBinsMultiplicity-1; | |
177 | } | |
178 | ||
037dc2db | 179 | void AliGammaConversionBGHandler::AddEvent(TClonesArray * const eventGammas, Double_t zvalue, Int_t multiplicity){ |
5e55d806 | 180 | // see header file for documantation |
181 | ||
037dc2db | 182 | // cout<<"Entering the AddEvent function"<<endl; |
183 | ||
5e55d806 | 184 | Int_t z = GetZBinIndex(zvalue); |
185 | Int_t m = GetMultiplicityBinIndex(multiplicity); | |
186 | ||
26923b22 | 187 | if(fBGEventCounter[z][m] >= fNEvents){ |
5e55d806 | 188 | fBGEventCounter[z][m]=0; |
189 | } | |
190 | Int_t eventCounter=fBGEventCounter[z][m]; | |
037dc2db | 191 | |
192 | //first clear the vector | |
193 | // cout<<"Size of vector: "<<fBGEvents[z][m][eventCounter].size()<<endl; | |
194 | // cout<<"Checking the entries: Z="<<z<<", M="<<m<<", eventCounter="<<eventCounter<<endl; | |
5e55d806 | 195 | |
037dc2db | 196 | // cout<<"The size of this vector is: "<<fBGEvents[z][m][eventCounter].size()<<endl; |
197 | for(UInt_t d=0;d<fBGEvents[z][m][eventCounter].size();d++){ | |
198 | delete (AliKFParticle*)(fBGEvents[z][m][eventCounter][d]); | |
199 | } | |
200 | fBGEvents[z][m][eventCounter].clear(); | |
5e55d806 | 201 | |
202 | // add the gammas to the vector | |
203 | for(Int_t i=0; i< eventGammas->GetEntriesFast();i++){ | |
037dc2db | 204 | // AliKFParticle *t = new AliKFParticle(*(AliKFParticle*)(eventGammas->At(i))); |
205 | fBGEvents[z][m][eventCounter].push_back(new AliKFParticle(*(AliKFParticle*)(eventGammas->At(i)))); | |
5e55d806 | 206 | } |
26923b22 | 207 | fBGEventCounter[z][m]++; |
5e55d806 | 208 | } |
7f3c7cc6 | 209 | void AliGammaConversionBGHandler::AddElectronEvent(TClonesArray* const eventENeg, Double_t zvalue, Int_t multiplicity){ |
210 | ||
211 | Int_t z = GetZBinIndex(zvalue); | |
212 | Int_t m = GetMultiplicityBinIndex(multiplicity); | |
213 | ||
214 | if(fBGEventENegCounter[z][m] >= fNEvents){ | |
215 | fBGEventENegCounter[z][m]=0; | |
216 | } | |
217 | ||
218 | ||
219 | Int_t eventENegCounter=fBGEventENegCounter[z][m]; | |
220 | ||
221 | //first clear the vector | |
222 | // cout<<"Size of vector: "<<fBGEvents[z][m][eventCounter].size()<<endl; | |
223 | // cout<<"Checking the entries: Z="<<z<<", M="<<m<<", eventCounter="<<eventCounter<<endl; | |
224 | ||
225 | // cout<<"The size of this vector is: "<<fBGEvents[z][m][eventCounter].size()<<endl; | |
226 | for(UInt_t d=0;d<fBGEventsENeg[z][m][eventENegCounter].size();d++){ | |
227 | delete (AliKFParticle*)(fBGEventsENeg[z][m][eventENegCounter][d]); | |
228 | } | |
229 | ||
230 | fBGEventsENeg[z][m][eventENegCounter].clear(); | |
231 | ||
232 | // add the electron to the vector | |
233 | for(Int_t i=0; i< eventENeg->GetEntriesFast();i++){ | |
234 | // AliKFParticle *t = new AliKFParticle(*(AliKFParticle*)(eventGammas->At(i))); | |
235 | fBGEventsENeg[z][m][eventENegCounter].push_back(new AliKFParticle(*(AliKFParticle*)(eventENeg->At(i)))); | |
236 | } | |
237 | ||
238 | fBGEventENegCounter[z][m]++; | |
5e55d806 | 239 | |
7f3c7cc6 | 240 | |
241 | } | |
5e55d806 | 242 | AliGammaConversionKFVector* AliGammaConversionBGHandler::GetBGGoodV0s(Int_t event, Double_t zvalue, Int_t multiplicity){ |
037dc2db | 243 | //see headerfile for documentation |
5e55d806 | 244 | Int_t z = GetZBinIndex(zvalue); |
245 | Int_t m = GetMultiplicityBinIndex(multiplicity); | |
246 | ||
037dc2db | 247 | return &(fBGEvents[z][m][event]); |
5e55d806 | 248 | } |
7f3c7cc6 | 249 | AliGammaConversionKFVector* AliGammaConversionBGHandler::GetBGGoodENeg(Int_t event, Double_t zvalue, Int_t multiplicity){ |
250 | ||
26923b22 | 251 | |
7f3c7cc6 | 252 | //see headerfile for documentation |
253 | Int_t z = GetZBinIndex(zvalue); | |
254 | Int_t m = GetMultiplicityBinIndex(multiplicity); | |
255 | return &(fBGEventsENeg[z][m][event]); | |
256 | ||
257 | ||
258 | } | |
26923b22 | 259 | void AliGammaConversionBGHandler::PrintBGArray(){ |
037dc2db | 260 | //see headerfile for documentation |
26923b22 | 261 | for(Int_t z=0;z<fNBinsZ;z++){ |
037dc2db | 262 | if(z==2){ |
263 | cout<<"Getting the data for z bin: "<<z<<endl; | |
264 | for(Int_t multiplicity=0;multiplicity<fNBinsMultiplicity;multiplicity++){ | |
265 | if(multiplicity==2){ | |
266 | cout<<"Getting the data for multiplicity bin: "<<multiplicity<<endl; | |
267 | for(Int_t event=0;event<fNEvents;event++){ | |
268 | if(fBGEvents[z][multiplicity][event].size()>0){ | |
269 | cout<<"Event: "<<event<<" has: "<<fBGEvents[z][multiplicity][event].size()<<endl; | |
270 | } | |
271 | } | |
26923b22 | 272 | } |
273 | } | |
274 | } | |
275 | } | |
276 | } |