]>
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); | |
8d122774 | 24 | |
25 | virtual ~AliAODCaloCells(); | |
26 | ||
27 | void CreateContainer(Short_t nCells); | |
28 | void DeleteContainer(); | |
29 | void Sort(); | |
30 | ||
c8fe2783 | 31 | Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time = -1); |
8d122774 | 32 | |
33 | Short_t GetNumberOfCells() const { return fNCells; } | |
c8fe2783 | 34 | void SetNumberOfCells(Int_t n) { fNCells = n ; } |
35 | inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, Double_t &time) const; | |
8d122774 | 36 | inline Double_t GetCellAmplitude(Short_t cellNumber); |
b4620c80 | 37 | inline Short_t GetCellPosition(Short_t cellNumber); |
8d122774 | 38 | inline Double_t GetAmplitude(Short_t pos) const; |
c8fe2783 | 39 | Double_t GetCellTime(Short_t /*cellNumber*/) {return -1;} |
8d122774 | 40 | inline Short_t GetCellNumber(Short_t pos) const; |
c8fe2783 | 41 | Double_t GetTime(Short_t /*pos*/) const {return -1;} |
42 | Bool_t IsEMCAL() const {return (fType == kEMCALCell);} | |
43 | Bool_t IsPHOS() const {return (fType == kPHOSCell);} | |
8d122774 | 44 | Char_t GetType() const { return fType;} |
c8fe2783 | 45 | void SetType(Char_t ttype) { fType=ttype; } |
46 | ||
8d122774 | 47 | |
48 | protected: | |
49 | Int_t fNCells; // Number of cells | |
50 | Short_t *fCellNumber; //[fNCells] array of cell numbers | |
e649177a | 51 | Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!) |
8d122774 | 52 | Bool_t fIsSorted; //! true if cell arrays are sorted by index |
53 | Char_t fType; // Cell type | |
54 | ||
8d122774 | 55 | |
c8fe2783 | 56 | ClassDef(AliAODCaloCells, 2); |
8d122774 | 57 | }; |
58 | ||
59 | ||
c8fe2783 | 60 | Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, Double_t& /*time*/) const |
8d122774 | 61 | { |
62 | if (pos>=0 && pos<fNCells) { | |
63 | cellNumber = fCellNumber[pos]; | |
64 | amplitude = fAmplitude[pos]; | |
65 | return kTRUE; | |
66 | } else { | |
37792174 | 67 | Warning("GetCell","Invalid cell array index %d", pos); |
8d122774 | 68 | return kFALSE; |
69 | } | |
70 | } | |
71 | ||
72 | ||
73 | Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber) | |
74 | { | |
75 | if (!fIsSorted) { | |
76 | Sort(); | |
77 | fIsSorted=kTRUE; | |
78 | } | |
79 | ||
80 | Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber); | |
37792174 | 81 | if (pos>=0 && fCellNumber[pos] == cellNumber) { |
8d122774 | 82 | return fAmplitude[pos]; |
83 | } else { | |
8d122774 | 84 | return 0.; |
85 | } | |
86 | } | |
87 | ||
88 | ||
89 | Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const | |
90 | { | |
91 | if (pos>=0 && pos<fNCells) { | |
92 | return fAmplitude[pos]; | |
93 | } else { | |
37792174 | 94 | Warning("GetAmplitude","Invalid cell array index %d", pos); |
8d122774 | 95 | return 0.; |
96 | } | |
97 | } | |
98 | ||
99 | ||
100 | Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const | |
101 | { | |
102 | if (pos>=0 && pos<fNCells) { | |
103 | return fCellNumber[pos]; | |
104 | } else { | |
37792174 | 105 | Warning("GetCellNumber","Invalid cell array index %d", pos); |
8d122774 | 106 | return fNCells; |
107 | } | |
108 | } | |
109 | ||
b4620c80 | 110 | Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber) |
111 | { | |
112 | if (!fIsSorted) { | |
113 | Sort(); | |
114 | fIsSorted=kTRUE; | |
115 | } | |
116 | ||
117 | Int_t nabove, nbelow, middle; | |
118 | Short_t pos = -1; | |
119 | ||
120 | nabove = fNCells + 1; | |
121 | nbelow = 0; | |
122 | while (nabove - nbelow > 1) { | |
123 | middle = (nabove + nbelow) / 2; | |
124 | if (cellNumber == fCellNumber[middle-1]) { | |
125 | pos = middle - 1; | |
126 | break; | |
127 | } | |
128 | if (cellNumber < fCellNumber[middle-1]) nabove = middle; | |
129 | else nbelow = middle; | |
130 | } | |
131 | ||
132 | return pos; | |
133 | } | |
134 | ||
8d122774 | 135 | |
136 | #endif |