AliRoot Core  ee782a0 (ee782a0)
AliESDCaloCells.h
Go to the documentation of this file.
1 #ifndef ALIESDCALOCELLS_H
2 #define ALIESDCALOCELLS_H
3 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice */
5 
6 //-------------------------------------------------------------------------
19 //-------------------------------------------------------------------------
20 
21 #include <AliVCaloCells.h>
22 #include <TMath.h>
23 
25 {
26  public:
27 
29  AliESDCaloCells(const char* name, const char* title, VCells_t ttype=kUndef);
30  AliESDCaloCells(const AliESDCaloCells & cells);
31  AliESDCaloCells & operator=(const AliESDCaloCells& source);
32  virtual ~AliESDCaloCells();
33 
34  virtual AliVCaloCells * CopyCaloCells(Bool_t all) const;
35  virtual void Copy(TObject &obj) const;
36  void Clear(const Option_t*);
37  void CreateContainer(Short_t nCells);
38  void DeleteContainer();
39  void Sort();
40 
41  Bool_t IsEMCAL() const { return (fType == kEMCALCell); }
42  Bool_t IsPHOS() const { return (fType == kPHOSCell) ; }
43  Char_t GetType() const { return fType ; }
44  void SetType(Char_t t){ fType = t ; }
45 
46  inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time, Int_t &mclabel, Double_t &efrac) const;
47  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);
48 
49  Short_t GetNumberOfCells() const { return fNCells ; }
50  void SetNumberOfCells(Int_t n) { fNCells = n ; }
51 
52 
53  inline Double_t GetCellAmplitude(Short_t cellNumber);
54  inline Bool_t GetCellHighGain(Short_t cellNumber); //is this cell High Gain
55  inline Short_t GetCellPosition(Short_t cellNumber);
56  inline Double_t GetCellTime(Short_t cellNumber);
57 
58  inline Double_t GetAmplitude(Short_t pos) const;
59  inline Bool_t GetHighGain(Short_t pos) const;
60  inline Double_t GetTime(Short_t pos) const;
61  inline Short_t GetCellNumber(Short_t pos) const;
62 
63  // MC & embedding
64  inline Int_t GetCellMCLabel(Short_t cellNumber) ;
65  inline Int_t GetMCLabel(Short_t pos) const ;
66  inline void SetMCLabel(Short_t pos, Int_t val);
67 
68  inline Double_t GetCellEFraction(Short_t cellNumber) ;
69  inline Double_t GetEFraction(Short_t pos) const ;
70 
71  inline void SetEFraction (Short_t pos, Double32_t efrac) ;
72  inline void SetCellEFraction(Short_t cellNumber, Double32_t efrac) ;
73 
74  protected:
75 
76  Int_t fNCells;
77 
79  Bool_t *fHGLG; //[fNCells]
80 
82  Short_t *fCellNumber; //[fNCells]
83 
85  Double32_t *fAmplitude; //[fNCells][0.,0.,16]
86 
88  Double32_t *fTime; //[fNCells][0.,0.,16]
89 
91  Double32_t *fEFraction; //[fNCells][0.,0.,16]
92 
94  Int_t *fMCLabel; //[fNCells]
95 
96  Bool_t fIsSorted;
97 
98  Char_t fType;
99 
101  ClassDef(AliESDCaloCells, 5) ;
103 
104 };
105 
118 Bool_t AliESDCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude,
119  Double_t & time, Int_t & mclabel, Double_t & efrac) const
120 {
121  if (pos>=0 && pos<fNCells)
122  {
123  cellNumber = fCellNumber[pos];
124  amplitude = fAmplitude[pos];
125  time = fTime[pos];
126 
127  if(fMCLabel) mclabel = fMCLabel[pos];
128  else mclabel =-1 ;
129  if(fEFraction) efrac = fEFraction[pos];
130  else efrac = 0 ;
131 
132  return kTRUE;
133 
134  } else
135  {
136  return kFALSE;
137  }
138 }
139 
144 Double_t AliESDCaloCells::GetCellAmplitude(Short_t cellNumber)
145 {
146  if (!fIsSorted) {
147  Sort();
148  fIsSorted=kTRUE;
149  }
150 
151  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
152  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
153  return fAmplitude[pos];
154  } else {
155  return 0.;
156  }
157 }
158 
163 Bool_t AliESDCaloCells::GetCellHighGain(Short_t cellNumber)
164 {
165  if (!fIsSorted) {
166  Sort();
167  fIsSorted=kTRUE;
168  }
169 
170  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
171  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
172  if(fHGLG)
173  return fHGLG[pos];
174  else{
175  if(fMCLabel)//old version of ESD, for data HG flag stored in MCLabel
176  return !(fMCLabel[pos]==-2) ;
177  else
178  return kTRUE ;
179  }
180  } else {
181  return kFALSE;
182  }
183 }
184 
189 Double_t AliESDCaloCells::GetCellTime(Short_t cellNumber)
190 {
191  if (!fIsSorted) {
192  Sort();
193  fIsSorted=kTRUE;
194  }
195 
196  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
197  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
198  return fTime[pos];
199  } else {
200  return -1.;
201  }
202 }
203 
208 Double_t AliESDCaloCells::GetAmplitude(Short_t pos) const
209 {
210  if (pos>=0 && pos<fNCells) {
211  return fAmplitude[pos];
212  } else {
213  return 0.;
214  }
215 }
216 
221 Bool_t AliESDCaloCells::GetHighGain(Short_t pos) const
222 {
223  if (pos>=0 && pos<fNCells) {
224  if(fHGLG)
225  return fHGLG[pos];
226  else{
227  if(fMCLabel)//old version of ESD, for data HG flag stored in MCLabel
228  return !(fMCLabel[pos]==-2) ;
229  else
230  return kTRUE ;
231  }
232  } else {
233  return kFALSE;
234  }
235 }
236 
241 Double_t AliESDCaloCells::GetTime(Short_t pos) const
242 {
243  if (pos>=0 && pos<fNCells) {
244  return fTime[pos];
245  } else {
246  return -1.;
247  }
248 }
249 
254 Short_t AliESDCaloCells::GetCellNumber(Short_t pos) const
255 {
256  if (pos>=0 && pos<fNCells) {
257  return fCellNumber[pos];
258  } else {
259  return fNCells;
260  }
261 }
262 
267 Short_t AliESDCaloCells::GetCellPosition(Short_t cellNumber)
268 {
269  if (!fIsSorted) {
270  Sort();
271  fIsSorted=kTRUE;
272  }
273 
274  Int_t nabove, nbelow, middle;
275  Short_t pos = -1;
276 
277  nabove = fNCells + 1;
278  nbelow = 0;
279  while (nabove - nbelow > 1) {
280  middle = (nabove + nbelow) / 2;
281  if (cellNumber == fCellNumber[middle-1]) {
282  pos = middle - 1;
283  break;
284  }
285  if (cellNumber < fCellNumber[middle-1]) nabove = middle;
286  else nbelow = middle;
287  }
288 
289  return pos;
290 }
291 
296 Int_t AliESDCaloCells::GetMCLabel(Short_t pos) const
297 {
298  if (pos>=0 && pos<fNCells && fMCLabel) {
299  return fMCLabel[pos];
300  } else {
301  return -1 ;
302  }
303 }
304 
305 void AliESDCaloCells::SetMCLabel(Short_t pos, Int_t val)
306 {
307  if (pos>=0 && pos<fNCells && fMCLabel) {
308  fMCLabel[pos] = val;
309  }
310 }
311 
316 Double_t AliESDCaloCells::GetEFraction(Short_t pos) const
317 {
318  if (pos>=0 && pos<fNCells && fEFraction) {
319  return fEFraction[pos];
320  } else {
321  return 0.;
322  }
323 }
324 
329 Int_t AliESDCaloCells::GetCellMCLabel(Short_t cellNumber)
330 {
331  if (!fIsSorted) {
332  Sort();
333  fIsSorted=kTRUE;
334  }
335 
336  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
337  if (pos>=0 && fCellNumber[pos] == cellNumber && fMCLabel) {
338  return fMCLabel[pos];
339  } else {
340  return -1;
341  }
342 }
343 
348 Double_t AliESDCaloCells::GetCellEFraction(Short_t cellNumber)
349 {
350  if (!fIsSorted) {
351  Sort();
352  fIsSorted=kTRUE;
353  }
354 
355  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
356  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber && fEFraction) {
357  return fEFraction[pos];
358  } else {
359  return 0.;
360  }
361 }
362 
368 void AliESDCaloCells::SetEFraction(Short_t pos, Double32_t efrac)
369 {
370  if (pos>=0 && pos < fNCells)
371  {
372  if(!fEFraction) fEFraction = new Double32_t[fNCells];
373  fEFraction[pos] = efrac;
374  }
375 }
376 
382 void AliESDCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac)
383 {
384  if (!fIsSorted) {
385  Sort();
386  fIsSorted=kTRUE;
387  }
388 
389  Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
390  if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber)
391  {
392  if(!fEFraction) fEFraction = new Double32_t[fNCells];
393  fEFraction[pos] = efrac;
394  }
395 }
396 
397 
398 #endif
void Clear(const Option_t *)
void SetEFraction(Short_t pos, Double32_t efrac)
Double32_t * fAmplitude
Array with cell amplitudes (= energy!).
virtual AliVCaloCells * CopyCaloCells(Bool_t all) const
Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time, Int_t &mclabel, Double_t &efrac) const
Char_t fType
Cell type.
Bool_t fIsSorted
! True if cell arrays are sorted by index.
Bool_t IsEMCAL() const
Char_t GetType() const
Virtual class for calorimeter cell data handling.
Definition: AliVCaloCells.h:19
Double32_t * fTime
Array with cell times.
AliESDCaloCells & operator=(const AliESDCaloCells &source)
void SetCellEFraction(Short_t cellNumber, Double32_t efrac)
Int_t fNCells
Number of cells.
void CreateContainer(Short_t nCells)
Short_t * fCellNumber
Array of cell absolute Id. numbers.
Bool_t GetCellHighGain(Short_t cellNumber)
virtual void Copy(TObject &obj) const
Int_t GetCellMCLabel(Short_t cellNumber)
Bool_t IsPHOS() const
void SetMCLabel(Short_t pos, Int_t val)
Double_t GetCellAmplitude(Short_t cellNumber)
Short_t GetCellNumber(Short_t pos) const
Double32_t * fEFraction
Array with fraction of MC energy and data - for embedding.
Double_t GetEFraction(Short_t pos) const
Bool_t * fHGLG
If Cell is High Gain or Low Gain.
Int_t * fMCLabel
Array of MC labels, each label is the highest contributor to the cell signal.
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)
Short_t GetNumberOfCells() const
Int_t GetMCLabel(Short_t pos) const
Double_t GetCellEFraction(Short_t cellNumber)
Double_t GetTime(Short_t pos) const
Class for calorimeter cell ESD data handling.
Bool_t GetHighGain(Short_t pos) const
virtual ~AliESDCaloCells()
void SetType(Char_t t)
Short_t GetCellPosition(Short_t cellNumber)
Double_t GetAmplitude(Short_t pos) const
void SetNumberOfCells(Int_t n)
Double_t GetCellTime(Short_t cellNumber)