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.),
43 fCellsAmpFraction(0x0)
45 // default constructor
49 //______________________________________________________________________________
50 AliAODCaloCluster::AliAODCaloCluster(Int_t id,
58 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
59 fDistToBadChannel(-999.),
63 fEmcCpvDistance(-999.),
71 fCellsAmpFraction(0x0)
77 //______________________________________________________________________________
78 AliAODCaloCluster::AliAODCaloCluster(Int_t id,
86 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
87 fDistToBadChannel(-999.),
91 fEmcCpvDistance(-999.),
99 fCellsAmpFraction(0x0)
105 //______________________________________________________________________________
106 AliAODCaloCluster::~AliAODCaloCluster()
109 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
110 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
113 //______________________________________________________________________________
114 void AliAODCaloCluster::Clear(const Option_t*)
118 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
119 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
122 //______________________________________________________________________________
123 AliAODCaloCluster::AliAODCaloCluster(const AliAODCaloCluster& clus) :
125 fDistToBadChannel(clus.fDistToBadChannel),
126 fDispersion(clus.fDispersion),
129 fEmcCpvDistance(clus.fEmcCpvDistance),
130 fTrackDx(clus.fTrackDx),
131 fTrackDz(clus.fTrackDz),
132 fNExMax(clus.fNExMax),
134 fTracksMatched(clus.fTracksMatched),
135 fNCells(clus.fNCells),
137 fCellsAmpFraction(0x0)
141 if (clus.fNCells > 0) {
143 if(clus.fCellsAbsId){
144 fCellsAbsId = new UShort_t[clus.fNCells];
145 for (Int_t i=0; i<clus.fNCells; i++)
146 fCellsAbsId[i]=clus.fCellsAbsId[i];
149 if(clus.fCellsAmpFraction){
150 fCellsAmpFraction = new Double32_t[clus.fNCells];
151 for (Int_t i=0; i<clus.fNCells; i++)
152 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
159 //______________________________________________________________________________
160 AliAODCaloCluster& AliAODCaloCluster::operator=(const AliAODCaloCluster& clus)
162 // Assignment operator
165 AliAODCluster::operator=(clus);
167 fDistToBadChannel = clus.fDistToBadChannel;
168 fDispersion = clus.fDispersion;
171 fEmcCpvDistance = clus.fEmcCpvDistance;
172 fTrackDx=clus.fTrackDx;
173 fTrackDz=clus.fTrackDz;
174 fNExMax = clus.fNExMax;
176 fTracksMatched = clus.fTracksMatched;
178 fNCells= clus. fNCells;
180 if(fCellsAbsId)delete [] fCellsAbsId;
181 if(fCellsAmpFraction)delete [] fCellsAmpFraction;
183 if (clus.fNCells > 0) {
185 if(clus.fCellsAbsId){
186 fCellsAbsId = new UShort_t[clus.fNCells];
187 for (Int_t i=0; i<clus.fNCells; i++)
188 fCellsAbsId[i]=clus.fCellsAbsId[i];
191 if(clus.fCellsAmpFraction){
192 fCellsAmpFraction = new Double32_t[clus.fNCells];
193 for (Int_t i=0; i<clus.fNCells; i++)
194 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
204 //_______________________________________________________________________
205 Bool_t AliAODCaloCluster::HasTrackMatched(TObject *trk) const
207 // Checks if the given track contributed to this cluster.
209 TRefArrayIter iter(&fTracksMatched);
210 while (TObject *track = iter.Next()) {
211 if (trk == track) return kTRUE;
216 //_______________________________________________________________________
217 void AliAODCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
218 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
219 // identified as photons or pi0 (overlapped gamma) produced on the vertex
220 //Vertex can be recovered with esd pointer doing:
221 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
223 Double32_t energy = E();
227 if(vertex){//calculate direction from vertex
233 Double_t r = TMath::Sqrt(pos[0]*pos[0]+
237 p.SetPxPyPzE( energy*pos[0]/r, energy*pos[1]/r, energy*pos[2]/r, energy) ;
242 void AliAODCaloCluster::SetCellsAbsId(UShort_t *array)
244 // Set the array of cell absId numbers
246 if(!fCellsAbsId)fCellsAbsId = new UShort_t[fNCells];
247 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
251 void AliAODCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
253 // Set the array of cell amplitude fraction
255 if(!fCellsAmpFraction)fCellsAmpFraction = new Double32_t[fNCells];
256 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];