6 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
9 /** @file AliHLTTPCPad.h
10 @author Matthias Richter
12 @brief Container Class for TPC Pads.
15 #include "AliHLTLogging.h"
17 typedef Int_t AliHLTTPCSignal_t;
21 * The class is a container for the raw ADC data of one TPCS pad. In order to
22 * avoid multiple unpacking/handling of the incoming raw data, the class holds
23 * a copy of the incoming data for one event. The copy is released when the
24 * end of the event was announced.
25 * The class calculates the base line of a TPC channel. Currently, only the
26 * average value is calculated, but further extension will include channel by
27 * channel histograming. The baseline history is kept and used for baseline
28 * re-evaluation and correction of subsequent events.
31 class AliHLTTPCPad : public AliHLTLogging {
33 /** standard constructor */
38 * @param offset The number of bins to ignore at the beginning
40 * @param nofBins The total number of bins for one channel
42 AliHLTTPCPad(Int_t offset, Int_t nofBins);
44 /** not a valid copy constructor, defined according to effective C++ style */
45 AliHLTTPCPad(const AliHLTTPCPad&);
46 /** not a valid assignment op, but defined according to effective C++ style */
47 AliHLTTPCPad& operator=(const AliHLTTPCPad&);
48 /** standard destructor */
49 virtual ~AliHLTTPCPad();
52 * Set the address the pad.
53 * The address consists of row and pad number.
54 * @param rowno The row number
55 * @param padno The pad number.
57 Int_t SetID(Int_t rowno, Int_t padno);
62 Int_t GetRowNumber() const {return fRowNo;}
67 Int_t GetPadNumber() const {return fPadNo;}
70 * Start accumulation for a new event.
71 * The class holds internally a history of the event data. The data can
72 * be fetched from the class without unpacking the input stream again.
73 * @return neg. error value if failed
74 * - ENOMEM memory allocation failed
75 * - EALREADY event data acquisition already started
80 * Check whether the event is started
81 * @return 1 if started, 0 if not
83 Int_t IsStarted() const { return fpRawData!=NULL;};
86 * Calculate the base line from the current event data.
87 * Only available within an event cycle. <br>
88 * The calculation requires a minimum number of bins which contribute
89 * to the sum, which can be specified by \e reqMinCount. The base line
90 * calculation will also be skipped if the number of contributing bins is
91 * less than half of the total number of time bins.
92 * @param reqMinCount the minimum number of bins contributing to the sum
93 * @return neg. error value if failed
94 * - ENODATA to little contributing bins
95 * - ENOBUFS no raw data available
97 Int_t CalculateBaseLine(Int_t reqMinCount=1);
100 * Stop processing of one event.
101 * The data history of the event will be released.
102 * @return neg. error value if failed
103 * - EBADF event not started
108 * Reset the base line history.
109 * @return neg. error code if failed
111 Int_t ResetHistory();
115 * The threshold effects to corrected data, signals smaller than threshold
117 * @param thresh Threshold for signal correction
118 * @return neg. error code if failed
120 Int_t SetThreshold(AliHLTTPCSignal_t thresh);
123 * Set the raw data value of a certain channel.
124 * @param bin Channel number
125 * @param value ADC value
126 * @return neg. error value if failed
127 * - ERANGE bin out of range
128 * - BADF event cycle not started
130 Int_t SetRawData(Int_t bin, AliHLTTPCSignal_t value);
133 * Get the raw data value of the current bin.
134 * The class holds the current read position which can be incremented by
135 * @ref Next() and reseted by @ref Rewind().
136 * Raw data is only available within an event cycle.
137 * @return raw data value
139 AliHLTTPCSignal_t GetRawData() const {return GetRawData(fReadPos);}
142 * Get the corrected data value the current bin.
143 * Corrected raw data is only available within an event cycle.
144 * The base line value is substracted from the bin's value and suppressed
145 * by the threshold. Bins smaller than the first bin considered for base
146 * line calculation return 0.
147 * The class holds the current read position which can be incremented by
148 * @ref Next() and reseted by @ref Rewind().
149 * @return corrected value
151 AliHLTTPCSignal_t GetCorrectedData() const {return GetCorrectedData(fReadPos);}
154 * Increment the read position.
155 * @param bZeroSuppression skip all bins effected by the zero suppression
156 * @return 1 if more data available, 0 if not
158 Int_t Next(Int_t bZeroSuppression=kTRUE);
161 * Rewind the read position.
162 * The read position is set to the first bin over the zero suppression.
163 * @param bZeroSuppression skip all bins effected by the zero suppression
164 * @return 1 if more data available, 0 if not
166 Int_t Rewind(Int_t bZeroSuppression=kTRUE);
169 * Get the current read position.
170 * @return read position, -1 if no data available
172 Int_t GetCurrentPosition() const {return fReadPos<fNofBins?fReadPos:-1;}
175 * Get the raw data value of a certain bin.
176 * Raw data is only available within an event cycle.
177 * @param bin Channel number
178 * @return raw data value
180 AliHLTTPCSignal_t GetRawData(Int_t bin) const;
183 * Get the corrected data value of a certain bin.
184 * Corrected raw data is only available within an event cycle.
185 * The base line value is substracted from the bin's value and suppressed
186 * by the threshold. Bins smaller than the first bin considered for base
187 * line calculation return 0.
188 * @param bin Channel number
189 * @return corrected value
191 AliHLTTPCSignal_t GetCorrectedData(Int_t bin) const;
194 * Get the base line value of a certain channel.
195 * @param bin Channel number
196 * @return base line value at bin
198 AliHLTTPCSignal_t GetBaseLine(Int_t bin) const;
201 * Get the avarage base line value.
202 * @return average base line value
204 AliHLTTPCSignal_t GetAverage() const;
207 * Get the occupancy for the pad in fractions of 1
208 * The occupancy is calculated from the number of time bins with non zero data
209 * after zero suppression.
210 * @return occupancy in percent
212 Float_t GetOccupancy() const;
215 * Get the occupancy average for the pad in fractions of 1
216 * The occupancy is calculated from the number of time bins with non zero data
217 * after zero suppression and averaged over all events.
218 * @return occupancy in percent
220 Float_t GetAveragedOccupancy() const;
223 * Get the size (number of time bins) of the pad
224 * @return number of bins
226 Int_t GetSize() const {return fNofBins;}
230 * Add a value to the base line calculation.
231 * The value is been added to the sum if it exceeds the current base line
232 * and bin is equal or greater than the first bin for base line calculation.
233 * @param bin Channel number
234 * @param value ADC value
236 Int_t AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value);
238 /** The row number of the pad */
239 Int_t fRowNo; // see above
240 /** The pad number of the pad */
241 Int_t fPadNo; // see above
242 /** Threshold for zero suppression */
243 AliHLTTPCSignal_t fThreshold; // see above
244 /** The average base line value */
245 AliHLTTPCSignal_t fAverage; // see above
246 /** Number of events included in the base line calculation*/
247 Int_t fNofEvents; // see above
248 /** The sum within one event */
249 AliHLTTPCSignal_t fSum; // see above
250 /** The number of bins contributing to the sum */
251 Int_t fCount; // see above
252 /** The total number of bins already set during the event */
253 Int_t fTotal; // see above
254 /** The maximum base line value within one event */
255 AliHLTTPCSignal_t fBLMax; // see above
256 /** The bin for the maximum bl value within one event */
257 Int_t fBLMaxBin; // see above
258 /** The minimum base line value within one event */
259 AliHLTTPCSignal_t fBLMin; // see above
260 /** The bin for the minimum bl value within one event */
261 Int_t fBLMinBin; // see above
262 /** The first bin included in the base line calculation */
263 Int_t fFirstBLBin; // see above
264 /** Number of bins */
265 Int_t fNofBins; // see above
267 /** The current read position */
268 Int_t fReadPos; // see above
270 /** The raw data history */
271 AliHLTTPCSignal_t* fpRawData; //! transient
273 ClassDef(AliHLTTPCPad, 0)