1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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
25 //-----------------------------------------------------------------
27 #include <TLorentzVector.h>
28 #include "AliESDCaloCluster.h"
30 ClassImp(AliESDCaloCluster)
32 //_______________________________________________________________________
33 AliESDCaloCluster::AliESDCaloCluster() :
39 fCellsAmpFraction(0x0),
45 fEmcCpvDistance(1024),
46 fTrackDx(1024),fTrackDz(1024),
47 fDistToBadChannel(1024),
50 fClusterType(kUndef), fTOF(0.)
53 // The default ESD constructor
55 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
56 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = 0.;
59 //_______________________________________________________________________
60 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
62 fTracksMatched(clus.fTracksMatched?new TArrayI(*clus.fTracksMatched):0x0),
63 fLabels(clus.fLabels?new TArrayI(*clus.fLabels):0x0),
64 fNCells(clus.fNCells),
67 fEnergy(clus.fEnergy),
68 fDispersion(clus.fDispersion),
72 fEmcCpvDistance(clus.fEmcCpvDistance),
73 fTrackDx(clus.fTrackDx),
74 fTrackDz(clus.fTrackDz),
75 fDistToBadChannel(clus.fDistToBadChannel),
77 fNExMax(clus.fNExMax),
78 fClusterType(clus.fClusterType),
82 // The copy constructor
84 fGlobalPos[0] = clus.fGlobalPos[0];
85 fGlobalPos[1] = clus.fGlobalPos[1];
86 fGlobalPos[2] = clus.fGlobalPos[2];
88 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
90 if (clus.fNCells > 0) {
93 fCellsAbsId = new UShort_t[clus.fNCells];
94 for (Int_t i=0; i<clus.fNCells; i++)
95 fCellsAbsId[i]=clus.fCellsAbsId[i];
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];
108 //_______________________________________________________________________
109 AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
111 // assignment operator
113 if(&source == this) return *this;
114 AliVCluster::operator=(source);
115 fGlobalPos[0] = source.fGlobalPos[0];
116 fGlobalPos[1] = source.fGlobalPos[1];
117 fGlobalPos[2] = source.fGlobalPos[2];
119 fEnergy = source.fEnergy;
120 fDispersion = source.fDispersion;
121 fChi2 = source.fChi2;
124 fEmcCpvDistance = source.fEmcCpvDistance;
125 fTrackDx= source.fTrackDx ;
126 fTrackDz= source.fTrackDz ;
127 fDistToBadChannel = source.fDistToBadChannel ;
128 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
131 fNCells= source.fNCells;
133 if (source.fNCells > 0) {
134 if(source.fCellsAbsId){
135 if(fNCells != source.fNCells||!fCellsAbsId){
136 if(fCellsAbsId)delete [] fCellsAbsId;
137 fCellsAbsId = new UShort_t[source.fNCells];
139 for (Int_t i=0; i<source.fNCells; i++){
140 fCellsAbsId[i]=source.fCellsAbsId[i];
144 if(source.fCellsAmpFraction){
145 if(fNCells != source.fNCells||!fCellsAmpFraction){
146 if(fCellsAmpFraction) delete [] fCellsAmpFraction;
147 fCellsAmpFraction = new Double32_t[source.fNCells];
149 for (Int_t i=0; i<source.fNCells; i++)
150 fCellsAmpFraction[i]=source.fCellsAmpFraction[i];
154 fNExMax = source.fNExMax;
155 fClusterType = source.fClusterType;
159 if(source.fTracksMatched){
160 // assign or copy construct
162 *fTracksMatched = *source.fTracksMatched;
164 else fTracksMatched = new TArrayI(*source.fTracksMatched);
167 if(fTracksMatched)delete fTracksMatched;
172 // assign or copy construct
174 *fLabels = *source.fLabels;
176 else fLabels = new TArrayI(*source.fLabels);
179 if(fLabels)delete fLabels;
188 //_______________________________________________________________________
189 void AliESDCaloCluster::Copy(TObject &obj) const {
191 // this overwrites the virtual TOBject::Copy()
192 // to allow run time copying without casting
195 if(this==&obj)return;
196 AliESDCaloCluster *robj = dynamic_cast<AliESDCaloCluster*>(&obj);
197 if(!robj)return; // not an AliESDCluster
202 //_______________________________________________________________________
203 AliESDCaloCluster::~AliESDCaloCluster(){
205 // This is destructor according Coding Conventions
207 if(fTracksMatched)delete fTracksMatched;fTracksMatched = 0;
208 if(fLabels) delete fLabels; fLabels = 0;
209 if(fCellsAmpFraction){ delete[] fCellsAmpFraction; fCellsAmpFraction=0;}
210 if(fCellsAbsId){ delete[] fCellsAbsId; fCellsAbsId = 0;}
213 //_______________________________________________________________________
214 void AliESDCaloCluster::Clear(const Option_t*){
216 // This is destructor according Coding Conventions
218 if(fTracksMatched)delete fTracksMatched;fTracksMatched = 0;
219 if(fLabels) delete fLabels; fLabels = 0;
220 if(fCellsAmpFraction){ delete[] fCellsAmpFraction; fCellsAmpFraction=0;}
221 if(fCellsAbsId){ delete[] fCellsAbsId; fCellsAbsId = 0;}
225 //_______________________________________________________________________
226 void AliESDCaloCluster::SetPID(const Float_t *p) {
227 // Sets the probability of each particle type
228 // Copied from AliESDtrack SetPIDValues
229 // This function copies "n" PID weights from "scr" to "dest"
230 // and normalizes their sum to 1 thus producing conditional
232 // The negative weights are set to 0.
233 // In case all the weights are non-positive they are replaced by
234 // uniform probabilities
236 Int_t n = AliPID::kSPECIESN;
238 Float_t uniform = 1./(Float_t)n;
241 for (Int_t i=0; i<n; i++)
251 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
253 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
257 //_______________________________________________________________________
258 void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
259 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
260 // identified as photons or pi0 (overlapped gamma) produced on the vertex
261 //Vertex can be recovered with esd pointer doing:
262 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
264 Double32_t pos[3]={ fGlobalPos[0], fGlobalPos[1], fGlobalPos[2]};
265 if(vertex){//calculate direction from vertex
271 Double_t r = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2] ) ;
273 p.SetPxPyPzE( fEnergy*pos[0]/r, fEnergy*pos[1]/r, fEnergy*pos[2]/r, fEnergy) ;
276 //_______________________________________________________________________
277 void AliESDCaloCluster::SetCellsAbsId(UShort_t *array)
279 // Set the array of cell absId numbers
281 fCellsAbsId = new UShort_t[fNCells];
282 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
286 //_______________________________________________________________________
287 void AliESDCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
289 // Set the array of cell amplitude fraction
291 fCellsAmpFraction = new Double32_t[fNCells];
292 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
296 //______________________________________________________________________________
297 void AliESDCaloCluster::SetPosition(Float_t *x)
302 fGlobalPos[0] = x[0];
303 fGlobalPos[1] = x[1];
304 fGlobalPos[2] = x[2];
307 fGlobalPos[0] = -999.;
308 fGlobalPos[1] = -999.;
309 fGlobalPos[2] = -999.;