]>
Commit | Line | Data |
---|---|---|
8d122774 | 1 | /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * |
2 | * See cxx source for full Copyright notice */ | |
3 | ||
4 | /* $Id$ */ | |
5 | ||
6 | //------------------------------------------------------------------------- | |
7 | // AOD class to store calorimeter cell data | |
8 | // Author: Markus Oldenburg, CERN | |
9 | //------------------------------------------------------------------------- | |
10 | ||
11 | #ifndef ALIAODCELLS_H | |
12 | #define ALIAODCELLS_H | |
13 | ||
c8fe2783 | 14 | #include <AliVCaloCells.h> |
8d122774 | 15 | #include <TMath.h> |
16 | ||
c8fe2783 | 17 | class AliAODCaloCells : public AliVCaloCells |
8d122774 | 18 | { |
19 | public: | |
8d122774 | 20 | AliAODCaloCells(); |
c8fe2783 | 21 | AliAODCaloCells(const char* name, const char* title, VCells_t ttype=kUndef); |
5c1dc41f | 22 | AliAODCaloCells(const AliAODCaloCells& cells); |
23 | AliAODCaloCells& operator=(const AliAODCaloCells& cells); | |
8d122774 | 24 | virtual ~AliAODCaloCells(); |
8dd6eba0 | 25 | |
77e93dc2 | 26 | virtual AliVCaloCells* CopyCaloCells(Bool_t all) const; |
27 | virtual void Copy(TObject &obj) const; | |
28 | void Clear(const Option_t*); | |
29 | void CreateContainer(Short_t nCells); | |
30 | void DeleteContainer(); | |
31 | void Sort(); | |
8d122774 | 32 | |
60d77596 | 33 | inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, Double_t &time, Int_t &mclabel, Double_t &efrac) const ; |
dcd7321d | 34 | Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time, Int_t mclabel = -1, Double_t efrac = 0., Bool_t isHG=kFALSE); |
77e93dc2 | 35 | |
36 | Short_t GetNumberOfCells() const { return fNCells ; } | |
37 | void SetNumberOfCells(Int_t n) { fNCells = n ; } | |
8d122774 | 38 | |
8d122774 | 39 | inline Double_t GetCellAmplitude(Short_t cellNumber); |
dcd7321d | 40 | inline Bool_t GetCellHighGain(Short_t cellNumber); //is this cell High Gain |
b4620c80 | 41 | inline Short_t GetCellPosition(Short_t cellNumber); |
77e93dc2 | 42 | inline Double_t GetCellTime(Short_t cellNumber); |
43 | ||
8d122774 | 44 | inline Double_t GetAmplitude(Short_t pos) const; |
dcd7321d | 45 | inline Bool_t GetHighGain(Short_t pos) const; |
8d122774 | 46 | inline Short_t GetCellNumber(Short_t pos) const; |
77e93dc2 | 47 | inline Double_t GetTime(Short_t pos) const; |
48 | ||
49 | Bool_t IsEMCAL() const { return (fType == kEMCALCell); } | |
50 | Bool_t IsPHOS() const { return (fType == kPHOSCell) ; } | |
51 | ||
52 | Char_t GetType() const { return fType;} | |
53 | void SetType(Char_t ttype) { fType=ttype; } | |
54 | ||
55 | // MC & embedding | |
60d77596 | 56 | inline Int_t GetCellMCLabel(Short_t cellNumber) ; |
57 | inline Int_t GetMCLabel(Short_t pos) const ; | |
77e93dc2 | 58 | |
59 | inline Double_t GetCellEFraction(Short_t cellNumber) ; | |
60 | inline Double_t GetEFraction(Short_t pos) const ; | |
61 | ||
62 | inline void SetEFraction (Short_t pos, Double32_t efrac) ; | |
63 | inline void SetCellEFraction(Short_t cellNumber, Double32_t efrac) ; | |
64 | ||
8d122774 | 65 | protected: |
77e93dc2 | 66 | |
8d122774 | 67 | Int_t fNCells; // Number of cells |
dcd7321d | 68 | Bool_t *fHGLG; //[fNCells] if sell HG or LG |
8d122774 | 69 | Short_t *fCellNumber; //[fNCells] array of cell numbers |
e649177a | 70 | Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!) |
77e93dc2 | 71 | Double32_t *fTime; //[fNCells][0.,0.,16] array with cell times |
72 | Double32_t *fEFraction; //[fNCells][0.,0.,16] array with fraction of MC energy and data - for embedding | |
60d77596 | 73 | Int_t *fMCLabel; //[fNCells] array of MC labels |
8d122774 | 74 | Bool_t fIsSorted; //! true if cell arrays are sorted by index |
75 | Char_t fType; // Cell type | |
76 | ||
cab01f50 | 77 | ClassDef(AliAODCaloCells, 5); |
8d122774 | 78 | |
8d122774 | 79 | }; |
80 | ||
77e93dc2 | 81 | Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, |
60d77596 | 82 | Double_t &time, Int_t & mclabel, Double_t & efrac) const |
8d122774 | 83 | { |
77e93dc2 | 84 | if (pos>=0 && pos<fNCells) |
85 | { | |
8d122774 | 86 | cellNumber = fCellNumber[pos]; |
77e93dc2 | 87 | amplitude = fAmplitude[pos]; |
88 | ||
89 | if(fTime) time = fTime[pos]; | |
90 | else time =-1.; | |
91 | if(fMCLabel) mclabel = fMCLabel[pos]; | |
92 | else mclabel =-1 ; | |
93 | if(fEFraction) efrac = fEFraction[pos]; | |
94 | else efrac = 0 ; | |
95 | ||
8d122774 | 96 | return kTRUE; |
77e93dc2 | 97 | |
8d122774 | 98 | } else { |
8d122774 | 99 | return kFALSE; |
100 | } | |
101 | } | |
102 | ||
8d122774 | 103 | Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber) |
104 | { | |
105 | if (!fIsSorted) { | |
106 | Sort(); | |
107 | fIsSorted=kTRUE; | |
108 | } | |
109 | ||
110 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
37792174 | 111 | if (pos>=0 && fCellNumber[pos] == cellNumber) { |
8d122774 | 112 | return fAmplitude[pos]; |
113 | } else { | |
8d122774 | 114 | return 0.; |
115 | } | |
116 | } | |
dcd7321d | 117 | Bool_t AliAODCaloCells::GetCellHighGain(Short_t cellNumber) |
118 | { | |
119 | if (!fIsSorted) { | |
120 | Sort(); | |
121 | fIsSorted=kTRUE; | |
122 | } | |
123 | ||
124 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
125 | if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) { | |
75f071c1 | 126 | if(fHGLG) |
127 | return fHGLG[pos]; | |
80cadf8a | 128 | else{ |
129 | if(fMCLabel) //old version of AOD, | |
130 | return !(fMCLabel[pos]==-2) ; | |
131 | else | |
132 | return kTRUE ; | |
133 | } | |
dcd7321d | 134 | } else { |
80cadf8a | 135 | return kFALSE; |
dcd7321d | 136 | } |
137 | } | |
8d122774 | 138 | |
77e93dc2 | 139 | Double_t AliAODCaloCells::GetCellTime(Short_t cellNumber) |
140 | { | |
141 | if(!fTime) return -1; | |
142 | ||
143 | if (!fIsSorted) { | |
144 | Sort(); | |
145 | fIsSorted=kTRUE; | |
146 | } | |
147 | ||
148 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
149 | if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) { | |
150 | return fTime[pos]; | |
151 | } else { | |
152 | return -1.; | |
153 | } | |
154 | } | |
8d122774 | 155 | |
156 | Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const | |
157 | { | |
158 | if (pos>=0 && pos<fNCells) { | |
159 | return fAmplitude[pos]; | |
160 | } else { | |
8d122774 | 161 | return 0.; |
162 | } | |
163 | } | |
dcd7321d | 164 | Bool_t AliAODCaloCells::GetHighGain(Short_t pos) const |
165 | { | |
166 | if (pos>=0 && pos<fNCells) { | |
75f071c1 | 167 | if(fHGLG) |
168 | return fHGLG[pos]; | |
80cadf8a | 169 | else{ |
170 | if(fMCLabel) //Old version of AOD store this flag in MCLabel | |
171 | return !(fMCLabel[pos]==-2) ; | |
172 | else | |
173 | return kTRUE ; | |
174 | } | |
dcd7321d | 175 | } else { |
80cadf8a | 176 | return kFALSE; |
dcd7321d | 177 | } |
178 | } | |
179 | ||
8d122774 | 180 | |
77e93dc2 | 181 | Double_t AliAODCaloCells::GetTime(Short_t pos) const |
182 | { | |
183 | if (pos>=0 && pos<fNCells && fTime) { | |
184 | return fTime[pos]; | |
185 | } else { | |
186 | return -1.; | |
187 | } | |
188 | } | |
8d122774 | 189 | |
190 | Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const | |
191 | { | |
192 | if (pos>=0 && pos<fNCells) { | |
193 | return fCellNumber[pos]; | |
194 | } else { | |
8d122774 | 195 | return fNCells; |
196 | } | |
197 | } | |
198 | ||
b4620c80 | 199 | Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber) |
200 | { | |
201 | if (!fIsSorted) { | |
202 | Sort(); | |
203 | fIsSorted=kTRUE; | |
204 | } | |
205 | ||
206 | Int_t nabove, nbelow, middle; | |
207 | Short_t pos = -1; | |
208 | ||
209 | nabove = fNCells + 1; | |
210 | nbelow = 0; | |
211 | while (nabove - nbelow > 1) { | |
212 | middle = (nabove + nbelow) / 2; | |
213 | if (cellNumber == fCellNumber[middle-1]) { | |
214 | pos = middle - 1; | |
215 | break; | |
216 | } | |
217 | if (cellNumber < fCellNumber[middle-1]) nabove = middle; | |
218 | else nbelow = middle; | |
219 | } | |
220 | ||
221 | return pos; | |
222 | } | |
223 | ||
60d77596 | 224 | Int_t AliAODCaloCells::GetMCLabel(Short_t pos) const |
77e93dc2 | 225 | { |
226 | if (pos>=0 && pos<fNCells && fMCLabel) { | |
227 | return fMCLabel[pos]; | |
228 | } else { | |
121a537d | 229 | return 0; |
77e93dc2 | 230 | } |
231 | } | |
232 | ||
233 | Double_t AliAODCaloCells::GetEFraction(Short_t pos) const | |
234 | { | |
235 | if (pos>=0 && pos<fNCells && fEFraction) { | |
236 | return fEFraction[pos]; | |
237 | } else { | |
238 | return 0.; | |
239 | } | |
240 | } | |
241 | ||
60d77596 | 242 | Int_t AliAODCaloCells::GetCellMCLabel(Short_t cellNumber) |
77e93dc2 | 243 | { |
244 | if(!fMCLabel) return -1; | |
245 | ||
246 | if (!fIsSorted) { | |
247 | Sort(); | |
248 | fIsSorted=kTRUE; | |
249 | } | |
250 | ||
251 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
252 | if (pos>=0 && fCellNumber[pos] == cellNumber) { | |
253 | return fMCLabel[pos]; | |
254 | } else { | |
121a537d | 255 | return 0; |
77e93dc2 | 256 | } |
257 | } | |
258 | ||
259 | Double_t AliAODCaloCells::GetCellEFraction(Short_t cellNumber) | |
260 | { | |
261 | if(!fEFraction) return 0; | |
262 | ||
263 | if (!fIsSorted) { | |
264 | Sort(); | |
265 | fIsSorted=kTRUE; | |
266 | } | |
267 | ||
268 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
269 | if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) { | |
270 | return fEFraction[pos]; | |
271 | } else { | |
272 | return -1.; | |
273 | } | |
274 | } | |
275 | ||
276 | void AliAODCaloCells::SetEFraction(Short_t pos, Double32_t efrac) | |
277 | { | |
278 | // Sets the fraction of energy from MC with respect to data at the given position | |
279 | ||
280 | ||
281 | if (pos>=0 && pos < fNCells) | |
282 | { | |
283 | if(!fEFraction) fEFraction = new Double32_t[fNCells]; | |
284 | fEFraction[pos] = efrac; | |
285 | } | |
286 | } | |
287 | ||
288 | void AliAODCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac) | |
289 | { | |
290 | if (!fIsSorted) { | |
291 | Sort(); | |
292 | fIsSorted=kTRUE; | |
293 | } | |
294 | ||
295 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
296 | if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) | |
297 | { | |
298 | if(!fEFraction) fEFraction = new Double32_t[fNCells]; | |
299 | fEFraction[pos] = efrac; | |
300 | } | |
301 | } | |
302 | ||
8d122774 | 303 | |
304 | #endif |