]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCPad.h
Adding setting default CDB storage and run number,
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCPad.h
CommitLineData
2a083ac4 1// -*- Mode: C++ -*-
46b33a24 2// @(#) $Id$
3
a1dbf058 4#ifndef ALIHLTTPCPAD_H
5#define ALIHLTTPCPAD_H
01f43166 6/* This file is property of and copyright by the ALICE HLT Project *
7 * ALICE Experiment at CERN, All rights reserved. *
46b33a24 8 * See cxx source for full Copyright notice */
9
10/** @file AliHLTTPCPad.h
11 @author Matthias Richter
12 @date
13 @brief Container Class for TPC Pads.
14*/
15
a1dbf058 16// see below for class documentation
17// or
18// refer to README to build package
19// or
20// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
21
46b33a24 22#include "AliHLTLogging.h"
01f43166 23#include "AliHLTTPCClusters.h"
24#include <vector>
46b33a24 25
26typedef Int_t AliHLTTPCSignal_t;
27
28/**
29 * @class AliHLTTPCPad
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.
38 * @ingroup alihlt_tpc
39 */
40class AliHLTTPCPad : public AliHLTLogging {
01f43166 41public:
46b33a24 42 /** standard constructor */
43 AliHLTTPCPad();
44
45 /**
46 * Constructor
47 * @param offset The number of bins to ignore at the beginning
48 * of the channels
49 * @param nofBins The total number of bins for one channel
50 */
51 AliHLTTPCPad(Int_t offset, Int_t nofBins);
52
46b33a24 53 /** standard destructor */
54 virtual ~AliHLTTPCPad();
55
01f43166 56
57 struct AliClusterData
58 {
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
69 };
70
71 typedef struct AliClusterData AliClusterData; //!
72
73
46b33a24 74 /**
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.
79 */
80 Int_t SetID(Int_t rowno, Int_t padno);
81
82 /**
83 * Get the row number.
84 */
85 Int_t GetRowNumber() const {return fRowNo;}
86
87 /**
88 * Get the pad number.
89 */
90 Int_t GetPadNumber() const {return fPadNo;}
91
92 /**
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
99 */
100 Int_t StartEvent();
101
102 /**
103 * Check whether the event is started
104 * @return 1 if started, 0 if not
105 */
106 Int_t IsStarted() const { return fpRawData!=NULL;};
107
108 /**
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
a655eae3 112 * to the sum, which can be specified by \e reqMinCount. The base line
46b33a24 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
119 */
120 Int_t CalculateBaseLine(Int_t reqMinCount=1);
121
122 /**
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
127 */
128 Int_t StopEvent();
129
130 /**
131 * Reset the base line history.
132 * @return neg. error code if failed
133 */
134 Int_t ResetHistory();
135
136 /**
137 * Set threshold.
138 * The threshold effects to corrected data, signals smaller than threshold
139 * are suppressed.
140 * @param thresh Threshold for signal correction
141 * @return neg. error code if failed
142 */
143 Int_t SetThreshold(AliHLTTPCSignal_t thresh);
144
145 /**
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
152 */
153 Int_t SetRawData(Int_t bin, AliHLTTPCSignal_t value);
154
155 /**
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
161 */
162 AliHLTTPCSignal_t GetRawData() const {return GetRawData(fReadPos);}
163
164 /**
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
173 */
174 AliHLTTPCSignal_t GetCorrectedData() const {return GetCorrectedData(fReadPos);}
175
176 /**
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
180 */
181 Int_t Next(Int_t bZeroSuppression=kTRUE);
182
183 /**
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
188 */
189 Int_t Rewind(Int_t bZeroSuppression=kTRUE);
190
191 /**
192 * Get the current read position.
193 * @return read position, -1 if no data available
194 */
195 Int_t GetCurrentPosition() const {return fReadPos<fNofBins?fReadPos:-1;}
196
197 /**
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
202 */
203 AliHLTTPCSignal_t GetRawData(Int_t bin) const;
204
205 /**
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
213 */
214 AliHLTTPCSignal_t GetCorrectedData(Int_t bin) const;
215
216 /**
217 * Get the base line value of a certain channel.
218 * @param bin Channel number
600e6a1b 219 * @return base line value at bin
46b33a24 220 */
221 AliHLTTPCSignal_t GetBaseLine(Int_t bin) const;
222
223 /**
224 * Get the avarage base line value.
225 * @return average base line value
226 */
227 AliHLTTPCSignal_t GetAverage() const;
228
5235c3e9 229 /**
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
234 */
235 Float_t GetOccupancy() const;
236
237 /**
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
242 */
243 Float_t GetAveragedOccupancy() const;
244
46b33a24 245 /**
246 * Get the size (number of time bins) of the pad
247 * @return number of bins
248 */
01f43166 249 Int_t GetSize() const {return fNofBins;}
250
251 /**
252 * Set the data array to -1
253 */
254 void SetDataToDefault();
255 /**
256 * Stores the signal in the data array, stores the timebin number of the signal,
257 * and increments a counter.
258 */
259 void SetDataSignal(Int_t bin,Int_t signal);
260
261 /**
262 * Returns the signal in the specified bin
263 */
a1dbf058 264 Int_t GetDataSignal(Int_t bin) const;
265
b1c46961 266 /**
267 * Zerosuppression where one can choose wether one want to cut on sigma(default 3) or a given adc threshold above baseline
268 * It works like this: Finds the signals above baseline+threshold, it then looks to the right of the signals adding the
269 * the signal below threshold but over the average. It stops when the adc value rises (since you should expect a fall)
270 * or if the signal in that bin is below average. It now does the same thing to the left.
271 * This is a very timeconsuming approach(but good), and will likely only be used only for cosmics and laser.
272 * If you use sigma approach you can give as input n sigma or stick with default=3. For channels with very large signals
273 * the (value-average)² is not calculated when value-average>50. This is due to sigma shooting sky high for only a few values.
274 * The method is checked with 2006 cosmics data, and it looks good.
275 * If you want to use the threshold approach you HAVE to set nSigma=-1 and threshold>0. For example: If you want all signals
276 * 30 adc counts above threshold you should call the function like this: ZeroSuppress(-1,30)
277 * @param nSigma Specify nSigma above threshold default=3
278 * @param threshold Specify what adc threshold above average default=20 (remember to give nSigma=-1 if you want to use this approach)
279 * @param reqMinPoint Required minimum number of points to do zerosuppression default AliHLTTPCTransform::GetNTimeBins/2 (1024/2).
280 * @param beginTime Lowest timebin value. Gating grid causes some problems in the first timebins. default= 50
281 * @param endTime Highest timebin value. Default AliHLTTPCTransform::GetNTimeBins-1
282 */
283 void ZeroSuppress(Double_t nSigma,Int_t threshold,Int_t reqMinPoint,Int_t beginTime,Int_t endTime);
284
01f43166 285 /**
286 * Finds the cluster candidate. If atleast two signals in the data array are neighbours
287 * they are stored in a cluster candidate vector.
288 */
289 void FindClusterCandidates();
290 /**
291 * Prints the raw data og this pad.
292 */
293 void PrintRawData();
b1c46961 294
295 /**
296 * Set the Signal Threshold
297 */
298 void SetSignalThreshold(Int_t i){fSignalThreshold=i;}
299
300 /**
301 * Set the nSigma threshold
302 */
303 void SetNSigmaThreshold(Double_t i){fNSigmaThreshold=i;}
304
305
01f43166 306 /**
307 * Vector of cluster candidates
308 */
a1dbf058 309 vector<AliHLTTPCClusters> fClusterCandidates; //! transient
01f43166 310
311 /**
312 * Vector of used clustercandidates, used so one do not use candidates multiple times
313 */
a1dbf058 314 vector<Int_t> fUsedClusterCandidates; //! transient
46b33a24 315
316 private:
a1dbf058 317 /** copy constructor prohibited */
318 AliHLTTPCPad(const AliHLTTPCPad&);
319 /** assignment operator prohibited */
320 AliHLTTPCPad& operator=(const AliHLTTPCPad&);
321
46b33a24 322 /**
323 * Add a value to the base line calculation.
324 * The value is been added to the sum if it exceeds the current base line
325 * and bin is equal or greater than the first bin for base line calculation.
326 * @param bin Channel number
327 * @param value ADC value
328 */
329 Int_t AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value);
330
331 /** The row number of the pad */
2a083ac4 332 Int_t fRowNo; // see above
46b33a24 333 /** The pad number of the pad */
2a083ac4 334 Int_t fPadNo; // see above
46b33a24 335 /** Threshold for zero suppression */
2a083ac4 336 AliHLTTPCSignal_t fThreshold; // see above
46b33a24 337 /** The average base line value */
2a083ac4 338 AliHLTTPCSignal_t fAverage; // see above
46b33a24 339 /** Number of events included in the base line calculation*/
2a083ac4 340 Int_t fNofEvents; // see above
46b33a24 341 /** The sum within one event */
2a083ac4 342 AliHLTTPCSignal_t fSum; // see above
46b33a24 343 /** The number of bins contributing to the sum */
2a083ac4 344 Int_t fCount; // see above
46b33a24 345 /** The total number of bins already set during the event */
2a083ac4 346 Int_t fTotal; // see above
46b33a24 347 /** The maximum base line value within one event */
2a083ac4 348 AliHLTTPCSignal_t fBLMax; // see above
46b33a24 349 /** The bin for the maximum bl value within one event */
2a083ac4 350 Int_t fBLMaxBin; // see above
84645eb0 351 /** The minimum base line value within one event */
2a083ac4 352 AliHLTTPCSignal_t fBLMin; // see above
84645eb0 353 /** The bin for the minimum bl value within one event */
2a083ac4 354 Int_t fBLMinBin; // see above
46b33a24 355 /** The first bin included in the base line calculation */
2a083ac4 356 Int_t fFirstBLBin; // see above
46b33a24 357 /** Number of bins */
2a083ac4 358 Int_t fNofBins; // see above
46b33a24 359
360 /** The current read position */
2a083ac4 361 Int_t fReadPos; // see above
46b33a24 362
363 /** The raw data history */
2a083ac4 364 AliHLTTPCSignal_t* fpRawData; //! transient
46b33a24 365
01f43166 366 /**
367 * Array containing the data
368 */
a1dbf058 369 AliHLTTPCSignal_t* fDataSignals; //! transient
01f43166 370
371 /**
372 * Array containing info on which bins have signals
373 */
a1dbf058 374 Int_t *fSignalPositionArray; //! transient
375 Int_t fSizeOfSignalPositionArray; //! transient
b1c46961 376
377 Double_t fNSigmaThreshold; //! transient
378 Double_t fSignalThreshold; //! transient
01f43166 379
b1c46961 380 ClassDef(AliHLTTPCPad, 3)
46b33a24 381};
a1dbf058 382#endif // ALIHLTTPCPAD_H