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),
40 fDigitAmplitude(0x0),//not in use
41 fDigitTime(0x0),//not in use
42 fDigitIndex(0x0),//not in use
49 fEmcCpvDistance(1024),
50 fDistToBadChannel(1024),
56 // The default ESD constructor
58 fGlobalPos[0] = fGlobalPos[1] = fGlobalPos[2] = 0.;
59 for(Int_t i=0; i<AliPID::kSPECIESN; 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 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
73 fEnergy(clus.fEnergy),
74 fDispersion(clus.fDispersion),
79 fEmcCpvDistance(clus.fEmcCpvDistance),
80 fDistToBadChannel(clus.fDistToBadChannel),
82 fNExMax(clus.fNExMax),
83 fClusterType(clus.fClusterType)
86 // The copy constructor
88 fGlobalPos[0] = clus.fGlobalPos[0];
89 fGlobalPos[1] = clus.fGlobalPos[1];
90 fGlobalPos[2] = clus.fGlobalPos[2];
92 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = clus.fPID[i];
94 if (clus.fNCells > 0) {
97 fCellsAbsId = new UShort_t[clus.fNCells];
98 for (Int_t i=0; i<clus.fNCells; i++)
99 fCellsAbsId[i]=clus.fCellsAbsId[i];
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];
112 //_______________________________________________________________________
113 AliESDCaloCluster &AliESDCaloCluster::operator=(const AliESDCaloCluster& source)
115 // assignment operator
117 if(&source == this) return *this;
118 TObject::operator=(source);
120 fGlobalPos[0] = source.fGlobalPos[0];
121 fGlobalPos[1] = source.fGlobalPos[1];
122 fGlobalPos[2] = source.fGlobalPos[2];
125 fEnergy = source.fEnergy;
126 fDispersion = source.fDispersion;
127 fChi2 = source.fChi2;
131 fEmcCpvDistance = source.fEmcCpvDistance;
132 fDistToBadChannel = source.fDistToBadChannel ;
133 for(Int_t i=0; i<AliPID::kSPECIESN; i++) fPID[i] = source.fPID[i];
136 fNCells= source. fNCells;
137 if (source.fNCells > 0) {
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];
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];
153 fNExMax = source.fNExMax;
154 fClusterType = source.fClusterType;
157 delete fTracksMatched;
158 fTracksMatched = source.fTracksMatched?new TArrayI(*source.fTracksMatched):0x0;
160 fLabels = source.fLabels?new TArrayI(*source.fLabels):0x0;
162 delete fDigitAmplitude;
163 fDigitAmplitude = source.fDigitAmplitude?new TArrayS(*source.fDigitAmplitude):0x0;
166 fDigitTime = source.fDigitTime?new TArrayS(*source.fDigitTime):0x0;
169 fDigitIndex = source.fDigitIndex?new TArrayS(*source.fDigitIndex):0x0;
176 //_______________________________________________________________________
177 AliESDCaloCluster::~AliESDCaloCluster(){
179 // This is destructor according Coding Conventions
181 delete fTracksMatched;
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;
190 //_______________________________________________________________________
191 void 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
197 // The negative weights are set to 0.
198 // In case all the weights are non-positive they are replaced by
199 // uniform probabilities
201 Int_t n = AliPID::kSPECIESN;
203 Float_t uniform = 1./(Float_t)n;
206 for (Int_t i=0; i<n; i++)
216 for (Int_t i=0; i<n; i++) fPID[i] /= sum;
218 for (Int_t i=0; i<n; i++) fPID[i] = uniform;
222 //_______________________________________________________________________
223 void AliESDCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
224 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
225 // identified as photons or pi0 (overlapped gamma) produced on the vertex
226 //Vertex can be recovered with esd pointer doing:
227 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
229 if(vertex){//calculate direction from vertex
230 fGlobalPos[0]-=vertex[0];
231 fGlobalPos[1]-=vertex[1];
232 fGlobalPos[2]-=vertex[2];
235 Double_t r = TMath::Sqrt(fGlobalPos[0]*fGlobalPos[0]+
236 fGlobalPos[1]*fGlobalPos[1]+
237 fGlobalPos[2]*fGlobalPos[2] ) ;
239 p.SetPxPyPzE( fEnergy*fGlobalPos[0]/r, fEnergy*fGlobalPos[1]/r, fEnergy*fGlobalPos[2]/r, fEnergy) ;