]>
Commit | Line | Data |
---|---|---|
8d122774 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
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 | /* $Id$ */ | |
17 | ||
18 | //------------------------------------------------------------------------- | |
19 | // AOD class to store calorimeter cell data | |
20 | // Author: Markus Oldenburg, CERN | |
21 | //------------------------------------------------------------------------- | |
22 | ||
23 | #include "AliAODCaloCells.h" | |
24 | ||
25 | ClassImp(AliAODCaloCells) | |
26 | ||
77e93dc2 | 27 | //_______________________________________________________ |
28 | AliAODCaloCells::AliAODCaloCells() : | |
dcd7321d | 29 | AliVCaloCells(), fNCells(0), fHGLG(0), fCellNumber(0), |
77e93dc2 | 30 | fAmplitude(0), fTime(0), fEFraction(0), fMCLabel(0), |
31 | fIsSorted(kTRUE), fType(kUndef) | |
8d122774 | 32 | { |
33 | // default constructor | |
34 | } | |
35 | ||
77e93dc2 | 36 | //_____________________________________________________________________________________ |
c8fe2783 | 37 | AliAODCaloCells::AliAODCaloCells(const char* name, const char* title, VCells_t ttype) : |
dcd7321d | 38 | AliVCaloCells(name, title), fNCells(0), fHGLG(0), fCellNumber(0), |
77e93dc2 | 39 | fAmplitude(0), fTime(0), fEFraction(0), fMCLabel(0), |
40 | fIsSorted(kTRUE), fType(ttype) | |
8d122774 | 41 | { |
c8fe2783 | 42 | //constructor |
8d122774 | 43 | } |
44 | ||
77e93dc2 | 45 | //________________________________________________________________ |
5c1dc41f | 46 | AliAODCaloCells::AliAODCaloCells(const AliAODCaloCells& cells) : |
dcd7321d | 47 | AliVCaloCells(cells), fNCells(cells.fNCells), fHGLG(0), fCellNumber(0), |
77e93dc2 | 48 | fAmplitude(0), fTime(0), fEFraction(0), fMCLabel(0), |
49 | fIsSorted(cells.fIsSorted), fType(cells.fType) | |
5c1dc41f | 50 | { |
51 | // Copy constructor | |
c8fe2783 | 52 | fCellNumber = new Short_t[fNCells]; |
53 | fAmplitude = new Double32_t[fNCells]; | |
77e93dc2 | 54 | fTime = new Double32_t[fNCells]; |
60d77596 | 55 | fMCLabel = new Int_t[fNCells]; |
77e93dc2 | 56 | fEFraction = new Double32_t[fNCells]; |
57 | ||
c8fe2783 | 58 | for (Int_t i = 0; i < fNCells; i++) { |
59 | fCellNumber[i] = cells.fCellNumber[i]; | |
60 | fAmplitude[i] = cells.fAmplitude[i]; | |
00c970e8 | 61 | if(cells.fTime) fTime[i] = cells.fTime[i]; |
77e93dc2 | 62 | if(cells.fMCLabel) fMCLabel[i] = cells.fMCLabel[i]; |
63 | if(cells.fEFraction)fEFraction[i] = cells.fEFraction[i]; | |
c8fe2783 | 64 | } |
75f071c1 | 65 | if(cells.fHGLG){ |
66 | fHGLG = new Bool_t[fNCells] ; | |
67 | for (Int_t i = 0; i < fNCells; i++) { | |
68 | fHGLG[i] = cells.fHGLG[i]; | |
69 | } | |
70 | } | |
5c1dc41f | 71 | } |
72 | ||
77e93dc2 | 73 | //________________________________________________________________________ |
0d7404df | 74 | AliAODCaloCells& AliAODCaloCells::operator=(const AliAODCaloCells& source) |
5c1dc41f | 75 | { |
77e93dc2 | 76 | // Assignment operator |
77 | if(this != &source) | |
78 | { | |
0d7404df | 79 | AliVCaloCells::operator=(source); |
80 | ||
77e93dc2 | 81 | if(fNCells != source.fNCells) |
82 | { | |
75f071c1 | 83 | if(fHGLG) |
84 | delete [] fHGLG ; | |
0d7404df | 85 | delete [] fCellNumber; |
86 | delete [] fAmplitude; | |
77e93dc2 | 87 | delete [] fTime; |
88 | delete [] fMCLabel; | |
89 | delete [] fEFraction; | |
90 | ||
0d7404df | 91 | fNCells = source.fNCells; |
77e93dc2 | 92 | |
75f071c1 | 93 | if(source.fHGLG) |
94 | fHGLG = new Bool_t[fNCells] ; | |
0d7404df | 95 | fCellNumber = new Short_t[fNCells]; |
96 | fAmplitude = new Double32_t[fNCells]; | |
77e93dc2 | 97 | fTime = new Double32_t[fNCells]; |
60d77596 | 98 | fMCLabel = new Int_t[fNCells]; |
77e93dc2 | 99 | fEFraction = new Double32_t[fNCells]; |
0d7404df | 100 | } |
77e93dc2 | 101 | |
75f071c1 | 102 | if(source.fHGLG) |
103 | memcpy(fCellNumber,source.fHGLG,fNCells*sizeof(Bool_t)); | |
0d7404df | 104 | memcpy(fCellNumber,source.fCellNumber, fNCells*sizeof(Short_t)); |
105 | memcpy(fAmplitude, source.fAmplitude, fNCells*sizeof(Double32_t)); | |
77e93dc2 | 106 | if(source.fTime && fTime) memcpy(fTime, source.fTime, fNCells*sizeof(Double32_t)); |
60d77596 | 107 | if(source.fMCLabel && fMCLabel) memcpy(fMCLabel, source.fMCLabel, fNCells*sizeof(Int_t)); |
77e93dc2 | 108 | if(source.fEFraction && fEFraction) memcpy(fEFraction, source.fEFraction, fNCells*sizeof(Double32_t)); |
109 | ||
0d7404df | 110 | fIsSorted = source.fIsSorted; |
111 | fType = source.fType; | |
c8fe2783 | 112 | } |
0d7404df | 113 | |
c8fe2783 | 114 | return *this; |
0d7404df | 115 | |
5c1dc41f | 116 | } |
117 | ||
77e93dc2 | 118 | //_________________________________ |
8d122774 | 119 | AliAODCaloCells::~AliAODCaloCells() |
120 | { | |
121 | // destructor | |
122 | ||
123 | DeleteContainer(); | |
124 | } | |
125 | ||
8dd6eba0 | 126 | void AliAODCaloCells::Clear(const Option_t*) |
127 | { | |
128 | // clear | |
129 | ||
130 | DeleteContainer(); | |
131 | } | |
ecff8f07 | 132 | |
77e93dc2 | 133 | void AliAODCaloCells::Copy(TObject &obj) const |
134 | { | |
ecff8f07 | 135 | |
136 | // this overwrites the virtual TOBject::Copy() | |
137 | // to allow run time copying without casting | |
138 | // in AliESDEvent | |
139 | ||
140 | if(this==&obj)return; | |
141 | AliAODCaloCells *robj = dynamic_cast<AliAODCaloCells*>(&obj); | |
142 | if(!robj)return; // not an AliAODCaloCells | |
143 | *robj = *this; | |
144 | ||
145 | } | |
146 | ||
77e93dc2 | 147 | //______________________________________________________________________ |
148 | AliVCaloCells *AliAODCaloCells::CopyCaloCells(Bool_t all = kTRUE) const | |
149 | { | |
ecff8f07 | 150 | |
151 | // copy the calo cells into a new object. If option all=FALSE, just the object type, | |
152 | // for mixing | |
153 | ||
154 | AliVCaloCells *obj = new AliAODCaloCells(); | |
155 | ||
156 | if(all){ | |
157 | obj->SetName (GetName()) ; | |
158 | obj->SetTitle(GetTitle()) ; | |
159 | obj->SetType (GetType()) ; | |
160 | ||
161 | obj->SetNumberOfCells(fNCells); | |
162 | for (Short_t i = 0; i < fNCells; i++) | |
77e93dc2 | 163 | { |
164 | Int_t mclabel = -1; | |
165 | if(fMCLabel) mclabel = fMCLabel[i]; | |
166 | ||
167 | Float_t efrac = 0.; | |
168 | if(fEFraction) efrac = fEFraction[i]; | |
169 | ||
170 | Float_t time = -1; | |
171 | if(fTime) time = fTime[i]; | |
172 | ||
173 | obj->SetCell(i,fCellNumber[i],fAmplitude[i],time,mclabel,efrac); | |
174 | } | |
ecff8f07 | 175 | } |
176 | ||
177 | return obj; | |
178 | ||
179 | } | |
180 | ||
77e93dc2 | 181 | //___________________________________________________ |
8d122774 | 182 | void AliAODCaloCells::CreateContainer(Short_t nCells) |
183 | { | |
184 | // function that creates container to store calorimeter cell data | |
185 | ||
186 | DeleteContainer(); | |
187 | ||
f8785caa | 188 | if (nCells <= 0) |
189 | { | |
8d122774 | 190 | fNCells = 0; |
191 | return; | |
192 | } | |
193 | ||
194 | fNCells = nCells; | |
195 | ||
dcd7321d | 196 | fHGLG = new Bool_t[fNCells]; |
8d122774 | 197 | fCellNumber = new Short_t[fNCells]; |
c8fe2783 | 198 | fAmplitude = new Double32_t[fNCells]; |
77e93dc2 | 199 | fTime = new Double32_t[fNCells]; |
60d77596 | 200 | fMCLabel = new Int_t[fNCells]; |
77e93dc2 | 201 | fEFraction = new Double32_t[fNCells]; |
c8fe2783 | 202 | |
341952b8 | 203 | // set to zero |
f8785caa | 204 | for(int i = 0;i<fNCells;++i) |
205 | { | |
dcd7321d | 206 | fHGLG[i]=kFALSE ; |
f8785caa | 207 | fAmplitude [i] = 0.; |
208 | fCellNumber[i] = -1 ; | |
209 | fEFraction [i] = 0.; | |
210 | fTime [i] = -1.; | |
211 | fMCLabel [i] = -1 ; | |
341952b8 | 212 | } |
8d122774 | 213 | } |
214 | ||
77e93dc2 | 215 | //_____________________________________ |
8d122774 | 216 | void AliAODCaloCells::DeleteContainer() |
217 | { | |
218 | // deletes allocated memory | |
dcd7321d | 219 | if(fHGLG){ |
220 | delete[] fHGLG; | |
221 | fHGLG = 0 ; | |
222 | } | |
8d122774 | 223 | |
224 | if (fCellNumber) | |
225 | { | |
226 | delete[] fCellNumber; | |
c8fe2783 | 227 | fCellNumber = NULL; |
8d122774 | 228 | } |
229 | ||
230 | if (fAmplitude) | |
231 | { | |
232 | delete[] fAmplitude; | |
c8fe2783 | 233 | fAmplitude = NULL; |
8d122774 | 234 | } |
c8fe2783 | 235 | |
77e93dc2 | 236 | if (fTime) |
237 | { | |
238 | delete[] fTime; | |
239 | fTime = NULL; | |
240 | } | |
241 | ||
242 | if (fMCLabel) | |
243 | { | |
244 | delete[] fMCLabel; | |
245 | fMCLabel = NULL; | |
246 | } | |
247 | ||
248 | if (fEFraction) | |
249 | { | |
250 | delete[] fEFraction; | |
251 | fEFraction = NULL; | |
252 | } | |
253 | ||
254 | ||
8d122774 | 255 | fNCells = 0; |
256 | fIsSorted = kFALSE; | |
257 | } | |
258 | ||
77e93dc2 | 259 | //__________________________ |
8d122774 | 260 | void AliAODCaloCells::Sort() |
261 | { | |
262 | // sort the cell array by cell number | |
263 | ||
264 | Int_t *idxArray = new Int_t[fNCells]; | |
265 | TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE); | |
266 | ||
75f071c1 | 267 | Bool_t *newHGLG =0x0 ; |
268 | if(fHGLG) newHGLG = new Bool_t[fNCells]; | |
c8fe2783 | 269 | Short_t *newIndex = new Short_t[fNCells]; |
8d122774 | 270 | Double32_t *newAmplitude = new Double32_t[fNCells]; |
f8785caa | 271 | |
272 | Double32_t *newTime = 0; | |
60d77596 | 273 | Int_t *newMCLabel = 0 ; |
f8785caa | 274 | Double32_t *newEFraction = 0 ; |
275 | if(fTime) newTime = new Double32_t[fNCells]; | |
60d77596 | 276 | if(fMCLabel) newMCLabel = new Int_t[fNCells]; |
f8785caa | 277 | if(fEFraction) newEFraction = new Double32_t[fNCells]; |
278 | ||
77e93dc2 | 279 | for (Int_t i=0; i < fNCells; i++) |
280 | { | |
c8fe2783 | 281 | newIndex[i] = fCellNumber[idxArray[i]]; |
77e93dc2 | 282 | newAmplitude[i] = fAmplitude [idxArray[i]]; |
283 | if(fTime) newTime[i] = fTime [idxArray[i]]; | |
284 | if(fMCLabel) newMCLabel[i] = fMCLabel [idxArray[i]]; | |
285 | if(fEFraction) newEFraction[i] = fEFraction[idxArray[i]]; | |
8d122774 | 286 | } |
75f071c1 | 287 | if(fHGLG){ |
288 | for (Int_t i=0; i < fNCells; i++) | |
289 | { | |
290 | newHGLG[i] = fHGLG[idxArray[i]]; | |
291 | } | |
292 | delete [] fHGLG; | |
293 | } | |
77e93dc2 | 294 | |
8d122774 | 295 | delete [] fCellNumber; |
296 | delete [] fAmplitude; | |
77e93dc2 | 297 | delete [] fTime; |
298 | delete [] fMCLabel; | |
299 | delete [] fEFraction; | |
300 | ||
dcd7321d | 301 | fHGLG = newHGLG; |
8d122774 | 302 | fCellNumber = newIndex; |
c8fe2783 | 303 | fAmplitude = newAmplitude; |
77e93dc2 | 304 | if(fTime) fTime = newTime; |
305 | if(fMCLabel) fMCLabel = newMCLabel; | |
306 | if(fEFraction) fEFraction = newEFraction; | |
307 | ||
8d122774 | 308 | delete [] idxArray; |
309 | ||
310 | fIsSorted = kTRUE; | |
311 | } | |
312 | ||
77e93dc2 | 313 | //________________________________________________________________________________________ |
314 | Bool_t AliAODCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, | |
dcd7321d | 315 | Double32_t time, Int_t mclabel, Double32_t efrac, Bool_t isHG) |
8d122774 | 316 | { |
317 | // Sets a cell at the given position | |
318 | ||
77e93dc2 | 319 | if (pos>=0 && pos < fNCells) |
320 | { | |
75f071c1 | 321 | if(fHGLG) |
322 | fHGLG[pos]=isHG ; | |
8d122774 | 323 | fCellNumber[pos] = cellNumber; |
c8fe2783 | 324 | fAmplitude[pos] = amplitude; |
77e93dc2 | 325 | |
00c970e8 | 326 | // note: initialize (can't use memset for non-0 values) |
327 | // plus sizeof(Double32_t) is 0 | |
328 | if(!fTime){ | |
329 | fTime = new Double32_t[fNCells]; | |
330 | ||
331 | for( Int_t i = 0; i < fNCells; i++ ) | |
332 | fTime[i] = -1; | |
333 | } | |
334 | if(!fMCLabel){ | |
60d77596 | 335 | fMCLabel = new Int_t[fNCells]; |
00c970e8 | 336 | |
337 | for( Int_t i = 0; i < fNCells; i++ ) | |
338 | fMCLabel[i] = -1; | |
339 | } | |
340 | if(!fEFraction){ | |
341 | fEFraction = new Double32_t[fNCells]; | |
342 | ||
343 | for( Int_t i = 0; i < fNCells; i++ ) | |
344 | fEFraction[i] = 0; | |
345 | } | |
77e93dc2 | 346 | |
347 | fTime[pos] = time; | |
348 | fMCLabel[pos] = mclabel; | |
349 | fEFraction[pos] = efrac; | |
350 | ||
351 | fIsSorted = kFALSE; | |
352 | ||
8d122774 | 353 | return kTRUE; |
77e93dc2 | 354 | |
8d122774 | 355 | } else { |
356 | return kFALSE; | |
357 | } | |
358 | } | |
77e93dc2 | 359 | |
360 | ||
361 | ||
362 |