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