]>
Commit | Line | Data |
---|---|---|
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 | ||
26 | ClassImp(AliAODCaloCluster) | |
27 | ||
28 | //______________________________________________________________________________ | |
29 | AliAODCaloCluster::AliAODCaloCluster() : | |
30 | AliAODCluster(), | |
31 | fDistToBadChannel(-999.), | |
32 | fDispersion(-1), | |
33 | fM20(0.), | |
fa86343a | 34 | fM02(0.), |
fa86343a | 35 | fEmcCpvDistance(-999.), |
78902954 | 36 | fNExMax(0), |
37 | fTOF(0.), | |
fa86343a | 38 | fTracksMatched(), |
e649177a | 39 | fNCells(0), |
341952b8 | 40 | fCellsAbsId(0x0), |
41 | fCellsAmpFraction(0x0) | |
fa86343a | 42 | { |
43 | // default constructor | |
44 | ||
45 | } | |
46 | ||
47 | //______________________________________________________________________________ | |
48 | AliAODCaloCluster::AliAODCaloCluster(Int_t id, | |
49 | UInt_t nLabel, | |
50 | Int_t *label, | |
51 | Double_t energy, | |
52 | Double_t x[3], | |
83dd7da3 | 53 | Double_t pid[13], |
fa86343a | 54 | Char_t ttype, |
55 | UInt_t selectInfo) : | |
56 | AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo), | |
57 | fDistToBadChannel(-999.), | |
58 | fDispersion(-1), | |
59 | fM20(0.), | |
fa86343a | 60 | fM02(0.), |
fa86343a | 61 | fEmcCpvDistance(-999.), |
62 | fNExMax(0), | |
78902954 | 63 | fTOF(0.), |
fa86343a | 64 | fTracksMatched(), |
e649177a | 65 | fNCells(0), |
341952b8 | 66 | fCellsAbsId(0x0), |
67 | fCellsAmpFraction(0x0) | |
fa86343a | 68 | { |
69 | // constructor | |
70 | ||
71 | } | |
72 | ||
73 | //______________________________________________________________________________ | |
74 | AliAODCaloCluster::AliAODCaloCluster(Int_t id, | |
75 | UInt_t nLabel, | |
76 | Int_t *label, | |
77 | Float_t energy, | |
78 | Float_t x[3], | |
83dd7da3 | 79 | Float_t pid[13], |
fa86343a | 80 | Char_t ttype, |
81 | UInt_t selectInfo) : | |
82 | AliAODCluster(id, nLabel, label, energy, x, pid, ttype, selectInfo), | |
83 | fDistToBadChannel(-999.), | |
84 | fDispersion(-1), | |
85 | fM20(0.), | |
fa86343a | 86 | fM02(0.), |
fa86343a | 87 | fEmcCpvDistance(-999.), |
88 | fNExMax(0), | |
78902954 | 89 | fTOF(0.), |
fa86343a | 90 | fTracksMatched(), |
e649177a | 91 | fNCells(0), |
341952b8 | 92 | fCellsAbsId(0x0), |
93 | fCellsAmpFraction(0x0) | |
fa86343a | 94 | { |
95 | // constructor | |
96 | } | |
97 | ||
98 | ||
99 | //______________________________________________________________________________ | |
100 | AliAODCaloCluster::~AliAODCaloCluster() | |
101 | { | |
102 | // destructor | |
e649177a | 103 | if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0; |
8dd6eba0 | 104 | if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0; |
fa86343a | 105 | } |
106 | ||
8dd6eba0 | 107 | //______________________________________________________________________________ |
108 | void AliAODCaloCluster::Clear(const Option_t*) | |
109 | { | |
110 | // clear | |
111 | RemoveLabel(); | |
112 | if(fCellsAmpFraction) delete[] fCellsAmpFraction; fCellsAmpFraction=0; | |
113 | if(fCellsAbsId) delete[] fCellsAbsId; fCellsAbsId = 0; | |
114 | } | |
fa86343a | 115 | |
116 | //______________________________________________________________________________ | |
117 | AliAODCaloCluster::AliAODCaloCluster(const AliAODCaloCluster& clus) : | |
118 | AliAODCluster(clus), | |
119 | fDistToBadChannel(clus.fDistToBadChannel), | |
120 | fDispersion(clus.fDispersion), | |
121 | fM20(clus.fM20), | |
fa86343a | 122 | fM02(clus.fM02), |
fa86343a | 123 | fEmcCpvDistance(clus.fEmcCpvDistance), |
124 | fNExMax(clus.fNExMax), | |
78902954 | 125 | fTOF(clus.fTOF), |
fa86343a | 126 | fTracksMatched(clus.fTracksMatched), |
e649177a | 127 | fNCells(clus.fNCells), |
341952b8 | 128 | fCellsAbsId(0x0), |
129 | fCellsAmpFraction(0x0) | |
fa86343a | 130 | { |
131 | // Copy constructor | |
e649177a | 132 | |
133 | if (clus.fNCells > 0) { | |
134 | ||
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]; | |
139 | } | |
140 | ||
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]; | |
145 | } | |
146 | ||
147 | } | |
148 | ||
fa86343a | 149 | } |
150 | ||
151 | //______________________________________________________________________________ | |
152 | AliAODCaloCluster& AliAODCaloCluster::operator=(const AliAODCaloCluster& clus) | |
153 | { | |
154 | // Assignment operator | |
155 | if(this!=&clus) { | |
156 | ||
157 | AliAODCluster::operator=(clus); | |
158 | ||
159 | fDistToBadChannel = clus.fDistToBadChannel; | |
160 | fDispersion = clus.fDispersion; | |
161 | fM20 = clus.fM20; | |
fa86343a | 162 | fM02 = clus.fM02; |
fa86343a | 163 | fEmcCpvDistance = clus.fEmcCpvDistance; |
164 | fNExMax = clus.fNExMax; | |
78902954 | 165 | fTOF = clus.fTOF; |
fa86343a | 166 | fTracksMatched = clus.fTracksMatched; |
e649177a | 167 | |
168 | fNCells= clus. fNCells; | |
341952b8 | 169 | // delete anyway |
170 | if(fCellsAbsId)delete [] fCellsAbsId; | |
171 | if(fCellsAmpFraction)delete [] fCellsAmpFraction; | |
172 | ||
e649177a | 173 | if (clus.fNCells > 0) { |
174 | ||
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]; | |
179 | } | |
180 | ||
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]; | |
185 | } | |
186 | ||
187 | } | |
188 | ||
fa86343a | 189 | } |
190 | ||
191 | return *this; | |
192 | } | |
193 | ||
194 | //_______________________________________________________________________ | |
195 | Bool_t AliAODCaloCluster::HasTrackMatched(TObject *trk) const | |
196 | { | |
197 | // Checks if the given track contributed to this cluster. | |
198 | ||
199 | TRefArrayIter iter(&fTracksMatched); | |
200 | while (TObject *track = iter.Next()) { | |
201 | if (trk == track) return kTRUE; | |
202 | } | |
203 | return kFALSE; | |
204 | } | |
78902954 | 205 | |
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) ; " | |
212 | ||
213 | Double32_t energy = E(); | |
c8fe2783 | 214 | Float_t pos[3]; |
78902954 | 215 | GetPosition(pos); |
216 | ||
217 | if(vertex){//calculate direction from vertex | |
218 | pos[0]-=vertex[0]; | |
219 | pos[1]-=vertex[1]; | |
220 | pos[2]-=vertex[2]; | |
221 | } | |
222 | ||
223 | Double_t r = TMath::Sqrt(pos[0]*pos[0]+ | |
224 | pos[1]*pos[1]+ | |
225 | pos[2]*pos[2] ) ; | |
226 | ||
227 | p.SetPxPyPzE( energy*pos[0]/r, energy*pos[1]/r, energy*pos[2]/r, energy) ; | |
228 | ||
229 | } | |
1b54b5a3 | 230 | |
231 | ||
232 | void AliAODCaloCluster::SetCellsAbsId(UShort_t *array) | |
233 | { | |
234 | // Set the array of cell absId numbers | |
235 | if (fNCells) { | |
341952b8 | 236 | if(!fCellsAbsId)fCellsAbsId = new UShort_t[fNCells]; |
237 | for (Int_t i = 0; i < fNCells; i++) fCellsAbsId[i] = array[i]; | |
1b54b5a3 | 238 | } |
239 | } | |
240 | ||
241 | void AliAODCaloCluster::SetCellsAmplitudeFraction(Double32_t *array) | |
242 | { | |
243 | // Set the array of cell amplitude fraction | |
244 | if (fNCells) { | |
341952b8 | 245 | if(!fCellsAmpFraction)fCellsAmpFraction = new Double32_t[fNCells]; |
246 | for (Int_t i = 0; i < fNCells; i++) fCellsAmpFraction[i] = array[i]; | |
1b54b5a3 | 247 | } |
248 | } |