AliRoot Core  edcc906 (edcc906)
AliAODCaloCells.h
Go to the documentation of this file.
1 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
2  * See cxx source for full Copyright notice */
3 
4 
5 //-------------------------------------------------------------------------
18 //-------------------------------------------------------------------------
19 
20 #ifndef ALIAODCELLS_H
21 #define ALIAODCELLS_H
22 
23 #include <AliVCaloCells.h>
24 #include <TMath.h>
25 
27 {
28  public:
30  AliAODCaloCells(const char* name, const char* title, VCells_t ttype=kUndef);
31  AliAODCaloCells(const AliAODCaloCells& cells);
33  virtual ~AliAODCaloCells();
34 
35  virtual AliVCaloCells* CopyCaloCells(Bool_t all) const;
36  virtual void Copy(TObject &obj) const;
37  void Clear(const Option_t*);
38  void CreateContainer(Short_t nCells);
39  void DeleteContainer();
40  void Sort();
41 
42  inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time, Int_t &mclabel, Double_t &efrac) const ;
43  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);
44 
45  Short_t GetNumberOfCells() const { return fNCells ; }
46  void SetNumberOfCells(Int_t n) { fNCells = n ; }
47 
48  inline Double_t GetCellAmplitude(Short_t cellNumber);
49  inline Bool_t GetCellHighGain(Short_t cellNumber); //is this cell High Gain
50  inline Short_t GetCellPosition(Short_t cellNumber);
51  inline Double_t GetCellTime(Short_t cellNumber);
52 
53  inline Double_t GetAmplitude(Short_t pos) const;
54  inline Bool_t GetHighGain(Short_t pos) const;
55  inline Short_t GetCellNumber(Short_t pos) const;
56  inline Double_t GetTime(Short_t pos) const;
57 
58  Bool_t IsEMCAL() const { return (fType == kEMCALCell); }
59  Bool_t IsPHOS() const { return (fType == kPHOSCell) ; }
60 
61  Char_t GetType() const { return fType;}
62  void SetType(Char_t ttype) { fType=ttype; }
63 
64  // MC & embedding
65  inline Int_t GetCellMCLabel(Short_t cellNumber) ;
66  inline Int_t GetMCLabel(Short_t pos) const ;
67  inline void SetMCLabel(Short_t pos, Int_t val);
68 
69  inline Double_t GetCellEFraction(Short_t cellNumber) ;
70  inline Double_t GetEFraction(Short_t pos) const ;
71 
72  inline void SetEFraction (Short_t pos, Double32_t efrac) ;
73  inline void SetCellEFraction(Short_t cellNumber, Double32_t efrac) ;
74 
75  protected:
76 
77  Int_t fNCells;
78 
80  Bool_t *fHGLG; //[fNCells]
81 
83  Short_t *fCellNumber; //[fNCells]
84 
86  Double32_t *fAmplitude; //[fNCells][0.,0.,16]
87 
89  Double32_t *fTime; //[fNCells][0.,0.,16]
90 
92  Double32_t *fEFraction; //[fNCells][0.,0.,16]
93 
95  Int_t *fMCLabel; //[fNCells]
96 
97  Bool_t fIsSorted;
98 
99  Char_t fType;
100 
102  ClassDef(AliAODCaloCells, 5) ;
104 
105 };
106 
119 Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude,
120  Double_t &time, Int_t & mclabel, Double_t & efrac) const
121 {
122  if (pos>=0 && pos<fNCells)
123  {
124  cellNumber = fCellNumber[pos];
125  amplitude = fAmplitude[pos];
126 
127  if(fTime) time = fTime[pos];
128  else time =-1.;
129  if(fMCLabel) mclabel = fMCLabel[pos];
130  else mclabel =-1 ;
131  if(fEFraction) efrac = fEFraction[pos];
132  else efrac = 0 ;
133 
134  return kTRUE;
135 
136  } else {
137  return kFALSE;
138  }
139 }
140 
145 Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber)
146 {
147  if (!fIsSorted) {
148  Sort();
149  fIsSorted=kTRUE;
150  }
151 
152  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
153  if (pos>=0 && fCellNumber[pos] == cellNumber) {
154  return fAmplitude[pos];
155  } else {
156  return 0.;
157  }
158 }
159 
164 Bool_t AliAODCaloCells::GetCellHighGain(Short_t cellNumber)
165 {
166  if (!fIsSorted) {
167  Sort();
168  fIsSorted=kTRUE;
169  }
170 
171  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
172  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
173  if(fHGLG)
174  return fHGLG[pos];
175  else{
176  if(fMCLabel) //old version of AOD,
177  return !(fMCLabel[pos]==-2) ;
178  else
179  return kTRUE ;
180  }
181  } else {
182  return kFALSE;
183  }
184 }
185 
190 Double_t AliAODCaloCells::GetCellTime(Short_t cellNumber)
191 {
192  if(!fTime) return -1;
193 
194  if (!fIsSorted) {
195  Sort();
196  fIsSorted=kTRUE;
197  }
198 
199  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
200  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
201  return fTime[pos];
202  } else {
203  return -1.;
204  }
205 }
206 
211 Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const
212 {
213  if (pos>=0 && pos<fNCells) {
214  return fAmplitude[pos];
215  } else {
216  return 0.;
217  }
218 }
219 
224 Bool_t AliAODCaloCells::GetHighGain(Short_t pos) const
225 {
226  if (pos>=0 && pos<fNCells) {
227  if(fHGLG)
228  return fHGLG[pos];
229  else{
230  if(fMCLabel) //Old version of AOD store this flag in MCLabel
231  return !(fMCLabel[pos]==-2) ;
232  else
233  return kTRUE ;
234  }
235  } else {
236  return kFALSE;
237  }
238 }
239 
244 Double_t AliAODCaloCells::GetTime(Short_t pos) const
245 {
246  if (pos>=0 && pos<fNCells && fTime) {
247  return fTime[pos];
248  } else {
249  return -1.;
250  }
251 }
252 
257 Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const
258 {
259  if (pos>=0 && pos<fNCells) {
260  return fCellNumber[pos];
261  } else {
262  return fNCells;
263  }
264 }
265 
270 Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber)
271 {
272  if (!fIsSorted) {
273  Sort();
274  fIsSorted=kTRUE;
275  }
276 
277  Int_t nabove, nbelow, middle;
278  Short_t pos = -1;
279 
280  nabove = fNCells + 1;
281  nbelow = 0;
282  while (nabove - nbelow > 1) {
283  middle = (nabove + nbelow) / 2;
284  if (cellNumber == fCellNumber[middle-1]) {
285  pos = middle - 1;
286  break;
287  }
288  if (cellNumber < fCellNumber[middle-1]) nabove = middle;
289  else nbelow = middle;
290  }
291 
292  return pos;
293 }
294 
299 Int_t AliAODCaloCells::GetMCLabel(Short_t pos) const
300 {
301  if (pos>=0 && pos<fNCells && fMCLabel) {
302  return fMCLabel[pos];
303  } else {
304  return 0;
305  }
306 }
307 
308 void AliAODCaloCells::SetMCLabel(Short_t pos, Int_t val)
309 {
310  if (pos>=0 && pos<fNCells && fMCLabel) {
311  fMCLabel[pos] = val;
312  }
313 }
314 
319 Double_t AliAODCaloCells::GetEFraction(Short_t pos) const
320 {
321  if (pos>=0 && pos<fNCells && fEFraction) {
322  return fEFraction[pos];
323  } else {
324  return 0.;
325  }
326 }
327 
332 Int_t AliAODCaloCells::GetCellMCLabel(Short_t cellNumber)
333 {
334  if(!fMCLabel) return -1;
335 
336  if (!fIsSorted) {
337  Sort();
338  fIsSorted=kTRUE;
339  }
340 
341  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
342  if (pos>=0 && fCellNumber[pos] == cellNumber) {
343  return fMCLabel[pos];
344  } else {
345  return 0;
346  }
347 }
348 
353 Double_t AliAODCaloCells::GetCellEFraction(Short_t cellNumber)
354 {
355  if(!fEFraction) return 0;
356 
357  if (!fIsSorted) {
358  Sort();
359  fIsSorted=kTRUE;
360  }
361 
362  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
363  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
364  return fEFraction[pos];
365  } else {
366  return -1.;
367  }
368 }
369 
375 void AliAODCaloCells::SetEFraction(Short_t pos, Double32_t efrac)
376 {
377  if (pos>=0 && pos < fNCells)
378  {
379  if(!fEFraction) fEFraction = new Double32_t[fNCells];
380  fEFraction[pos] = efrac;
381  }
382 }
383 
389 void AliAODCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac)
390 {
391  if (!fIsSorted) {
392  Sort();
393  fIsSorted=kTRUE;
394  }
395 
396  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
397  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber)
398  {
399  if(!fEFraction) fEFraction = new Double32_t[fNCells];
400  fEFraction[pos] = efrac;
401  }
402 }
403 
404 
405 #endif
Bool_t GetHighGain(Short_t pos) const
Double32_t * fTime
Array with cell times.
Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time, Int_t &mclabel, Double_t &efrac) const
void SetType(Char_t ttype)
Double_t GetAmplitude(Short_t pos) const
Class for calorimeter cell AOD data handling.
Double32_t * fEFraction
Array with fraction of MC energy and data - for embedding.
Virtual class for calorimeter cell data handling.
Definition: AliVCaloCells.h:19
AliAODCaloCells & operator=(const AliAODCaloCells &cells)
Int_t fNCells
Number of cells.
Double_t GetTime(Short_t pos) const
void SetCellEFraction(Short_t cellNumber, Double32_t efrac)
Int_t GetMCLabel(Short_t pos) const
Short_t GetCellNumber(Short_t pos) const
Int_t * fMCLabel
Array of MC labels, each label is the highest contributor to the cell signal.
virtual void Copy(TObject &obj) const
void SetMCLabel(Short_t pos, Int_t val)
Short_t GetCellPosition(Short_t cellNumber)
Double_t GetCellEFraction(Short_t cellNumber)
Double_t GetCellAmplitude(Short_t cellNumber)
void CreateContainer(Short_t nCells)
Double_t GetEFraction(Short_t pos) const
Double_t GetCellTime(Short_t cellNumber)
Bool_t IsEMCAL() const
void SetEFraction(Short_t pos, Double32_t efrac)
void Clear(const Option_t *)
Short_t * fCellNumber
Array of cell absolute Id. numbers.
Short_t GetNumberOfCells() const
Bool_t GetCellHighGain(Short_t cellNumber)
virtual AliVCaloCells * CopyCaloCells(Bool_t all) const
Bool_t * fHGLG
If Cell is High Gain or Low Gain.
Char_t fType
Cell type.
Double32_t * fAmplitude
Array with cell amplitudes (= energy!).
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)
Bool_t IsPHOS() const
Int_t GetCellMCLabel(Short_t cellNumber)
void SetNumberOfCells(Int_t n)
Char_t GetType() const
virtual ~AliAODCaloCells()
Bool_t fIsSorted
! True if cell arrays are sorted by index.