]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/ESD/AliESDCaloCells.h
bug fix in AliTOFtracker when ESD seeds array are empty for matching
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDCaloCells.h
CommitLineData
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
c8fe2783 16#include <AliVCaloCells.h>
e649177a 17#include <TMath.h>
18
c8fe2783 19class AliESDCaloCells : public AliVCaloCells
e649177a 20{
21 public:
22
e649177a 23 AliESDCaloCells();
c8fe2783 24 AliESDCaloCells(const char* name, const char* title, VCells_t ttype=kUndef);
e649177a 25 AliESDCaloCells(const AliESDCaloCells & cells);
26 AliESDCaloCells & operator=(const AliESDCaloCells& source);
27 virtual ~AliESDCaloCells();
77e93dc2 28
ecff8f07 29 virtual AliVCaloCells * CopyCaloCells(Bool_t all) const;
77e93dc2 30 virtual void Copy(TObject &obj) const;
31 void Clear(const Option_t*);
32 void CreateContainer(Short_t nCells);
33 void DeleteContainer();
34 void Sort();
e649177a 35
77e93dc2 36 Bool_t IsEMCAL() const { return (fType == kEMCALCell); }
37 Bool_t IsPHOS() const { return (fType == kPHOSCell) ; }
38 Char_t GetType() const { return fType ; }
39 void SetType(Char_t t){ fType = t ; }
40
60d77596 41 inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time, Int_t &mclabel, Double_t &efrac) const;
42 Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time, Int_t mclabel = -1, Double_t efrac = 0.);
77e93dc2 43
44 Short_t GetNumberOfCells() const { return fNCells ; }
45 void SetNumberOfCells(Int_t n) { fNCells = n ; }
e649177a 46
e649177a 47
e649177a 48 inline Double_t GetCellAmplitude(Short_t cellNumber);
77e93dc2 49 inline Short_t GetCellPosition(Short_t cellNumber);
e649177a 50 inline Double_t GetCellTime(Short_t cellNumber);
77e93dc2 51
e649177a 52 inline Double_t GetAmplitude(Short_t pos) const;
53 inline Double_t GetTime(Short_t pos) const;
54 inline Short_t GetCellNumber(Short_t pos) const;
55
77e93dc2 56 // MC & embedding
60d77596 57 inline Int_t GetCellMCLabel(Short_t cellNumber) ;
58 inline Int_t GetMCLabel(Short_t pos) const ;
77e93dc2 59
60 inline Double_t GetCellEFraction(Short_t cellNumber) ;
61 inline Double_t GetEFraction(Short_t pos) const ;
62
63 inline void SetEFraction (Short_t pos, Double32_t efrac) ;
64 inline void SetCellEFraction(Short_t cellNumber, Double32_t efrac) ;
65
e649177a 66 protected:
77e93dc2 67
e649177a 68 Int_t fNCells; // Number of cells
69 Short_t *fCellNumber; //[fNCells] array of cell numbers
5a578907 70 Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
71 Double32_t *fTime; //[fNCells][0.,0.,16] array with cell times
72 Double32_t *fEFraction; //[fNCells][0.,0.,16] array with fraction of MC energy and data - for embedding
60d77596 73 Int_t *fMCLabel; //[fNCells] array of MC labels
e649177a 74 Bool_t fIsSorted; //! true if cell arrays are sorted by index
75 Char_t fType; // Cell type
76
60d77596 77 ClassDef(AliESDCaloCells, 4);
e649177a 78};
79
80
77e93dc2 81Bool_t AliESDCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude,
60d77596 82 Double_t & time, Int_t & mclabel, Double_t & efrac) const
e649177a 83{
77e93dc2 84 if (pos>=0 && pos<fNCells)
85 {
e649177a 86 cellNumber = fCellNumber[pos];
77e93dc2 87 amplitude = fAmplitude[pos];
88 time = fTime[pos];
89
90 if(fMCLabel) mclabel = fMCLabel[pos];
91 else mclabel =-1 ;
92 if(fEFraction) efrac = fEFraction[pos];
93 else efrac = 0 ;
94
e649177a 95 return kTRUE;
77e93dc2 96
97 } else
98 {
e649177a 99 return kFALSE;
100 }
101}
102
e649177a 103Double_t AliESDCaloCells::GetCellAmplitude(Short_t cellNumber)
104{
105 if (!fIsSorted) {
106 Sort();
107 fIsSorted=kTRUE;
108 }
109
110 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
111 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
112 return fAmplitude[pos];
113 } else {
e649177a 114 return 0.;
115 }
116}
117
118Double_t AliESDCaloCells::GetCellTime(Short_t cellNumber)
119{
120 if (!fIsSorted) {
121 Sort();
122 fIsSorted=kTRUE;
123 }
124
125 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
126 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
127 return fTime[pos];
128 } else {
09037126 129 return -1.;
e649177a 130 }
131}
132
133Double_t AliESDCaloCells::GetAmplitude(Short_t pos) const
134{
135 if (pos>=0 && pos<fNCells) {
136 return fAmplitude[pos];
137 } else {
e649177a 138 return 0.;
139 }
140}
141
142Double_t AliESDCaloCells::GetTime(Short_t pos) const
143{
144 if (pos>=0 && pos<fNCells) {
145 return fTime[pos];
146 } else {
77e93dc2 147 return -1.;
e649177a 148 }
149}
150
151Short_t AliESDCaloCells::GetCellNumber(Short_t pos) const
152{
153 if (pos>=0 && pos<fNCells) {
154 return fCellNumber[pos];
155 } else {
e649177a 156 return fNCells;
157 }
158}
159
77e93dc2 160Short_t AliESDCaloCells::GetCellPosition(Short_t cellNumber)
161{
162 if (!fIsSorted) {
163 Sort();
164 fIsSorted=kTRUE;
165 }
166
167 Int_t nabove, nbelow, middle;
168 Short_t pos = -1;
169
170 nabove = fNCells + 1;
171 nbelow = 0;
172 while (nabove - nbelow > 1) {
173 middle = (nabove + nbelow) / 2;
174 if (cellNumber == fCellNumber[middle-1]) {
175 pos = middle - 1;
176 break;
177 }
178 if (cellNumber < fCellNumber[middle-1]) nabove = middle;
179 else nbelow = middle;
180 }
181
182 return pos;
183}
184
60d77596 185Int_t AliESDCaloCells::GetMCLabel(Short_t pos) const
77e93dc2 186{
187 if (pos>=0 && pos<fNCells && fMCLabel) {
188 return fMCLabel[pos];
189 } else {
190 return -1 ;
191 }
192}
193
194Double_t AliESDCaloCells::GetEFraction(Short_t pos) const
195{
196 if (pos>=0 && pos<fNCells && fEFraction) {
197 return fEFraction[pos];
198 } else {
199 return 0.;
200 }
201}
202
60d77596 203Int_t AliESDCaloCells::GetCellMCLabel(Short_t cellNumber)
77e93dc2 204{
205 if (!fIsSorted) {
206 Sort();
207 fIsSorted=kTRUE;
208 }
209
210 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
211 if (pos>=0 && fCellNumber[pos] == cellNumber && fMCLabel) {
212 return fMCLabel[pos];
213 } else {
214 return -1;
215 }
216}
217
218Double_t AliESDCaloCells::GetCellEFraction(Short_t cellNumber)
219{
220 if (!fIsSorted) {
221 Sort();
222 fIsSorted=kTRUE;
223 }
224
225 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
226 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber && fEFraction) {
227 return fEFraction[pos];
228 } else {
229 return 0.;
230 }
231}
232
233void AliESDCaloCells::SetEFraction(Short_t pos, Double32_t efrac)
234{
235 // Sets the fraction of energy from MC with respect to data at the given position
236
237 if (pos>=0 && pos < fNCells)
238 {
239 if(!fEFraction) fEFraction = new Double32_t[fNCells];
240 fEFraction[pos] = efrac;
241 }
242}
243
244void AliESDCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac)
245{
246 if (!fIsSorted) {
247 Sort();
248 fIsSorted=kTRUE;
249 }
250
251 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
252 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber)
253 {
254 if(!fEFraction) fEFraction = new Double32_t[fNCells];
255 fEFraction[pos] = efrac;
256 }
257}
258
259
e649177a 260#endif