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),
55 // The default ESD constructor
57 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
58 for(Int_t i=0; i<AliPID::kSPECIESCN; i++) fPID[i] = 0.;
61 //_______________________________________________________________________
62 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
64 fTracksMatched(clus.fTracksMatched?new TArrayI(*clus.fTracksMatched):0x0),
65 fLabels(clus.fLabels?new TArrayI(*clus.fLabels):0x0),
66 fNCells(clus.fNCells),
69 fEnergy(clus.fEnergy),
70 fDispersion(clus.fDispersion),
74 fEmcCpvDistance(clus.fEmcCpvDistance),
75 fTrackDx(clus.fTrackDx),
76 fTrackDz(clus.fTrackDz),
77 fDistToBadChannel(clus.fDistToBadChannel),
79 fNExMax(clus.fNExMax),
80 fClusterType(clus.fClusterType),
82 fMCEnergyFraction(clus.fMCEnergyFraction)
85 // The copy constructor
87 fGlobalPos[0] = clus.fGlobalPos[0];
88 fGlobalPos[1] = clus.fGlobalPos[1];
89 fGlobalPos[2] = clus.fGlobalPos[2];
91 for(Int_t i=0; i<AliPID::kSPECIESCN; i++) fPID[i] = clus.fPID[i];
93 if (clus.fNCells > 0) {
96 fCellsAbsId = new UShort_t[clus.fNCells];
97 for (Int_t i=0; i<clus.fNCells; i++)
98 fCellsAbsId[i]=clus.fCellsAbsId[i];
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];
111 //_______________________________________________________________________
112 AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
114 // assignment operator
116 if(&source == this) return *this;
117 AliVCluster::operator=(source);
118 fGlobalPos[0] = source.fGlobalPos[0];
119 fGlobalPos[1] = source.fGlobalPos[1];
120 fGlobalPos[2] = source.fGlobalPos[2];
122 fEnergy = source.fEnergy;
123 fDispersion = source.fDispersion;
124 fChi2 = source.fChi2;
127 fEmcCpvDistance = source.fEmcCpvDistance;
128 fTrackDx= source.fTrackDx ;
129 fTrackDz= source.fTrackDz ;
130 fDistToBadChannel = source.fDistToBadChannel ;
131 for(Int_t i=0; i<AliPID::kSPECIESCN; i++) fPID[i] = source.fPID[i];
134 fNCells= source.fNCells;
136 if (source.fNCells > 0) {
137 if(source.fCellsAbsId){
138 if(fNCells != source.fNCells||!fCellsAbsId){
139 if(fCellsAbsId)delete [] fCellsAbsId;
140 fCellsAbsId = new UShort_t[source.fNCells];
142 for (Int_t i=0; i<source.fNCells; i++){
143 fCellsAbsId[i]=source.fCellsAbsId[i];
147 if(source.fCellsAmpFraction){
148 if(fNCells != source.fNCells||!fCellsAmpFraction){
149 if(fCellsAmpFraction) delete [] fCellsAmpFraction;
150 fCellsAmpFraction = new Double32_t[source.fNCells];
152 for (Int_t i=0; i<source.fNCells; i++)
153 fCellsAmpFraction[i]=source.fCellsAmpFraction[i];
157 fNExMax = source.fNExMax;
158 fClusterType = source.fClusterType;
162 if(source.fTracksMatched){
163 // assign or copy construct
165 *fTracksMatched = *source.fTracksMatched;
167 else fTracksMatched = new TArrayI(*source.fTracksMatched);
170 if(fTracksMatched)delete fTracksMatched;
175 // assign or copy construct
177 *fLabels = *source.fLabels;
179 else fLabels = new TArrayI(*source.fLabels);
182 if(fLabels)delete fLabels;
186 fMCEnergyFraction = source.fMCEnergyFraction;
192 //_______________________________________________________________________
193 void AliESDCaloCluster::Copy(TObject &obj) const {
195 // this overwrites the virtual TOBject::Copy()
196 // to allow run time copying without casting
199 if(this==&obj)return;
200 AliESDCaloCluster *robj = dynamic_cast<AliESDCaloCluster*>(&obj);
201 if(!robj)return; // not an AliESDCluster
206 //_______________________________________________________________________
207 AliESDCaloCluster::~AliESDCaloCluster(){
209 // This is destructor according Coding Conventions
211 if(fTracksMatched)delete fTracksMatched;fTracksMatched = 0;
212 if(fLabels) delete fLabels; fLabels = 0;
213 if(fCellsAmpFraction){ delete[] fCellsAmpFraction; fCellsAmpFraction=0;}
214 if(fCellsAbsId){ delete[] fCellsAbsId; fCellsAbsId = 0;}
217 //_______________________________________________________________________
218 void AliESDCaloCluster::Clear(const Option_t*){
220 // This is destructor according Coding Conventions
222 if(fTracksMatched)delete fTracksMatched;fTracksMatched = 0;
223 if(fLabels) delete fLabels; fLabels = 0;
224 if(fCellsAmpFraction){ delete[] fCellsAmpFraction; fCellsAmpFraction=0;}
225 if(fCellsAbsId){ delete[] fCellsAbsId; fCellsAbsId = 0;}
229 //_______________________________________________________________________
230 void AliESDCaloCluster::SetPID(const Float_t *p) {
231 // Sets the probability of each particle type
232 // Copied from AliESDtrack SetPIDValues
233 // This function copies "n" PID weights from "scr" to "dest"
234 // and normalizes their sum to 1 thus producing conditional
236 // The negative weights are set to 0.
237 // In case all the weights are non-positive they are replaced by
238 // uniform probabilities
240 Int_t n = AliPID::kSPECIESCN;
242 Float_t uniform = 1./(Float_t)n;
245 for (Int_t i=0; i<n; i++)
255 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
257 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
261 //_______________________________________________________________________
262 void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
263 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
264 // identified as photons or pi0 (overlapped gamma) produced on the vertex
265 //Vertex can be recovered with esd pointer doing:
266 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
268 Double32_t pos[3]={ fGlobalPos[0], fGlobalPos[1], fGlobalPos[2]};
269 if(vertex){//calculate direction from vertex
275 Double_t r = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2] ) ;
277 p.SetPxPyPzE( fEnergy*pos[0]/r, fEnergy*pos[1]/r, fEnergy*pos[2]/r, fEnergy) ;
280 //_______________________________________________________________________
281 void AliESDCaloCluster::SetCellsAbsId(UShort_t *array)
283 // Set the array of cell absId numbers
285 fCellsAbsId = new UShort_t[fNCells];
286 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
290 //_______________________________________________________________________
291 void AliESDCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
293 // Set the array of cell amplitude fraction
295 fCellsAmpFraction = new Double32_t[fNCells];
296 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
300 //______________________________________________________________________________
301 void AliESDCaloCluster::SetPosition(Float_t *x)
306 fGlobalPos[0] = x[0];
307 fGlobalPos[1] = x[1];
308 fGlobalPos[2] = x[2];
311 fGlobalPos[0] = -999.;
312 fGlobalPos[1] = -999.;
313 fGlobalPos[2] = -999.;