]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODCaloCells.h
bug fixed for alignment, removed alignment database access from AliPMDUtility class
[u/mrichter/AliRoot.git] / STEER / AliAODCaloCells.h
CommitLineData
8d122774 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
c8fe2783 14#include <AliVCaloCells.h>
8d122774 15#include <TMath.h>
16
c8fe2783 17class AliAODCaloCells : public AliVCaloCells
8d122774 18{
19 public:
8d122774 20 AliAODCaloCells();
c8fe2783 21 AliAODCaloCells(const char* name, const char* title, VCells_t ttype=kUndef);
5c1dc41f 22 AliAODCaloCells(const AliAODCaloCells& cells);
23 AliAODCaloCells& operator=(const AliAODCaloCells& cells);
ecff8f07 24 virtual void Copy(TObject &obj) const;
25 virtual AliVCaloCells* CopyCaloCells(Bool_t all) const;
26
8d122774 27 virtual ~AliAODCaloCells();
28
29 void CreateContainer(Short_t nCells);
30 void DeleteContainer();
31 void Sort();
32
c8fe2783 33 Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time = -1);
8d122774 34
35 Short_t GetNumberOfCells() const { return fNCells; }
c8fe2783 36 void SetNumberOfCells(Int_t n) { fNCells = n ; }
37 inline Bool_t GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t &time) const;
8d122774 38 inline Double_t GetCellAmplitude(Short_t cellNumber);
b4620c80 39 inline Short_t GetCellPosition(Short_t cellNumber);
8d122774 40 inline Double_t GetAmplitude(Short_t pos) const;
c8fe2783 41 Double_t GetCellTime(Short_t /*cellNumber*/) {return -1;}
8d122774 42 inline Short_t GetCellNumber(Short_t pos) const;
c8fe2783 43 Double_t GetTime(Short_t /*pos*/) const {return -1;}
44 Bool_t IsEMCAL() const {return (fType == kEMCALCell);}
45 Bool_t IsPHOS() const {return (fType == kPHOSCell);}
8d122774 46 Char_t GetType() const { return fType;}
c8fe2783 47 void SetType(Char_t ttype) { fType=ttype; }
48
8d122774 49
50 protected:
51 Int_t fNCells; // Number of cells
52 Short_t *fCellNumber; //[fNCells] array of cell numbers
e649177a 53 Double32_t *fAmplitude; //[fNCells][0.,0.,16] array with cell amplitudes (= energy!)
8d122774 54 Bool_t fIsSorted; //! true if cell arrays are sorted by index
55 Char_t fType; // Cell type
56
8d122774 57
c8fe2783 58 ClassDef(AliAODCaloCells, 2);
8d122774 59};
60
61
c8fe2783 62Bool_t AliAODCaloCells::GetCell(Short_t pos, Short_t &cellNumber, Double_t &amplitude, Double_t& /*time*/) const
8d122774 63{
64 if (pos>=0 && pos<fNCells) {
65 cellNumber = fCellNumber[pos];
66 amplitude = fAmplitude[pos];
67 return kTRUE;
68 } else {
37792174 69 Warning("GetCell","Invalid cell array index %d", pos);
8d122774 70 return kFALSE;
71 }
72}
73
74
75Double_t AliAODCaloCells::GetCellAmplitude(Short_t cellNumber)
76{
77 if (!fIsSorted) {
78 Sort();
79 fIsSorted=kTRUE;
80 }
81
82 Short_t pos = TMath::BinarySearch(fNCells, fCellNumber, cellNumber);
37792174 83 if (pos>=0 && fCellNumber[pos] == cellNumber) {
8d122774 84 return fAmplitude[pos];
85 } else {
8d122774 86 return 0.;
87 }
88}
89
90
91Double_t AliAODCaloCells::GetAmplitude(Short_t pos) const
92{
93 if (pos>=0 && pos<fNCells) {
94 return fAmplitude[pos];
95 } else {
37792174 96 Warning("GetAmplitude","Invalid cell array index %d", pos);
8d122774 97 return 0.;
98 }
99}
100
101
102Short_t AliAODCaloCells::GetCellNumber(Short_t pos) const
103{
104 if (pos>=0 && pos<fNCells) {
105 return fCellNumber[pos];
106 } else {
37792174 107 Warning("GetCellNumber","Invalid cell array index %d", pos);
8d122774 108 return fNCells;
109 }
110}
111
b4620c80 112Short_t AliAODCaloCells::GetCellPosition(Short_t cellNumber)
113{
114 if (!fIsSorted) {
115 Sort();
116 fIsSorted=kTRUE;
117 }
118
119 Int_t nabove, nbelow, middle;
120 Short_t pos = -1;
121
122 nabove = fNCells + 1;
123 nbelow = 0;
124 while (nabove - nbelow > 1) {
125 middle = (nabove + nbelow) / 2;
126 if (cellNumber == fCellNumber[middle-1]) {
127 pos = middle - 1;
128 break;
129 }
130 if (cellNumber < fCellNumber[middle-1]) nabove = middle;
131 else nbelow = middle;
132 }
133
134 return pos;
135}
136
8d122774 137
138#endif