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 // 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.),
73 //______________________________________________________________________________
74 AliAODCaloCluster::AliAODCaloCluster(Int_t id,
82 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
83 fDistToBadChannel(-999.),
87 fEmcCpvDistance(-999.),
99 //______________________________________________________________________________
100 AliAODCaloCluster::~AliAODCaloCluster()
103 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
104 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
108 //______________________________________________________________________________
109 AliAODCaloCluster::AliAODCaloCluster(const AliAODCaloCluster& clus) :
111 fDistToBadChannel(clus.fDistToBadChannel),
112 fDispersion(clus.fDispersion),
115 fEmcCpvDistance(clus.fEmcCpvDistance),
116 fNExMax(clus.fNExMax),
118 fTracksMatched(clus.fTracksMatched),
119 fNCells(clus.fNCells),
125 if (clus.fNCells > 0) {
127 if(clus.fCellsAbsId){
128 fCellsAbsId = new UShort_t[clus.fNCells];
129 for (Int_t i=0; i<clus.fNCells; i++)
130 fCellsAbsId[i]=clus.fCellsAbsId[i];
133 if(clus.fCellsAmpFraction){
134 fCellsAmpFraction = new Double32_t[clus.fNCells];
135 for (Int_t i=0; i<clus.fNCells; i++)
136 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
143 //______________________________________________________________________________
144 AliAODCaloCluster& AliAODCaloCluster::operator=(const AliAODCaloCluster& clus)
146 // Assignment operator
149 AliAODCluster::operator=(clus);
151 fDistToBadChannel = clus.fDistToBadChannel;
152 fDispersion = clus.fDispersion;
155 fEmcCpvDistance = clus.fEmcCpvDistance;
156 fNExMax = clus.fNExMax;
158 fTracksMatched = clus.fTracksMatched;
160 fNCells= clus. fNCells;
161 if (clus.fNCells > 0) {
163 if(clus.fCellsAbsId){
164 fCellsAbsId = new UShort_t[clus.fNCells];
165 for (Int_t i=0; i<clus.fNCells; i++)
166 fCellsAbsId[i]=clus.fCellsAbsId[i];
169 if(clus.fCellsAmpFraction){
170 fCellsAmpFraction = new Double32_t[clus.fNCells];
171 for (Int_t i=0; i<clus.fNCells; i++)
172 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
182 //_______________________________________________________________________
183 Bool_t AliAODCaloCluster::HasTrackMatched(TObject *trk) const
185 // Checks if the given track contributed to this cluster.
187 TRefArrayIter iter(&fTracksMatched);
188 while (TObject *track = iter.Next()) {
189 if (trk == track) return kTRUE;
194 //_______________________________________________________________________
195 void AliAODCaloCluster::GetMomentum(TLorentzVector& p, Double_t *vertex ) {
196 // Returns TLorentzVector with momentum of the cluster. Only valid for clusters
197 // identified as photons or pi0 (overlapped gamma) produced on the vertex
198 //Vertex can be recovered with esd pointer doing:
199 //" Double_t vertex[3] ; esd->GetVertex()->GetXYZ(vertex) ; "
201 Double32_t energy = E();
205 if(vertex){//calculate direction from vertex
211 Double_t r = TMath::Sqrt(pos[0]*pos[0]+
215 p.SetPxPyPzE( energy*pos[0]/r, energy*pos[1]/r, energy*pos[2]/r, energy) ;
220 void AliAODCaloCluster::SetCellsAbsId(UShort_t *array)
222 // Set the array of cell absId numbers
224 fCellsAbsId = new UShort_t[fNCells];
225 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
229 void AliAODCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
231 // Set the array of cell amplitude fraction
233 fCellsAmpFraction = new Double32_t[fNCells];
234 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];