]>
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 | { | |
dcd7321d | 61 | fHGLG[i] = c.fHGLG[i]; |
c8fe2783 | 62 | fCellNumber[i] = c.fCellNumber[i]; |
63 | fAmplitude[i] = c.fAmplitude[i]; | |
64 | fTime[i] = c.fTime[i]; | |
77e93dc2 | 65 | if(c.fMCLabel) fMCLabel[i] = c.fMCLabel[i]; |
66 | if(c.fEFraction)fEFraction[i] = c.fEFraction[i]; | |
e649177a | 67 | } |
68 | } | |
69 | ||
77e93dc2 | 70 | //__________________________________________________________________________ |
e649177a | 71 | AliESDCaloCells & AliESDCaloCells::operator =(const AliESDCaloCells& source) |
72 | { | |
73 | // assignment operator | |
74 | ||
77e93dc2 | 75 | if(this != &source) |
76 | { | |
80e4768f | 77 | AliVCaloCells::operator=(source); |
78 | ||
77e93dc2 | 79 | if(fNCells != source.fNCells) |
80 | { | |
dcd7321d | 81 | delete [] fHGLG ; |
80e4768f | 82 | delete [] fCellNumber; |
83 | delete [] fAmplitude; | |
84 | delete [] fTime; | |
77e93dc2 | 85 | delete [] fMCLabel; |
86 | delete [] fEFraction; | |
87 | ||
80e4768f | 88 | fNCells = source.fNCells; |
77e93dc2 | 89 | |
dcd7321d | 90 | fHGLG = new Bool_t[fNCells] ; |
80e4768f | 91 | fCellNumber = new Short_t[fNCells]; |
77e93dc2 | 92 | fAmplitude = new Double32_t[fNCells]; |
93 | fTime = new Double32_t[fNCells]; | |
60d77596 | 94 | fMCLabel = new Int_t[fNCells]; |
f8785caa | 95 | fEFraction = new Double32_t[fNCells]; |
80e4768f | 96 | } |
80e4768f | 97 | |
dcd7321d | 98 | memcpy(fCellNumber,source.fHGLG,fNCells*sizeof(Bool_t)); |
77e93dc2 | 99 | memcpy(fCellNumber,source.fCellNumber,fNCells*sizeof(Short_t)); |
100 | memcpy(fAmplitude, source.fAmplitude, fNCells*sizeof(Double32_t)); | |
101 | memcpy(fTime, source.fTime, fNCells*sizeof(Double32_t)); | |
60d77596 | 102 | if(source.fMCLabel && fMCLabel) memcpy(fMCLabel, source.fMCLabel, fNCells*sizeof(Int_t)); |
77e93dc2 | 103 | if(source.fEFraction && fEFraction) memcpy(fEFraction, source.fEFraction, fNCells*sizeof(Double32_t)); |
104 | ||
80e4768f | 105 | fIsSorted = source.fIsSorted; |
106 | fType = source.fType; | |
107 | ||
e649177a | 108 | } |
109 | ||
110 | return *this; | |
e649177a | 111 | } |
112 | ||
77e93dc2 | 113 | //____________________________________________ |
114 | void AliESDCaloCells::Copy(TObject &obj) const | |
115 | { | |
732a24fe | 116 | // this overwrites the virtual TOBject::Copy() |
117 | // to allow run time copying without casting | |
118 | // in AliESDEvent | |
119 | ||
120 | if(this==&obj)return; | |
121 | AliESDCaloCells *robj = dynamic_cast<AliESDCaloCells*>(&obj); | |
122 | if(!robj)return; // not an AliESDCaloCells | |
123 | *robj = *this; | |
124 | ||
125 | } | |
126 | ||
77e93dc2 | 127 | //______________________________________________________________________ |
128 | AliVCaloCells* AliESDCaloCells::CopyCaloCells(Bool_t all = kTRUE) const | |
129 | { | |
ecff8f07 | 130 | // copy the calo cells into a new object. If option all=FALSE, just the object type, |
131 | // for mixing | |
132 | ||
133 | AliVCaloCells *obj = new AliESDCaloCells(); | |
134 | ||
135 | if(all){ | |
136 | obj->SetName (GetName()) ; | |
137 | obj->SetTitle(GetTitle()) ; | |
138 | obj->SetType (GetType()) ; | |
139 | ||
140 | obj->SetNumberOfCells(fNCells); | |
141 | for (Short_t i = 0; i < fNCells; i++) | |
77e93dc2 | 142 | { |
143 | Int_t mclabel = -1; | |
144 | if(fMCLabel) mclabel = fMCLabel[i]; | |
145 | ||
146 | Float_t efrac = 0.; | |
147 | if(fEFraction) efrac = fEFraction[i]; | |
148 | ||
149 | obj->SetCell(i,fCellNumber[i],fAmplitude[i],fTime[i],mclabel,efrac); | |
150 | } | |
ecff8f07 | 151 | } |
152 | ||
153 | return obj; | |
154 | } | |
155 | ||
156 | ||
77e93dc2 | 157 | //_________________________________ |
e649177a | 158 | AliESDCaloCells::~AliESDCaloCells() |
159 | { | |
160 | // destructor | |
161 | ||
162 | DeleteContainer(); | |
163 | } | |
164 | ||
77e93dc2 | 165 | //__________________________________________ |
8dd6eba0 | 166 | void AliESDCaloCells::Clear(const Option_t*) |
167 | { | |
168 | // clear | |
169 | ||
170 | DeleteContainer(); | |
171 | } | |
172 | ||
173 | ||
77e93dc2 | 174 | //___________________________________________________ |
e649177a | 175 | void AliESDCaloCells::CreateContainer(Short_t nCells) |
176 | { | |
177 | // function that creates container to store calorimeter cell data | |
178 | ||
179 | DeleteContainer(); | |
180 | ||
f8785caa | 181 | if (nCells <= 0) |
182 | { | |
e649177a | 183 | fNCells = 0; |
184 | return; | |
185 | } | |
186 | ||
187 | fNCells = nCells; | |
188 | ||
dcd7321d | 189 | fHGLG = new Bool_t[fNCells]; |
e649177a | 190 | fCellNumber = new Short_t[fNCells]; |
c8fe2783 | 191 | fAmplitude = new Double32_t[fNCells]; |
192 | fTime = new Double32_t[fNCells]; | |
60d77596 | 193 | fMCLabel = new Int_t[fNCells]; |
77e93dc2 | 194 | fEFraction = new Double32_t[fNCells]; |
195 | ||
196 | // set to zero | |
197 | for(int i = 0;i<fNCells;++i) | |
198 | { | |
dcd7321d | 199 | fHGLG[i]=kFALSE ; |
f8785caa | 200 | fAmplitude [i] = 0.; |
201 | fCellNumber[i] = -1 ; | |
202 | fEFraction [i] = 0.; | |
203 | fTime [i] = -1.; | |
204 | fMCLabel [i] = -1 ; | |
c8fe2783 | 205 | } |
e649177a | 206 | } |
207 | ||
77e93dc2 | 208 | //_____________________________________ |
e649177a | 209 | void AliESDCaloCells::DeleteContainer() |
210 | { | |
211 | // deletes allocated memory | |
dcd7321d | 212 | if(fHGLG){ |
213 | delete[] fHGLG; | |
214 | fHGLG = 0 ; | |
215 | } | |
216 | ||
e649177a | 217 | if (fCellNumber) |
218 | { | |
219 | delete[] fCellNumber; | |
220 | fCellNumber = 0; | |
221 | } | |
222 | ||
223 | if (fAmplitude) | |
224 | { | |
225 | delete[] fAmplitude; | |
c8fe2783 | 226 | fAmplitude = NULL; |
e649177a | 227 | } |
228 | ||
229 | if (fTime) | |
230 | { | |
231 | delete[] fTime; | |
c8fe2783 | 232 | fTime = NULL; |
e649177a | 233 | } |
c8fe2783 | 234 | |
77e93dc2 | 235 | if (fMCLabel) |
236 | { | |
237 | delete[] fMCLabel; | |
238 | fMCLabel = NULL; | |
239 | } | |
240 | ||
241 | if (fEFraction) | |
242 | { | |
243 | delete[] fEFraction; | |
244 | fEFraction = NULL; | |
245 | } | |
246 | ||
e649177a | 247 | fNCells = 0; |
248 | fIsSorted = kFALSE; | |
77e93dc2 | 249 | |
e649177a | 250 | } |
251 | ||
77e93dc2 | 252 | //__________________________ |
e649177a | 253 | void AliESDCaloCells::Sort() |
254 | { | |
255 | // sort the cell array by cell number | |
256 | ||
257 | Int_t *idxArray = new Int_t[fNCells]; | |
258 | TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE); | |
259 | ||
dcd7321d | 260 | Bool_t *newHGLG = new Bool_t[fNCells]; |
77e93dc2 | 261 | Short_t *newIndex = new Short_t[fNCells]; |
e649177a | 262 | Double32_t *newAmplitude = new Double32_t[fNCells]; |
c8fe2783 | 263 | Double32_t *newTime = new Double32_t[fNCells]; |
f8785caa | 264 | |
60d77596 | 265 | Int_t *newMCLabel = 0 ; |
f8785caa | 266 | Double32_t *newEFraction = 0 ; |
60d77596 | 267 | if(fMCLabel) newMCLabel = new Int_t[fNCells]; |
f8785caa | 268 | if(fEFraction) newEFraction = new Double32_t[fNCells]; |
77e93dc2 | 269 | |
270 | for (Int_t i=0; i < fNCells; i++) | |
271 | { | |
dcd7321d | 272 | newHGLG[i] = fHGLG[idxArray[i]]; |
c8fe2783 | 273 | newIndex[i] = fCellNumber[idxArray[i]]; |
77e93dc2 | 274 | newAmplitude[i] = fAmplitude [idxArray[i]]; |
275 | newTime[i] = fTime [idxArray[i]]; | |
276 | if(fMCLabel) newMCLabel[i] = fMCLabel [idxArray[i]]; | |
277 | if(fEFraction) newEFraction[i] = fEFraction[idxArray[i]]; | |
e649177a | 278 | } |
77e93dc2 | 279 | |
dcd7321d | 280 | delete [] fHGLG; |
e649177a | 281 | delete [] fCellNumber; |
282 | delete [] fAmplitude; | |
283 | delete [] fTime; | |
77e93dc2 | 284 | delete [] fMCLabel; |
285 | delete [] fEFraction; | |
c8fe2783 | 286 | |
dcd7321d | 287 | fHGLG = newHGLG; |
e649177a | 288 | fCellNumber = newIndex; |
c8fe2783 | 289 | fAmplitude = newAmplitude; |
290 | fTime = newTime; | |
77e93dc2 | 291 | if(fMCLabel) fMCLabel = newMCLabel; |
292 | if(fEFraction) fEFraction = newEFraction; | |
e649177a | 293 | |
294 | delete [] idxArray; | |
295 | ||
296 | fIsSorted = kTRUE; | |
297 | } | |
298 | ||
77e93dc2 | 299 | //________________________________________________________________________________________ |
300 | Bool_t AliESDCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, | |
dcd7321d | 301 | Double32_t time, Int_t mclabel, Double32_t efrac, Bool_t isHG) |
e649177a | 302 | { |
303 | // Sets a cell at the given position | |
304 | ||
77e93dc2 | 305 | if (pos>=0 && pos < fNCells) |
306 | { | |
dcd7321d | 307 | fHGLG[pos]=isHG ; |
e649177a | 308 | fCellNumber[pos] = cellNumber; |
c8fe2783 | 309 | fAmplitude[pos] = amplitude; |
310 | fTime[pos] = time; | |
77e93dc2 | 311 | |
00c970e8 | 312 | // note: initialize (can't use memset for non-0 values) |
313 | // plus sizeof(Double32_t) is 0 | |
314 | if(!fMCLabel){ | |
60d77596 | 315 | fMCLabel = new Int_t[fNCells]; |
00c970e8 | 316 | |
317 | for( Int_t i = 0; i < fNCells; i++ ) | |
318 | fMCLabel[i] = -1; | |
319 | } | |
320 | if(!fEFraction){ | |
321 | fEFraction = new Double32_t[fNCells]; | |
322 | ||
323 | for( Int_t i = 0; i < fNCells; i++ ) | |
324 | fEFraction[i] = 0; | |
325 | } | |
c8fe2783 | 326 | |
77e93dc2 | 327 | fMCLabel[pos] = mclabel; |
328 | fEFraction[pos] = efrac; | |
329 | ||
e649177a | 330 | fIsSorted = kFALSE; |
77e93dc2 | 331 | |
e649177a | 332 | return kTRUE; |
77e93dc2 | 333 | |
e649177a | 334 | } else { |
335 | return kFALSE; | |
336 | } | |
337 | } |