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),
52 fMCEnergyFraction(0.),
56 // The default ESD constructor
58 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
59 for(Int_t i=0; i<AliPID::kSPECIESCN; i++) fPID[i] = 0.;
62 //_______________________________________________________________________
63 AliESDCaloCluster::AliESDCaloCluster(const AliESDCaloCluster& clus) :
65 fTracksMatched(clus.fTracksMatched?new TArrayI(*clus.fTracksMatched):0x0),
66 fLabels(clus.fLabels?new TArrayI(*clus.fLabels):0x0),
67 fNCells(clus.fNCells),
70 fEnergy(clus.fEnergy),
71 fDispersion(clus.fDispersion),
75 fEmcCpvDistance(clus.fEmcCpvDistance),
76 fTrackDx(clus.fTrackDx),
77 fTrackDz(clus.fTrackDz),
78 fDistToBadChannel(clus.fDistToBadChannel),
80 fNExMax(clus.fNExMax),
81 fClusterType(clus.fClusterType),
83 fMCEnergyFraction(clus.fMCEnergyFraction),
84 fCoreEnergy(clus.fCoreEnergy)
87 // The copy constructor
89 fGlobalPos[0] = clus.fGlobalPos[0];
90 fGlobalPos[1] = clus.fGlobalPos[1];
91 fGlobalPos[2] = clus.fGlobalPos[2];
93 for(Int_t i=0; i<AliPID::kSPECIESCN; i++) fPID[i] = clus.fPID[i];
95 if (clus.fNCells > 0) {
98 fCellsAbsId = new UShort_t[clus.fNCells];
99 for (Int_t i=0; i<clus.fNCells; i++)
100 fCellsAbsId[i]=clus.fCellsAbsId[i];
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];
113 //_______________________________________________________________________
114 AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
116 // assignment operator
118 if(&source == this) return *this;
119 AliVCluster::operator=(source);
120 fGlobalPos[0] = source.fGlobalPos[0];
121 fGlobalPos[1] = source.fGlobalPos[1];
122 fGlobalPos[2] = source.fGlobalPos[2];
124 fEnergy = source.fEnergy;
125 fDispersion = source.fDispersion;
126 fChi2 = source.fChi2;
129 fEmcCpvDistance = source.fEmcCpvDistance;
130 fTrackDx= source.fTrackDx ;
131 fTrackDz= source.fTrackDz ;
132 fDistToBadChannel = source.fDistToBadChannel ;
133 for(Int_t i=0; i<AliPID::kSPECIESCN; i++) fPID[i] = source.fPID[i];
136 fNCells= source.fNCells;
138 if (source.fNCells > 0) {
139 if(source.fCellsAbsId){
140 if(fNCells != source.fNCells||!fCellsAbsId){
141 if(fCellsAbsId)delete [] fCellsAbsId;
142 fCellsAbsId = new UShort_t[source.fNCells];
144 for (Int_t i=0; i<source.fNCells; i++){
145 fCellsAbsId[i]=source.fCellsAbsId[i];
149 if(source.fCellsAmpFraction){
150 if(fNCells != source.fNCells||!fCellsAmpFraction){
151 if(fCellsAmpFraction) delete [] fCellsAmpFraction;
152 fCellsAmpFraction = new Double32_t[source.fNCells];
154 for (Int_t i=0; i<source.fNCells; i++)
155 fCellsAmpFraction[i]=source.fCellsAmpFraction[i];
159 fNExMax = source.fNExMax;
160 fClusterType = source.fClusterType;
164 if(source.fTracksMatched){
165 // assign or copy construct
167 *fTracksMatched = *source.fTracksMatched;
169 else fTracksMatched = new TArrayI(*source.fTracksMatched);
172 if(fTracksMatched)delete fTracksMatched;
177 // assign or copy construct
179 *fLabels = *source.fLabels;
181 else fLabels = new TArrayI(*source.fLabels);
184 if(fLabels)delete fLabels;
188 fMCEnergyFraction = source.fMCEnergyFraction;
190 fCoreEnergy = source.fCoreEnergy;
196 //_______________________________________________________________________
197 void AliESDCaloCluster::Copy(TObject &obj) const {
199 // this overwrites the virtual TOBject::Copy()
200 // to allow run time copying without casting
203 if(this==&obj)return;
204 AliESDCaloCluster *robj = dynamic_cast<AliESDCaloCluster*>(&obj);
205 if(!robj)return; // not an AliESDCluster
210 //_______________________________________________________________________
211 AliESDCaloCluster::~AliESDCaloCluster(){
213 // This is destructor according Coding Conventions
215 if(fTracksMatched)delete fTracksMatched;fTracksMatched = 0;
216 if(fLabels) delete fLabels; fLabels = 0;
217 if(fCellsAmpFraction){ delete[] fCellsAmpFraction; fCellsAmpFraction=0;}
218 if(fCellsAbsId){ delete[] fCellsAbsId; fCellsAbsId = 0;}
221 //_______________________________________________________________________
222 void AliESDCaloCluster::Clear(const Option_t*){
224 // This is destructor according Coding Conventions
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;}
233 //_______________________________________________________________________
234 void AliESDCaloCluster::SetPID(const Float_t *p) {
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
240 // The negative weights are set to 0.
241 // In case all the weights are non-positive they are replaced by
242 // uniform probabilities
244 Int_t n = AliPID::kSPECIESCN;
246 Float_t uniform = 1./(Float_t)n;
249 for (Int_t i=0; i<n; i++)
259 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
261 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
265 //_______________________________________________________________________
266 void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) const {
267 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
268 // identified as photons or pi0 (overlapped gamma) produced on the vertex
269 //Vertex can be recovered with esd pointer doing:
270 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
272 Double32_t pos[3]={ fGlobalPos[0], fGlobalPos[1], fGlobalPos[2]};
273 if(vertex){//calculate direction from vertex
279 Double_t r = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]+pos[2]*pos[2] ) ;
281 p.SetPxPyPzE( fEnergy*pos[0]/r, fEnergy*pos[1]/r, fEnergy*pos[2]/r, fEnergy) ;
284 //_______________________________________________________________________
285 void AliESDCaloCluster::SetCellsAbsId(UShort_t *array)
287 // Set the array of cell absId numbers
289 fCellsAbsId = new UShort_t[fNCells];
290 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
294 //_______________________________________________________________________
295 void AliESDCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
297 // Set the array of cell amplitude fraction
299 fCellsAmpFraction = new Double32_t[fNCells];
300 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
304 //______________________________________________________________________________
305 void AliESDCaloCluster::SetPosition(Float_t *x)
310 fGlobalPos[0] = x[0];
311 fGlobalPos[1] = x[1];
312 fGlobalPos[2] = x[2];
315 fGlobalPos[0] = -999.;
316 fGlobalPos[1] = -999.;
317 fGlobalPos[2] = -999.;