Summary of all changes:
[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),
48 fM11(0),
49 fEmcCpvDistance(1024),
50 fDistToBadChannel(1024),
51 fID(0),
52 fNExMax(0),
53 fClusterType(kUndef)
85c60a8e 54{
55 //
56 // The default ESD constructor
57 //
58 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
59 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.;
60}
61
62//_______________________________________________________________________
63AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
64 TObject(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(),
70 fDigitAmplitude(clus.fDigitAmplitude?new TArrayS(*clus.fDigitAmplitude):0x0),//not in use
71 fDigitTime(clus.fDigitTime?new TArrayS(*clus.fDigitTime):0x0),//not in use
72 fDigitIndex(clus.fDigitIndex?new TArrayS(*clus.fDigitIndex):0x0),//not in use
85c60a8e 73 fEnergy(clus.fEnergy),
74 fDispersion(clus.fDispersion),
75 fChi2(clus.fChi2),
e3e93796 76 fM20(clus.fM20),
77 fM02(clus.fM02),
e0af7ed2 78 fM11(clus.fM11),
e3e93796 79 fEmcCpvDistance(clus.fEmcCpvDistance),
45636e1b 80 fDistToBadChannel(clus.fDistToBadChannel),
8ada0ffe 81 fID(clus.fID),
82 fNExMax(clus.fNExMax),
83 fClusterType(clus.fClusterType)
85c60a8e 84{
85 //
86 // The copy constructor
87 //
88 fGlobalPos[0] = clus.fGlobalPos[0];
89 fGlobalPos[1] = clus.fGlobalPos[1];
90 fGlobalPos[2] = clus.fGlobalPos[2];
91
92 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
93
e649177a 94 if (clus.fNCells > 0) {
95
96 if(clus.fCellsAbsId){
97 fCellsAbsId = new UShort_t[clus.fNCells];
98 for (Int_t i=0; i<clus.fNCells; i++)
99 fCellsAbsId[i]=clus.fCellsAbsId[i];
100 }
101
102 if(clus.fCellsAmpFraction){
103 fCellsAmpFraction = new Double32_t[clus.fNCells];
104 for (Int_t i=0; i<clus.fNCells; i++)
105 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
106 }
107
108 }
109
85c60a8e 110}
111
fe12e09c 112//_______________________________________________________________________
113AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
114{
115 // assignment operator
116
117 if(&source == this) return *this;
8ada0ffe 118 TObject::operator=(source);
119
120 fGlobalPos[0] = source.fGlobalPos[0];
121 fGlobalPos[1] = source.fGlobalPos[1];
122 fGlobalPos[2] = source.fGlobalPos[2];
123
fe12e09c 124
fe12e09c 125 fEnergy = source.fEnergy;
126 fDispersion = source.fDispersion;
127 fChi2 = source.fChi2;
fe12e09c 128 fM20 = source.fM20;
129 fM02 = source.fM02;
130 fM11 = source.fM11;
fe12e09c 131 fEmcCpvDistance = source.fEmcCpvDistance;
45636e1b 132 fDistToBadChannel = source.fDistToBadChannel ;
fe12e09c 133 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
8ada0ffe 134 fID = source.fID;
fe12e09c 135
e649177a 136 fNCells= source. fNCells;
137 if (source.fNCells > 0) {
138
139 if(source.fCellsAbsId){
140 fCellsAbsId = new UShort_t[source.fNCells];
141 for (Int_t i=0; i<source.fNCells; i++)
142 fCellsAbsId[i]=source.fCellsAbsId[i];
143 }
144
145 if(source.fCellsAmpFraction){
146 fCellsAmpFraction = new Double32_t[source.fNCells];
147 for (Int_t i=0; i<source.fNCells; i++)
148 fCellsAmpFraction[i]=source.fCellsAmpFraction[i];
149 }
150
151 }
152
153 fNExMax = source.fNExMax;
154 fClusterType = source.fClusterType;
155
156 //not in use
8ada0ffe 157 delete fTracksMatched;
4dd59c4a 158 fTracksMatched = source.fTracksMatched?new TArrayI(*source.fTracksMatched):0x0;
8ada0ffe 159 delete fLabels;
4dd59c4a 160 fLabels = source.fLabels?new TArrayI(*source.fLabels):0x0;
e649177a 161
8ada0ffe 162 delete fDigitAmplitude;
a934c866 163 fDigitAmplitude = source.fDigitAmplitude?new TArrayS(*source.fDigitAmplitude):0x0;
e649177a 164
8ada0ffe 165 delete fDigitTime;
a934c866 166 fDigitTime = source.fDigitTime?new TArrayS(*source.fDigitTime):0x0;
e649177a 167
8ada0ffe 168 delete fDigitIndex;
a934c866 169 fDigitIndex = source.fDigitIndex?new TArrayS(*source.fDigitIndex):0x0;
e649177a 170
fe12e09c 171 return *this;
172
173}
174
85c60a8e 175
176//_______________________________________________________________________
177AliESDCaloCluster::~AliESDCaloCluster(){
178 //
5efdec54 179 // This is destructor according Coding Conventions
85c60a8e 180 //
5efdec54 181 delete fTracksMatched;
182 delete fLabels;
e649177a 183 delete fDigitAmplitude; //not in use
184 delete fDigitTime; //not in use
185 delete fDigitIndex; //not in use
186 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
187 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
85c60a8e 188}
189
190//_______________________________________________________________________
191void AliESDCaloCluster::SetPid(const Float_t *p) {
192 // Sets the probability of each particle type
193 // Copied from AliESDtrack SetPIDValues
194 // This function copies "n" PID weights from "scr" to "dest"
195 // and normalizes their sum to 1 thus producing conditional
196 // probabilities.
197 // The negative weights are set to 0.
198 // In case all the weights are non-positive they are replaced by
199 // uniform probabilities
200
201 Int_t n = AliPID::kSPECIESN;
202
203 Float_t uniform = 1./(Float_t)n;
204
205 Float_t sum = 0;
206 for (Int_t i=0; i<n; i++)
207 if (p[i]>=0) {
208 sum+=p[i];
209 fPID[i] = p[i];
210 }
211 else {
212 fPID[i] = 0;
213 }
214
215 if(sum>0)
216 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
217 else
218 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
219
220}
bab0b5f0 221
222//_______________________________________________________________________
5efdec54 223void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
bab0b5f0 224 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
225 // identified as photons or pi0 (overlapped gamma) produced on the vertex
5efdec54 226 //Vertex can be recovered with esd pointer doing:
227 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
228
229 if(vertex){//calculate direction from vertex
230 fGlobalPos[0]-=vertex[0];
231 fGlobalPos[1]-=vertex[1];
232 fGlobalPos[2]-=vertex[2];
233 }
bab0b5f0 234
235 Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
236 fGlobalPos[1]*fGlobalPos[1]+
237 fGlobalPos[2]*fGlobalPos[2] ) ;
238
239 p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r, fEnergy*fGlobalPos[1]/r, fEnergy*fGlobalPos[2]/r, fEnergy) ;
240
241}