#99183: commit to trunk and port to release AliAODTZERO with T0 vertex
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODCaloCluster.cxx
... / ...
CommitLineData
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
23#include <TLorentzVector.h>
24#include "AliAODCaloCluster.h"
25
26ClassImp(AliAODCaloCluster)
27
28//______________________________________________________________________________
29AliAODCaloCluster::AliAODCaloCluster() :
30 AliAODCluster(),
31 fDistToBadChannel(-999.),
32 fDispersion(-1),
33 fM20(0.),
34 fM02(0.),
35 fEmcCpvDistance(-999.),
36 fTrackDx(-999),
37 fTrackDz(-999),
38 fNExMax(0),
39 fTOF(0.),
40 fTracksMatched(),
41 fNCells(0),
42 fCellsAbsId(0x0),
43 fCellsAmpFraction(0x0)
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],
55 Double_t pid[13],
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.),
62 fM02(0.),
63 fEmcCpvDistance(-999.),
64 fTrackDx(-999),
65 fTrackDz(-999),
66 fNExMax(0),
67 fTOF(0.),
68 fTracksMatched(),
69 fNCells(0),
70 fCellsAbsId(0x0),
71 fCellsAmpFraction(0x0)
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],
83 Float_t pid[13],
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.),
90 fM02(0.),
91 fEmcCpvDistance(-999.),
92 fTrackDx(-999),
93 fTrackDz(-999),
94 fNExMax(0),
95 fTOF(0.),
96 fTracksMatched(),
97 fNCells(0),
98 fCellsAbsId(0x0),
99 fCellsAmpFraction(0x0)
100{
101 // constructor
102}
103
104
105//______________________________________________________________________________
106AliAODCaloCluster::~AliAODCaloCluster()
107{
108 // destructor
109 if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0;
110 if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0;
111}
112
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}
121
122//______________________________________________________________________________
123AliAODCaloCluster::AliAODCaloCluster(const AliAODCaloCluster& clus) :
124 AliAODCluster(clus),
125 fDistToBadChannel(clus.fDistToBadChannel),
126 fDispersion(clus.fDispersion),
127 fM20(clus.fM20),
128 fM02(clus.fM02),
129 fEmcCpvDistance(clus.fEmcCpvDistance),
130 fTrackDx(clus.fTrackDx),
131 fTrackDz(clus.fTrackDz),
132 fNExMax(clus.fNExMax),
133 fTOF(clus.fTOF),
134 fTracksMatched(clus.fTracksMatched),
135 fNCells(clus.fNCells),
136 fCellsAbsId(0x0),
137 fCellsAmpFraction(0x0)
138{
139 // Copy constructor
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++)
146 fCellsAbsId[i]=clus.fCellsAbsId[i];
147 }
148
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];
153 }
154
155 }
156
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;
170 fM02 = clus.fM02;
171 fEmcCpvDistance = clus.fEmcCpvDistance;
172 fTrackDx=clus.fTrackDx;
173 fTrackDz=clus.fTrackDz;
174 fNExMax = clus.fNExMax;
175 fTOF = clus.fTOF;
176 fTracksMatched = clus.fTracksMatched;
177
178 fNCells= clus. fNCells;
179 // delete anyway
180 if(fCellsAbsId)delete [] fCellsAbsId;
181 if(fCellsAmpFraction)delete [] fCellsAmpFraction;
182
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
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}
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();
224 Float_t pos[3];
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}
240
241
242void AliAODCaloCluster::SetCellsAbsId(UShort_t *array)
243{
244 // Set the array of cell absId numbers
245 if (fNCells) {
246 if(!fCellsAbsId)fCellsAbsId = new UShort_t[fNCells];
247 for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i];
248 }
249}
250
251void AliAODCaloCluster::SetCellsAmplitudeFraction(Double32_t *array)
252{
253 // Set the array of cell amplitude fraction
254 if (fNCells) {
255 if(!fCellsAmpFraction)fCellsAmpFraction = new Double32_t[fNCells];
256 for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i];
257 }
258}