1 /**************************************************************************
2 * Copyright(c) 1998-2007, 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 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // AOD calorimeter cluster class (for PHOS and EMCAL)
20 // Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
23 #include <TLorentzVector.h>
24 #include "AliAODCaloCluster.h"
26 ClassImp(AliAODCaloCluster)
28 //______________________________________________________________________________
29 AliAODCaloCluster::AliAODCaloCluster() :
31 fDistToBadChannel(-999.),
35 fEmcCpvDistance(-999.),
44 fCellsAmpFraction(0x0)
46 // default constructor
50 //______________________________________________________________________________
51 AliAODCaloCluster::AliAODCaloCluster(Int_t id,
59 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
60 fDistToBadChannel(-999.),
64 fEmcCpvDistance(-999.),
73 fCellsAmpFraction(0x0)
79 //______________________________________________________________________________
80 AliAODCaloCluster::AliAODCaloCluster(Int_t id,
88 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
89 fDistToBadChannel(-999.),
93 fEmcCpvDistance(-999.),
102 fCellsAmpFraction(0x0)
108 //______________________________________________________________________________
109 AliAODCaloCluster::~AliAODCaloCluster()
112 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
113 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
116 //______________________________________________________________________________
117 void AliAODCaloCluster::Clear(const Option_t*)
121 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
122 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
125 //______________________________________________________________________________
126 AliAODCaloCluster::AliAODCaloCluster(const AliAODCaloCluster& clus) :
128 fDistToBadChannel(clus.fDistToBadChannel),
129 fDispersion(clus.fDispersion),
132 fEmcCpvDistance(clus.fEmcCpvDistance),
133 fTrackDx(clus.fTrackDx),
134 fTrackDz(clus.fTrackDz),
135 fNExMax(clus.fNExMax),
137 fCoreEnergy(clus.fCoreEnergy),
138 fTracksMatched(clus.fTracksMatched),
139 fNCells(clus.fNCells),
141 fCellsAmpFraction(0x0)
145 if (clus.fNCells > 0) {
147 if(clus.fCellsAbsId){
148 fCellsAbsId = new UShort_t[clus.fNCells];
149 for (Int_t i=0; i<clus.fNCells; i++)
150 fCellsAbsId[i]=clus.fCellsAbsId[i];
153 if(clus.fCellsAmpFraction){
154 fCellsAmpFraction = new Double32_t[clus.fNCells];
155 for (Int_t i=0; i<clus.fNCells; i++)
156 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
163 //______________________________________________________________________________
164 AliAODCaloCluster& AliAODCaloCluster::operator=(const AliAODCaloCluster& clus)
166 // Assignment operator
169 AliAODCluster::operator=(clus);
171 fDistToBadChannel = clus.fDistToBadChannel;
172 fDispersion = clus.fDispersion;
175 fEmcCpvDistance = clus.fEmcCpvDistance;
176 fTrackDx=clus.fTrackDx;
177 fTrackDz=clus.fTrackDz;
178 fNExMax = clus.fNExMax;
180 fCoreEnergy = clus.fCoreEnergy;
181 fTracksMatched = clus.fTracksMatched;
183 fNCells= clus. fNCells;
185 if(fCellsAbsId)delete [] fCellsAbsId;
186 if(fCellsAmpFraction)delete [] fCellsAmpFraction;
188 if (clus.fNCells > 0) {
190 if(clus.fCellsAbsId){
191 fCellsAbsId = new UShort_t[clus.fNCells];
192 for (Int_t i=0; i<clus.fNCells; i++)
193 fCellsAbsId[i]=clus.fCellsAbsId[i];
196 if(clus.fCellsAmpFraction){
197 fCellsAmpFraction = new Double32_t[clus.fNCells];
198 for (Int_t i=0; i<clus.fNCells; i++)
199 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
209 //_______________________________________________________________________
210 Bool_t AliAODCaloCluster::HasTrackMatched(TObject *trk) const
212 // Checks if the given track contributed to this cluster.
214 TRefArrayIter iter(&fTracksMatched);
215 while (TObject *track = iter.Next()) {
216 if (trk == track) return kTRUE;
221 //_______________________________________________________________________
222 void AliAODCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) const {
223 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
224 // identified as photons or pi0 (overlapped gamma) produced on the vertex
225 //Vertex can be recovered with esd pointer doing:
226 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
228 Double32_t energy = E();
232 if(vertex){//calculate direction from vertex
238 Double_t r = TMath::Sqrt(pos[0]*pos[0]+
242 p.SetPxPyPzE( energy*pos[0]/r, energy*pos[1]/r, energy*pos[2]/r, energy) ;
247 void AliAODCaloCluster::SetCellsAbsId(UShort_t *array)
249 // Set the array of cell absId numbers
251 if(!fCellsAbsId)fCellsAbsId = new UShort_t[fNCells];
252 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
256 void AliAODCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
258 // Set the array of cell amplitude fraction
260 if(!fCellsAmpFraction)fCellsAmpFraction = new Double32_t[fNCells];
261 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];