- added TPCLib to doxygen docu, code corrections according to documentation and effC++
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCPad.h
CommitLineData
46b33a24 1// @(#) $Id$
2
3#ifndef ALIHLTPAD_H
4#define ALIHLTPAD_H
5/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
7
8/** @file AliHLTTPCPad.h
9 @author Matthias Richter
10 @date
11 @brief Container Class for TPC Pads.
12*/
13
14#include "AliHLTLogging.h"
15
16typedef Int_t AliHLTTPCSignal_t;
17
18/**
19 * @class AliHLTTPCPad
20 * The class is a container for the raw ADC data of one TPCS pad. In order to
21 * avoid multiple unpacking/handling of the incoming raw data, the class holds
22 * a copy of the incoming data for one event. The copy is released when the
23 * end of the event was announced.
24 * The class calculates the base line of a TPC channel. Currently, only the
25 * average value is calculated, but further extension will include channel by
26 * channel histograming. The baseline history is kept and used for baseline
27 * re-evaluation and correction of subsequent events.
28 * @ingroup alihlt_tpc
29 */
30class AliHLTTPCPad : public AliHLTLogging {
31 public:
32 /** standard constructor */
33 AliHLTTPCPad();
34
35 /**
36 * Constructor
37 * @param offset The number of bins to ignore at the beginning
38 * of the channels
39 * @param nofBins The total number of bins for one channel
40 */
41 AliHLTTPCPad(Int_t offset, Int_t nofBins);
42
43 /** not a valid copy constructor, defined according to effective C++ style */
44 AliHLTTPCPad(const AliHLTTPCPad&);
45 /** not a valid assignment op, but defined according to effective C++ style */
46 AliHLTTPCPad& operator=(const AliHLTTPCPad&);
47 /** standard destructor */
48 virtual ~AliHLTTPCPad();
49
50 /**
51 * Set the address the pad.
52 * The address consists of row and pad number.
53 * @param rowno The row number
54 * @param padno The pad number.
55 */
56 Int_t SetID(Int_t rowno, Int_t padno);
57
58 /**
59 * Get the row number.
60 */
61 Int_t GetRowNumber() const {return fRowNo;}
62
63 /**
64 * Get the pad number.
65 */
66 Int_t GetPadNumber() const {return fPadNo;}
67
68 /**
69 * Start accumulation for a new event.
70 * The class holds internally a history of the event data. The data can
71 * be fetched from the class without unpacking the input stream again.
72 * @return neg. error value if failed
73 * - ENOMEM memory allocation failed
74 * - EALREADY event data acquisition already started
75 */
76 Int_t StartEvent();
77
78 /**
79 * Check whether the event is started
80 * @return 1 if started, 0 if not
81 */
82 Int_t IsStarted() const { return fpRawData!=NULL;};
83
84 /**
85 * Calculate the base line from the current event data.
86 * Only available within an event cycle. <br>
87 * The calculation requires a minimum number of bins which contribute
88 * to the sum, which can be specified by @param reqMinCount. The base line
89 * calculation will also be skipped if the number of contributing bins is
90 * less than half of the total number of time bins.
91 * @param reqMinCount the minimum number of bins contributing to the sum
92 * @return neg. error value if failed
93 * - ENODATA to little contributing bins
94 * - ENOBUFS no raw data available
95 */
96 Int_t CalculateBaseLine(Int_t reqMinCount=1);
97
98 /**
99 * Stop processing of one event.
100 * The data history of the event will be released.
101 * @return neg. error value if failed
102 * - EBADF event not started
103 */
104 Int_t StopEvent();
105
106 /**
107 * Reset the base line history.
108 * @return neg. error code if failed
109 */
110 Int_t ResetHistory();
111
112 /**
113 * Set threshold.
114 * The threshold effects to corrected data, signals smaller than threshold
115 * are suppressed.
116 * @param thresh Threshold for signal correction
117 * @return neg. error code if failed
118 */
119 Int_t SetThreshold(AliHLTTPCSignal_t thresh);
120
121 /**
122 * Set the raw data value of a certain channel.
123 * @param bin Channel number
124 * @param value ADC value
125 * @return neg. error value if failed
126 * - ERANGE bin out of range
127 * - BADF event cycle not started
128 */
129 Int_t SetRawData(Int_t bin, AliHLTTPCSignal_t value);
130
131 /**
132 * Get the raw data value of the current bin.
133 * The class holds the current read position which can be incremented by
134 * @ref Next() and reseted by @ref Rewind().
135 * Raw data is only available within an event cycle.
136 * @return raw data value
137 */
138 AliHLTTPCSignal_t GetRawData() const {return GetRawData(fReadPos);}
139
140 /**
141 * Get the corrected data value the current bin.
142 * Corrected raw data is only available within an event cycle.
143 * The base line value is substracted from the bin's value and suppressed
144 * by the threshold. Bins smaller than the first bin considered for base
145 * line calculation return 0.
146 * The class holds the current read position which can be incremented by
147 * @ref Next() and reseted by @ref Rewind().
148 * @return corrected value
149 */
150 AliHLTTPCSignal_t GetCorrectedData() const {return GetCorrectedData(fReadPos);}
151
152 /**
153 * Increment the read position.
154 * @param bZeroSuppression skip all bins effected by the zero suppression
155 * @return 1 if more data available, 0 if not
156 */
157 Int_t Next(Int_t bZeroSuppression=kTRUE);
158
159 /**
160 * Rewind the read position.
161 * The read position is set to the first bin over the zero suppression.
162 * @param bZeroSuppression skip all bins effected by the zero suppression
163 * @return 1 if more data available, 0 if not
164 */
165 Int_t Rewind(Int_t bZeroSuppression=kTRUE);
166
167 /**
168 * Get the current read position.
169 * @return read position, -1 if no data available
170 */
171 Int_t GetCurrentPosition() const {return fReadPos<fNofBins?fReadPos:-1;}
172
173 /**
174 * Get the raw data value of a certain bin.
175 * Raw data is only available within an event cycle.
176 * @param bin Channel number
177 * @return raw data value
178 */
179 AliHLTTPCSignal_t GetRawData(Int_t bin) const;
180
181 /**
182 * Get the corrected data value of a certain bin.
183 * Corrected raw data is only available within an event cycle.
184 * The base line value is substracted from the bin's value and suppressed
185 * by the threshold. Bins smaller than the first bin considered for base
186 * line calculation return 0.
187 * @param bin Channel number
188 * @return corrected value
189 */
190 AliHLTTPCSignal_t GetCorrectedData(Int_t bin) const;
191
192 /**
193 * Get the base line value of a certain channel.
194 * @param bin Channel number
600e6a1b 195 * @return base line value at bin
46b33a24 196 */
197 AliHLTTPCSignal_t GetBaseLine(Int_t bin) const;
198
199 /**
200 * Get the avarage base line value.
201 * @return average base line value
202 */
203 AliHLTTPCSignal_t GetAverage() const;
204
205 /**
5235c3e9 206 * Get the occupancy for the pad in fractions of 1
207 * The occupancy is calculated from the number of time bins with non zero data
208 * after zero suppression.
209 * @return occupancy in percent
210 */
211 Float_t GetOccupancy() const;
212
213 /**
214 * Get the occupancy average for the pad in fractions of 1
215 * The occupancy is calculated from the number of time bins with non zero data
216 * after zero suppression and averaged over all events.
217 * @return occupancy in percent
218 */
219 Float_t GetAveragedOccupancy() const;
220
221 /**
46b33a24 222 * Get the size (number of time bins) of the pad
223 * @return number of bins
224 */
225 Int_t GetSize() const {return fNofBins;}
226
227 private:
228 /**
229 * Add a value to the base line calculation.
230 * The value is been added to the sum if it exceeds the current base line
231 * and bin is equal or greater than the first bin for base line calculation.
232 * @param bin Channel number
233 * @param value ADC value
234 */
235 Int_t AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value);
236
237 /** The row number of the pad */
238 Int_t fRowNo;
239 /** The pad number of the pad */
240 Int_t fPadNo;
241 /** Threshold for zero suppression */
242 AliHLTTPCSignal_t fThreshold;
243 /** The average base line value */
244 AliHLTTPCSignal_t fAverage;
245 /** Number of events included in the base line calculation*/
246 Int_t fNofEvents;
247 /** The sum within one event */
248 AliHLTTPCSignal_t fSum;
249 /** The number of bins contributing to the sum */
250 Int_t fCount;
251 /** The total number of bins already set during the event */
252 Int_t fTotal;
253 /** The maximum base line value within one event */
254 AliHLTTPCSignal_t fBLMax;
255 /** The bin for the maximum bl value within one event */
256 Int_t fBLMaxBin;
84645eb0 257 /** The minimum base line value within one event */
258 AliHLTTPCSignal_t fBLMin;
259 /** The bin for the minimum bl value within one event */
260 Int_t fBLMinBin;
46b33a24 261 /** The first bin included in the base line calculation */
262 Int_t fFirstBLBin;
263 /** Number of bins */
264 Int_t fNofBins;
265
266 /** The current read position */
267 Int_t fReadPos;
268
269 /** The raw data history */
270 AliHLTTPCSignal_t* fpRawData;
271
272 ClassDef(AliHLTTPCPad, 0)
273};
274#endif