]>
Commit | Line | Data |
---|---|---|
8d122774 | 1 | /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * |
2 | * See cxx source for full Copyright notice */ | |
3 | ||
4 | /* $Id$ */ | |
5 | ||
6 | //------------------------------------------------------------------------- | |
7 | // AOD class to store calorimeter cell data | |
8 | // Author: Markus Oldenburg, CERN | |
9 | //------------------------------------------------------------------------- | |
10 | ||
11 | #ifndef ALIAODCELLS_H | |
12 | #define ALIAODCELLS_H | |
13 | ||
c8fe2783 | 14 | #include <AliVCaloCells.h> |
8d122774 | 15 | #include <TMath.h> |
16 | ||
c8fe2783 | 17 | class AliAODCaloCells : public AliVCaloCells |
8d122774 | 18 | { |
19 | public: | |
8d122774 | 20 | AliAODCaloCells(); |
c8fe2783 | 21 | AliAODCaloCells(const char* name, const char* title, VCells_t ttype=kUndef); |
5c1dc41f | 22 | AliAODCaloCells(const AliAODCaloCells& cells); |
23 | AliAODCaloCells& operator=(const AliAODCaloCells& cells); | |
ecff8f07 | 24 | virtual void Copy(TObject &obj) const; |
25 | virtual AliVCaloCells* CopyCaloCells(Bool_t all) const; | |
26 | ||
8d122774 | 27 | virtual ~AliAODCaloCells(); |
8dd6eba0 | 28 | void Clear(const Option_t*); |
29 | ||
8d122774 | 30 | void CreateContainer(Short_t nCells); |
31 | void DeleteContainer(); | |
32 | void Sort(); | |
33 | ||
c8fe2783 | 34 | Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time = -1); |
8d122774 | 35 | |
36 | Short_t GetNumberOfCells() const { return fNCells; } | |
c8fe2783 | 37 | void SetNumberOfCells(Int_t n) { fNCells = n ; } |
38 | inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, Double_t &time) const; | |
8d122774 | 39 | inline Double_t GetCellAmplitude(Short_t cellNumber); |
b4620c80 | 40 | inline Short_t GetCellPosition(Short_t cellNumber); |
8d122774 | 41 | inline Double_t GetAmplitude(Short_t pos) const; |
c8fe2783 | 42 | Double_t GetCellTime(Short_t /*cellNumber*/) {return -1;} |
8d122774 | 43 | inline Short_t GetCellNumber(Short_t pos) const; |
c8fe2783 | 44 | Double_t GetTime(Short_t /*pos*/) const {return -1;} |
45 | Bool_t IsEMCAL() const {return (fType == kEMCALCell);} | |
46 | Bool_t IsPHOS() const {return (fType == kPHOSCell);} | |
8d122774 | 47 | Char_t GetType() const { return fType;} |
c8fe2783 | 48 | void SetType(Char_t ttype) { fType=ttype; } |
49 | ||
8d122774 | 50 | |
51 | protected: | |
52 | Int_t fNCells; // Number of cells | |
53 | Short_t *fCellNumber; //[fNCells] array of cell numbers | |
e649177a | 54 | Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!) |
8d122774 | 55 | Bool_t fIsSorted; //! true if cell arrays are sorted by index |
56 | Char_t fType; // Cell type | |
57 | ||
8d122774 | 58 | |
c8fe2783 | 59 | ClassDef(AliAODCaloCells, 2); |
8d122774 | 60 | }; |
61 | ||
62 | ||
c8fe2783 | 63 | Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, Double_t& /*time*/) const |
8d122774 | 64 | { |
65 | if (pos>=0 && pos<fNCells) { | |
66 | cellNumber = fCellNumber[pos]; | |
67 | amplitude = fAmplitude[pos]; | |
68 | return kTRUE; | |
69 | } else { | |
37792174 | 70 | Warning("GetCell","Invalid cell array index %d", pos); |
8d122774 | 71 | return kFALSE; |
72 | } | |
73 | } | |
74 | ||
75 | ||
76 | Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber) | |
77 | { | |
78 | if (!fIsSorted) { | |
79 | Sort(); | |
80 | fIsSorted=kTRUE; | |
81 | } | |
82 | ||
83 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
37792174 | 84 | if (pos>=0 && fCellNumber[pos] == cellNumber) { |
8d122774 | 85 | return fAmplitude[pos]; |
86 | } else { | |
8d122774 | 87 | return 0.; |
88 | } | |
89 | } | |
90 | ||
91 | ||
92 | Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const | |
93 | { | |
94 | if (pos>=0 && pos<fNCells) { | |
95 | return fAmplitude[pos]; | |
96 | } else { | |
37792174 | 97 | Warning("GetAmplitude","Invalid cell array index %d", pos); |
8d122774 | 98 | return 0.; |
99 | } | |
100 | } | |
101 | ||
102 | ||
103 | Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const | |
104 | { | |
105 | if (pos>=0 && pos<fNCells) { | |
106 | return fCellNumber[pos]; | |
107 | } else { | |
37792174 | 108 | Warning("GetCellNumber","Invalid cell array index %d", pos); |
8d122774 | 109 | return fNCells; |
110 | } | |
111 | } | |
112 | ||
b4620c80 | 113 | Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber) |
114 | { | |
115 | if (!fIsSorted) { | |
116 | Sort(); | |
117 | fIsSorted=kTRUE; | |
118 | } | |
119 | ||
120 | Int_t nabove, nbelow, middle; | |
121 | Short_t pos = -1; | |
122 | ||
123 | nabove = fNCells + 1; | |
124 | nbelow = 0; | |
125 | while (nabove - nbelow > 1) { | |
126 | middle = (nabove + nbelow) / 2; | |
127 | if (cellNumber == fCellNumber[middle-1]) { | |
128 | pos = middle - 1; | |
129 | break; | |
130 | } | |
131 | if (cellNumber < fCellNumber[middle-1]) nabove = middle; | |
132 | else nbelow = middle; | |
133 | } | |
134 | ||
135 | return pos; | |
136 | } | |
137 | ||
8d122774 | 138 | |
139 | #endif |