]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDCaloCells.h
Avoid change of wd in Notify()
[u/mrichter/AliRoot.git] / STEER / AliESDCaloCells.h
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   virtual void Copy(TObject &obj) const;
33   
34   Bool_t IsEMCAL() const {return (fType == kEMCALCell);}
35   Bool_t IsPHOS() const {return (fType == kPHOSCell);}
36   Char_t  GetType() const { return fType;}
37   void    SetType(ESDCells_t ttype) { fType=ttype; }
38
39   void CreateContainer(Short_t nCells);
40   void DeleteContainer();
41   void Sort();
42   
43   Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time);
44   
45   Short_t GetNumberOfCells() const { return fNCells; }
46   void SetNumberOfCells(Int_t n) { fNCells = n ; }
47   inline Bool_t   GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time) const;
48   inline Double_t GetCellAmplitude(Short_t cellNumber);
49   inline Double_t GetCellTime(Short_t cellNumber);
50   inline Double_t GetAmplitude(Short_t pos) const;
51   inline Double_t GetTime(Short_t pos) const;
52   inline Short_t  GetCellNumber(Short_t pos) const;
53
54
55  protected:
56   Int_t       fNCells;       // Number of cells
57   Short_t    *fCellNumber;   //[fNCells] array of cell numbers
58   Double32_t *fAmplitude;    //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
59   Double32_t *fTime;    //[fNCells][0.,0.,16] array with cell times
60   Bool_t      fIsSorted;     //! true if cell arrays are sorted by index
61   Char_t      fType;         // Cell type
62
63   ClassDef(AliESDCaloCells, 1);
64 };
65
66
67 Bool_t AliESDCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t & time) const 
68
69   if (pos>=0 && pos<fNCells) {
70     cellNumber = fCellNumber[pos];
71     amplitude = fAmplitude[pos];
72     time = fTime[pos];
73     return kTRUE;
74   } else {
75     Error("GetCell","Invalid cell array index %d", pos);
76     return kFALSE;
77   }
78 }
79
80
81 Double_t AliESDCaloCells::GetCellAmplitude(Short_t cellNumber)
82
83   if (!fIsSorted) {
84     Sort();
85     fIsSorted=kTRUE;
86   }
87
88   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
89   if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber ) {
90     return fAmplitude[pos];
91   } else {
92     Warning("GetCellAmplitude","Wrong cell array index %d", pos);
93     return 0.;
94   }
95 }
96
97 Double_t AliESDCaloCells::GetCellTime(Short_t cellNumber)
98
99   if (!fIsSorted) {
100     Sort();
101     fIsSorted=kTRUE;
102   }
103
104   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
105   if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
106     return fTime[pos];
107   } else {
108     Warning("GetCellTime","Wrong cell array index %d", pos);
109     return 0.;
110   }
111 }
112
113 Double_t AliESDCaloCells::GetAmplitude(Short_t pos) const 
114
115   if (pos>=0 && pos<fNCells) {
116     return fAmplitude[pos];
117   } else {
118     Error("GetAmplitude","Invalid cell array index %d", pos);
119     return 0.;
120   }
121 }
122
123 Double_t AliESDCaloCells::GetTime(Short_t pos) const 
124
125   if (pos>=0 && pos<fNCells) {
126     return fTime[pos];
127   } else {
128     Error("GetTime","Invalid cell array index %d", pos);
129     return 0.;
130   }
131 }
132
133 Short_t AliESDCaloCells::GetCellNumber(Short_t pos) const 
134
135   if (pos>=0 && pos<fNCells) {
136     return fCellNumber[pos];
137   } else {
138     Error("GetCellNumber","Invalid cell array index %d", pos);
139     return fNCells;
140   }
141 }
142
143
144 #endif