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