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 */
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
13 //-------------------------------------------------------------------------
16 #include <AliVCaloCells.h>
19 class AliESDCaloCells : public AliVCaloCells
24 AliESDCaloCells(const char* name, const char* title, VCells_t ttype=kUndef);
25 AliESDCaloCells(const AliESDCaloCells & cells);
26 AliESDCaloCells & operator=(const AliESDCaloCells& source);
27 virtual ~AliESDCaloCells();
29 virtual AliVCaloCells * CopyCaloCells(Bool_t all) const;
30 virtual void Copy(TObject &obj) const;
31 void Clear(const Option_t*);
32 void CreateContainer(Short_t nCells);
33 void DeleteContainer();
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 ; }
41 inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude, 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., Bool_t isHG=kFALSE);
44 Short_t GetNumberOfCells() const { return fNCells ; }
45 void SetNumberOfCells(Int_t n) { fNCells = n ; }
48 inline Double_t GetCellAmplitude(Short_t cellNumber);
49 inline Bool_t GetCellHighGain(Short_t cellNumber); //is this cell High Gain
50 inline Short_t GetCellPosition(Short_t cellNumber);
51 inline Double_t GetCellTime(Short_t cellNumber);
53 inline Double_t GetAmplitude(Short_t pos) const;
54 inline Bool_t GetHighGain(Short_t pos) const;
55 inline Double_t GetTime(Short_t pos) const;
56 inline Short_t GetCellNumber(Short_t pos) const;
59 inline Int_t GetCellMCLabel(Short_t cellNumber) ;
60 inline Int_t GetMCLabel(Short_t pos) const ;
62 inline Double_t GetCellEFraction(Short_t cellNumber) ;
63 inline Double_t GetEFraction(Short_t pos) const ;
65 inline void SetEFraction (Short_t pos, Double32_t efrac) ;
66 inline void SetCellEFraction(Short_t cellNumber, Double32_t efrac) ;
70 Int_t fNCells; // Number of cells
71 Bool_t *fHGLG; //[fNCells] if sell HG or LG
72 Short_t *fCellNumber; //[fNCells] array of cell numbers
73 Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
74 Double32_t *fTime; //[fNCells][0.,0.,16] array with cell times
75 Double32_t *fEFraction; //[fNCells][0.,0.,16] array with fraction of MC energy and data - for embedding
76 Int_t *fMCLabel; //[fNCells] array of MC labels
77 Bool_t fIsSorted; //! true if cell arrays are sorted by index
78 Char_t fType; // Cell type
80 ClassDef(AliESDCaloCells, 5);
84 Bool_t AliESDCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &litude,
85 Double_t & time, Int_t & mclabel, Double_t & efrac) const
87 if (pos>=0 && pos<fNCells)
89 cellNumber = fCellNumber[pos];
90 amplitude = fAmplitude[pos];
93 if(fMCLabel) mclabel = fMCLabel[pos];
95 if(fEFraction) efrac = fEFraction[pos];
106 Double_t AliESDCaloCells::GetCellAmplitude(Short_t cellNumber)
113 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
114 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
115 return fAmplitude[pos];
121 Bool_t AliESDCaloCells::GetCellHighGain(Short_t cellNumber)
128 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
129 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
133 if(fMCLabel)//old version of ESD, for data HG flag stored in MCLabel
134 return !(fMCLabel[pos]==-2) ;
143 Double_t AliESDCaloCells::GetCellTime(Short_t cellNumber)
150 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
151 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
158 Double_t AliESDCaloCells::GetAmplitude(Short_t pos) const
160 if (pos>=0 && pos<fNCells) {
161 return fAmplitude[pos];
166 Bool_t AliESDCaloCells::GetHighGain(Short_t pos) const
168 if (pos>=0 && pos<fNCells) {
172 if(fMCLabel)//old version of ESD, for data HG flag stored in MCLabel
173 return !(fMCLabel[pos]==-2) ;
182 Double_t AliESDCaloCells::GetTime(Short_t pos) const
184 if (pos>=0 && pos<fNCells) {
191 Short_t AliESDCaloCells::GetCellNumber(Short_t pos) const
193 if (pos>=0 && pos<fNCells) {
194 return fCellNumber[pos];
200 Short_t AliESDCaloCells::GetCellPosition(Short_t cellNumber)
207 Int_t nabove, nbelow, middle;
210 nabove = fNCells + 1;
212 while (nabove - nbelow > 1) {
213 middle = (nabove + nbelow) / 2;
214 if (cellNumber == fCellNumber[middle-1]) {
218 if (cellNumber < fCellNumber[middle-1]) nabove = middle;
219 else nbelow = middle;
225 Int_t AliESDCaloCells::GetMCLabel(Short_t pos) const
227 if (pos>=0 && pos<fNCells && fMCLabel) {
228 return fMCLabel[pos];
234 Double_t AliESDCaloCells::GetEFraction(Short_t pos) const
236 if (pos>=0 && pos<fNCells && fEFraction) {
237 return fEFraction[pos];
243 Int_t AliESDCaloCells::GetCellMCLabel(Short_t cellNumber)
250 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
251 if (pos>=0 && fCellNumber[pos] == cellNumber && fMCLabel) {
252 return fMCLabel[pos];
258 Double_t AliESDCaloCells::GetCellEFraction(Short_t cellNumber)
265 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
266 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber && fEFraction) {
267 return fEFraction[pos];
273 void AliESDCaloCells::SetEFraction(Short_t pos, Double32_t efrac)
275 // Sets the fraction of energy from MC with respect to data at the given position
277 if (pos>=0 && pos < fNCells)
279 if(!fEFraction) fEFraction = new Double32_t[fNCells];
280 fEFraction[pos] = efrac;
284 void AliESDCaloCells::SetCellEFraction(Short_t cellNumber, Double32_t efrac)
291 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
292 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber)
294 if(!fEFraction) fEFraction = new Double32_t[fNCells];
295 fEFraction[pos] = efrac;