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