]>
Commit | Line | Data |
---|---|---|
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 cluster base class | |
20 | // Author: Markus Oldenburg, CERN | |
21 | //------------------------------------------------------------------------- | |
22 | ||
23 | #include "AliAODCluster.h" | |
24 | ||
25 | ClassImp(AliAODCluster) | |
26 | ||
27 | //______________________________________________________________________________ | |
28 | AliAODCluster::AliAODCluster() : | |
29 | fEnergy(0), | |
30 | fChi2(-999.), | |
31 | fID(-999), | |
32 | fNLabel(0), | |
33 | fLabel(0x0), | |
34 | fFilterMap(0), | |
35 | fType(kUndef) | |
36 | { | |
37 | // default constructor | |
38 | ||
39 | SetPosition((Float_t*)NULL); | |
40 | SetPID((Float_t*)NULL); | |
41 | } | |
42 | ||
43 | //______________________________________________________________________________ | |
44 | AliAODCluster::AliAODCluster(Int_t id, | |
45 | UInt_t nLabel, | |
46 | Int_t *label, | |
47 | Double_t energy, | |
48 | Double_t x[3], | |
49 | Double_t pid[13], | |
50 | Char_t ttype, | |
51 | UInt_t selectInfo) : | |
52 | fEnergy(energy), | |
53 | fChi2(-999.), | |
54 | fID(id), | |
55 | fNLabel(0), | |
56 | fLabel(0x0), | |
57 | fFilterMap(selectInfo), | |
58 | fType(ttype) | |
59 | { | |
60 | // constructor | |
61 | ||
62 | SetPosition(x); | |
63 | SetPID(pid); | |
64 | SetLabel(label, nLabel); | |
65 | } | |
66 | ||
67 | //______________________________________________________________________________ | |
68 | AliAODCluster::AliAODCluster(Int_t id, | |
69 | UInt_t nLabel, | |
70 | Int_t *label, | |
71 | Float_t energy, | |
72 | Float_t x[3], | |
73 | Float_t pid[13], | |
74 | Char_t ttype, | |
75 | UInt_t selectInfo) : | |
76 | fEnergy(energy), | |
77 | fChi2(-999.), | |
78 | fID(id), | |
79 | fNLabel(0), | |
80 | fLabel(0x0), | |
81 | fFilterMap(selectInfo), | |
82 | fType(ttype) | |
83 | { | |
84 | // constructor | |
85 | ||
86 | SetPosition(x); | |
87 | SetPID(pid); | |
88 | SetLabel(label, nLabel); | |
89 | } | |
90 | ||
91 | ||
92 | //______________________________________________________________________________ | |
93 | AliAODCluster::~AliAODCluster() | |
94 | { | |
95 | // destructor | |
96 | ||
97 | RemoveLabel(); | |
98 | } | |
99 | ||
100 | ||
101 | //______________________________________________________________________________ | |
102 | AliAODCluster::AliAODCluster(const AliAODCluster& clus) : | |
103 | TObject(clus), | |
104 | fEnergy(clus.fEnergy), | |
105 | fChi2(clus.fChi2), | |
106 | fID(clus.fID), | |
107 | fNLabel(0), | |
108 | fLabel(0x0), | |
109 | fFilterMap(clus.fFilterMap), | |
110 | fType(clus.fType) | |
111 | { | |
112 | // Copy constructor | |
113 | ||
114 | clus.GetPosition(fPosition); | |
115 | SetPID(clus.fPID); | |
116 | SetLabel(clus.fLabel, clus.fNLabel); | |
117 | } | |
118 | ||
119 | //______________________________________________________________________________ | |
120 | AliAODCluster& AliAODCluster::operator=(const AliAODCluster& clus) | |
121 | { | |
122 | // Assignment operator | |
123 | if(this!=&clus) { | |
124 | ||
125 | clus.GetPosition(fPosition); | |
126 | clus.GetPID(fPID); | |
127 | ||
128 | fEnergy = clus.fEnergy; | |
129 | fChi2 = clus.fChi2; | |
130 | ||
131 | fID = clus.fID; | |
132 | SetLabel(clus.fLabel, clus.fNLabel); | |
133 | fFilterMap = clus.fFilterMap; | |
134 | ||
135 | fType = clus.fType; | |
136 | } | |
137 | ||
138 | return *this; | |
139 | } | |
140 | ||
141 | //______________________________________________________________________________ | |
142 | template <class T> void AliAODCluster::SetPosition(const T *x) | |
143 | { | |
144 | // set the position | |
145 | ||
146 | if (x) { | |
147 | fPosition[0] = x[0]; | |
148 | fPosition[1] = x[1]; | |
149 | fPosition[2] = x[2]; | |
150 | } else { | |
151 | ||
152 | fPosition[0] = -999.; | |
153 | fPosition[1] = -999.; | |
154 | fPosition[2] = -999.; | |
155 | } | |
156 | } | |
157 | ||
158 | //______________________________________________________________________________ | |
159 | AliAODCluster::AODCluPID_t AliAODCluster::GetMostProbablePID() const | |
160 | { | |
161 | // Returns the most probable PID array element. | |
162 | ||
163 | Int_t nPID = 13; | |
164 | if (fPID) { | |
165 | AODCluPID_t loc = kUnknown; | |
166 | Double_t max = 0.; | |
167 | Bool_t allTheSame = kTRUE; | |
168 | ||
169 | for (Int_t iPID = 0; iPID < nPID; iPID++) { | |
170 | if (fPID[iPID] >= max) { | |
171 | if (fPID[iPID] > max) { | |
172 | allTheSame = kFALSE; | |
173 | max = fPID[iPID]; | |
174 | loc = (AODCluPID_t)iPID; | |
175 | } else { | |
176 | allTheSame = kTRUE; | |
177 | } | |
178 | } | |
179 | } | |
180 | ||
181 | return allTheSame ? kUnknown : loc; | |
182 | } else { | |
183 | return kUnknown; | |
184 | } | |
185 | } | |
186 | ||
187 | //______________________________________________________________________________ | |
188 | void AliAODCluster::SetLabel(Int_t *label, UInt_t size) | |
189 | { | |
190 | if (label && size>0) { | |
191 | if (size != (UInt_t)fNLabel) { | |
192 | RemoveLabel(); | |
193 | fNLabel = size; | |
194 | fLabel = new Int_t[fNLabel]; | |
195 | } | |
196 | ||
197 | for (Int_t i = 0; i < fNLabel; i++) { | |
198 | fLabel[i] = label[i]; | |
199 | } | |
200 | } else { | |
201 | RemoveLabel(); | |
202 | } | |
203 | ||
204 | return; | |
205 | } | |
206 | ||
207 | //______________________________________________________________________________ | |
208 | Int_t AliAODCluster::GetLabel(UInt_t i) const | |
209 | { | |
210 | if (fLabel && i < (UInt_t)fNLabel) { | |
211 | return fLabel[i]; | |
212 | } else { | |
213 | return -999; | |
214 | } | |
215 | } | |
216 | ||
217 | //______________________________________________________________________________ | |
218 | void AliAODCluster::RemoveLabel() | |
219 | { | |
220 | delete[] fLabel; | |
221 | fLabel = 0x0; | |
222 | fNLabel = 0; | |
223 | ||
224 | return; | |
225 | } | |
226 | ||
227 | //______________________________________________________________________________ | |
228 | void AliAODCluster::Print(Option_t* /* option */) const | |
229 | { | |
230 | // prints information about AliAODCluster | |
231 | ||
232 | printf("Cluster type: %d\n", GetType()); | |
233 | printf(" energy = %f\n", E()); | |
234 | printf(" chi2 = %f\n", Chi2()); | |
235 | printf(" PID object: %p\n", static_cast<const void*>(PID())); | |
236 | } |