2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
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 **************************************************************************/
10 #ifndef ALIEVE_TPCSectorData_H
11 #define ALIEVE_TPCSectorData_H
22 class AliEveTPCSectorData : public TObject
24 AliEveTPCSectorData(const AliEveTPCSectorData&); // Not implemented
25 AliEveTPCSectorData& operator=(const AliEveTPCSectorData&); // Not implemented
36 PadData(Short_t* d=0, Short_t l=0) : fData(d), fLength(l) {}
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; }
42 Short_t* Data() const { return fData; }
43 Short_t Length() const { return fLength; }
45 void SetDataLength(Short_t* d, Short_t l) { fData = d; fLength = l; }
47 void Print(Option_t* opt="");
53 Short_t *fBeg, *fEnd, *fPos;
54 Short_t fTime, fSignal;
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)
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)
67 virtual ~PadIterator() {}
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;
77 void Reset(const PadData& pd);
79 Short_t Time() const { return fTime; }
80 Short_t Signal() const { return fSignal; }
82 Short_t Threshold() const { return fThreshold; }
83 void SetThreshold(Short_t t) { fThreshold = t; }
88 class RowIterator : public PadIterator
91 const PadData* fPadArray;
96 RowIterator(const PadData* first, Short_t npads, Short_t thr=0) :
97 PadIterator(*first, thr),
98 fPadArray(first), fNPads(npads),
101 RowIterator(const RowIterator& i) :
103 fPadArray(i.fPadArray), fNPads(i.fNPads), fPad(i.fPad)
106 RowIterator& operator=(const RowIterator& i) {
107 fPadArray = i.fPadArray; fNPads = i.fNPads; fPad = i.fPad;
113 void ResetRow(const PadData* first, Short_t npads);
115 Short_t TEvePad() const { return fPad; }
120 class SegmentInfo : public TObject
122 friend class AliEveTPCSectorData;
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
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]; }
148 ClassDef(SegmentInfo, 0);
152 static AliTPCParam *fgParam;
153 static Float_t fgZLength;
154 static Int_t fgNAllRows;
155 static Int_t fgNAllPads;
156 static Int_t *fgRowBegs;
158 static SegmentInfo fgInnSeg;
159 static SegmentInfo fgOut1Seg;
160 static SegmentInfo fgOut2Seg;
162 static SegmentInfo* fgSegInfoPtrs[3];
167 std::vector<PadData> fPads;
169 // Blocks of pad-data.
170 const Int_t fBlockSize;
172 std::vector<Short_t*> fBlocks;
176 // Intermediate buffer/vars for pad-data.
177 Short_t fPadBuffer[2048];
178 Int_t fCurrentRow, fCurrentPad, fCurrentPos, fCurrentStep;
180 Int_t PadIndex(Int_t row, Int_t pad) { return fgRowBegs[row] + pad; }
183 AliEveTPCSectorData(Int_t sector, Int_t bsize=65536);
184 virtual ~AliEveTPCSectorData();
188 virtual void Print(Option_t* opt="") const;
190 void BeginPad(Int_t row, Int_t pad, Bool_t reverseTime=kFALSE);
191 void RegisterData(Short_t time, Short_t signal);
192 void EndPad(Bool_t autoPedestal=kFALSE, Short_t threshold=0);
194 const PadData& GetPadData(Int_t padAddr);
195 const PadData& GetPadData(Int_t row, Int_t pad);
197 PadIterator MakePadIterator(Int_t padAddr, Short_t thr=0);
198 PadIterator MakePadIterator(Int_t row, Int_t pad, Short_t thr=0);
200 RowIterator MakeRowIterator(Int_t row, Short_t thr=0);
202 // --- Static functions
204 static const AliTPCParam& GetParam() { return *fgParam; }
205 static Float_t GetZLength() { return fgZLength; }
206 static Int_t GetNAllRows() { return fgNAllRows; }
207 static Int_t GetNAllPads() { return fgNAllPads; }
209 static Int_t GetNPadsInRow(Int_t row);
211 static const SegmentInfo& GetInnSeg() { return fgInnSeg; }
212 static const SegmentInfo& GetOut1Seg() { return fgOut1Seg; }
213 static const SegmentInfo& GetOut2Seg() { return fgOut2Seg; }
215 static const SegmentInfo& GetSeg(Int_t seg);
217 static void InitStatics();
220 //----------------------------------------------------------------
221 // Hack for noisy pad-row removal
222 //----------------------------------------------------------------
229 Float_t fThrFac; // Actual threshold = fThrExt + fThrFac*thr
231 PadRowHack(Int_t r, Int_t p, Int_t te=0, Float_t tf=1) :
232 fRow(r), fPad(p), fThrExt(te), fThrFac(tf) {}
233 bool operator<(const PadRowHack& a) const
234 { return (fRow == a.fRow) ? fPad < a.fPad : fRow < a.fRow; }
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();
243 void* fPadRowHackSet;
246 ClassDef(AliEveTPCSectorData, 0);
247 }; // endclass AliEveTPCSectorData
250 inline void AliEveTPCSectorData::RegisterData(Short_t time, Short_t signal)
252 fPadBuffer[fCurrentPos] = time;
253 fPadBuffer[fCurrentPos+1] = signal;
254 fCurrentPos += fCurrentStep;