]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODCaloCells.h
Included also 3 and 4 prong decays; added variables to ntuple
[u/mrichter/AliRoot.git] / STEER / AliAODCaloCells.h
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
14 #include <TNamed.h>
15 #include <TMath.h>
16
17 class AliAODCaloCells : public TNamed 
18 {
19  public:
20   enum AODCells_t {kUndef = -1, 
21                   kEMCAL, 
22                   kPHOS};
23
24   AliAODCaloCells();
25   AliAODCaloCells(const char* name, const char* title, AODCells_t ttype=kUndef);
26   AliAODCaloCells(const AliAODCaloCells& cells); 
27   AliAODCaloCells& operator=(const AliAODCaloCells& cells);
28   
29   virtual ~AliAODCaloCells();
30   
31   void CreateContainer(Short_t nCells);
32   void DeleteContainer();
33   void Sort();
34   
35   Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude);
36   
37   Short_t GetNumberOfCells() const { return fNCells; }
38   inline Bool_t   GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude) const;
39   inline Double_t GetCellAmplitude(Short_t cellNumber);
40   inline Double_t GetAmplitude(Short_t pos) const;
41   inline Short_t  GetCellNumber(Short_t pos) const;
42
43   Char_t  GetType() const { return fType;}
44   void    SetType(AODCells_t ttype) { fType=ttype; }
45
46  protected:
47   Int_t       fNCells;       // Number of cells
48   Short_t    *fCellNumber;   //[fNCells] array of cell numbers
49   Double32_t *fAmplitude;    //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
50   Bool_t      fIsSorted;     //! true if cell arrays are sorted by index
51   Char_t      fType;         // Cell type
52   
53   
54   ClassDef(AliAODCaloCells, 1);
55 };
56
57
58 Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude) const 
59
60   if (pos>=0 && pos<fNCells) {
61     cellNumber = fCellNumber[pos];
62     amplitude = fAmplitude[pos];
63     return kTRUE;
64   } else {
65     Warning("GetCell","Invalid cell array index %d", pos);
66     return kFALSE;
67   }
68 }
69
70
71 Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber)
72
73   if (!fIsSorted) {
74     Sort();
75     fIsSorted=kTRUE;
76   }
77
78   Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
79   if (pos>=0 && fCellNumber[pos] == cellNumber) {
80     return fAmplitude[pos];
81   } else {
82     Warning("GetCellAmplitude","Wrong cell array index %d", pos);
83     return 0.;
84   }
85 }
86
87
88 Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const 
89
90   if (pos>=0 && pos<fNCells) {
91     return fAmplitude[pos];
92   } else {
93     Warning("GetAmplitude","Invalid cell array index %d", pos);
94     return 0.;
95   }
96 }
97
98
99 Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const 
100
101   if (pos>=0 && pos<fNCells) {
102     return fCellNumber[pos];
103   } else {
104     Warning("GetCellNumber","Invalid cell array index %d", pos);
105     return fNCells;
106   }
107 }
108
109
110 #endif