6 /* This file is property of and copyright by the ALICE HLT Project *
7 * ALICE Experiment at CERN, All rights reserved. *
8 * See cxx source for full Copyright notice */
10 /** @file AliHLTTPCPad.h
11 @author Matthias Richter
13 @brief Container Class for TPC Pads.
16 #include "AliHLTLogging.h"
17 #include "AliHLTTPCClusters.h"
20 typedef Int_t AliHLTTPCSignal_t;
24 * The class is a container for the raw ADC data of one TPCS pad. In order to
25 * avoid multiple unpacking/handling of the incoming raw data, the class holds
26 * a copy of the incoming data for one event. The copy is released when the
27 * end of the event was announced.
28 * The class calculates the base line of a TPC channel. Currently, only the
29 * average value is calculated, but further extension will include channel by
30 * channel histograming. The baseline history is kept and used for baseline
31 * re-evaluation and correction of subsequent events.
34 class AliHLTTPCPad : public AliHLTLogging {
36 /** standard constructor */
41 * @param offset The number of bins to ignore at the beginning
43 * @param nofBins The total number of bins for one channel
45 AliHLTTPCPad(Int_t offset, Int_t nofBins);
47 /** not a valid copy constructor, defined according to effective C++ style */
48 AliHLTTPCPad(const AliHLTTPCPad&);
49 /** not a valid assignment op, but defined according to effective C++ style */
50 AliHLTTPCPad& operator=(const AliHLTTPCPad&);
51 /** standard destructor */
52 virtual ~AliHLTTPCPad();
57 UInt_t fTotalCharge; //tot charge of cluster
58 UInt_t fPad; //pad value
59 UInt_t fTime; //time value
60 ULong64_t fPad2; //for error in XY direction
61 ULong64_t fTime2; //for error in Z direction
62 UInt_t fMean; //mean in time
63 UInt_t fFlags; //different flags
64 UInt_t fChargeFalling; //for deconvolution
65 UInt_t fLastCharge; //for deconvolution
66 UInt_t fLastMergedPad; //dont merge twice per pad
69 typedef struct AliClusterData AliClusterData; //!
73 * Set the address the pad.
74 * The address consists of row and pad number.
75 * @param rowno The row number
76 * @param padno The pad number.
78 Int_t SetID(Int_t rowno, Int_t padno);
83 Int_t GetRowNumber() const {return fRowNo;}
88 Int_t GetPadNumber() const {return fPadNo;}
91 * Start accumulation for a new event.
92 * The class holds internally a history of the event data. The data can
93 * be fetched from the class without unpacking the input stream again.
94 * @return neg. error value if failed
95 * - ENOMEM memory allocation failed
96 * - EALREADY event data acquisition already started
101 * Check whether the event is started
102 * @return 1 if started, 0 if not
104 Int_t IsStarted() const { return fpRawData!=NULL;};
107 * Calculate the base line from the current event data.
108 * Only available within an event cycle. <br>
109 * The calculation requires a minimum number of bins which contribute
110 * to the sum, which can be specified by \e reqMinCount. The base line
111 * calculation will also be skipped if the number of contributing bins is
112 * less than half of the total number of time bins.
113 * @param reqMinCount the minimum number of bins contributing to the sum
114 * @return neg. error value if failed
115 * - ENODATA to little contributing bins
116 * - ENOBUFS no raw data available
118 Int_t CalculateBaseLine(Int_t reqMinCount=1);
121 * Stop processing of one event.
122 * The data history of the event will be released.
123 * @return neg. error value if failed
124 * - EBADF event not started
129 * Reset the base line history.
130 * @return neg. error code if failed
132 Int_t ResetHistory();
136 * The threshold effects to corrected data, signals smaller than threshold
138 * @param thresh Threshold for signal correction
139 * @return neg. error code if failed
141 Int_t SetThreshold(AliHLTTPCSignal_t thresh);
144 * Set the raw data value of a certain channel.
145 * @param bin Channel number
146 * @param value ADC value
147 * @return neg. error value if failed
148 * - ERANGE bin out of range
149 * - BADF event cycle not started
151 Int_t SetRawData(Int_t bin, AliHLTTPCSignal_t value);
154 * Get the raw data value of the current bin.
155 * The class holds the current read position which can be incremented by
156 * @ref Next() and reseted by @ref Rewind().
157 * Raw data is only available within an event cycle.
158 * @return raw data value
160 AliHLTTPCSignal_t GetRawData() const {return GetRawData(fReadPos);}
163 * Get the corrected data value the current bin.
164 * Corrected raw data is only available within an event cycle.
165 * The base line value is substracted from the bin's value and suppressed
166 * by the threshold. Bins smaller than the first bin considered for base
167 * line calculation return 0.
168 * The class holds the current read position which can be incremented by
169 * @ref Next() and reseted by @ref Rewind().
170 * @return corrected value
172 AliHLTTPCSignal_t GetCorrectedData() const {return GetCorrectedData(fReadPos);}
175 * Increment the read position.
176 * @param bZeroSuppression skip all bins effected by the zero suppression
177 * @return 1 if more data available, 0 if not
179 Int_t Next(Int_t bZeroSuppression=kTRUE);
182 * Rewind the read position.
183 * The read position is set to the first bin over the zero suppression.
184 * @param bZeroSuppression skip all bins effected by the zero suppression
185 * @return 1 if more data available, 0 if not
187 Int_t Rewind(Int_t bZeroSuppression=kTRUE);
190 * Get the current read position.
191 * @return read position, -1 if no data available
193 Int_t GetCurrentPosition() const {return fReadPos<fNofBins?fReadPos:-1;}
196 * Get the raw data value of a certain bin.
197 * Raw data is only available within an event cycle.
198 * @param bin Channel number
199 * @return raw data value
201 AliHLTTPCSignal_t GetRawData(Int_t bin) const;
204 * Get the corrected data value of a certain bin.
205 * Corrected raw data is only available within an event cycle.
206 * The base line value is substracted from the bin's value and suppressed
207 * by the threshold. Bins smaller than the first bin considered for base
208 * line calculation return 0.
209 * @param bin Channel number
210 * @return corrected value
212 AliHLTTPCSignal_t GetCorrectedData(Int_t bin) const;
215 * Get the base line value of a certain channel.
216 * @param bin Channel number
217 * @return base line value at bin
219 AliHLTTPCSignal_t GetBaseLine(Int_t bin) const;
222 * Get the avarage base line value.
223 * @return average base line value
225 AliHLTTPCSignal_t GetAverage() const;
228 * Get the occupancy for the pad in fractions of 1
229 * The occupancy is calculated from the number of time bins with non zero data
230 * after zero suppression.
231 * @return occupancy in percent
233 Float_t GetOccupancy() const;
236 * Get the occupancy average for the pad in fractions of 1
237 * The occupancy is calculated from the number of time bins with non zero data
238 * after zero suppression and averaged over all events.
239 * @return occupancy in percent
241 Float_t GetAveragedOccupancy() const;
244 * Get the size (number of time bins) of the pad
245 * @return number of bins
247 Int_t GetSize() const {return fNofBins;}
250 * Set the data array to -1
252 void SetDataToDefault();
254 * Stores the signal in the data array, stores the timebin number of the signal,
255 * and increments a counter.
257 void SetDataSignal(Int_t bin,Int_t signal);
260 * Returns the signal in the specified bin
262 Int_t GetDataSignal(Int_t bin);
264 * Finds the cluster candidate. If atleast two signals in the data array are neighbours
265 * they are stored in a cluster candidate vector.
267 void FindClusterCandidates();
269 * Prints the raw data og this pad.
274 * Vector of cluster candidates
276 vector<AliHLTTPCClusters> fClusterCandidates;
279 * Vector of used clustercandidates, used so one do not use candidates multiple times
281 vector<Int_t> fUsedClusterCandidates;
285 * Add a value to the base line calculation.
286 * The value is been added to the sum if it exceeds the current base line
287 * and bin is equal or greater than the first bin for base line calculation.
288 * @param bin Channel number
289 * @param value ADC value
291 Int_t AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value);
293 /** The row number of the pad */
294 Int_t fRowNo; // see above
295 /** The pad number of the pad */
296 Int_t fPadNo; // see above
297 /** Threshold for zero suppression */
298 AliHLTTPCSignal_t fThreshold; // see above
299 /** The average base line value */
300 AliHLTTPCSignal_t fAverage; // see above
301 /** Number of events included in the base line calculation*/
302 Int_t fNofEvents; // see above
303 /** The sum within one event */
304 AliHLTTPCSignal_t fSum; // see above
305 /** The number of bins contributing to the sum */
306 Int_t fCount; // see above
307 /** The total number of bins already set during the event */
308 Int_t fTotal; // see above
309 /** The maximum base line value within one event */
310 AliHLTTPCSignal_t fBLMax; // see above
311 /** The bin for the maximum bl value within one event */
312 Int_t fBLMaxBin; // see above
313 /** The minimum base line value within one event */
314 AliHLTTPCSignal_t fBLMin; // see above
315 /** The bin for the minimum bl value within one event */
316 Int_t fBLMinBin; // see above
317 /** The first bin included in the base line calculation */
318 Int_t fFirstBLBin; // see above
319 /** Number of bins */
320 Int_t fNofBins; // see above
322 /** The current read position */
323 Int_t fReadPos; // see above
325 /** The raw data history */
326 AliHLTTPCSignal_t* fpRawData; //! transient
329 * Array containing the data
331 AliHLTTPCSignal_t* fDataSignals;
334 * Array containing info on which bins have signals
336 Int_t *fSignalPositionArray;
337 Int_t fSizeOfSignalPositionArray;
339 ClassDef(AliHLTTPCPad, 0)