]>
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 ; |
34 | Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time, Int_t mclabel = -1, Double_t efrac = 0.) ; | |
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); |
b4620c80 | 40 | inline Short_t GetCellPosition(Short_t cellNumber); |
77e93dc2 | 41 | inline Double_t GetCellTime(Short_t cellNumber); |
42 | ||
8d122774 | 43 | inline Double_t GetAmplitude(Short_t pos) const; |
44 | inline Short_t GetCellNumber(Short_t pos) const; | |
77e93dc2 | 45 | inline Double_t GetTime(Short_t pos) const; |
46 | ||
47 | Bool_t IsEMCAL() const { return (fType == kEMCALCell); } | |
48 | Bool_t IsPHOS() const { return (fType == kPHOSCell) ; } | |
49 | ||
50 | Char_t GetType() const { return fType;} | |
51 | void SetType(Char_t ttype) { fType=ttype; } | |
52 | ||
53 | // MC & embedding | |
60d77596 | 54 | inline Int_t GetCellMCLabel(Short_t cellNumber) ; |
55 | inline Int_t GetMCLabel(Short_t pos) const ; | |
77e93dc2 | 56 | |
57 | inline Double_t GetCellEFraction(Short_t cellNumber) ; | |
58 | inline Double_t GetEFraction(Short_t pos) const ; | |
59 | ||
60 | inline void SetEFraction (Short_t pos, Double32_t efrac) ; | |
61 | inline void SetCellEFraction(Short_t cellNumber, Double32_t efrac) ; | |
62 | ||
8d122774 | 63 | protected: |
77e93dc2 | 64 | |
8d122774 | 65 | Int_t fNCells; // Number of cells |
66 | Short_t *fCellNumber; //[fNCells] array of cell numbers | |
e649177a | 67 | Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!) |
77e93dc2 | 68 | Double32_t *fTime; //[fNCells][0.,0.,16] array with cell times |
69 | Double32_t *fEFraction; //[fNCells][0.,0.,16] array with fraction of MC energy and data - for embedding | |
60d77596 | 70 | Int_t *fMCLabel; //[fNCells] array of MC labels |
8d122774 | 71 | Bool_t fIsSorted; //! true if cell arrays are sorted by index |
72 | Char_t fType; // Cell type | |
73 | ||
60d77596 | 74 | ClassDef(AliAODCaloCells, 4); |
8d122774 | 75 | |
8d122774 | 76 | }; |
77 | ||
77e93dc2 | 78 | Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, |
60d77596 | 79 | Double_t &time, Int_t & mclabel, Double_t & efrac) const |
8d122774 | 80 | { |
77e93dc2 | 81 | if (pos>=0 && pos<fNCells) |
82 | { | |
8d122774 | 83 | cellNumber = fCellNumber[pos]; |
77e93dc2 | 84 | amplitude = fAmplitude[pos]; |
85 | ||
86 | if(fTime) time = fTime[pos]; | |
87 | else time =-1.; | |
88 | if(fMCLabel) mclabel = fMCLabel[pos]; | |
89 | else mclabel =-1 ; | |
90 | if(fEFraction) efrac = fEFraction[pos]; | |
91 | else efrac = 0 ; | |
92 | ||
8d122774 | 93 | return kTRUE; |
77e93dc2 | 94 | |
8d122774 | 95 | } else { |
8d122774 | 96 | return kFALSE; |
97 | } | |
98 | } | |
99 | ||
8d122774 | 100 | Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber) |
101 | { | |
102 | if (!fIsSorted) { | |
103 | Sort(); | |
104 | fIsSorted=kTRUE; | |
105 | } | |
106 | ||
107 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
37792174 | 108 | if (pos>=0 && fCellNumber[pos] == cellNumber) { |
8d122774 | 109 | return fAmplitude[pos]; |
110 | } else { | |
8d122774 | 111 | return 0.; |
112 | } | |
113 | } | |
114 | ||
77e93dc2 | 115 | Double_t AliAODCaloCells::GetCellTime(Short_t cellNumber) |
116 | { | |
117 | if(!fTime) return -1; | |
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) { | |
126 | return fTime[pos]; | |
127 | } else { | |
128 | return -1.; | |
129 | } | |
130 | } | |
8d122774 | 131 | |
132 | Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const | |
133 | { | |
134 | if (pos>=0 && pos<fNCells) { | |
135 | return fAmplitude[pos]; | |
136 | } else { | |
8d122774 | 137 | return 0.; |
138 | } | |
139 | } | |
140 | ||
77e93dc2 | 141 | Double_t AliAODCaloCells::GetTime(Short_t pos) const |
142 | { | |
143 | if (pos>=0 && pos<fNCells && fTime) { | |
144 | return fTime[pos]; | |
145 | } else { | |
146 | return -1.; | |
147 | } | |
148 | } | |
8d122774 | 149 | |
150 | Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const | |
151 | { | |
152 | if (pos>=0 && pos<fNCells) { | |
153 | return fCellNumber[pos]; | |
154 | } else { | |
8d122774 | 155 | return fNCells; |
156 | } | |
157 | } | |
158 | ||
b4620c80 | 159 | Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber) |
160 | { | |
161 | if (!fIsSorted) { | |
162 | Sort(); | |
163 | fIsSorted=kTRUE; | |
164 | } | |
165 | ||
166 | Int_t nabove, nbelow, middle; | |
167 | Short_t pos = -1; | |
168 | ||
169 | nabove = fNCells + 1; | |
170 | nbelow = 0; | |
171 | while (nabove - nbelow > 1) { | |
172 | middle = (nabove + nbelow) / 2; | |
173 | if (cellNumber == fCellNumber[middle-1]) { | |
174 | pos = middle - 1; | |
175 | break; | |
176 | } | |
177 | if (cellNumber < fCellNumber[middle-1]) nabove = middle; | |
178 | else nbelow = middle; | |
179 | } | |
180 | ||
181 | return pos; | |
182 | } | |
183 | ||
60d77596 | 184 | Int_t AliAODCaloCells::GetMCLabel(Short_t pos) const |
77e93dc2 | 185 | { |
186 | if (pos>=0 && pos<fNCells && fMCLabel) { | |
187 | return fMCLabel[pos]; | |
188 | } else { | |
121a537d | 189 | return 0; |
77e93dc2 | 190 | } |
191 | } | |
192 | ||
193 | Double_t AliAODCaloCells::GetEFraction(Short_t pos) const | |
194 | { | |
195 | if (pos>=0 && pos<fNCells && fEFraction) { | |
196 | return fEFraction[pos]; | |
197 | } else { | |
198 | return 0.; | |
199 | } | |
200 | } | |
201 | ||
60d77596 | 202 | Int_t AliAODCaloCells::GetCellMCLabel(Short_t cellNumber) |
77e93dc2 | 203 | { |
204 | if(!fMCLabel) return -1; | |
205 | ||
206 | if (!fIsSorted) { | |
207 | Sort(); | |
208 | fIsSorted=kTRUE; | |
209 | } | |
210 | ||
211 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
212 | if (pos>=0 && fCellNumber[pos] == cellNumber) { | |
213 | return fMCLabel[pos]; | |
214 | } else { | |
121a537d | 215 | return 0; |
77e93dc2 | 216 | } |
217 | } | |
218 | ||
219 | Double_t AliAODCaloCells::GetCellEFraction(Short_t cellNumber) | |
220 | { | |
221 | if(!fEFraction) return 0; | |
222 | ||
223 | if (!fIsSorted) { | |
224 | Sort(); | |
225 | fIsSorted=kTRUE; | |
226 | } | |
227 | ||
228 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
229 | if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) { | |
230 | return fEFraction[pos]; | |
231 | } else { | |
232 | return -1.; | |
233 | } | |
234 | } | |
235 | ||
236 | void AliAODCaloCells::SetEFraction(Short_t pos, Double32_t efrac) | |
237 | { | |
238 | // Sets the fraction of energy from MC with respect to data at the given position | |
239 | ||
240 | ||
241 | if (pos>=0 && pos < fNCells) | |
242 | { | |
243 | if(!fEFraction) fEFraction = new Double32_t[fNCells]; | |
244 | fEFraction[pos] = efrac; | |
245 | } | |
246 | } | |
247 | ||
248 | void AliAODCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac) | |
249 | { | |
250 | if (!fIsSorted) { | |
251 | Sort(); | |
252 | fIsSorted=kTRUE; | |
253 | } | |
254 | ||
255 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
256 | if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) | |
257 | { | |
258 | if(!fEFraction) fEFraction = new Double32_t[fNCells]; | |
259 | fEFraction[pos] = efrac; | |
260 | } | |
261 | } | |
262 | ||
8d122774 | 263 | |
264 | #endif |