]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDCaloCells.cxx
Transient pointer of ESDtrack back to the event introduced.
[u/mrichter/AliRoot.git] / STEER / 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() :
30 TNamed(), fNCells(0), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(kTRUE), fType(kUndef)
31{
32 // default constructor
33}
34//_______________________________________________________________________
35 AliESDCaloCells::AliESDCaloCells(const char* name, const char* title, ESDCells_t ttype) :
36 TNamed(name, title), fNCells(0), fCellNumber(0), fAmplitude(0), fTime(0), fIsSorted(kTRUE), fType(ttype)
37 {
38 // TNamed constructor
39 }
40
41//_______________________________________________________________________
42AliESDCaloCells::AliESDCaloCells(const AliESDCaloCells& c) :
43 TNamed(c), fNCells(c.fNCells), fCellNumber(), fAmplitude(), fTime(), fIsSorted(c.fIsSorted), fType(c.fType)
44{
45 // copy constructor
46
47 for(Int_t i = 0; i < fNCells; i++){
48 fCellNumber[i] = c.fCellNumber[i];
49 fAmplitude[i] = c.fAmplitude[i];
50 fTime[i] = c.fTime[i];
51 }
52}
53
54//_______________________________________________________________________
55AliESDCaloCells & AliESDCaloCells::operator =(const AliESDCaloCells& source)
56{
57 // assignment operator
58
59 if(&source == this) return *this;
60 TNamed::operator=(source);
61
732a24fe 62 if(fNCells != source.fNCells){
63 DeleteContainer();
64 CreateContainer(source.fNCells);
65 }
66
e649177a 67 fNCells = source.fNCells;
68 fIsSorted = source.fIsSorted;
69 fType = source.fType;
732a24fe 70
71
72
e649177a 73 for(Int_t i = 0; i < fNCells; i++){
74 fCellNumber[i] = source.fCellNumber[i];
75 fAmplitude[i] = source.fAmplitude[i];
76 fTime[i] = source.fTime[i];
77 }
78
79 return *this;
80
81}
82
732a24fe 83
84void AliESDCaloCells::Copy(TObject &obj) const {
85
86 // this overwrites the virtual TOBject::Copy()
87 // to allow run time copying without casting
88 // in AliESDEvent
89
90 if(this==&obj)return;
91 AliESDCaloCells *robj = dynamic_cast<AliESDCaloCells*>(&obj);
92 if(!robj)return; // not an AliESDCaloCells
93 *robj = *this;
94
95}
96
e649177a 97//_______________________________________________________________________
98AliESDCaloCells::~AliESDCaloCells()
99{
100 // destructor
101
102 DeleteContainer();
103}
104
105//_______________________________________________________________________
106void AliESDCaloCells::CreateContainer(Short_t nCells)
107{
108 // function that creates container to store calorimeter cell data
109
110 DeleteContainer();
111
112 if (nCells <= 0) {
113 fNCells = 0;
114 return;
115 }
116
117 fNCells = nCells;
118
119 fCellNumber = new Short_t[fNCells];
120 fAmplitude = new Double32_t[fNCells];
121 fTime = new Double32_t[fNCells];
122}
123
124//_______________________________________________________________________
125void AliESDCaloCells::DeleteContainer()
126{
127 // deletes allocated memory
128
129 if (fCellNumber)
130 {
131 delete[] fCellNumber;
132 fCellNumber = 0;
133 }
134
135 if (fAmplitude)
136 {
137 delete[] fAmplitude;
138 fAmplitude = 0;
139 }
140
141 if (fTime)
142 {
143 delete[] fTime;
144 fTime = 0;
145 }
146
147 fNCells = 0;
148 fIsSorted = kFALSE;
149}
150
151//_______________________________________________________________________
152void AliESDCaloCells::Sort()
153{
154 // sort the cell array by cell number
155
156 Int_t *idxArray = new Int_t[fNCells];
157 TMath::Sort(fNCells,fCellNumber,idxArray,kFALSE);
158
159 Short_t *newIndex = new Short_t[fNCells];
160 Double32_t *newAmplitude = new Double32_t[fNCells];
161 Double32_t *newTime = new Double32_t[fNCells];
162 for (Int_t i=0; i < fNCells; i++) {
163 newIndex[i] = fCellNumber[idxArray[i]];
164 newAmplitude[i] = fAmplitude[idxArray[i]];
165 newTime[i] = fTime[idxArray[i]];
166 }
167 delete [] fCellNumber;
168 delete [] fAmplitude;
169 delete [] fTime;
170 fCellNumber = newIndex;
171 fAmplitude = newAmplitude;
172 fTime = newTime;
173
174 delete [] idxArray;
175
176 fIsSorted = kTRUE;
177}
178
179//_______________________________________________________________________
180Bool_t AliESDCaloCells::SetCell(Short_t pos, Short_t cellNumber, Double32_t amplitude, Double32_t time)
181{
182 // Sets a cell at the given position
183
184 if (pos>=0 && pos < fNCells) {
185 fCellNumber[pos] = cellNumber;
186 fAmplitude[pos] = amplitude;
187 fTime[pos] = time;
188 fIsSorted = kFALSE;
189 return kTRUE;
190 } else {
191 return kFALSE;
192 }
193}