]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/TPCSectorData.h
Fix effc++ warnings.
[u/mrichter/AliRoot.git] / EVE / Alieve / TPCSectorData.h
1 // $Header$
2
3 #ifndef ALIEVE_TPCSectorData_H
4 #define ALIEVE_TPCSectorData_H
5
6 #include <Reve/Reve.h>
7
8 #include <TObject.h>
9
10 #include <vector>
11
12 class AliTPCParam;
13
14 namespace Alieve {
15
16 class TPCSectorData : public TObject
17 {
18   TPCSectorData(const TPCSectorData&);            // Not implemented
19   TPCSectorData& operator=(const TPCSectorData&); // Not implemented
20
21 public:
22
23   class PadData
24   {
25   protected:
26     Short_t* fData;
27     Short_t  fLength;
28
29   public:
30     PadData(Short_t* d=0, Short_t l=0) : fData(d), fLength(l) {}
31
32     Short_t* Data()   const { return fData; }
33     Short_t  Length() const { return fLength; }
34
35     void SetDataLength(Short_t* d, Short_t l) { fData = d; fLength = l; }
36
37     void Print(Option_t* opt="");
38   };
39
40   class PadIterator
41   {
42   protected:
43     Short_t *fBeg, *fEnd, *fPos;
44     Short_t  fTime, fSignal;
45     Short_t  fThreshold;
46     Short_t  fNChunk;
47
48   public:
49     PadIterator(const PadData& pd, Short_t thr=0) :
50       fBeg(pd.Data()), fEnd(pd.Data() + pd.Length()), fPos(pd.Data()),
51       fTime(-1), fSignal(-1), fThreshold(thr), fNChunk(0)
52     {}
53     PadIterator(const PadIterator& i) :
54       fBeg(i.fBeg), fEnd(i.fEnd), fPos(i.fPos),
55       fTime(i.fTime), fSignal(i.fSignal), fThreshold(i.fThreshold), fNChunk(i.fNChunk)
56     {}
57     virtual ~PadIterator() {}
58
59     PadIterator& operator=(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       return *this;
63     }
64
65     Bool_t Next();
66     void   Reset();
67     void   Reset(const PadData& pd);
68
69     Short_t Time()   const { return fTime; }
70     Short_t Signal() const { return fSignal; }
71
72     Short_t Threshold()    const { return fThreshold; }
73     void SetThreshold(Short_t t) { fThreshold = t; }
74
75     void Test();
76   };
77
78   class RowIterator : public PadIterator
79   {
80   protected:
81     const PadData* fPadArray;
82     Short_t fNPads;
83     Short_t fPad;
84
85   public:
86     RowIterator(const PadData* first, Short_t npads, Short_t thr=0) :
87       PadIterator(*first, thr),
88       fPadArray(first), fNPads(npads),
89       fPad(-1)
90     {}
91     RowIterator(const RowIterator& i) :
92       PadIterator(i),
93       fPadArray(i.fPadArray), fNPads(i.fNPads), fPad(i.fPad)
94     {}
95
96     RowIterator& operator=(const RowIterator& i) {
97       fPadArray = i.fPadArray; fNPads = i.fNPads; fPad = i.fPad;
98       return *this;
99     }
100
101     Bool_t NextPad();
102     void   ResetRow();
103     void   ResetRow(const PadData* first, Short_t npads);
104     
105     Short_t Pad() const { return fPad; }
106
107     void Test();
108   };
109
110   class SegmentInfo : public TObject
111   {
112     friend class TPCSectorData;
113
114   private:
115     Float_t   fPadWidth;
116     Float_t   fPadHeight;
117     Float_t   fRLow;      // Radius at the bottom of first row
118     Int_t     fNRows;     // Number of rows in this segment
119     Int_t     fFirstRow;  // First row index within sector
120     Int_t     fLastRow;   // Last row index within sector
121     Int_t     fNMaxPads;  // Maximum number of pads in a row
122     Int_t     fNYSteps;   // Number of steps in pad-count
123     Float_t   fYStep[64]; // Y coords where pad-count changes
124
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
138     ClassDef(SegmentInfo, 0);
139   };
140
141 private:
142   static AliTPCParam *fgParam;
143   static Float_t      fgZLength;
144   static Int_t        fgNAllRows;
145   static Int_t        fgNAllPads;
146   static Int_t       *fgRowBegs;
147
148   static SegmentInfo  fgInnSeg;
149   static SegmentInfo  fgOut1Seg;
150   static SegmentInfo  fgOut2Seg;
151
152   static SegmentInfo* fgSegInfoPtrs[3];
153
154 protected:
155   Int_t                 fSectorID;
156   Int_t                 fNPadsFilled;
157   std::vector<PadData>  fPads;
158
159   // Blocks of pad-data.
160   const Int_t           fBlockSize;
161   Int_t                 fBlockPos;
162   std::vector<Short_t*> fBlocks;
163
164   void NewBlock();
165
166   // Intermediate buffer/vars for pad-data.
167   Short_t fPadBuffer[2048];
168   Int_t   fCurrentRow, fCurrentPad, fCurrentPos, fCurrentStep;
169
170   Int_t PadIndex(Int_t row, Int_t pad) { return fgRowBegs[row] + pad; }
171
172 public:
173   TPCSectorData(Int_t sector, Int_t bsize=65536);
174   virtual ~TPCSectorData();
175
176   void DropData();
177
178   virtual void Print(Option_t* opt="") const;
179
180   void BeginPad(Int_t row, Int_t pad, Bool_t reverseTime=kFALSE);
181   void RegisterData(Short_t time, Short_t signal);
182   void EndPad(Bool_t autoPedestal=kFALSE, Short_t threshold=0);
183
184   const PadData& GetPadData(Int_t padAddr);
185   const PadData& GetPadData(Int_t row, Int_t pad);
186
187   PadIterator MakePadIterator(Int_t padAddr, Short_t thr=0);
188   PadIterator MakePadIterator(Int_t row, Int_t pad, Short_t thr=0);
189
190   RowIterator MakeRowIterator(Int_t row, Short_t thr=0);
191
192   // --- Static functions
193
194   static const AliTPCParam& GetParam() { return *fgParam; }
195   static Float_t GetZLength()  { return fgZLength;  }
196   static Int_t   GetNAllRows() { return fgNAllRows; }
197   static Int_t   GetNAllPads() { return fgNAllPads; }
198
199   static Int_t GetNPadsInRow(Int_t row);
200
201   static const SegmentInfo& GetInnSeg()  { return fgInnSeg;  }
202   static const SegmentInfo& GetOut1Seg() { return fgOut1Seg; }
203   static const SegmentInfo& GetOut2Seg() { return fgOut2Seg; }
204
205   static const SegmentInfo& GetSeg(Int_t seg);
206   
207   static void InitStatics();
208
209
210   //----------------------------------------------------------------
211   // Hack for noisy pad-row removal
212   //----------------------------------------------------------------
213
214   class PadRowHack
215   {
216   public:
217     Int_t   fRow, fPad;
218     Int_t   fThrExt;
219     Float_t fThrFac; // Actual threshold = fThrExt + fThrFac*thr
220
221     PadRowHack(Int_t r, Int_t p, Int_t te=0, Float_t tf=1) :
222       fRow(r), fPad(p), fThrExt(te), fThrFac(tf) {}
223     bool operator<(const PadRowHack& a) const
224     { return (fRow == a.fRow) ? fPad < a.fPad : fRow < a.fRow; }
225   };
226
227   PadRowHack* GetPadRowHack(Int_t r, Int_t p);
228   void AddPadRowHack(Int_t r, Int_t p, Int_t te=0, Float_t tf=1);
229   void RemovePadRowHack(Int_t r, Int_t p);
230   void DeletePadRowHack();
231
232 protected:
233   void* fPadRowHackSet;
234   
235
236   ClassDef(TPCSectorData, 0);
237 }; // endclass TPCSectorData
238
239
240 inline void TPCSectorData::RegisterData(Short_t time, Short_t signal)
241 {
242   fPadBuffer[fCurrentPos]   = time;
243   fPadBuffer[fCurrentPos+1] = signal;
244   fCurrentPos += fCurrentStep;
245 }
246
247 }
248
249 #endif