]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AOD/AliAODCaloCluster.cxx
#99183: commit to trunk and port to release AliAODTZERO with T0 vertex
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODCaloCluster.cxx
CommitLineData
fa86343a 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18//-------------------------------------------------------------------------
19// AOD calorimeter cluster class (for PHOS and EMCAL)
20// Author: Markus Oldenburg, CERN
21//-------------------------------------------------------------------------
22
78902954 23#include <TLorentzVector.h>
fa86343a 24#include "AliAODCaloCluster.h"
25
26ClassImp(AliAODCaloCluster)
27
28//______________________________________________________________________________
29AliAODCaloCluster::AliAODCaloCluster() :
30 AliAODCluster(),
31 fDistToBadChannel(-999.),
32 fDispersion(-1),
33 fM20(0.),
fa86343a 34 fM02(0.),
fa86343a 35 fEmcCpvDistance(-999.),
d1388fe9 36 fTrackDx(-999),
37 fTrackDz(-999),
78902954 38 fNExMax(0),
39 fTOF(0.),
fa86343a 40 fTracksMatched(),
e649177a 41 fNCells(0),
341952b8 42 fCellsAbsId(0x0),
43 fCellsAmpFraction(0x0)
fa86343a 44{
45 // default constructor
46
47}
48
49//______________________________________________________________________________
50AliAODCaloCluster::AliAODCaloCluster(Int_t id,
51 UInt_t nLabel,
52 Int_t *label,
53 Double_t energy,
54 Double_t x[3],
83dd7da3 55 Double_t pid[13],
fa86343a 56 Char_t ttype,
57 UInt_t selectInfo) :
58 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
59 fDistToBadChannel(-999.),
60 fDispersion(-1),
61 fM20(0.),
fa86343a 62 fM02(0.),
fa86343a 63 fEmcCpvDistance(-999.),
d1388fe9 64 fTrackDx(-999),
65 fTrackDz(-999),
fa86343a 66 fNExMax(0),
78902954 67 fTOF(0.),
fa86343a 68 fTracksMatched(),
e649177a 69 fNCells(0),
341952b8 70 fCellsAbsId(0x0),
71 fCellsAmpFraction(0x0)
fa86343a 72{
73 // constructor
74
75}
76
77//______________________________________________________________________________
78AliAODCaloCluster::AliAODCaloCluster(Int_t id,
79 UInt_t nLabel,
80 Int_t *label,
81 Float_t energy,
82 Float_t x[3],
83dd7da3 83 Float_t pid[13],
fa86343a 84 Char_t ttype,
85 UInt_t selectInfo) :
86 AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo),
87 fDistToBadChannel(-999.),
88 fDispersion(-1),
89 fM20(0.),
fa86343a 90 fM02(0.),
fa86343a 91 fEmcCpvDistance(-999.),
d1388fe9 92 fTrackDx(-999),
93 fTrackDz(-999),
fa86343a 94 fNExMax(0),
78902954 95 fTOF(0.),
fa86343a 96 fTracksMatched(),
e649177a 97 fNCells(0),
341952b8 98 fCellsAbsId(0x0),
99 fCellsAmpFraction(0x0)
fa86343a 100{
101 // constructor
102}
103
104
105//______________________________________________________________________________
106AliAODCaloCluster::~AliAODCaloCluster()
107{
108 // destructor
e649177a 109 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
8dd6eba0 110 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
fa86343a 111}
112
8dd6eba0 113//______________________________________________________________________________
114void AliAODCaloCluster::Clear(const Option_t*)
115{
116 // clear
117 RemoveLabel();
118 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
119 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
120}
fa86343a 121
122//______________________________________________________________________________
123AliAODCaloCluster::AliAODCaloCluster(const AliAODCaloCluster& clus) :
124 AliAODCluster(clus),
125 fDistToBadChannel(clus.fDistToBadChannel),
126 fDispersion(clus.fDispersion),
127 fM20(clus.fM20),
fa86343a 128 fM02(clus.fM02),
fa86343a 129 fEmcCpvDistance(clus.fEmcCpvDistance),
d1388fe9 130 fTrackDx(clus.fTrackDx),
131 fTrackDz(clus.fTrackDz),
fa86343a 132 fNExMax(clus.fNExMax),
78902954 133 fTOF(clus.fTOF),
fa86343a 134 fTracksMatched(clus.fTracksMatched),
e649177a 135 fNCells(clus.fNCells),
341952b8 136 fCellsAbsId(0x0),
137 fCellsAmpFraction(0x0)
fa86343a 138{
139 // Copy constructor
e649177a 140
141 if (clus.fNCells > 0) {
142
143 if(clus.fCellsAbsId){
144 fCellsAbsId = new UShort_t[clus.fNCells];
145 for (Int_t i=0; i<clus.fNCells; i++)
d1388fe9 146 fCellsAbsId[i]=clus.fCellsAbsId[i];
e649177a 147 }
148
149 if(clus.fCellsAmpFraction){
150 fCellsAmpFraction = new Double32_t[clus.fNCells];
151 for (Int_t i=0; i<clus.fNCells; i++)
d1388fe9 152 fCellsAmpFraction[i]=clus.fCellsAmpFraction[i];
e649177a 153 }
154
155 }
156
fa86343a 157}
158
159//______________________________________________________________________________
160AliAODCaloCluster& AliAODCaloCluster::operator=(const AliAODCaloCluster& clus)
161{
162 // Assignment operator
163 if(this!=&clus) {
164
165 AliAODCluster::operator=(clus);
166
167 fDistToBadChannel = clus.fDistToBadChannel;
168 fDispersion = clus.fDispersion;
169 fM20 = clus.fM20;
fa86343a 170 fM02 = clus.fM02;
fa86343a 171 fEmcCpvDistance = clus.fEmcCpvDistance;
d1388fe9 172 fTrackDx=clus.fTrackDx;
173 fTrackDz=clus.fTrackDz;
fa86343a 174 fNExMax = clus.fNExMax;
78902954 175 fTOF = clus.fTOF;
fa86343a 176 fTracksMatched = clus.fTracksMatched;
e649177a 177
178 fNCells= clus. fNCells;
341952b8 179 // delete anyway
180 if(fCellsAbsId)delete [] fCellsAbsId;
181 if(fCellsAmpFraction)delete [] fCellsAmpFraction;
182
e649177a 183 if (clus.fNCells > 0) {
184
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];
189 }
190
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];
195 }
196
197 }
198
fa86343a 199 }
200
201 return *this;
202}
203
204//_______________________________________________________________________
205Bool_t AliAODCaloCluster::HasTrackMatched(TObject *trk) const
206{
207 // Checks if the given track contributed to this cluster.
208
209 TRefArrayIter iter(&fTracksMatched);
210 while (TObject *track = iter.Next()) {
211 if (trk == track) return kTRUE;
212 }
213 return kFALSE;
214}
78902954 215
216//_______________________________________________________________________
217void 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) ; "
222
223 Double32_t energy = E();
c8fe2783 224 Float_t pos[3];
78902954 225 GetPosition(pos);
226
227 if(vertex){//calculate direction from vertex
228 pos[0]-=vertex[0];
229 pos[1]-=vertex[1];
230 pos[2]-=vertex[2];
231 }
232
233 Double_t r = TMath::Sqrt(pos[0]*pos[0]+
234 pos[1]*pos[1]+
235 pos[2]*pos[2] ) ;
236
237 p.SetPxPyPzE( energy*pos[0]/r, energy*pos[1]/r, energy*pos[2]/r, energy) ;
238
239}
1b54b5a3 240
241
242void AliAODCaloCluster::SetCellsAbsId(UShort_t *array)
243{
244 // Set the array of cell absId numbers
245 if (fNCells) {
341952b8 246 if(!fCellsAbsId)fCellsAbsId = new UShort_t[fNCells];
247 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
1b54b5a3 248 }
249}
250
251void AliAODCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
252{
253 // Set the array of cell amplitude fraction
254 if (fNCells) {
341952b8 255 if(!fCellsAmpFraction)fCellsAmpFraction = new Double32_t[fNCells];
256 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
1b54b5a3 257 }
258}