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