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