]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCPad.h
Bogdan: new version of MUON visualization.
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCPad.h
CommitLineData
2a083ac4 1// -*- Mode: C++ -*-
46b33a24 2// @(#) $Id$
3
4#ifndef ALIHLTPAD_H
5#define ALIHLTPAD_H
6/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
8
9/** @file AliHLTTPCPad.h
10 @author Matthias Richter
11 @date
12 @brief Container Class for TPC Pads.
13*/
14
15#include "AliHLTLogging.h"
16
17typedef Int_t AliHLTTPCSignal_t;
18
19/**
20 * @class AliHLTTPCPad
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.
29 * @ingroup alihlt_tpc
30 */
31class AliHLTTPCPad : public AliHLTLogging {
32 public:
33 /** standard constructor */
34 AliHLTTPCPad();
35
36 /**
37 * Constructor
38 * @param offset The number of bins to ignore at the beginning
39 * of the channels
40 * @param nofBins The total number of bins for one channel
41 */
42 AliHLTTPCPad(Int_t offset, Int_t nofBins);
43
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();
50
51 /**
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.
56 */
57 Int_t SetID(Int_t rowno, Int_t padno);
58
59 /**
60 * Get the row number.
61 */
62 Int_t GetRowNumber() const {return fRowNo;}
63
64 /**
65 * Get the pad number.
66 */
67 Int_t GetPadNumber() const {return fPadNo;}
68
69 /**
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
76 */
77 Int_t StartEvent();
78
79 /**
80 * Check whether the event is started
81 * @return 1 if started, 0 if not
82 */
83 Int_t IsStarted() const { return fpRawData!=NULL;};
84
85 /**
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
a655eae3 89 * to the sum, which can be specified by \e reqMinCount. The base line
46b33a24 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
96 */
97 Int_t CalculateBaseLine(Int_t reqMinCount=1);
98
99 /**
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
104 */
105 Int_t StopEvent();
106
107 /**
108 * Reset the base line history.
109 * @return neg. error code if failed
110 */
111 Int_t ResetHistory();
112
113 /**
114 * Set threshold.
115 * The threshold effects to corrected data, signals smaller than threshold
116 * are suppressed.
117 * @param thresh Threshold for signal correction
118 * @return neg. error code if failed
119 */
120 Int_t SetThreshold(AliHLTTPCSignal_t thresh);
121
122 /**
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
129 */
130 Int_t SetRawData(Int_t bin, AliHLTTPCSignal_t value);
131
132 /**
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
138 */
139 AliHLTTPCSignal_t GetRawData() const {return GetRawData(fReadPos);}
140
141 /**
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
150 */
151 AliHLTTPCSignal_t GetCorrectedData() const {return GetCorrectedData(fReadPos);}
152
153 /**
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
157 */
158 Int_t Next(Int_t bZeroSuppression=kTRUE);
159
160 /**
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
165 */
166 Int_t Rewind(Int_t bZeroSuppression=kTRUE);
167
168 /**
169 * Get the current read position.
170 * @return read position, -1 if no data available
171 */
172 Int_t GetCurrentPosition() const {return fReadPos<fNofBins?fReadPos:-1;}
173
174 /**
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
179 */
180 AliHLTTPCSignal_t GetRawData(Int_t bin) const;
181
182 /**
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
190 */
191 AliHLTTPCSignal_t GetCorrectedData(Int_t bin) const;
192
193 /**
194 * Get the base line value of a certain channel.
195 * @param bin Channel number
600e6a1b 196 * @return base line value at bin
46b33a24 197 */
198 AliHLTTPCSignal_t GetBaseLine(Int_t bin) const;
199
200 /**
201 * Get the avarage base line value.
202 * @return average base line value
203 */
204 AliHLTTPCSignal_t GetAverage() const;
205
5235c3e9 206 /**
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
211 */
212 Float_t GetOccupancy() const;
213
214 /**
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
219 */
220 Float_t GetAveragedOccupancy() const;
221
46b33a24 222 /**
223 * Get the size (number of time bins) of the pad
224 * @return number of bins
225 */
226 Int_t GetSize() const {return fNofBins;}
227
228 private:
229 /**
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
235 */
236 Int_t AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value);
237
238 /** The row number of the pad */
2a083ac4 239 Int_t fRowNo; // see above
46b33a24 240 /** The pad number of the pad */
2a083ac4 241 Int_t fPadNo; // see above
46b33a24 242 /** Threshold for zero suppression */
2a083ac4 243 AliHLTTPCSignal_t fThreshold; // see above
46b33a24 244 /** The average base line value */
2a083ac4 245 AliHLTTPCSignal_t fAverage; // see above
46b33a24 246 /** Number of events included in the base line calculation*/
2a083ac4 247 Int_t fNofEvents; // see above
46b33a24 248 /** The sum within one event */
2a083ac4 249 AliHLTTPCSignal_t fSum; // see above
46b33a24 250 /** The number of bins contributing to the sum */
2a083ac4 251 Int_t fCount; // see above
46b33a24 252 /** The total number of bins already set during the event */
2a083ac4 253 Int_t fTotal; // see above
46b33a24 254 /** The maximum base line value within one event */
2a083ac4 255 AliHLTTPCSignal_t fBLMax; // see above
46b33a24 256 /** The bin for the maximum bl value within one event */
2a083ac4 257 Int_t fBLMaxBin; // see above
84645eb0 258 /** The minimum base line value within one event */
2a083ac4 259 AliHLTTPCSignal_t fBLMin; // see above
84645eb0 260 /** The bin for the minimum bl value within one event */
2a083ac4 261 Int_t fBLMinBin; // see above
46b33a24 262 /** The first bin included in the base line calculation */
2a083ac4 263 Int_t fFirstBLBin; // see above
46b33a24 264 /** Number of bins */
2a083ac4 265 Int_t fNofBins; // see above
46b33a24 266
267 /** The current read position */
2a083ac4 268 Int_t fReadPos; // see above
46b33a24 269
270 /** The raw data history */
2a083ac4 271 AliHLTTPCSignal_t* fpRawData; //! transient
46b33a24 272
273 ClassDef(AliHLTTPCPad, 0)
274};
275#endif