]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDCaloCells.h
Optimisation
[u/mrichter/AliRoot.git] / STEER / 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 {
89 Warning("GetCellAmplitude","Wrong cell array index %d", pos);
90 return 0.;
91 }
92}
93
94Double_t AliESDCaloCells::GetCellTime(Short_t cellNumber)
95{
96 if (!fIsSorted) {
97 Sort();
98 fIsSorted=kTRUE;
99 }
100
101 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
102 if (pos>=0 && pos < fNCells && fCellNumber[pos] == cellNumber) {
103 return fTime[pos];
104 } else {
105 Warning("GetCellTime","Wrong cell array index %d", pos);
106 return 0.;
107 }
108}
109
110Double_t AliESDCaloCells::GetAmplitude(Short_t pos) const
111{
112 if (pos>=0 && pos<fNCells) {
113 return fAmplitude[pos];
114 } else {
115 Error("GetAmplitude","Invalid cell array index %d", pos);
116 return 0.;
117 }
118}
119
120Double_t AliESDCaloCells::GetTime(Short_t pos) const
121{
122 if (pos>=0 && pos<fNCells) {
123 return fTime[pos];
124 } else {
125 Error("GetTime","Invalid cell array index %d", pos);
126 return 0.;
127 }
128}
129
130Short_t AliESDCaloCells::GetCellNumber(Short_t pos) const
131{
132 if (pos>=0 && pos<fNCells) {
133 return fCellNumber[pos];
134 } else {
135 Error("GetCellNumber","Invalid cell array index %d", pos);
136 return fNCells;
137 }
138}
139
e649177a 140#endif