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.) ;
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 Short_t GetCellPosition(Short_t cellNumber);
41 inline Double_t GetCellTime(Short_t cellNumber);
43 inline Double_t GetAmplitude(Short_t pos) const;
44 inline Short_t GetCellNumber(Short_t pos) const;
45 inline Double_t GetTime(Short_t pos) const;
47 Bool_t IsEMCAL() const { return (fType == kEMCALCell); }
48 Bool_t IsPHOS() const { return (fType == kPHOSCell) ; }
50 Char_t GetType() const { return fType;}
51 void SetType(Char_t ttype) { fType=ttype; }
54 inline Int_t GetCellMCLabel(Short_t cellNumber) ;
55 inline Int_t GetMCLabel(Short_t pos) const ;
57 inline Double_t GetCellEFraction(Short_t cellNumber) ;
58 inline Double_t GetEFraction(Short_t pos) const ;
60 inline void SetEFraction (Short_t pos, Double32_t efrac) ;
61 inline void SetCellEFraction(Short_t cellNumber, Double32_t efrac) ;
65 Int_t fNCells; // Number of cells
66 Short_t *fCellNumber; //[fNCells] array of cell numbers
67 Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
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
70 Int_t *fMCLabel; //[fNCells] array of MC labels
71 Bool_t fIsSorted; //! true if cell arrays are sorted by index
72 Char_t fType; // Cell type
74 ClassDef(AliAODCaloCells, 4);
78 Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude,
79 Double_t &time, Int_t & mclabel, Double_t & efrac) const
81 if (pos>=0 && pos<fNCells)
83 cellNumber = fCellNumber[pos];
84 amplitude = fAmplitude[pos];
86 if(fTime) time = fTime[pos];
88 if(fMCLabel) mclabel = fMCLabel[pos];
90 if(fEFraction) efrac = fEFraction[pos];
100 Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber)
107 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
108 if (pos>=0 && fCellNumber[pos] == cellNumber) {
109 return fAmplitude[pos];
115 Double_t AliAODCaloCells::GetCellTime(Short_t cellNumber)
117 if(!fTime) return -1;
124 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
125 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
132 Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const
134 if (pos>=0 && pos<fNCells) {
135 return fAmplitude[pos];
141 Double_t AliAODCaloCells::GetTime(Short_t pos) const
143 if (pos>=0 && pos<fNCells && fTime) {
150 Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const
152 if (pos>=0 && pos<fNCells) {
153 return fCellNumber[pos];
159 Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber)
166 Int_t nabove, nbelow, middle;
169 nabove = fNCells + 1;
171 while (nabove - nbelow > 1) {
172 middle = (nabove + nbelow) / 2;
173 if (cellNumber == fCellNumber[middle-1]) {
177 if (cellNumber < fCellNumber[middle-1]) nabove = middle;
178 else nbelow = middle;
184 Int_t AliAODCaloCells::GetMCLabel(Short_t pos) const
186 if (pos>=0 && pos<fNCells && fMCLabel) {
187 return fMCLabel[pos];
193 Double_t AliAODCaloCells::GetEFraction(Short_t pos) const
195 if (pos>=0 && pos<fNCells && fEFraction) {
196 return fEFraction[pos];
202 Int_t AliAODCaloCells::GetCellMCLabel(Short_t cellNumber)
204 if(!fMCLabel) return -1;
211 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
212 if (pos>=0 && fCellNumber[pos] == cellNumber) {
213 return fMCLabel[pos];
219 Double_t AliAODCaloCells::GetCellEFraction(Short_t cellNumber)
221 if(!fEFraction) return 0;
228 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
229 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
230 return fEFraction[pos];
236 void AliAODCaloCells::SetEFraction(Short_t pos, Double32_t efrac)
238 // Sets the fraction of energy from MC with respect to data at the given position
241 if (pos>=0 && pos < fNCells)
243 if(!fEFraction) fEFraction = new Double32_t[fNCells];
244 fEFraction[pos] = efrac;
248 void AliAODCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac)
255 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
256 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber)
258 if(!fEFraction) fEFraction = new Double32_t[fNCells];
259 fEFraction[pos] = efrac;