]>
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 * | |
7 | * full copyright notice. * | |
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: | |
32 | Short_t* fData; | |
33 | Short_t fLength; | |
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: | |
53 | Short_t *fBeg, *fEnd, *fPos; | |
54 | Short_t fTime, fSignal; | |
55 | Short_t fThreshold; | |
56 | Short_t fNChunk; | |
57 | ||
58 | public: | |
59 | PadIterator(const PadData& pd, Short_t thr=0) : | |
60 | fBeg(pd.Data()), fEnd(pd.Data() + pd.Length()), fPos(pd.Data()), | |
61 | fTime(-1), fSignal(-1), fThreshold(thr), fNChunk(0) | |
62 | {} | |
265ecb21 | 63 | PadIterator(const PadIterator& i) : |
64 | fBeg(i.fBeg), fEnd(i.fEnd), fPos(i.fPos), | |
65 | fTime(i.fTime), fSignal(i.fSignal), fThreshold(i.fThreshold), fNChunk(i.fNChunk) | |
66 | {} | |
67 | virtual ~PadIterator() {} | |
68 | ||
69 | PadIterator& operator=(const PadIterator& i) { | |
70 | fBeg = i.fBeg; fEnd = i.fEnd; fPos = i.fPos; | |
71 | fTime = i.fTime; fSignal = i.fSignal; fThreshold = i.fThreshold; fNChunk = i.fNChunk; | |
72 | return *this; | |
73 | } | |
915dabe1 | 74 | |
75 | Bool_t Next(); | |
76 | void Reset(); | |
77 | void Reset(const PadData& pd); | |
78 | ||
79 | Short_t Time() const { return fTime; } | |
80 | Short_t Signal() const { return fSignal; } | |
81 | ||
82 | Short_t Threshold() const { return fThreshold; } | |
83 | void SetThreshold(Short_t t) { fThreshold = t; } | |
84 | ||
85 | void Test(); | |
86 | }; | |
87 | ||
88 | class RowIterator : public PadIterator | |
89 | { | |
90 | protected: | |
91 | const PadData* fPadArray; | |
92 | Short_t fNPads; | |
93 | Short_t fPad; | |
94 | ||
95 | public: | |
96 | RowIterator(const PadData* first, Short_t npads, Short_t thr=0) : | |
97 | PadIterator(*first, thr), | |
98 | fPadArray(first), fNPads(npads), | |
99 | fPad(-1) | |
100 | {} | |
265ecb21 | 101 | RowIterator(const RowIterator& i) : |
102 | PadIterator(i), | |
103 | fPadArray(i.fPadArray), fNPads(i.fNPads), fPad(i.fPad) | |
104 | {} | |
105 | ||
106 | RowIterator& operator=(const RowIterator& i) { | |
107 | fPadArray = i.fPadArray; fNPads = i.fNPads; fPad = i.fPad; | |
108 | return *this; | |
109 | } | |
915dabe1 | 110 | |
111 | Bool_t NextPad(); | |
112 | void ResetRow(); | |
113 | void ResetRow(const PadData* first, Short_t npads); | |
114 | ||
84aff7a4 | 115 | Short_t TEvePad() const { return fPad; } |
915dabe1 | 116 | |
117 | void Test(); | |
118 | }; | |
119 | ||
120 | class SegmentInfo : public TObject | |
121 | { | |
d810d0de | 122 | friend class AliEveTPCSectorData; |
915dabe1 | 123 | |
124 | private: | |
125 | Float_t fPadWidth; | |
126 | Float_t fPadHeight; | |
127 | Float_t fRLow; // Radius at the bottom of first row | |
128 | Int_t fNRows; // Number of rows in this segment | |
129 | Int_t fFirstRow; // First row index within sector | |
130 | Int_t fLastRow; // Last row index within sector | |
131 | Int_t fNMaxPads; // Maximum number of pads in a row | |
132 | Int_t fNYSteps; // Number of steps in pad-count | |
133 | Float_t fYStep[64]; // Y coords where pad-count changes | |
134 | ||
135 | public: | |
136 | SegmentInfo(); | |
137 | ||
138 | Float_t GetPadWidth() const { return fPadWidth; } | |
139 | Float_t GetPadHeight() const { return fPadHeight; } | |
140 | Float_t GetRLow() const { return fRLow; } | |
141 | Int_t GetNRows() const { return fNRows; } | |
142 | Int_t GetFirstRow() const { return fFirstRow; } | |
143 | Int_t GetLastRow() const { return fLastRow; } | |
144 | Int_t GetNMaxPads() const { return fNMaxPads; } | |
145 | Int_t GetNYSteps() const { return fNYSteps; } | |
146 | Float_t GetYStep(Int_t step) const { return fYStep[step]; } | |
147 | ||
148 | ClassDef(SegmentInfo, 0); | |
149 | }; | |
150 | ||
151 | private: | |
152 | static AliTPCParam *fgParam; | |
c7e321e3 | 153 | static Float_t fgZLength; |
915dabe1 | 154 | static Int_t fgNAllRows; |
155 | static Int_t fgNAllPads; | |
156 | static Int_t *fgRowBegs; | |
157 | ||
158 | static SegmentInfo fgInnSeg; | |
159 | static SegmentInfo fgOut1Seg; | |
160 | static SegmentInfo fgOut2Seg; | |
161 | ||
162 | static SegmentInfo* fgSegInfoPtrs[3]; | |
163 | ||
164 | protected: | |
165 | Int_t fSectorID; | |
166 | Int_t fNPadsFilled; | |
167 | std::vector<PadData> fPads; | |
168 | ||
169 | // Blocks of pad-data. | |
170 | const Int_t fBlockSize; | |
171 | Int_t fBlockPos; | |
172 | std::vector<Short_t*> fBlocks; | |
173 | ||
174 | void NewBlock(); | |
175 | ||
176 | // Intermediate buffer/vars for pad-data. | |
177 | Short_t fPadBuffer[2048]; | |
178 | Int_t fCurrentRow, fCurrentPad, fCurrentPos, fCurrentStep; | |
179 | ||
180 | Int_t PadIndex(Int_t row, Int_t pad) { return fgRowBegs[row] + pad; } | |
181 | ||
182 | public: | |
d810d0de | 183 | AliEveTPCSectorData(Int_t sector, Int_t bsize=65536); |
184 | virtual ~AliEveTPCSectorData(); | |
915dabe1 | 185 | |
092578a7 | 186 | void DropData(); |
187 | ||
915dabe1 | 188 | virtual void Print(Option_t* opt="") const; |
189 | ||
190 | void BeginPad(Int_t row, Int_t pad, Bool_t reverseTime=kFALSE); | |
191 | void RegisterData(Short_t time, Short_t signal); | |
d6433e5d | 192 | void EndPad(Bool_t autoPedestal=kFALSE, Short_t threshold=0); |
915dabe1 | 193 | |
194 | const PadData& GetPadData(Int_t padAddr); | |
195 | const PadData& GetPadData(Int_t row, Int_t pad); | |
196 | ||
197 | PadIterator MakePadIterator(Int_t padAddr, Short_t thr=0); | |
198 | PadIterator MakePadIterator(Int_t row, Int_t pad, Short_t thr=0); | |
199 | ||
200 | RowIterator MakeRowIterator(Int_t row, Short_t thr=0); | |
201 | ||
202 | // --- Static functions | |
203 | ||
204 | static const AliTPCParam& GetParam() { return *fgParam; } | |
c7e321e3 | 205 | static Float_t GetZLength() { return fgZLength; } |
206 | static Int_t GetNAllRows() { return fgNAllRows; } | |
207 | static Int_t GetNAllPads() { return fgNAllPads; } | |
915dabe1 | 208 | |
209 | static Int_t GetNPadsInRow(Int_t row); | |
210 | ||
211 | static const SegmentInfo& GetInnSeg() { return fgInnSeg; } | |
212 | static const SegmentInfo& GetOut1Seg() { return fgOut1Seg; } | |
213 | static const SegmentInfo& GetOut2Seg() { return fgOut2Seg; } | |
214 | ||
215 | static const SegmentInfo& GetSeg(Int_t seg); | |
216 | ||
217 | static void InitStatics(); | |
218 | ||
75a20dc1 | 219 | |
220 | //---------------------------------------------------------------- | |
221 | // Hack for noisy pad-row removal | |
222 | //---------------------------------------------------------------- | |
223 | ||
224 | class PadRowHack | |
225 | { | |
226 | public: | |
227 | Int_t fRow, fPad; | |
228 | Int_t fThrExt; | |
229 | Float_t fThrFac; // Actual threshold = fThrExt + fThrFac*thr | |
230 | ||
231 | PadRowHack(Int_t r, Int_t p, Int_t te=0, Float_t tf=1) : | |
2d830acc | 232 | fRow(r), fPad(p), fThrExt(te), fThrFac(tf) {} |
75a20dc1 | 233 | bool operator<(const PadRowHack& a) const |
234 | { return (fRow == a.fRow) ? fPad < a.fPad : fRow < a.fRow; } | |
235 | }; | |
236 | ||
237 | PadRowHack* GetPadRowHack(Int_t r, Int_t p); | |
238 | void AddPadRowHack(Int_t r, Int_t p, Int_t te=0, Float_t tf=1); | |
239 | void RemovePadRowHack(Int_t r, Int_t p); | |
240 | void DeletePadRowHack(); | |
241 | ||
242 | protected: | |
243 | void* fPadRowHackSet; | |
244 | ||
245 | ||
d810d0de | 246 | ClassDef(AliEveTPCSectorData, 0); |
247 | }; // endclass AliEveTPCSectorData | |
915dabe1 | 248 | |
249 | ||
d810d0de | 250 | inline void AliEveTPCSectorData::RegisterData(Short_t time, Short_t signal) |
915dabe1 | 251 | { |
252 | fPadBuffer[fCurrentPos] = time; | |
253 | fPadBuffer[fCurrentPos+1] = signal; | |
254 | fCurrentPos += fCurrentStep; | |
255 | } | |
256 | ||
915dabe1 | 257 | #endif |