Line data Source code
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 : #include "AliAODCluster.h"
17 :
18 : /// \cond CLASSIMP
19 170 : ClassImp(AliAODCluster) ;
20 : /// \endcond
21 :
22 : ///
23 : /// Default constructor.
24 : ///
25 : //______________________________________________________________________________
26 : AliAODCluster::AliAODCluster() :
27 6 : AliVCluster(),
28 6 : fEnergy(0),
29 6 : fChi2(-999.),
30 6 : fID(-999),
31 6 : fNLabel(0),
32 6 : fLabel(0x0),
33 6 : fFilterMap(0),
34 6 : fType(kUndef),
35 6 : fMCEnergyFraction(0.),
36 6 : fClusterMCEdepFraction(0x0)
37 18 : {
38 :
39 6 : SetPosition(NULL);
40 6 : SetPID(NULL);
41 6 : }
42 :
43 : ///
44 : /// Constructor.
45 : ///
46 : //______________________________________________________________________________
47 : AliAODCluster::AliAODCluster(Int_t id,
48 : UInt_t nLabel,
49 : Int_t *label,
50 : Double_t energy,
51 : Double_t x[3],
52 : Double_t pid[13],
53 : Char_t ttype,
54 : UInt_t selectInfo) :
55 172 : AliVCluster(),
56 172 : fEnergy(energy),
57 172 : fChi2(-999.),
58 172 : fID(id),
59 172 : fNLabel(0),
60 172 : fLabel(0x0),
61 172 : fFilterMap(selectInfo),
62 172 : fType(ttype),
63 172 : fMCEnergyFraction(0.),
64 172 : fClusterMCEdepFraction(0x0)
65 516 : {
66 1376 : for (Int_t i = 0; i < 3; i++) fPosition[i] = 0.;
67 4816 : for (Int_t i = 0; i < 13; i++) fPID[i] = 0;
68 :
69 2236 : if(x) {for (Int_t i = 0; i < 3 ; i++) SetPositionAt(x[i] ,i);}
70 7396 : if(pid) {for (Int_t i = 0; i < 13 ; i++) SetPIDAt (pid[i],i);}
71 172 : SetLabel(label, nLabel);
72 172 : }
73 :
74 : ///
75 : /// Constructor.
76 : ///
77 : //______________________________________________________________________________
78 : AliAODCluster::AliAODCluster(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 43 : AliVCluster(),
87 43 : fEnergy(energy),
88 43 : fChi2(-999.),
89 43 : fID(id),
90 43 : fNLabel(0),
91 43 : fLabel(0x0),
92 43 : fFilterMap(selectInfo),
93 43 : fType(ttype),
94 43 : fMCEnergyFraction(0.),
95 43 : fClusterMCEdepFraction(0x0)
96 129 : {
97 344 : for (Int_t i = 0; i < 3; i++) fPosition[i] = 0.;
98 1204 : for (Int_t i = 0; i < 13; i++) fPID[i] = 0;
99 :
100 559 : if(x) {for (Int_t i = 0; i < 3 ; i++) SetPositionAt(x[i] ,i);}
101 43 : if(pid) {for (Int_t i = 0; i < 13 ; i++) SetPIDAt (pid[i],i);}
102 43 : SetLabel(label, nLabel);
103 43 : }
104 :
105 : ///
106 : /// Destructor
107 : ///
108 : //______________________________________________________________________________
109 : AliAODCluster::~AliAODCluster()
110 442 : {
111 221 : RemoveLabel();
112 221 : }
113 :
114 : ///
115 : /// Clear
116 : ///
117 : //______________________________________________________________________________
118 : void AliAODCluster::Clear(const Option_t*)
119 : {
120 0 : RemoveLabel();
121 0 : }
122 :
123 : ///
124 : /// Copy constructor.
125 : ///
126 : //______________________________________________________________________________
127 : AliAODCluster::AliAODCluster(const AliAODCluster& clus) :
128 0 : AliVCluster(clus),
129 0 : fEnergy(clus.fEnergy),
130 0 : fChi2(clus.fChi2),
131 0 : fID(clus.fID),
132 0 : fNLabel(0),
133 0 : fLabel(0x0),
134 0 : fFilterMap(clus.fFilterMap),
135 0 : fType(clus.fType),
136 0 : fMCEnergyFraction(clus.fMCEnergyFraction),
137 0 : fClusterMCEdepFraction(0x0)
138 0 : {
139 0 : for(Int_t i = 0; i < 3 ; i++) fPosition[i] = clus.fPosition[i];
140 0 : for(Int_t i = 0; i < 13 ; i++) fPID[i] = clus.fPID[i];
141 :
142 0 : SetLabel(clus.fLabel, clus.fNLabel);
143 0 : SetClusterMCEdepFraction(clus.fClusterMCEdepFraction);
144 0 : }
145 :
146 : ///
147 : /// Assignment operator.
148 : ///
149 : //______________________________________________________________________________
150 : AliAODCluster& AliAODCluster::operator=(const AliAODCluster& clus)
151 : {
152 0 : if(this!=&clus) {
153 :
154 0 : for(Int_t i = 0; i < 3 ; i++) fPosition[i] = clus.fPosition[i];
155 0 : for(Int_t i = 0; i < 13 ; i++) fPID[i] = clus.fPID[i];
156 :
157 0 : fEnergy = clus.fEnergy;
158 0 : fChi2 = clus.fChi2;
159 :
160 0 : fID = clus.fID;
161 :
162 0 : SetLabel(clus.fLabel, clus.fNLabel);
163 0 : SetClusterMCEdepFraction(clus.fClusterMCEdepFraction);
164 :
165 0 : fFilterMap = clus.fFilterMap;
166 :
167 0 : fType = clus.fType;
168 :
169 0 : fMCEnergyFraction = clus.fMCEnergyFraction;
170 0 : }
171 :
172 0 : return *this;
173 : }
174 :
175 : ///
176 : /// Set cluster global position.
177 : ///
178 : //______________________________________________________________________________
179 : void AliAODCluster::SetPosition(Float_t *x)
180 : {
181 12 : if (x) {
182 0 : fPosition[0] = x[0];
183 0 : fPosition[1] = x[1];
184 0 : fPosition[2] = x[2];
185 0 : } else {
186 6 : fPosition[0] = -999.;
187 6 : fPosition[1] = -999.;
188 6 : fPosition[2] = -999.;
189 : }
190 6 : }
191 :
192 : ///
193 : /// \return The most probable PID array element.
194 : ///
195 : //______________________________________________________________________________
196 : UShort_t AliAODCluster::GetMostProbablePID() const
197 : {
198 : Int_t nPID = 13;
199 : UShort_t unknown = AliVCluster::kUnknown;
200 :
201 : UShort_t loc = unknown;
202 : Double_t max = 0.;
203 : Bool_t allTheSame = kTRUE;
204 :
205 0 : for (Int_t iPID = 0; iPID < nPID; iPID++) {
206 0 : if (fPID[iPID] >= max) {
207 0 : if (fPID[iPID] > max) {
208 : allTheSame = kFALSE;
209 : max = fPID[iPID];
210 0 : loc = (UShort_t)iPID;
211 0 : } else {
212 : allTheSame = kTRUE;
213 : }
214 : }
215 : }
216 0 : return allTheSame ? unknown : loc;
217 : }
218 :
219 : ///
220 : /// Set the array with MC particle labels and number of labels.
221 : ///
222 : //______________________________________________________________________________
223 : void AliAODCluster::SetLabel(Int_t *label, UInt_t size)
224 : {
225 430 : if (label && size>0) {
226 22 : if (size != (UInt_t)fNLabel) {
227 22 : RemoveLabel();
228 22 : fNLabel = size;
229 22 : fLabel = new Int_t[fNLabel];
230 22 : }
231 :
232 90 : for (Int_t i = 0; i < fNLabel; i++) {
233 23 : fLabel[i] = label[i];
234 : }
235 22 : } else {
236 193 : RemoveLabel();
237 : }
238 :
239 215 : return;
240 : }
241 :
242 : ///
243 : /// Get the label i of the possible fNLabel in the array fLabel
244 : ///
245 : //______________________________________________________________________________
246 : Int_t AliAODCluster::GetLabelAt(UInt_t i) const
247 : {
248 69 : if (fLabel && i < (UInt_t)fNLabel) {
249 23 : return fLabel[i];
250 : } else {
251 0 : return -999;
252 : }
253 23 : }
254 :
255 : ///
256 : /// Delete MC arrays, used in destructor and Clear() and SetLabel() methods
257 : ///
258 : //______________________________________________________________________________
259 : void AliAODCluster::RemoveLabel()
260 : {
261 894 : delete[] fLabel;
262 436 : fLabel = 0x0;
263 436 : fNLabel = 0;
264 :
265 436 : if(fClusterMCEdepFraction)
266 34 : delete[] fClusterMCEdepFraction;
267 436 : fClusterMCEdepFraction = 0 ;
268 :
269 436 : return;
270 : }
271 :
272 : ///
273 : /// Prints information about AliAODCluster.
274 : ///
275 : //______________________________________________________________________________
276 : void AliAODCluster::Print(Option_t* /* option */) const
277 : {
278 0 : printf("Cluster type: %d\n", GetType());
279 0 : printf(" energy = %f\n", E());
280 0 : printf(" chi2 = %f\n", Chi2());
281 0 : const Double_t *pid = GetPID();
282 0 : printf("PID weights: photon %0.2f, pi0 %0.2f, electron %0.2f, conversion electron %0.2f\n, hadrons: pion %0.2f, kaon %0.2f, proton %0.2f , neutron %0.2f, kaon %0.2f \n",
283 0 : pid[AliVCluster::kPhoton], pid[AliVCluster::kPi0],
284 0 : pid[AliVCluster::kElectron], pid[AliVCluster::kEleCon],
285 0 : pid[AliVCluster::kPion], pid[AliVCluster::kKaon], pid[AliVCluster::kProton],
286 0 : pid[AliVCluster::kNeutron], pid[AliVCluster::kKaon0]);
287 0 : }
288 :
289 : ///
290 : /// \return Fraction of deposited energy by the one of the particles in array fLable
291 : ///
292 : /// \param mcIndex: position of MC particle in array GetLabels()
293 : ///
294 : /// The parameter is stored as %, return the corresponding float.
295 : //______________________________________________________________________________
296 : Float_t AliAODCluster::GetClusterMCEdepFraction(Int_t mcIndex) const
297 : {
298 0 : if ( mcIndex < 0 || mcIndex >= fNLabel || !fClusterMCEdepFraction ) return 0. ;
299 :
300 0 : return fClusterMCEdepFraction[mcIndex]/100. ;
301 0 : }
302 :
303 : ///
304 : /// Set the array with the fraction of deposited energy in cluster by a given primary
305 : /// particle. Each entry of the array corresponds to the same entry in GetLabels().
306 : /// Set the fraction in % with respect the cluster energy, store a value between 0 and 100
307 : ///
308 : /// Not sure this method is usable for AODs
309 : ///
310 : /// \param array: energy deposition array
311 : //______________________________________________________________________________
312 : void AliAODCluster::SetClusterMCEdepFractionFromEdepArray(Float_t *array)
313 : {
314 0 : if ( fNLabel <= 0 || !array ) return ;
315 :
316 0 : fClusterMCEdepFraction = new UShort_t[fNLabel];
317 :
318 : // Get total deposited energy (can be different from reconstructed energy)
319 : Float_t totalE = 0;
320 0 : for (Int_t i = 0; i < fNLabel; i++) totalE+=array[i];
321 :
322 : // Set the fraction of energy per MC contributor in %
323 0 : for (Int_t i = 0; i < fNLabel; i++)
324 0 : fClusterMCEdepFraction[i] = TMath::Nint(array[i]/totalE*100.);
325 0 : }
326 :
327 : ///
328 : /// Set the array with the fraction of deposited energy in cluster by a given primary
329 : /// particle. Each entry of the array corresponds to the same entry in GetLabels().
330 : ///
331 : /// The fraction must already be in % with respect the cluster energy, store a value between 0 and 100
332 : ///
333 : /// Execute after setting of fLable and fNLabel
334 : ///
335 : /// \param array: array of fraction of energy deposition / cluster energy
336 : //______________________________________________________________________________
337 : void AliAODCluster::SetClusterMCEdepFraction(UShort_t *array)
338 : {
339 86 : if ( fNLabel <= 0 || !array )
340 : return ;
341 :
342 17 : fClusterMCEdepFraction = new UShort_t[fNLabel];
343 :
344 70 : for (Int_t i = 0; i < fNLabel; i++)
345 18 : fClusterMCEdepFraction[i] = array[i];
346 43 : }
347 :
348 :
349 :
350 :
|