]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/ESD/AliESDCaloCells.cxx
including task to run in PWGGA train
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDCaloCells.cxx
CommitLineData
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
26ClassImp(AliESDCaloCells)
27
28//_______________________________________________________________________
29AliESDCaloCells::AliESDCaloCells() :
c8fe2783 30 AliVCaloCells(), fNCells(0), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(kTRUE), fType(kUndef)
e649177a 31{
32 // default constructor
33}
34//_______________________________________________________________________
c8fe2783 35 AliESDCaloCells::AliESDCaloCells(const char* name, const char* title, VCells_t ttype) :
36 AliVCaloCells(name, title), fNCells(0), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(kTRUE), fType(ttype)
37{
38 // AliVCaloCells constructor
e649177a 39 }
40
41//_______________________________________________________________________
42AliESDCaloCells::AliESDCaloCells(const AliESDCaloCells& c) :
c8fe2783 43 AliVCaloCells(c), fNCells(c.fNCells), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(c.fIsSorted), fType(c.fType)
e649177a 44{
45 // copy constructor
46
c8fe2783 47 fCellNumber = new Short_t[fNCells];
48 fAmplitude = new Double32_t[fNCells];
41086670 49 fTime = new Double32_t[fNCells];
c8fe2783 50
e649177a 51 for(Int_t i = 0; i < fNCells; i++){
c8fe2783 52 fCellNumber[i] = c.fCellNumber[i];
53 fAmplitude[i] = c.fAmplitude[i];
54 fTime[i] = c.fTime[i];
55 fAmplitude[i] = c.fAmplitude[i];
56
e649177a 57 }
58}
59
60//_______________________________________________________________________
61AliESDCaloCells & AliESDCaloCells::operator =(const AliESDCaloCells& source)
62{
63 // assignment operator
64
80e4768f 65 if(this != &source) {
66 AliVCaloCells::operator=(source);
67
68 if(fNCells != source.fNCells) {
69 delete [] fCellNumber;
70 delete [] fAmplitude;
71 delete [] fTime;
72 fNCells = source.fNCells;
73 fCellNumber = new Short_t[fNCells];
74 fAmplitude = new Double32_t[fNCells];
75 fTime = new Double32_t[fNCells];
76 }
77 memcpy(fCellNumber,source.fCellNumber,fNCells*sizeof(Short_t));
78 memcpy(fAmplitude,source.fAmplitude,fNCells*sizeof(Double32_t));
79 memcpy(fTime,source.fTime,fNCells*sizeof(Double32_t));
80
81 fIsSorted = source.fIsSorted;
82 fType = source.fType;
83
e649177a 84 }
85
86 return *this;
e649177a 87}
88
ecff8f07 89//_______________________________________________________________________
732a24fe 90void AliESDCaloCells::Copy(TObject &obj) const {
91
92 // this overwrites the virtual TOBject::Copy()
93 // to allow run time copying without casting
94 // in AliESDEvent
95
96 if(this==&obj)return;
97 AliESDCaloCells *robj = dynamic_cast<AliESDCaloCells*>(&obj);
98 if(!robj)return; // not an AliESDCaloCells
99 *robj = *this;
100
101}
102
ecff8f07 103//_______________________________________________________________________
104AliVCaloCells* AliESDCaloCells::CopyCaloCells(Bool_t all = kTRUE) const {
105
106 // copy the calo cells into a new object. If option all=FALSE, just the object type,
107 // for mixing
108
109 AliVCaloCells *obj = new AliESDCaloCells();
110
111 if(all){
112 obj->SetName (GetName()) ;
113 obj->SetTitle(GetTitle()) ;
114 obj->SetType (GetType()) ;
115
116 obj->SetNumberOfCells(fNCells);
117 for (Short_t i = 0; i < fNCells; i++)
118 obj->SetCell(i,fCellNumber[i],fAmplitude[i],fTime[i]);
119 }
120
121 return obj;
122}
123
124
e649177a 125//_______________________________________________________________________
126AliESDCaloCells::~AliESDCaloCells()
127{
128 // destructor
129
130 DeleteContainer();
131}
132
8dd6eba0 133//_______________________________________________________________________
134void AliESDCaloCells::Clear(const Option_t*)
135{
136 // clear
137
138 DeleteContainer();
139}
140
141
e649177a 142//_______________________________________________________________________
143void AliESDCaloCells::CreateContainer(Short_t nCells)
144{
145 // function that creates container to store calorimeter cell data
146
147 DeleteContainer();
148
149 if (nCells <= 0) {
150 fNCells = 0;
151 return;
152 }
153
154 fNCells = nCells;
155
156 fCellNumber = new Short_t[fNCells];
c8fe2783 157 fAmplitude = new Double32_t[fNCells];
158 fTime = new Double32_t[fNCells];
159
160 // set to zero
161 for(int i = 0;i<fNCells;++i){
162 fAmplitude[i] = fCellNumber[i] = 0 ;
163 }
e649177a 164}
165
166//_______________________________________________________________________
167void AliESDCaloCells::DeleteContainer()
168{
169 // deletes allocated memory
170
171 if (fCellNumber)
172 {
173 delete[] fCellNumber;
174 fCellNumber = 0;
175 }
176
177 if (fAmplitude)
178 {
179 delete[] fAmplitude;
c8fe2783 180 fAmplitude = NULL;
e649177a 181 }
182
183 if (fTime)
184 {
185 delete[] fTime;
c8fe2783 186 fTime = NULL;
e649177a 187 }
c8fe2783 188
e649177a 189 fNCells = 0;
190 fIsSorted = kFALSE;
191}
192
193//_______________________________________________________________________
194void AliESDCaloCells::Sort()
195{
196 // sort the cell array by cell number
197
198 Int_t *idxArray = new Int_t[fNCells];
199 TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE);
200
c8fe2783 201 Short_t *newIndex = new Short_t[fNCells];
e649177a 202 Double32_t *newAmplitude = new Double32_t[fNCells];
c8fe2783 203 Double32_t *newTime = new Double32_t[fNCells];
e649177a 204 for (Int_t i=0; i < fNCells; i++) {
c8fe2783 205 newIndex[i] = fCellNumber[idxArray[i]];
e649177a 206 newAmplitude[i] = fAmplitude[idxArray[i]];
c8fe2783 207 newTime[i] = fTime[idxArray[i]];
e649177a 208 }
209 delete [] fCellNumber;
210 delete [] fAmplitude;
211 delete [] fTime;
c8fe2783 212
e649177a 213 fCellNumber = newIndex;
c8fe2783 214 fAmplitude = newAmplitude;
215 fTime = newTime;
e649177a 216
217 delete [] idxArray;
218
219 fIsSorted = kTRUE;
220}
221
222//_______________________________________________________________________
223Bool_t AliESDCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, Double32_t time)
224{
225 // Sets a cell at the given position
226
227 if (pos>=0 && pos < fNCells) {
228 fCellNumber[pos] = cellNumber;
c8fe2783 229 fAmplitude[pos] = amplitude;
230 fTime[pos] = time;
231
e649177a 232 fIsSorted = kFALSE;
233 return kTRUE;
234 } else {
235 return kFALSE;
236 }
237}