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 // see below for class documentation
18 // refer to README to build package
20 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
22 #include "AliHLTLogging.h"
23 #include "AliHLTTPCClusters.h"
26 typedef Int_t AliHLTTPCSignal_t;
30 * The class is a container for the raw ADC data of one TPCS pad. In order to
31 * avoid multiple unpacking/handling of the incoming raw data, the class holds
32 * a copy of the incoming data for one event. The copy is released when the
33 * end of the event was announced.
34 * The class calculates the base line of a TPC channel. Currently, only the
35 * average value is calculated, but further extension will include channel by
36 * channel histograming. The baseline history is kept and used for baseline
37 * re-evaluation and correction of subsequent events.
40 class AliHLTTPCPad : public AliHLTLogging {
42 /** standard constructor */
47 * @param offset The number of bins to ignore at the beginning
49 * @param nofBins The total number of bins for one channel
51 AliHLTTPCPad(Int_t offset, Int_t nofBins);
53 /** standard destructor */
54 virtual ~AliHLTTPCPad();
59 UInt_t fTotalCharge; //tot charge of cluster
60 UInt_t fPad; //pad value
61 UInt_t fTime; //time value
62 ULong64_t fPad2; //for error in XY direction
63 ULong64_t fTime2; //for error in Z direction
64 UInt_t fMean; //mean in time
65 UInt_t fFlags; //different flags
66 UInt_t fChargeFalling; //for deconvolution
67 UInt_t fLastCharge; //for deconvolution
68 UInt_t fLastMergedPad; //dont merge twice per pad
71 typedef struct AliClusterData AliClusterData; //!
75 * Set the address the pad.
76 * The address consists of row and pad number.
77 * @param rowno The row number
78 * @param padno The pad number.
80 Int_t SetID(Int_t rowno, Int_t padno);
85 Int_t GetRowNumber() const {return fRowNo;}
90 Int_t GetPadNumber() const {return fPadNo;}
93 * Start accumulation for a new event.
94 * The class holds internally a history of the event data. The data can
95 * be fetched from the class without unpacking the input stream again.
96 * @return neg. error value if failed
97 * - ENOMEM memory allocation failed
98 * - EALREADY event data acquisition already started
103 * Check whether the event is started
104 * @return 1 if started, 0 if not
106 Int_t IsStarted() const { return fpRawData!=NULL;};
109 * Calculate the base line from the current event data.
110 * Only available within an event cycle. <br>
111 * The calculation requires a minimum number of bins which contribute
112 * to the sum, which can be specified by \e reqMinCount. The base line
113 * calculation will also be skipped if the number of contributing bins is
114 * less than half of the total number of time bins.
115 * @param reqMinCount the minimum number of bins contributing to the sum
116 * @return neg. error value if failed
117 * - ENODATA to little contributing bins
118 * - ENOBUFS no raw data available
120 Int_t CalculateBaseLine(Int_t reqMinCount=1);
123 * Stop processing of one event.
124 * The data history of the event will be released.
125 * @return neg. error value if failed
126 * - EBADF event not started
131 * Reset the base line history.
132 * @return neg. error code if failed
134 Int_t ResetHistory();
138 * The threshold effects to corrected data, signals smaller than threshold
140 * @param thresh Threshold for signal correction
141 * @return neg. error code if failed
143 Int_t SetThreshold(AliHLTTPCSignal_t thresh);
146 * Set the raw data value of a certain channel.
147 * @param bin Channel number
148 * @param value ADC value
149 * @return neg. error value if failed
150 * - ERANGE bin out of range
151 * - BADF event cycle not started
153 Int_t SetRawData(Int_t bin, AliHLTTPCSignal_t value);
156 * Get the raw data value of the current bin.
157 * The class holds the current read position which can be incremented by
158 * @ref Next() and reseted by @ref Rewind().
159 * Raw data is only available within an event cycle.
160 * @return raw data value
162 AliHLTTPCSignal_t GetRawData() const {return GetRawData(fReadPos);}
165 * Get the corrected data value the current bin.
166 * Corrected raw data is only available within an event cycle.
167 * The base line value is substracted from the bin's value and suppressed
168 * by the threshold. Bins smaller than the first bin considered for base
169 * line calculation return 0.
170 * The class holds the current read position which can be incremented by
171 * @ref Next() and reseted by @ref Rewind().
172 * @return corrected value
174 AliHLTTPCSignal_t GetCorrectedData() const {return GetCorrectedData(fReadPos);}
177 * Increment the read position.
178 * @param bZeroSuppression skip all bins effected by the zero suppression
179 * @return 1 if more data available, 0 if not
181 Int_t Next(Int_t bZeroSuppression=kTRUE);
184 * Rewind the read position.
185 * The read position is set to the first bin over the zero suppression.
186 * @param bZeroSuppression skip all bins effected by the zero suppression
187 * @return 1 if more data available, 0 if not
189 Int_t Rewind(Int_t bZeroSuppression=kTRUE);
192 * Get the current read position.
193 * @return read position, -1 if no data available
195 Int_t GetCurrentPosition() const {return fReadPos<fNofBins?fReadPos:-1;}
198 * Get the raw data value of a certain bin.
199 * Raw data is only available within an event cycle.
200 * @param bin Channel number
201 * @return raw data value
203 AliHLTTPCSignal_t GetRawData(Int_t bin) const;
206 * Get the corrected data value of a certain bin.
207 * Corrected raw data is only available within an event cycle.
208 * The base line value is substracted from the bin's value and suppressed
209 * by the threshold. Bins smaller than the first bin considered for base
210 * line calculation return 0.
211 * @param bin Channel number
212 * @return corrected value
214 AliHLTTPCSignal_t GetCorrectedData(Int_t bin) const;
217 * Get the base line value of a certain channel.
218 * @param bin Channel number
219 * @return base line value at bin
221 AliHLTTPCSignal_t GetBaseLine(Int_t bin) const;
224 * Get the avarage base line value.
225 * @return average base line value
227 AliHLTTPCSignal_t GetAverage() const;
230 * Get the occupancy for the pad in fractions of 1
231 * The occupancy is calculated from the number of time bins with non zero data
232 * after zero suppression.
233 * @return occupancy in percent
235 Float_t GetOccupancy() const;
238 * Get the occupancy average for the pad in fractions of 1
239 * The occupancy is calculated from the number of time bins with non zero data
240 * after zero suppression and averaged over all events.
241 * @return occupancy in percent
243 Float_t GetAveragedOccupancy() const;
246 * Get the size (number of time bins) of the pad
247 * @return number of bins
249 Int_t GetSize() const {return fNofBins;}
252 * Set the data array to -1
254 void SetDataToDefault();
256 * Stores the signal in the data array, stores the timebin number of the signal,
257 * and increments a counter.
259 void SetDataSignal(Int_t bin,Int_t signal);
262 * Returns the signal in the specified bin
264 Int_t GetDataSignal(Int_t bin) const;
267 * Finds the cluster candidate. If atleast two signals in the data array are neighbours
268 * they are stored in a cluster candidate vector.
270 void FindClusterCandidates();
272 * Prints the raw data og this pad.
277 * Vector of cluster candidates
279 vector<AliHLTTPCClusters> fClusterCandidates; //! transient
282 * Vector of used clustercandidates, used so one do not use candidates multiple times
284 vector<Int_t> fUsedClusterCandidates; //! transient
287 /** copy constructor prohibited */
288 AliHLTTPCPad(const AliHLTTPCPad&);
289 /** assignment operator prohibited */
290 AliHLTTPCPad& operator=(const AliHLTTPCPad&);
293 * Add a value to the base line calculation.
294 * The value is been added to the sum if it exceeds the current base line
295 * and bin is equal or greater than the first bin for base line calculation.
296 * @param bin Channel number
297 * @param value ADC value
299 Int_t AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value);
301 /** The row number of the pad */
302 Int_t fRowNo; // see above
303 /** The pad number of the pad */
304 Int_t fPadNo; // see above
305 /** Threshold for zero suppression */
306 AliHLTTPCSignal_t fThreshold; // see above
307 /** The average base line value */
308 AliHLTTPCSignal_t fAverage; // see above
309 /** Number of events included in the base line calculation*/
310 Int_t fNofEvents; // see above
311 /** The sum within one event */
312 AliHLTTPCSignal_t fSum; // see above
313 /** The number of bins contributing to the sum */
314 Int_t fCount; // see above
315 /** The total number of bins already set during the event */
316 Int_t fTotal; // see above
317 /** The maximum base line value within one event */
318 AliHLTTPCSignal_t fBLMax; // see above
319 /** The bin for the maximum bl value within one event */
320 Int_t fBLMaxBin; // see above
321 /** The minimum base line value within one event */
322 AliHLTTPCSignal_t fBLMin; // see above
323 /** The bin for the minimum bl value within one event */
324 Int_t fBLMinBin; // see above
325 /** The first bin included in the base line calculation */
326 Int_t fFirstBLBin; // see above
327 /** Number of bins */
328 Int_t fNofBins; // see above
330 /** The current read position */
331 Int_t fReadPos; // see above
333 /** The raw data history */
334 AliHLTTPCSignal_t* fpRawData; //! transient
337 * Array containing the data
339 AliHLTTPCSignal_t* fDataSignals; //! transient
342 * Array containing info on which bins have signals
344 Int_t *fSignalPositionArray; //! transient
345 Int_t fSizeOfSignalPositionArray; //! transient
347 ClassDef(AliHLTTPCPad, 1)
349 #endif // ALIHLTTPCPAD_H