]>
Commit | Line | Data |
---|---|---|
6b15c309 | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Timm Steinbeck, Matthias Richter * | |
8 | //* Developers: Kenneth Aamodt <kenneth.aamodt@student.uib.no> * | |
9 | //* for The ALICE HLT Project. * | |
10 | //* * | |
11 | //* Permission to use, copy, modify and distribute this software and its * | |
12 | //* documentation strictly for non-commercial purposes is hereby granted * | |
13 | //* without fee, provided that the above copyright notice appears in all * | |
14 | //* copies and that both the copyright notice and this permission notice * | |
15 | //* appear in the supporting documentation. The authors make no claims * | |
16 | //* about the suitability of this software for any purpose. It is * | |
17 | //* provided "as is" without express or implied warranty. * | |
18 | //************************************************************************** | |
46b33a24 | 19 | |
20 | /** @file AliHLTTPCPad.cxx | |
01f43166 | 21 | @author Matthias Richter, Kenneth Aamodt |
46b33a24 | 22 | @date |
23 | @brief Container Class for TPC Pads. | |
24 | */ | |
25 | ||
26 | #if __GNUC__>= 3 | |
27 | using namespace std; | |
28 | #endif | |
29 | ||
30 | #include <cerrno> | |
31 | #include "AliHLTTPCPad.h" | |
84645eb0 | 32 | #include "AliHLTStdIncludes.h" |
46b33a24 | 33 | |
01f43166 | 34 | |
35 | //added by kenneth | |
36 | #include "AliHLTTPCTransform.h" | |
37 | #include "AliHLTTPCClusters.h" | |
38 | #include <sys/time.h> | |
afa4418c | 39 | #include "TMath.h" |
40 | #include "TFile.h" | |
01f43166 | 41 | //------------------------------ |
42 | ||
46b33a24 | 43 | /** margin for the base line be re-avaluated */ |
44 | #define ALIHLTPAD_BASELINE_MARGIN (2*fAverage) | |
45 | ||
46 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
47 | ClassImp(AliHLTTPCPad) | |
48 | ||
49 | AliHLTTPCPad::AliHLTTPCPad() | |
50 | : | |
a1dbf058 | 51 | fClusterCandidates(), |
52 | fUsedClusterCandidates(), | |
2fdb1ae7 | 53 | fSelectedPad(kFALSE), |
54 | fHWAddress(0), | |
46b33a24 | 55 | fRowNo(-1), |
56 | fPadNo(-1), | |
57 | fThreshold(0), | |
58 | fAverage(-1), | |
59 | fNofEvents(0), | |
60 | fSum(0), | |
2a083ac4 | 61 | fCount(0), |
62 | fTotal(0), | |
46b33a24 | 63 | fBLMax(-1), |
64 | fBLMaxBin(-1), | |
84645eb0 | 65 | fBLMin(-1), |
66 | fBLMinBin(-1), | |
46b33a24 | 67 | fFirstBLBin(0), |
68 | fNofBins(0), | |
2a083ac4 | 69 | fReadPos(0), |
01f43166 | 70 | fpRawData(NULL), |
01f43166 | 71 | fDataSignals(NULL), |
72 | fSignalPositionArray(NULL), | |
b1c46961 | 73 | fSizeOfSignalPositionArray(0), |
deba5d85 | 74 | fNGoodSignalsSent(0), |
75 | fCandidateDigitsVector() | |
46b33a24 | 76 | { |
2a083ac4 | 77 | // see header file for class documentation |
78 | // or | |
79 | // refer to README to build package | |
80 | // or | |
81 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
01f43166 | 82 | // HLTInfo("Entering default constructor"); |
83 | fDataSignals= new AliHLTTPCSignal_t[AliHLTTPCTransform::GetNTimeBins()]; | |
84 | memset( fDataSignals, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins())); | |
8252a538 | 85 | |
a74855c2 | 86 | fSignalPositionArray= new Int_t[AliHLTTPCTransform::GetNTimeBins()]; |
01f43166 | 87 | memset( fSignalPositionArray, 0xFF, sizeof(Int_t)*(AliHLTTPCTransform::GetNTimeBins())); |
88 | fSizeOfSignalPositionArray=0; | |
afa4418c | 89 | |
46b33a24 | 90 | } |
91 | ||
c9602aeb | 92 | AliHLTTPCPad::AliHLTTPCPad(Int_t /*dummy*/) |
8252a538 | 93 | : |
a74855c2 | 94 | fClusterCandidates(), |
95 | fUsedClusterCandidates(), | |
2fdb1ae7 | 96 | fSelectedPad(kFALSE), |
97 | fHWAddress(0), | |
8252a538 | 98 | fRowNo(-1), |
99 | fPadNo(-1), | |
100 | fThreshold(0), | |
101 | fAverage(-1), | |
102 | fNofEvents(0), | |
103 | fSum(0), | |
104 | fCount(0), | |
105 | fTotal(0), | |
106 | fBLMax(-1), | |
107 | fBLMaxBin(-1), | |
108 | fBLMin(-1), | |
109 | fBLMinBin(-1), | |
110 | fFirstBLBin(0), | |
111 | fNofBins(0), | |
112 | fReadPos(0), | |
113 | fpRawData(NULL), | |
114 | fDataSignals(NULL), | |
115 | fSignalPositionArray(NULL), | |
116 | fSizeOfSignalPositionArray(0), | |
deba5d85 | 117 | fNGoodSignalsSent(0), |
118 | fCandidateDigitsVector() | |
8252a538 | 119 | { |
120 | // see header file for class documentation | |
121 | // or | |
122 | // refer to README to build package | |
123 | // or | |
124 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
125 | } | |
126 | ||
46b33a24 | 127 | AliHLTTPCPad::AliHLTTPCPad(Int_t offset, Int_t nofBins) |
128 | : | |
a1dbf058 | 129 | fClusterCandidates(), |
130 | fUsedClusterCandidates(), | |
2fdb1ae7 | 131 | fSelectedPad(kFALSE), |
132 | fHWAddress(0), | |
46b33a24 | 133 | fRowNo(-1), |
134 | fPadNo(-1), | |
135 | fThreshold(0), | |
136 | fAverage(-1), | |
137 | fNofEvents(0), | |
138 | fSum(0), | |
2a083ac4 | 139 | fCount(0), |
140 | fTotal(0), | |
46b33a24 | 141 | fBLMax(-1), |
142 | fBLMaxBin(-1), | |
84645eb0 | 143 | fBLMin(-1), |
144 | fBLMinBin(-1), | |
46b33a24 | 145 | fFirstBLBin(offset), |
146 | fNofBins(nofBins), | |
2a083ac4 | 147 | fReadPos(0), |
01f43166 | 148 | fpRawData(NULL), |
01f43166 | 149 | fDataSignals(NULL), |
150 | fSignalPositionArray(NULL), | |
b1c46961 | 151 | fSizeOfSignalPositionArray(0), |
deba5d85 | 152 | fNGoodSignalsSent(0), |
153 | fCandidateDigitsVector() | |
46b33a24 | 154 | { |
2a083ac4 | 155 | // see header file for class documentation |
46b33a24 | 156 | } |
157 | ||
46b33a24 | 158 | AliHLTTPCPad::~AliHLTTPCPad() |
159 | { | |
2a083ac4 | 160 | // see header file for class documentation |
46b33a24 | 161 | if (fpRawData) { |
162 | HLTWarning("event data acquisition not stopped"); | |
163 | StopEvent(); | |
164 | } | |
01f43166 | 165 | if (fDataSignals) { |
afa4418c | 166 | delete [] fDataSignals; |
01f43166 | 167 | fDataSignals=NULL; |
01f43166 | 168 | } |
a74855c2 | 169 | if (fSignalPositionArray!=NULL) { |
afa4418c | 170 | delete [] fSignalPositionArray; |
01f43166 | 171 | fSignalPositionArray=NULL; |
01f43166 | 172 | } |
46b33a24 | 173 | } |
174 | ||
175 | Int_t AliHLTTPCPad::SetID(Int_t rowno, Int_t padno) | |
176 | { | |
2a083ac4 | 177 | // see header file for class documentation |
46b33a24 | 178 | fRowNo=rowno; |
179 | fPadNo=padno; | |
afa4418c | 180 | |
2a083ac4 | 181 | return 0; |
46b33a24 | 182 | } |
183 | ||
184 | Int_t AliHLTTPCPad::StartEvent() | |
185 | { | |
2a083ac4 | 186 | // see header file for class documentation |
46b33a24 | 187 | Int_t iResult=0; |
188 | if (fpRawData==NULL) { | |
189 | fBLMax=-1; | |
190 | fBLMaxBin=-1; | |
84645eb0 | 191 | fBLMin=-1; |
192 | fBLMinBin=-1; | |
46b33a24 | 193 | fSum=0; |
194 | fCount=0; | |
195 | fTotal=0; | |
196 | if (fNofBins>0) { | |
197 | fpRawData=new AliHLTTPCSignal_t[fNofBins]; | |
198 | if (fpRawData) { | |
199 | for (int i=0; i<fNofBins; i++) fpRawData[i]=-1; | |
200 | } else { | |
201 | HLTError("memory allocation failed"); | |
202 | iResult=-ENOMEM; | |
203 | } | |
204 | } | |
205 | } else { | |
206 | HLTWarning("event data acquisition already started"); | |
207 | iResult=-EALREADY; | |
208 | } | |
209 | return iResult; | |
210 | } | |
211 | ||
212 | Int_t AliHLTTPCPad::CalculateBaseLine(Int_t reqMinCount) | |
213 | { | |
2a083ac4 | 214 | // see header file for class documentation |
46b33a24 | 215 | Int_t iResult=0; |
216 | AliHLTTPCSignal_t avBackup=fAverage; | |
84645eb0 | 217 | //HLTDebug("reqMinCount=%d fCount=%d fTotal=%d fSum=%d fBLMax=%d fBLMin=%d", reqMinCount, fCount, fTotal, fSum, fBLMax, fBLMin); |
46b33a24 | 218 | if (fCount>=reqMinCount && fCount>=fTotal/2) { |
219 | fAverage=fCount>0?fSum/fCount:0; | |
220 | if (fAverage>0) { | |
84645eb0 | 221 | //HLTDebug("average for current event %d (%d - %d)", fAverage, fBLMax, fBLMin); |
46b33a24 | 222 | fCount=0;fSum=-1; |
223 | if (fBLMax>ALIHLTPAD_BASELINE_MARGIN) { | |
224 | // calculate again | |
21b6a334 | 225 | //HLTDebug("maximum value %d exceeds margin for base line (%d) " |
226 | // "-> re-evaluate base line", fBLMax, ALIHLTPAD_BASELINE_MARGIN); | |
46b33a24 | 227 | if (fpRawData) { |
228 | for (Int_t i=fFirstBLBin; i<fNofBins; i++) | |
229 | if (fpRawData[i]>=0) AddBaseLineValue(i, fpRawData[i]); | |
230 | if (fCount>0 && fCount>=reqMinCount && fCount>=fTotal/2) { | |
231 | fAverage=fSum/fCount; | |
3cde846d | 232 | //HLTDebug("new average %d", fAverage); |
46b33a24 | 233 | } else { |
b1c46961 | 234 | // HLTDebug("baseline re-eveluation skipped because of to few " |
235 | // "contributing bins: total=%d, contributing=%d, req=%d" | |
236 | // "\ndata might be already zero suppressed" | |
237 | // , fTotal, fCount, reqMinCount); | |
46b33a24 | 238 | iResult=-ENODATA; |
239 | } | |
240 | fCount=0;fSum=-1; | |
241 | } else { | |
242 | HLTError("missing raw data for base line calculation"); | |
243 | iResult=-ENOBUFS; | |
244 | } | |
245 | } | |
246 | if (iResult>=0) { | |
247 | // calculate average for all events | |
248 | fAverage=((avBackup*fNofEvents)+fAverage)/(fNofEvents+1); | |
84645eb0 | 249 | //HLTDebug("base line average for %d event(s): %d", fNofEvents+1, fAverage); |
46b33a24 | 250 | } else { |
251 | fAverage=avBackup; | |
252 | } | |
253 | } else { | |
254 | fAverage=avBackup; | |
255 | } | |
256 | } else { | |
b1c46961 | 257 | // HLTDebug("baseline calculation skipped because of to few contributing " |
258 | // "bins: total=%d, contributing=%d, required=%d \ndata might be " | |
259 | // "already zero suppressed", fTotal, fCount, reqMinCount); | |
46b33a24 | 260 | } |
261 | ||
262 | return iResult; | |
263 | } | |
264 | ||
265 | Int_t AliHLTTPCPad::StopEvent() | |
266 | { | |
2a083ac4 | 267 | // see header file for class documentation |
46b33a24 | 268 | Int_t iResult=0; |
269 | if (fpRawData) { | |
270 | AliHLTTPCSignal_t* pData=fpRawData; | |
271 | fpRawData=NULL; | |
272 | delete [] pData; | |
273 | fTotal=0; | |
274 | fNofEvents++; | |
275 | Rewind(); | |
276 | } else if (fNofBins>0) { | |
277 | HLTError("event data acquisition not started"); | |
278 | iResult=-EBADF; | |
279 | } | |
280 | return iResult; | |
281 | } | |
282 | ||
283 | Int_t AliHLTTPCPad::ResetHistory() | |
284 | { | |
2a083ac4 | 285 | // see header file for class documentation |
46b33a24 | 286 | Int_t iResult=0; |
287 | fAverage=-1; | |
288 | fNofEvents=0; | |
289 | return iResult; | |
290 | } | |
291 | ||
292 | Int_t AliHLTTPCPad::SetThreshold(AliHLTTPCSignal_t thresh) | |
293 | { | |
2a083ac4 | 294 | // see header file for class documentation |
46b33a24 | 295 | Int_t iResult=0; |
296 | fThreshold=thresh; | |
297 | return iResult; | |
298 | } | |
299 | ||
300 | Int_t AliHLTTPCPad::AddBaseLineValue(Int_t bin, AliHLTTPCSignal_t value) | |
301 | { | |
2a083ac4 | 302 | // see header file for class documentation |
46b33a24 | 303 | Int_t iResult=0; |
304 | if (bin>=fFirstBLBin) { | |
305 | if (fAverage<0 || value<ALIHLTPAD_BASELINE_MARGIN) { | |
306 | // add to the current sum and count | |
307 | fSum+=value; | |
308 | fCount++; | |
309 | if (fBLMax<value) { | |
310 | // keep the maximum value for later quality control of the base | |
311 | // line calculation | |
312 | fBLMax=value; | |
313 | fBLMaxBin=bin; | |
314 | } | |
84645eb0 | 315 | if (fBLMin<0 || fBLMin>value) { |
316 | // keep the minimum value for later quality control of the base | |
317 | // line calculation | |
318 | fBLMin=value; | |
319 | fBLMinBin=bin; | |
320 | } | |
46b33a24 | 321 | } else { |
b1c46961 | 322 | // HLTDebug("ignoring value %d (bin %d) for base line calculation " |
323 | // "(current average is %d)", | |
324 | // value, bin, fAverage); | |
46b33a24 | 325 | } |
326 | } | |
327 | return iResult; | |
328 | } | |
329 | ||
330 | Int_t AliHLTTPCPad::SetRawData(Int_t bin, AliHLTTPCSignal_t value) | |
331 | { | |
2a083ac4 | 332 | // see header file for class documentation |
afa4418c | 333 | // printf("Row: %d Pad: %d Time: %d Charge %d", fRowNo, fPadNo, bin, value); |
46b33a24 | 334 | Int_t iResult=0; |
335 | if (fpRawData) { | |
336 | if (bin<fNofBins) { | |
337 | if (value>=0) { | |
338 | if (fpRawData[bin]<0) { | |
339 | AddBaseLineValue(bin, value); | |
340 | fTotal++; | |
341 | } else { | |
342 | // ignore value for average calculation | |
84645eb0 | 343 | HLTWarning("overriding content of bin %d (%d)", bin, fpRawData[bin]); |
46b33a24 | 344 | } |
345 | fpRawData[bin]=value; | |
346 | } else { | |
347 | HLTWarning("ignoring neg. raw data"); | |
348 | } | |
349 | } else { | |
350 | HLTWarning("bin %d out of range (%d)", bin, fNofBins); | |
351 | iResult=-ERANGE; | |
352 | } | |
353 | } else if (fNofBins>0) { | |
354 | HLTError("event cycle not started"); | |
355 | iResult=-EBADF; | |
356 | } | |
357 | return iResult; | |
358 | } | |
359 | ||
360 | Int_t AliHLTTPCPad::Next(Int_t bZeroSuppression) | |
361 | { | |
2a083ac4 | 362 | // see header file for class documentation |
46b33a24 | 363 | if (fpRawData==NULL) return 0; |
364 | Int_t iResult=fReadPos<fNofBins; | |
365 | if (iResult>0 && (iResult=(++fReadPos<fNofBins))>0) { | |
366 | if (bZeroSuppression) { | |
367 | while ((iResult=(fReadPos<fNofBins))>0 && | |
368 | GetCorrectedData(fReadPos)<=0) | |
369 | fReadPos++; | |
370 | } | |
371 | } | |
372 | return iResult; | |
373 | } | |
374 | ||
375 | Int_t AliHLTTPCPad::Rewind(Int_t bZeroSuppression) | |
376 | { | |
2a083ac4 | 377 | // see header file for class documentation |
46b33a24 | 378 | fReadPos=(bZeroSuppression>0?0:fFirstBLBin)-1; |
379 | return Next(bZeroSuppression); | |
380 | } | |
381 | ||
382 | AliHLTTPCSignal_t AliHLTTPCPad::GetRawData(Int_t bin) const | |
383 | { | |
2a083ac4 | 384 | // see header file for class documentation |
46b33a24 | 385 | AliHLTTPCSignal_t data=0; |
386 | if (fpRawData) { | |
387 | if (bin<fNofBins) { | |
388 | data=fpRawData[bin]; | |
389 | } else { | |
390 | HLTWarning("requested bin %d out of range (%d)", bin, fNofBins); | |
391 | } | |
392 | } else if (fNofBins>0) { | |
393 | HLTWarning("data only available within event cycle"); | |
394 | } | |
395 | return data; | |
396 | } | |
397 | ||
398 | AliHLTTPCSignal_t AliHLTTPCPad::GetCorrectedData(Int_t bin) const | |
399 | { | |
2a083ac4 | 400 | // see header file for class documentation |
46b33a24 | 401 | AliHLTTPCSignal_t data=GetRawData(bin)-GetBaseLine(bin); |
5235c3e9 | 402 | AliHLTTPCSignal_t prev=0; |
403 | if (bin>1) prev=GetRawData(bin-1)-GetBaseLine(bin-1); | |
404 | AliHLTTPCSignal_t succ=0; | |
405 | if (bin+1<GetSize()) succ=GetRawData(bin+1)-GetBaseLine(bin+1); | |
406 | if (fThreshold>0) { | |
407 | data-=fThreshold; | |
408 | prev-=fThreshold; | |
409 | succ-=fThreshold; | |
410 | } | |
411 | ||
412 | // case 1: | |
413 | // the signal is below the base-line and threshold | |
46b33a24 | 414 | if (data<0) data=0; |
5235c3e9 | 415 | |
416 | //case 2: | |
417 | // the neighboring bins are both below base-line/threshold | |
418 | // a real signal is always more than one bin wide because of the shaper | |
419 | if (prev<=0 && succ<=0) data=0; | |
420 | ||
421 | // case 3: | |
422 | // the bin is inside the range of ignored bins | |
46b33a24 | 423 | if (bin<fFirstBLBin) data=0; |
84645eb0 | 424 | //HLTDebug("fReadPos=%d data=%d threshold=%d raw data=%d base line=%d", fReadPos, data, fThreshold, GetRawData(bin), GetBaseLine(bin)); |
46b33a24 | 425 | return data; |
426 | } | |
427 | ||
5d2abf3b | 428 | AliHLTTPCSignal_t AliHLTTPCPad::GetBaseLine(Int_t /*bin*/) const //TODO: Why is bin being ignored? |
46b33a24 | 429 | { |
2a083ac4 | 430 | // see header file for class documentation |
84645eb0 | 431 | AliHLTTPCSignal_t val=0; |
432 | if (fAverage>0) { | |
433 | // we take the minumum value as the base line if it doesn't differ from | |
434 | // the average to much | |
84645eb0 | 435 | val=fAverage; |
5235c3e9 | 436 | #ifdef KEEP_NOISE |
2a083ac4 | 437 | const AliHLTTPCSignal_t kMaxDifference=15; |
84645eb0 | 438 | if ((fAverage-fBLMin)<=kMaxDifference) val=fBLMin; |
439 | else val>kMaxDifference?val-=kMaxDifference:0; | |
5235c3e9 | 440 | #endif |
84645eb0 | 441 | } |
442 | if (val<0) { | |
443 | // here we should never get | |
444 | val=0; | |
445 | HLTFatal("wrong base line value"); | |
446 | } | |
447 | return val; | |
46b33a24 | 448 | } |
449 | ||
450 | AliHLTTPCSignal_t AliHLTTPCPad::GetAverage() const | |
451 | { | |
2a083ac4 | 452 | // see header file for class documentation |
46b33a24 | 453 | return fAverage>0?fAverage:0; |
454 | } | |
455 | ||
5235c3e9 | 456 | Float_t AliHLTTPCPad::GetOccupancy() const |
457 | { | |
2a083ac4 | 458 | // see header file for class documentation |
5235c3e9 | 459 | Float_t occupancy=0; |
460 | if (fpRawData && fNofBins>0) { | |
461 | for (Int_t i=fFirstBLBin; i<fNofBins; i++) { | |
462 | if (GetCorrectedData(i)>0) occupancy+=1; | |
463 | } | |
464 | if (fNofBins-fFirstBLBin>0) | |
465 | occupancy/=fNofBins-fFirstBLBin; | |
466 | } | |
467 | return occupancy; | |
468 | } | |
469 | ||
470 | Float_t AliHLTTPCPad::GetAveragedOccupancy() const | |
471 | { | |
2a083ac4 | 472 | // see header file for class documentation |
473 | ||
5235c3e9 | 474 | // history is not yet implemented |
475 | return GetOccupancy(); | |
476 | } | |
a1dbf058 | 477 | void AliHLTTPCPad::PrintRawData() |
478 | { | |
479 | // see header file for class documentation | |
01f43166 | 480 | for(Int_t bin=0;bin<AliHLTTPCTransform::GetNTimeBins();bin++){ |
481 | if(GetDataSignal(bin)>0) | |
a74855c2 | 482 | //This cout should be here since using logging produces output that is much more difficult to read |
483 | cout<<fRowNo<<"\t"<<fPadNo<<"\t"<<bin<<"\t"<<GetDataSignal(bin)<<endl; | |
01f43166 | 484 | } |
01f43166 | 485 | } |
486 | ||
8252a538 | 487 | void AliHLTTPCPad::ClearCandidates(){ |
488 | fClusterCandidates.clear(); | |
489 | fUsedClusterCandidates.clear(); | |
deba5d85 | 490 | fCandidateDigitsVector.clear(); |
8252a538 | 491 | } |
492 | ||
a1dbf058 | 493 | void AliHLTTPCPad::SetDataToDefault() |
494 | { | |
495 | // see header file for class documentation | |
a74855c2 | 496 | // if(fDataSignals && fSignalPositionArray){ |
afa4418c | 497 | for(Int_t i =0;i<fSizeOfSignalPositionArray;i++){ |
498 | fDataSignals[fSignalPositionArray[i]]=-1; | |
499 | } | |
01f43166 | 500 | fSizeOfSignalPositionArray=0; |
a74855c2 | 501 | fNGoodSignalsSent = 0; |
502 | // } | |
01f43166 | 503 | } |
a1dbf058 | 504 | |
505 | void AliHLTTPCPad::SetDataSignal(Int_t bin,Int_t signal) | |
506 | { | |
507 | // see header file for class documentation | |
01f43166 | 508 | fDataSignals[bin]=signal; |
509 | fSignalPositionArray[fSizeOfSignalPositionArray]=bin; | |
510 | fSizeOfSignalPositionArray++; | |
afa4418c | 511 | } |
512 | ||
c0971196 | 513 | Bool_t AliHLTTPCPad::GetNextGoodSignal(Int_t &time,Int_t &bunchSize){ |
a1dbf058 | 514 | |
a74855c2 | 515 | if(fNGoodSignalsSent<fSizeOfSignalPositionArray&&fSizeOfSignalPositionArray>0){ |
516 | time = fSignalPositionArray[fNGoodSignalsSent]; | |
517 | bunchSize=1; | |
518 | fNGoodSignalsSent++; | |
519 | while(fNGoodSignalsSent<fSizeOfSignalPositionArray){ | |
520 | if(fDataSignals[time+bunchSize+1]>0){ | |
521 | bunchSize++; | |
522 | fNGoodSignalsSent++; | |
523 | } | |
524 | else{ | |
525 | break; | |
526 | } | |
527 | } | |
deba5d85 | 528 | // fNGoodSignalsSent++; |
a74855c2 | 529 | return kTRUE; |
530 | } | |
531 | return kFALSE; | |
532 | } | |
533 | ||
a1dbf058 | 534 | Int_t AliHLTTPCPad::GetDataSignal(Int_t bin) const |
535 | { | |
536 | // see header file for class documentation | |
01f43166 | 537 | return fDataSignals[bin]; |
538 | } | |
a1dbf058 | 539 | |
74b8bf74 | 540 | void AliHLTTPCPad::ZeroSuppress(Double_t nRMS, Int_t threshold, Int_t reqMinPoint, Int_t beginTime, Int_t endTime, Int_t timebinsLeft, Int_t timebinsRight, Int_t valueUnderAverage, bool speedup){ |
b1c46961 | 541 | //see headerfile for documentation |
542 | ||
afa4418c | 543 | //HLTDebug("In Pad: nRMS=%d, threshold=%d, reqMinPoint=%d, beginTime=%d, endTime=%d, timebinsLeft=%d timebinsRight=%d valueUnderAverage=%d \n",nRMS,threshold,reqMinPoint,beginTime,endTime,timebinsLeft,timebinsRight,valueUnderAverage); |
544 | ||
545 | Bool_t useRMS= kFALSE; | |
546 | if(nRMS>0){ | |
547 | useRMS=kTRUE; | |
548 | if(threshold>0){ | |
549 | HLTInfo("Both RMSThreshold and SignalThreshold defined, using RMSThreshold"); | |
550 | } | |
b1c46961 | 551 | } |
afa4418c | 552 | if(threshold<1 && nRMS<=0){ |
b1c46961 | 553 | //setting the data to -1 for this pad |
afa4418c | 554 | HLTInfo("Neither of RMSThreshold and SignalThreshold set, zerosuppression aborted"); |
b1c46961 | 555 | return; |
556 | } | |
b1c46961 | 557 | |
558 | Int_t fThresholdUsed=threshold; | |
74b8bf74 | 559 | |
560 | Int_t maxVal=0; | |
b1c46961 | 561 | Int_t nAdded=0; |
562 | Int_t sumNAdded=0; | |
563 | fSizeOfSignalPositionArray=0; | |
afa4418c | 564 | if(useRMS){ |
565 | for(Int_t i=beginTime;i<endTime+1;i++){ | |
566 | if(fDataSignals[i]>0){ | |
567 | nAdded++; | |
568 | sumNAdded+=fDataSignals[i]*fDataSignals[i]; | |
74b8bf74 | 569 | if (maxVal<fDataSignals[i]) maxVal=fDataSignals[i]; |
afa4418c | 570 | } |
b1c46961 | 571 | } |
572 | } | |
afa4418c | 573 | else if(threshold>0){ |
574 | for(Int_t i=beginTime;i<endTime+1;i++){ | |
b1c46961 | 575 | if(fDataSignals[i]>0){ |
afa4418c | 576 | nAdded++; |
577 | sumNAdded+=fDataSignals[i]; | |
74b8bf74 | 578 | if (maxVal<fDataSignals[i]) maxVal=fDataSignals[i]; |
b1c46961 | 579 | } |
580 | } | |
b1c46961 | 581 | } |
afa4418c | 582 | else{ |
583 | HLTFatal("This should never happen because this is tested earlier in the code.(nRMSThreshold<1&&signal-threshold<1)"); | |
584 | } | |
585 | if(nAdded<reqMinPoint){ | |
586 | HLTInfo("Number of signals is less than required, zero suppression aborted"); | |
587 | return; | |
b1c46961 | 588 | } |
afa4418c | 589 | |
590 | if(nAdded==0){ | |
591 | HLTInfo("No signals added for this pad, zerosuppression aborted: pad %d row %d",fPadNo,fRowNo); | |
592 | return; | |
b1c46961 | 593 | } |
a74855c2 | 594 | |
afa4418c | 595 | Double_t averageValue=(Double_t)sumNAdded/nAdded;//true average for threshold approach, average of signals squared for rms approach |
b1c46961 | 596 | |
afa4418c | 597 | if(useRMS){ |
598 | //Calculate the RMS | |
599 | if(averageValue>0){ | |
600 | fThresholdUsed =(Int_t)(TMath::Sqrt(averageValue)*nRMS); | |
601 | } | |
602 | else{ | |
603 | HLTFatal("average value in ZeroSuppression less than 0, investigation needed. This should never happen"); | |
604 | } | |
605 | } | |
606 | else{ | |
607 | fThresholdUsed = (Int_t)(averageValue + threshold); | |
608 | } | |
74b8bf74 | 609 | if (maxVal<fThresholdUsed) return; |
afa4418c | 610 | |
a74855c2 | 611 | // Do zero suppression on the adc values within [beginTime,endTime](add the good values) |
afa4418c | 612 | for(Int_t i=beginTime;i<endTime;i++){ |
613 | if(fDataSignals[i]>fThresholdUsed){ | |
afa4418c | 614 | Int_t firstSignalTime=i; |
615 | for(Int_t left=1;left<timebinsLeft;left++){//looking 5 to the left of the signal to add tail | |
a74855c2 | 616 | if(fDataSignals[i-left]-averageValue+valueUnderAverage>0 && i-left>=beginTime){ |
afa4418c | 617 | firstSignalTime--; |
b1c46961 | 618 | } |
afa4418c | 619 | else{ |
620 | break; | |
b1c46961 | 621 | } |
622 | } | |
afa4418c | 623 | Int_t lastSignalTime=i; |
a74855c2 | 624 | while(fDataSignals[lastSignalTime+1]>fThresholdUsed && lastSignalTime+1<endTime){ |
625 | lastSignalTime++; | |
626 | } | |
afa4418c | 627 | for(Int_t right=1;right<timebinsRight;right++){//looking 5 to the left of the signal to add tail |
628 | if(fDataSignals[i+right]-averageValue+valueUnderAverage>0&&i+right<endTime){ | |
629 | lastSignalTime++; | |
b1c46961 | 630 | } |
631 | else{ | |
afa4418c | 632 | break; |
633 | } | |
634 | } | |
a74855c2 | 635 | |
afa4418c | 636 | for(Int_t t=firstSignalTime;t<lastSignalTime;t++){ |
afa4418c | 637 | fDataSignals[t]=(AliHLTTPCSignal_t)(fDataSignals[t]-averageValue + valueUnderAverage); |
afa4418c | 638 | fSignalPositionArray[fSizeOfSignalPositionArray]=t; |
639 | fSizeOfSignalPositionArray++; | |
74b8bf74 | 640 | // Matthias Oct 10 2008: trying hard to make the code faster for the |
641 | // AltroChannelSelection. For that we only need to know there is data | |
642 | if (speedup) return; | |
b1c46961 | 643 | } |
afa4418c | 644 | i+=lastSignalTime; |
b1c46961 | 645 | } |
a74855c2 | 646 | } |
647 | //reset the rest of the data | |
648 | Int_t counterSize=fSizeOfSignalPositionArray; | |
649 | ||
650 | for(Int_t d=endTime;d>=beginTime;d--){ | |
651 | if(d==fSignalPositionArray[counterSize-1]&&counterSize-1>=0){ | |
652 | counterSize--; | |
653 | } | |
b1c46961 | 654 | else{ |
a74855c2 | 655 | fDataSignals[d]=-1; |
afa4418c | 656 | } |
b1c46961 | 657 | } |
a74855c2 | 658 | if(fDataSignals[beginTime+1]<1){ |
659 | fDataSignals[beginTime]=0; | |
660 | } | |
b1c46961 | 661 | } |
afa4418c | 662 | |
bd8210c3 | 663 | void AliHLTTPCPad::AddClusterCandidate(const AliHLTTPCClusters& candidate){ |
8252a538 | 664 | fClusterCandidates.push_back(candidate); |
665 | fUsedClusterCandidates.push_back(0); | |
666 | } | |
deba5d85 | 667 | |
bd8210c3 | 668 | void AliHLTTPCPad::AddCandidateDigits(const vector<AliHLTTPCDigitData>& candidateDigits){ |
deba5d85 | 669 | fCandidateDigitsVector.push_back(candidateDigits); |
670 | } | |
671 | ||
0f98f30d | 672 | vector<AliHLTTPCDigitData> *AliHLTTPCPad::GetCandidateDigits(Int_t candidateIndex){ |
1be5a40d | 673 | return (size_t(candidateIndex) < fCandidateDigitsVector.size()) ? &fCandidateDigitsVector.at(candidateIndex) :0; |
deba5d85 | 674 | } |