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.),
41 fCellsAmpFraction(0x0)
43 // default constructor
47 //______________________________________________________________________________
48 AliAODCaloCluster::AliAODCaloCluster(Int_t id,
56 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
57 fDistToBadChannel(-999.),
61 fEmcCpvDistance(-999.),
67 fCellsAmpFraction(0x0)
73 //______________________________________________________________________________
74 AliAODCaloCluster::AliAODCaloCluster(Int_t id,
82 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
83 fDistToBadChannel(-999.),
87 fEmcCpvDistance(-999.),
93 fCellsAmpFraction(0x0)
99 //______________________________________________________________________________
100 AliAODCaloCluster::~AliAODCaloCluster()
103 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
104 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
107 //______________________________________________________________________________
108 void AliAODCaloCluster::Clear(const Option_t*)
112 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
113 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
116 //______________________________________________________________________________
117 AliAODCaloCluster::AliAODCaloCluster(const AliAODCaloCluster& clus) :
119 fDistToBadChannel(clus.fDistToBadChannel),
120 fDispersion(clus.fDispersion),
123 fEmcCpvDistance(clus.fEmcCpvDistance),
124 fNExMax(clus.fNExMax),
126 fTracksMatched(clus.fTracksMatched),
127 fNCells(clus.fNCells),
129 fCellsAmpFraction(0x0)
133 if (clus.fNCells > 0) {
135 if(clus.fCellsAbsId){
136 fCellsAbsId = new UShort_t[clus.fNCells];
137 for (Int_t i=0; i<clus.fNCells; i++)
138 fCellsAbsId[i]=clus.fCellsAbsId[i];
141 if(clus.fCellsAmpFraction){
142 fCellsAmpFraction = new Double32_t[clus.fNCells];
143 for (Int_t i=0; i<clus.fNCells; i++)
144 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
151 //______________________________________________________________________________
152 AliAODCaloCluster& AliAODCaloCluster::operator=(const AliAODCaloCluster& clus)
154 // Assignment operator
157 AliAODCluster::operator=(clus);
159 fDistToBadChannel = clus.fDistToBadChannel;
160 fDispersion = clus.fDispersion;
163 fEmcCpvDistance = clus.fEmcCpvDistance;
164 fNExMax = clus.fNExMax;
166 fTracksMatched = clus.fTracksMatched;
168 fNCells= clus. fNCells;
170 if(fCellsAbsId)delete [] fCellsAbsId;
171 if(fCellsAmpFraction)delete [] fCellsAmpFraction;
173 if (clus.fNCells > 0) {
175 if(clus.fCellsAbsId){
176 fCellsAbsId = new UShort_t[clus.fNCells];
177 for (Int_t i=0; i<clus.fNCells; i++)
178 fCellsAbsId[i]=clus.fCellsAbsId[i];
181 if(clus.fCellsAmpFraction){
182 fCellsAmpFraction = new Double32_t[clus.fNCells];
183 for (Int_t i=0; i<clus.fNCells; i++)
184 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
194 //_______________________________________________________________________
195 Bool_t AliAODCaloCluster::HasTrackMatched(TObject *trk) const
197 // Checks if the given track contributed to this cluster.
199 TRefArrayIter iter(&fTracksMatched);
200 while (TObject *track = iter.Next()) {
201 if (trk == track) return kTRUE;
206 //_______________________________________________________________________
207 void AliAODCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
208 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
209 // identified as photons or pi0 (overlapped gamma) produced on the vertex
210 //Vertex can be recovered with esd pointer doing:
211 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
213 Double32_t energy = E();
217 if(vertex){//calculate direction from vertex
223 Double_t r = TMath::Sqrt(pos[0]*pos[0]+
227 p.SetPxPyPzE( energy*pos[0]/r, energy*pos[1]/r, energy*pos[2]/r, energy) ;
232 void AliAODCaloCluster::SetCellsAbsId(UShort_t *array)
234 // Set the array of cell absId numbers
236 if(!fCellsAbsId)fCellsAbsId = new UShort_t[fNCells];
237 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
241 void AliAODCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
243 // Set the array of cell amplitude fraction
245 if(!fCellsAmpFraction)fCellsAmpFraction = new Double32_t[fNCells];
246 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];