Coverity
[u/mrichter/AliRoot.git] / EVE / EveDet / AliEveTPCSectorData.h
CommitLineData
d810d0de 1// $Id$
2// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
915dabe1 9
a15e6d7d 10#ifndef AliEveTPCSectorData_H
11#define AliEveTPCSectorData_H
915dabe1 12
13#include <TObject.h>
14
15#include <vector>
16
17class AliTPCParam;
18
a15e6d7d 19//------------------------------------------------------------------------------
20// AliEveTPCSectorData
21//
22// Constainer for pad-data of a single TPC sector.
23// Also stores relevant geometry information in static data-members.
24//
915dabe1 25
d810d0de 26class AliEveTPCSectorData : public TObject
915dabe1 27{
28public:
4b456ebb 29 // --- Inner classes ---
915dabe1 30
31 class PadData
32 {
915dabe1 33 public:
34 PadData(Short_t* d=0, Short_t l=0) : fData(d), fLength(l) {}
35
3c67f72c 36 PadData(const PadData& p) : fData(p.fData), fLength(p.fLength) {}
37 PadData& operator=(const PadData& p)
38 { fData = p.fData; fLength = p.fLength; return *this; }
39
915dabe1 40 Short_t* Data() const { return fData; }
41 Short_t Length() const { return fLength; }
42
43 void SetDataLength(Short_t* d, Short_t l) { fData = d; fLength = l; }
44
45 void Print(Option_t* opt="");
4b456ebb 46
47 protected:
48 Short_t* fData; // Data for given pad.
49 Short_t fLength; // Length of pad-data.
915dabe1 50 };
51
52 class PadIterator
53 {
915dabe1 54 public:
55 PadIterator(const PadData& pd, Short_t thr=0) :
56 fBeg(pd.Data()), fEnd(pd.Data() + pd.Length()), fPos(pd.Data()),
57 fTime(-1), fSignal(-1), fThreshold(thr), fNChunk(0)
58 {}
265ecb21 59 PadIterator(const PadIterator& i) :
60 fBeg(i.fBeg), fEnd(i.fEnd), fPos(i.fPos),
61 fTime(i.fTime), fSignal(i.fSignal), fThreshold(i.fThreshold), fNChunk(i.fNChunk)
62 {}
63 virtual ~PadIterator() {}
64
65 PadIterator& operator=(const PadIterator& i) {
66 fBeg = i.fBeg; fEnd = i.fEnd; fPos = i.fPos;
67 fTime = i.fTime; fSignal = i.fSignal; fThreshold = i.fThreshold; fNChunk = i.fNChunk;
68 return *this;
69 }
915dabe1 70
71 Bool_t Next();
72 void Reset();
73 void Reset(const PadData& pd);
74
75 Short_t Time() const { return fTime; }
76 Short_t Signal() const { return fSignal; }
77
78 Short_t Threshold() const { return fThreshold; }
79 void SetThreshold(Short_t t) { fThreshold = t; }
80
81 void Test();
4b456ebb 82
83 protected:
84 Short_t *fBeg, *fEnd; // Begin and end of data.
85 Short_t *fPos; // Current position.
86 Short_t fTime, fSignal; // Current time and signal.
87 Short_t fThreshold; // Threshold for data iteration.
88 Short_t fNChunk; // Number of contiguous signals still to read.
915dabe1 89 };
90
91 class RowIterator : public PadIterator
92 {
915dabe1 93 public:
94 RowIterator(const PadData* first, Short_t npads, Short_t thr=0) :
95 PadIterator(*first, thr),
96 fPadArray(first), fNPads(npads),
97 fPad(-1)
98 {}
265ecb21 99 RowIterator(const RowIterator& i) :
100 PadIterator(i),
101 fPadArray(i.fPadArray), fNPads(i.fNPads), fPad(i.fPad)
102 {}
103
104 RowIterator& operator=(const RowIterator& i) {
105 fPadArray = i.fPadArray; fNPads = i.fNPads; fPad = i.fPad;
106 return *this;
107 }
915dabe1 108
109 Bool_t NextPad();
110 void ResetRow();
111 void ResetRow(const PadData* first, Short_t npads);
51346b82 112
84aff7a4 113 Short_t TEvePad() const { return fPad; }
4b456ebb 114
115 protected:
116 const PadData *fPadArray; // Pointer to array of pad-data.
117 Short_t fNPads; // Number of pads in row.
118 Short_t fPad; // Current pad.
915dabe1 119 };
120
121 class SegmentInfo : public TObject
122 {
d810d0de 123 friend class AliEveTPCSectorData;
915dabe1 124
915dabe1 125 public:
126 SegmentInfo();
127
128 Float_t GetPadWidth() const { return fPadWidth; }
129 Float_t GetPadHeight() const { return fPadHeight; }
130 Float_t GetRLow() const { return fRLow; }
131 Int_t GetNRows() const { return fNRows; }
132 Int_t GetFirstRow() const { return fFirstRow; }
133 Int_t GetLastRow() const { return fLastRow; }
134 Int_t GetNMaxPads() const { return fNMaxPads; }
135 Int_t GetNYSteps() const { return fNYSteps; }
136 Float_t GetYStep(Int_t step) const { return fYStep[step]; }
137
4b456ebb 138 private:
139 Float_t fPadWidth; // Width of pad in this segment.
140 Float_t fPadHeight; // Height of pad in this segment.
141 Float_t fRLow; // Radius at the bottom of first row.
142 Int_t fNRows; // Number of rows in this segment.
143 Int_t fFirstRow; // First row index within sector.
144 Int_t fLastRow; // Last row index within sector.
145 Int_t fNMaxPads; // Maximum number of pads in a row.
146 Int_t fNYSteps; // Number of steps in pad-count.
147 Float_t fYStep[64]; // Y coords where pad-count changes.
148
915dabe1 149 ClassDef(SegmentInfo, 0);
150 };
151
4b456ebb 152 // --- Interface ---
a97abca8 153
d810d0de 154 AliEveTPCSectorData(Int_t sector, Int_t bsize=65536);
155 virtual ~AliEveTPCSectorData();
915dabe1 156
092578a7 157 void DropData();
158
915dabe1 159 virtual void Print(Option_t* opt="") const;
160
161 void BeginPad(Int_t row, Int_t pad, Bool_t reverseTime=kFALSE);
162 void RegisterData(Short_t time, Short_t signal);
d6433e5d 163 void EndPad(Bool_t autoPedestal=kFALSE, Short_t threshold=0);
915dabe1 164
a15e6d7d 165 const PadData& GetPadData(Int_t padAddr) const;
166 const PadData& GetPadData(Int_t row, Int_t pad) const;
915dabe1 167
168 PadIterator MakePadIterator(Int_t padAddr, Short_t thr=0);
169 PadIterator MakePadIterator(Int_t row, Int_t pad, Short_t thr=0);
170
171 RowIterator MakeRowIterator(Int_t row, Short_t thr=0);
172
173 // --- Static functions
174
175 static const AliTPCParam& GetParam() { return *fgParam; }
c7e321e3 176 static Float_t GetZLength() { return fgZLength; }
177 static Int_t GetNAllRows() { return fgNAllRows; }
178 static Int_t GetNAllPads() { return fgNAllPads; }
915dabe1 179
180 static Int_t GetNPadsInRow(Int_t row);
181
182 static const SegmentInfo& GetInnSeg() { return fgInnSeg; }
183 static const SegmentInfo& GetOut1Seg() { return fgOut1Seg; }
184 static const SegmentInfo& GetOut2Seg() { return fgOut2Seg; }
185
186 static const SegmentInfo& GetSeg(Int_t seg);
51346b82 187
915dabe1 188 static void InitStatics();
189
75a20dc1 190
4b456ebb 191protected:
192 Int_t fSectorID; // Sector id.
193 Int_t fNPadsFilled; // Number of filled pads.
194 std::vector<PadData> fPads; // Vector of pad-data.
75a20dc1 195
4b456ebb 196 // Blocks of pad-data.
197 const Int_t fkBlockSize; // Size of pad-data block.
198 Int_t fBlockPos; // Position in current block.
199 std::vector<Short_t*> fBlocks; // Vector of blocks.
200
201 void NewBlock();
75a20dc1 202
75a20dc1 203
4b456ebb 204 // Intermediate buffer/vars used during filling of pad-data.
205 Short_t fPadBuffer[2048]; // Buffer for current pad.
206 Int_t fCurrentRow; // Current row.
207 Int_t fCurrentPad; // Current pad.
208 Int_t fCurrentPos; // Current position in pad-buffer.
209 Int_t fCurrentStep; // Step, can be -2 or +2, depending on fill direction.
210
211 Int_t PadIndex(Int_t row, Int_t pad) const { return fgRowBegs[row] + pad; }
51346b82 212
75a20dc1 213
4b456ebb 214private:
215 static AliTPCParam *fgParam; // Global TPC parameters.
216 static Float_t fgZLength; // Z-length of a sector.
217 static Int_t fgNAllRows; // Number of rows in all segments.
218 static Int_t fgNAllPads; // Number of pads in all segments.
219 static Int_t *fgRowBegs; // Ids of pads at row-beginnings.
220
221 static SegmentInfo fgInnSeg; // Geometry information for inner segment.
222 static SegmentInfo fgOut1Seg; // Geometry information for middle segment.
223 static SegmentInfo fgOut2Seg; // Geometry information for outer segment.
224
225 static SegmentInfo* fgSegInfoPtrs[3]; // Array of geometry information objects, for access by segment id.
226
227 AliEveTPCSectorData(const AliEveTPCSectorData&); // Not implemented
228 AliEveTPCSectorData& operator=(const AliEveTPCSectorData&); // Not implemented
229
a97abca8 230 ClassDef(AliEveTPCSectorData, 0); // Holds pad-data of a single TPC sector. Also stores geometry information in static data-members.
231};
915dabe1 232
233
d810d0de 234inline void AliEveTPCSectorData::RegisterData(Short_t time, Short_t signal)
915dabe1 235{
a97abca8 236 // Register data for given time.
237
915dabe1 238 fPadBuffer[fCurrentPos] = time;
239 fPadBuffer[fCurrentPos+1] = signal;
240 fCurrentPos += fCurrentStep;
241}
242
915dabe1 243#endif