1 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
2 * See cxx source for full Copyright notice */
6 //-------------------------------------------------------------------------
7 // AOD class to store calorimeter cell data
8 // Author: Markus Oldenburg, CERN
9 //-------------------------------------------------------------------------
14 #include <AliVCaloCells.h>
17 class AliAODCaloCells : public AliVCaloCells
21 AliAODCaloCells(const char* name, const char* title, VCells_t ttype=kUndef);
22 AliAODCaloCells(const AliAODCaloCells& cells);
23 AliAODCaloCells& operator=(const AliAODCaloCells& cells);
24 virtual ~AliAODCaloCells();
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();
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., Bool_t isHG=kFALSE);
36 Short_t GetNumberOfCells() const { return fNCells ; }
37 void SetNumberOfCells(Int_t n) { fNCells = n ; }
39 inline Double_t GetCellAmplitude(Short_t cellNumber);
40 inline Bool_t GetCellHighGain(Short_t cellNumber); //is this cell High Gain
41 inline Short_t GetCellPosition(Short_t cellNumber);
42 inline Double_t GetCellTime(Short_t cellNumber);
44 inline Double_t GetAmplitude(Short_t pos) const;
45 inline Bool_t GetHighGain(Short_t pos) const;
46 inline Short_t GetCellNumber(Short_t pos) const;
47 inline Double_t GetTime(Short_t pos) const;
49 Bool_t IsEMCAL() const { return (fType == kEMCALCell); }
50 Bool_t IsPHOS() const { return (fType == kPHOSCell) ; }
52 Char_t GetType() const { return fType;}
53 void SetType(Char_t ttype) { fType=ttype; }
56 inline Int_t GetCellMCLabel(Short_t cellNumber) ;
57 inline Int_t GetMCLabel(Short_t pos) const ;
59 inline Double_t GetCellEFraction(Short_t cellNumber) ;
60 inline Double_t GetEFraction(Short_t pos) const ;
62 inline void SetEFraction (Short_t pos, Double32_t efrac) ;
63 inline void SetCellEFraction(Short_t cellNumber, Double32_t efrac) ;
67 Int_t fNCells; // Number of cells
68 Bool_t *fHGLG; //[fNCells] if sell HG or LG
69 Short_t *fCellNumber; //[fNCells] array of cell numbers
70 Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
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
73 Int_t *fMCLabel; //[fNCells] array of MC labels
74 Bool_t fIsSorted; //! true if cell arrays are sorted by index
75 Char_t fType; // Cell type
77 ClassDef(AliAODCaloCells, 5);
81 Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude,
82 Double_t &time, Int_t & mclabel, Double_t & efrac) const
84 if (pos>=0 && pos<fNCells)
86 cellNumber = fCellNumber[pos];
87 amplitude = fAmplitude[pos];
89 if(fTime) time = fTime[pos];
91 if(fMCLabel) mclabel = fMCLabel[pos];
93 if(fEFraction) efrac = fEFraction[pos];
103 Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber)
110 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
111 if (pos>=0 && fCellNumber[pos] == cellNumber) {
112 return fAmplitude[pos];
117 Bool_t AliAODCaloCells::GetCellHighGain(Short_t cellNumber)
124 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
125 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
129 if(fMCLabel) //old version of AOD,
130 return !(fMCLabel[pos]==-2) ;
139 Double_t AliAODCaloCells::GetCellTime(Short_t cellNumber)
141 if(!fTime) return -1;
148 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
149 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
156 Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const
158 if (pos>=0 && pos<fNCells) {
159 return fAmplitude[pos];
164 Bool_t AliAODCaloCells::GetHighGain(Short_t pos) const
166 if (pos>=0 && pos<fNCells) {
170 if(fMCLabel) //Old version of AOD store this flag in MCLabel
171 return !(fMCLabel[pos]==-2) ;
181 Double_t AliAODCaloCells::GetTime(Short_t pos) const
183 if (pos>=0 && pos<fNCells && fTime) {
190 Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const
192 if (pos>=0 && pos<fNCells) {
193 return fCellNumber[pos];
199 Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber)
206 Int_t nabove, nbelow, middle;
209 nabove = fNCells + 1;
211 while (nabove - nbelow > 1) {
212 middle = (nabove + nbelow) / 2;
213 if (cellNumber == fCellNumber[middle-1]) {
217 if (cellNumber < fCellNumber[middle-1]) nabove = middle;
218 else nbelow = middle;
224 Int_t AliAODCaloCells::GetMCLabel(Short_t pos) const
226 if (pos>=0 && pos<fNCells && fMCLabel) {
227 return fMCLabel[pos];
233 Double_t AliAODCaloCells::GetEFraction(Short_t pos) const
235 if (pos>=0 && pos<fNCells && fEFraction) {
236 return fEFraction[pos];
242 Int_t AliAODCaloCells::GetCellMCLabel(Short_t cellNumber)
244 if(!fMCLabel) return -1;
251 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
252 if (pos>=0 && fCellNumber[pos] == cellNumber) {
253 return fMCLabel[pos];
259 Double_t AliAODCaloCells::GetCellEFraction(Short_t cellNumber)
261 if(!fEFraction) return 0;
268 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
269 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
270 return fEFraction[pos];
276 void AliAODCaloCells::SetEFraction(Short_t pos, Double32_t efrac)
278 // Sets the fraction of energy from MC with respect to data at the given position
281 if (pos>=0 && pos < fNCells)
283 if(!fEFraction) fEFraction = new Double32_t[fNCells];
284 fEFraction[pos] = efrac;
288 void AliAODCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac)
295 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
296 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber)
298 if(!fEFraction) fEFraction = new Double32_t[fNCells];
299 fEFraction[pos] = efrac;