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