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