]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveDet/AliEveTPCSectorData.h
Changes in configuration
[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{
d810d0de 28 AliEveTPCSectorData(const AliEveTPCSectorData&); // Not implemented
29 AliEveTPCSectorData& operator=(const AliEveTPCSectorData&); // Not implemented
265ecb21 30
915dabe1 31public:
32
33 class PadData
34 {
35 protected:
a97abca8 36 Short_t* fData; // Data for given pad.
37 Short_t fLength; // Length of pad-data.
915dabe1 38
39 public:
40 PadData(Short_t* d=0, Short_t l=0) : fData(d), fLength(l) {}
41
3c67f72c 42 PadData(const PadData& p) : fData(p.fData), fLength(p.fLength) {}
43 PadData& operator=(const PadData& p)
44 { fData = p.fData; fLength = p.fLength; return *this; }
45
915dabe1 46 Short_t* Data() const { return fData; }
47 Short_t Length() const { return fLength; }
48
49 void SetDataLength(Short_t* d, Short_t l) { fData = d; fLength = l; }
50
51 void Print(Option_t* opt="");
52 };
53
54 class PadIterator
55 {
56 protected:
a97abca8 57 Short_t *fBeg, *fEnd; // Begin and end of data.
58 Short_t *fPos; // Current position.
59 Short_t fTime, fSignal; // Current time and signal.
60 Short_t fThreshold; // Threshold for data iteration.
61 Short_t fNChunk; // Number of contiguous signals still to read.
915dabe1 62
63 public:
64 PadIterator(const PadData& pd, Short_t thr=0) :
65 fBeg(pd.Data()), fEnd(pd.Data() + pd.Length()), fPos(pd.Data()),
66 fTime(-1), fSignal(-1), fThreshold(thr), fNChunk(0)
67 {}
265ecb21 68 PadIterator(const PadIterator& i) :
69 fBeg(i.fBeg), fEnd(i.fEnd), fPos(i.fPos),
70 fTime(i.fTime), fSignal(i.fSignal), fThreshold(i.fThreshold), fNChunk(i.fNChunk)
71 {}
72 virtual ~PadIterator() {}
73
74 PadIterator& operator=(const PadIterator& i) {
75 fBeg = i.fBeg; fEnd = i.fEnd; fPos = i.fPos;
76 fTime = i.fTime; fSignal = i.fSignal; fThreshold = i.fThreshold; fNChunk = i.fNChunk;
77 return *this;
78 }
915dabe1 79
80 Bool_t Next();
81 void Reset();
82 void Reset(const PadData& pd);
83
84 Short_t Time() const { return fTime; }
85 Short_t Signal() const { return fSignal; }
86
87 Short_t Threshold() const { return fThreshold; }
88 void SetThreshold(Short_t t) { fThreshold = t; }
89
90 void Test();
91 };
92
93 class RowIterator : public PadIterator
94 {
95 protected:
a97abca8 96 const PadData *fPadArray; // Pointer to array of pad-data.
97 Short_t fNPads; // Number of pads in row.
98 Short_t fPad; // Current pad.
915dabe1 99
100 public:
101 RowIterator(const PadData* first, Short_t npads, Short_t thr=0) :
102 PadIterator(*first, thr),
103 fPadArray(first), fNPads(npads),
104 fPad(-1)
105 {}
265ecb21 106 RowIterator(const RowIterator& i) :
107 PadIterator(i),
108 fPadArray(i.fPadArray), fNPads(i.fNPads), fPad(i.fPad)
109 {}
110
111 RowIterator& operator=(const RowIterator& i) {
112 fPadArray = i.fPadArray; fNPads = i.fNPads; fPad = i.fPad;
113 return *this;
114 }
915dabe1 115
116 Bool_t NextPad();
117 void ResetRow();
118 void ResetRow(const PadData* first, Short_t npads);
51346b82 119
84aff7a4 120 Short_t TEvePad() const { return fPad; }
915dabe1 121 };
122
123 class SegmentInfo : public TObject
124 {
d810d0de 125 friend class AliEveTPCSectorData;
915dabe1 126
127 private:
a97abca8 128 Float_t fPadWidth; // Width of pad in this segment.
129 Float_t fPadHeight; // Height of pad in this segment.
130 Float_t fRLow; // Radius at the bottom of first row.
131 Int_t fNRows; // Number of rows in this segment.
132 Int_t fFirstRow; // First row index within sector.
133 Int_t fLastRow; // Last row index within sector.
134 Int_t fNMaxPads; // Maximum number of pads in a row.
135 Int_t fNYSteps; // Number of steps in pad-count.
136 Float_t fYStep[64]; // Y coords where pad-count changes.
915dabe1 137
138 public:
139 SegmentInfo();
140
141 Float_t GetPadWidth() const { return fPadWidth; }
142 Float_t GetPadHeight() const { return fPadHeight; }
143 Float_t GetRLow() const { return fRLow; }
144 Int_t GetNRows() const { return fNRows; }
145 Int_t GetFirstRow() const { return fFirstRow; }
146 Int_t GetLastRow() const { return fLastRow; }
147 Int_t GetNMaxPads() const { return fNMaxPads; }
148 Int_t GetNYSteps() const { return fNYSteps; }
149 Float_t GetYStep(Int_t step) const { return fYStep[step]; }
150
151 ClassDef(SegmentInfo, 0);
152 };
153
154private:
a97abca8 155 static AliTPCParam *fgParam; // Global TPC parameters.
156 static Float_t fgZLength; // Z-length of a sector.
157 static Int_t fgNAllRows; // Number of rows in all segments.
158 static Int_t fgNAllPads; // Number of pads in all segments.
159 static Int_t *fgRowBegs; // Ids of pads at row-beginnings.
915dabe1 160
a97abca8 161 static SegmentInfo fgInnSeg; // Geometry information for inner segment.
162 static SegmentInfo fgOut1Seg; // Geometry information for middle segment.
163 static SegmentInfo fgOut2Seg; // Geometry information for outer segment.
915dabe1 164
a97abca8 165 static SegmentInfo* fgSegInfoPtrs[3]; // Array of geometry information objects, for access by segment id.
915dabe1 166
167protected:
a97abca8 168 Int_t fSectorID; // Sector id.
169 Int_t fNPadsFilled; // Number of filled pads.
170 std::vector<PadData> fPads; // Vector of pad-data.
915dabe1 171
172 // Blocks of pad-data.
a15e6d7d 173 const Int_t fkBlockSize; // Size of pad-data block.
a97abca8 174 Int_t fBlockPos; // Position in current block.
175 std::vector<Short_t*> fBlocks; // Vector of blocks.
915dabe1 176
177 void NewBlock();
178
a97abca8 179
180 // Intermediate buffer/vars used during filling of pad-data.
181 Short_t fPadBuffer[2048]; // Buffer for current pad.
182 Int_t fCurrentRow; // Current row.
183 Int_t fCurrentPad; // Current pad.
184 Int_t fCurrentPos; // Current position in pad-buffer.
185 Int_t fCurrentStep; // Step, can be -2 or +2, depending on fill direction.
915dabe1 186
a15e6d7d 187 Int_t PadIndex(Int_t row, Int_t pad) const { return fgRowBegs[row] + pad; }
915dabe1 188
189public:
d810d0de 190 AliEveTPCSectorData(Int_t sector, Int_t bsize=65536);
191 virtual ~AliEveTPCSectorData();
915dabe1 192
092578a7 193 void DropData();
194
915dabe1 195 virtual void Print(Option_t* opt="") const;
196
197 void BeginPad(Int_t row, Int_t pad, Bool_t reverseTime=kFALSE);
198 void RegisterData(Short_t time, Short_t signal);
d6433e5d 199 void EndPad(Bool_t autoPedestal=kFALSE, Short_t threshold=0);
915dabe1 200
a15e6d7d 201 const PadData& GetPadData(Int_t padAddr) const;
202 const PadData& GetPadData(Int_t row, Int_t pad) const;
915dabe1 203
204 PadIterator MakePadIterator(Int_t padAddr, Short_t thr=0);
205 PadIterator MakePadIterator(Int_t row, Int_t pad, Short_t thr=0);
206
207 RowIterator MakeRowIterator(Int_t row, Short_t thr=0);
208
209 // --- Static functions
210
211 static const AliTPCParam& GetParam() { return *fgParam; }
c7e321e3 212 static Float_t GetZLength() { return fgZLength; }
213 static Int_t GetNAllRows() { return fgNAllRows; }
214 static Int_t GetNAllPads() { return fgNAllPads; }
915dabe1 215
216 static Int_t GetNPadsInRow(Int_t row);
217
218 static const SegmentInfo& GetInnSeg() { return fgInnSeg; }
219 static const SegmentInfo& GetOut1Seg() { return fgOut1Seg; }
220 static const SegmentInfo& GetOut2Seg() { return fgOut2Seg; }
221
222 static const SegmentInfo& GetSeg(Int_t seg);
51346b82 223
915dabe1 224 static void InitStatics();
225
75a20dc1 226
227 //----------------------------------------------------------------
228 // Hack for noisy pad-row removal
229 //----------------------------------------------------------------
230
231 class PadRowHack
232 {
233 public:
a97abca8 234 Int_t fRow, fPad; // For which row, pad we hack.
235 Int_t fThrExt; // Additional treshold
236 Float_t fThrFac; // Additional threshold factor.
237 // Actual threshold = fThrExt + fThrFac*thr
75a20dc1 238
239 PadRowHack(Int_t r, Int_t p, Int_t te=0, Float_t tf=1) :
2d830acc 240 fRow(r), fPad(p), fThrExt(te), fThrFac(tf) {}
75a20dc1 241 bool operator<(const PadRowHack& a) const
242 { return (fRow == a.fRow) ? fPad < a.fPad : fRow < a.fRow; }
243 };
244
245 PadRowHack* GetPadRowHack(Int_t r, Int_t p);
246 void AddPadRowHack(Int_t r, Int_t p, Int_t te=0, Float_t tf=1);
247 void RemovePadRowHack(Int_t r, Int_t p);
248 void DeletePadRowHack();
249
250protected:
a97abca8 251 void* fPadRowHackSet; // Pointer to set of PadRowHacks.
51346b82 252
75a20dc1 253
a97abca8 254 ClassDef(AliEveTPCSectorData, 0); // Holds pad-data of a single TPC sector. Also stores geometry information in static data-members.
255};
915dabe1 256
257
d810d0de 258inline void AliEveTPCSectorData::RegisterData(Short_t time, Short_t signal)
915dabe1 259{
a97abca8 260 // Register data for given time.
261
915dabe1 262 fPadBuffer[fCurrentPos] = time;
263 fPadBuffer[fCurrentPos+1] = signal;
264 fCurrentPos += fCurrentStep;
265}
266
915dabe1 267#endif