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 void Copy(TObject &obj) const;
25 virtual AliVCaloCells* CopyCaloCells(Bool_t all) const;
27 virtual ~AliAODCaloCells();
29 void CreateContainer(Short_t nCells);
30 void DeleteContainer();
33 Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time = -1);
35 Short_t GetNumberOfCells() const { return fNCells; }
36 void SetNumberOfCells(Int_t n) { fNCells = n ; }
37 inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, Double_t &time) const;
38 inline Double_t GetCellAmplitude(Short_t cellNumber);
39 inline Short_t GetCellPosition(Short_t cellNumber);
40 inline Double_t GetAmplitude(Short_t pos) const;
41 Double_t GetCellTime(Short_t /*cellNumber*/) {return -1;}
42 inline Short_t GetCellNumber(Short_t pos) const;
43 Double_t GetTime(Short_t /*pos*/) const {return -1;}
44 Bool_t IsEMCAL() const {return (fType == kEMCALCell);}
45 Bool_t IsPHOS() const {return (fType == kPHOSCell);}
46 Char_t GetType() const { return fType;}
47 void SetType(Char_t ttype) { fType=ttype; }
51 Int_t fNCells; // Number of cells
52 Short_t *fCellNumber; //[fNCells] array of cell numbers
53 Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
54 Bool_t fIsSorted; //! true if cell arrays are sorted by index
55 Char_t fType; // Cell type
58 ClassDef(AliAODCaloCells, 2);
62 Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, Double_t& /*time*/) const
64 if (pos>=0 && pos<fNCells) {
65 cellNumber = fCellNumber[pos];
66 amplitude = fAmplitude[pos];
69 Warning("GetCell","Invalid cell array index %d", pos);
75 Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber)
82 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
83 if (pos>=0 && fCellNumber[pos] == cellNumber) {
84 return fAmplitude[pos];
91 Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const
93 if (pos>=0 && pos<fNCells) {
94 return fAmplitude[pos];
96 Warning("GetAmplitude","Invalid cell array index %d", pos);
102 Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const
104 if (pos>=0 && pos<fNCells) {
105 return fCellNumber[pos];
107 Warning("GetCellNumber","Invalid cell array index %d", pos);
112 Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber)
119 Int_t nabove, nbelow, middle;
122 nabove = fNCells + 1;
124 while (nabove - nbelow > 1) {
125 middle = (nabove + nbelow) / 2;
126 if (cellNumber == fCellNumber[middle-1]) {
130 if (cellNumber < fCellNumber[middle-1]) nabove = middle;
131 else nbelow = middle;