]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDCaloCluster.cxx
Replication of arrays in setters. (G. Conesa Balbastre)
[u/mrichter/AliRoot.git] / STEER / AliESDCaloCluster.cxx
CommitLineData
85c60a8e 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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/* $Log $ */
18
19//-----------------------------------------------------------------
20// Implementation of the ESD Calorimeter cluster class
21// ESD = Event Summary Data
22// This is the class to deal with during the phisics analysis of data
23//
24// J.L. Klay (LLNL)
25//-----------------------------------------------------------------
26
bab0b5f0 27#include <TLorentzVector.h>
85c60a8e 28#include "AliESDCaloCluster.h"
29
30ClassImp(AliESDCaloCluster)
31
32//_______________________________________________________________________
33AliESDCaloCluster::AliESDCaloCluster() :
8ada0ffe 34 TObject(),
5efdec54 35 fTracksMatched(0x0),
36 fLabels(0x0),
e649177a 37 fNCells(0),
38 fCellsAbsId(0x0),
39 fCellsAmpFraction(0x0),
40 fDigitAmplitude(0x0),//not in use
41 fDigitTime(0x0),//not in use
42 fDigitIndex(0x0),//not in use
8ada0ffe 43 fEnergy(0),
44 fDispersion(0),
45 fChi2(0),
46 fM20(0),
47 fM02(0),
8ada0ffe 48 fEmcCpvDistance(1024),
49 fDistToBadChannel(1024),
50 fID(0),
51 fNExMax(0),
78902954 52 fClusterType(kUndef), fTOF(0.)
85c60a8e 53{
54 //
55 // The default ESD constructor
56 //
57 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
58 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.;
59}
60
61//_______________________________________________________________________
62AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
63 TObject(clus),
4dd59c4a 64 fTracksMatched(clus.fTracksMatched?new TArrayI(*clus.fTracksMatched):0x0),
65 fLabels(clus.fLabels?new TArrayI(*clus.fLabels):0x0),
e649177a 66 fNCells(clus.fNCells),
67 fCellsAbsId(),
68 fCellsAmpFraction(),
69 fDigitAmplitude(clus.fDigitAmplitude?new TArrayS(*clus.fDigitAmplitude):0x0),//not in use
70 fDigitTime(clus.fDigitTime?new TArrayS(*clus.fDigitTime):0x0),//not in use
71 fDigitIndex(clus.fDigitIndex?new TArrayS(*clus.fDigitIndex):0x0),//not in use
85c60a8e 72 fEnergy(clus.fEnergy),
73 fDispersion(clus.fDispersion),
74 fChi2(clus.fChi2),
e3e93796 75 fM20(clus.fM20),
76 fM02(clus.fM02),
e3e93796 77 fEmcCpvDistance(clus.fEmcCpvDistance),
45636e1b 78 fDistToBadChannel(clus.fDistToBadChannel),
8ada0ffe 79 fID(clus.fID),
80 fNExMax(clus.fNExMax),
78902954 81 fClusterType(clus.fClusterType),
82 fTOF(clus.fTOF)
85c60a8e 83{
84 //
85 // The copy constructor
86 //
87 fGlobalPos[0] = clus.fGlobalPos[0];
88 fGlobalPos[1] = clus.fGlobalPos[1];
89 fGlobalPos[2] = clus.fGlobalPos[2];
90
91 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
92
e649177a 93 if (clus.fNCells > 0) {
94
95 if(clus.fCellsAbsId){
96 fCellsAbsId = new UShort_t[clus.fNCells];
97 for (Int_t i=0; i<clus.fNCells; i++)
98 fCellsAbsId[i]=clus.fCellsAbsId[i];
99 }
100
101 if(clus.fCellsAmpFraction){
102 fCellsAmpFraction = new Double32_t[clus.fNCells];
103 for (Int_t i=0; i<clus.fNCells; i++)
104 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
105 }
106
107 }
108
85c60a8e 109}
110
fe12e09c 111//_______________________________________________________________________
112AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
113{
114 // assignment operator
115
116 if(&source == this) return *this;
8ada0ffe 117 TObject::operator=(source);
118
119 fGlobalPos[0] = source.fGlobalPos[0];
120 fGlobalPos[1] = source.fGlobalPos[1];
121 fGlobalPos[2] = source.fGlobalPos[2];
122
fe12e09c 123
fe12e09c 124 fEnergy = source.fEnergy;
125 fDispersion = source.fDispersion;
126 fChi2 = source.fChi2;
fe12e09c 127 fM20 = source.fM20;
128 fM02 = source.fM02;
fe12e09c 129 fEmcCpvDistance = source.fEmcCpvDistance;
45636e1b 130 fDistToBadChannel = source.fDistToBadChannel ;
fe12e09c 131 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
8ada0ffe 132 fID = source.fID;
fe12e09c 133
732a24fe 134 fNCells= source.fNCells;
135
e649177a 136 if (source.fNCells > 0) {
e649177a 137 if(source.fCellsAbsId){
732a24fe 138 if(fNCells != source.fNCells){
139 delete [] fCellsAbsId;
140 fCellsAbsId = new UShort_t[source.fNCells];
141 }
e649177a 142 for (Int_t i=0; i<source.fNCells; i++)
143 fCellsAbsId[i]=source.fCellsAbsId[i];
144 }
145
146 if(source.fCellsAmpFraction){
732a24fe 147 if(fNCells != source.fNCells){
148 delete [] fCellsAmpFraction;
149 fCellsAmpFraction = new Double32_t[source.fNCells];
150 }
e649177a 151 for (Int_t i=0; i<source.fNCells; i++)
152 fCellsAmpFraction[i]=source.fCellsAmpFraction[i];
732a24fe 153 }
e649177a 154 }
155
156 fNExMax = source.fNExMax;
157 fClusterType = source.fClusterType;
78902954 158 fTOF = source.fTOF;
e649177a 159
160 //not in use
732a24fe 161 if(source.fTracksMatched){
162 // assign or copy construct
163 if(fTracksMatched) *fTracksMatched = *source.fTracksMatched;
164 else fTracksMatched = new TArrayI(*source.fTracksMatched);
165 }
166 else{
167 delete fTracksMatched;
168 fTracksMatched = 0;
169 }
170
171 if(source.fLabels){
172 // assign or copy construct
173 if(fLabels) *fLabels = *source.fLabels;
174 else fLabels = new TArrayI(*source.fLabels);
175 }
176 else{
177 delete fLabels;
178 fLabels = 0;
179 }
180
181
182 if(source.fDigitAmplitude){
183 // assign or copy construct
184 if(fDigitAmplitude) *fDigitAmplitude = *source.fDigitAmplitude;
185 else fDigitAmplitude = new TArrayS(*source.fDigitAmplitude);
186 }
187 else{
188 delete fDigitAmplitude;
189 fDigitAmplitude = 0;
190 }
191
192
193
194 if(source.fDigitTime){
195 // assign or copy construct
196 if(fDigitTime) *fDigitTime = *source.fDigitTime;
197 else fDigitTime = new TArrayS(*source.fDigitTime);
198 }
199 else{
200 delete fDigitTime;
201 fDigitTime = 0;
202 }
203
204
205
206 if(source.fDigitIndex){
207 // assign or copy construct
208 if(fDigitIndex) *fDigitIndex = *source.fDigitIndex;
209 else fDigitIndex = new TArrayS(*source.fDigitIndex);
210 }
211 else{
212 delete fDigitIndex;
213 fDigitIndex = 0;
214 }
e649177a 215
fe12e09c 216 return *this;
217
218}
219
732a24fe 220void AliESDCaloCluster::Copy(TObject &obj) const {
221
222 // this overwrites the virtual TOBject::Copy()
223 // to allow run time copying without casting
224 // in AliESDEvent
225
226 if(this==&obj)return;
227 AliESDCaloCluster *robj = dynamic_cast<AliESDCaloCluster*>(&obj);
228 if(!robj)return; // not an AliESDCluster
229 *robj = *this;
230
231}
85c60a8e 232
233//_______________________________________________________________________
234AliESDCaloCluster::~AliESDCaloCluster(){
235 //
5efdec54 236 // This is destructor according Coding Conventions
85c60a8e 237 //
5efdec54 238 delete fTracksMatched;
239 delete fLabels;
e649177a 240 delete fDigitAmplitude; //not in use
241 delete fDigitTime; //not in use
242 delete fDigitIndex; //not in use
243 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
244 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
85c60a8e 245}
246
247//_______________________________________________________________________
248void AliESDCaloCluster::SetPid(const Float_t *p) {
249 // Sets the probability of each particle type
250 // Copied from AliESDtrack SetPIDValues
251 // This function copies "n" PID weights from "scr" to "dest"
252 // and normalizes their sum to 1 thus producing conditional
253 // probabilities.
254 // The negative weights are set to 0.
255 // In case all the weights are non-positive they are replaced by
256 // uniform probabilities
257
258 Int_t n = AliPID::kSPECIESN;
259
260 Float_t uniform = 1./(Float_t)n;
261
262 Float_t sum = 0;
263 for (Int_t i=0; i<n; i++)
264 if (p[i]>=0) {
265 sum+=p[i];
266 fPID[i] = p[i];
267 }
268 else {
269 fPID[i] = 0;
270 }
271
272 if(sum>0)
273 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
274 else
275 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
276
277}
bab0b5f0 278
279//_______________________________________________________________________
5efdec54 280void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
bab0b5f0 281 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
282 // identified as photons or pi0 (overlapped gamma) produced on the vertex
5efdec54 283 //Vertex can be recovered with esd pointer doing:
284 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
285
286 if(vertex){//calculate direction from vertex
287 fGlobalPos[0]-=vertex[0];
288 fGlobalPos[1]-=vertex[1];
289 fGlobalPos[2]-=vertex[2];
290 }
bab0b5f0 291
292 Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
293 fGlobalPos[1]*fGlobalPos[1]+
294 fGlobalPos[2]*fGlobalPos[2] ) ;
295
296 p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r, fEnergy*fGlobalPos[1]/r, fEnergy*fGlobalPos[2]/r, fEnergy) ;
297
298}
ed712271 299
300//_______________________________________________________________________
301void AliESDCaloCluster::SetCellsAbsId(UShort_t *array)
302{
303 // Set the array of cell absId numbers
304 if (fNCells) {
305 fCellsAbsId = new UShort_t[fNCells];
306 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
307 }
308}
309
310//_______________________________________________________________________
311void AliESDCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
312{
313 // Set the array of cell amplitude fraction
314 if (fNCells) {
315 fCellsAmpFraction = new Double32_t[fNCells];
316 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
317 }
318}