ATTPCROOT  0.3.0-alpha
A ROOT-based framework for analyzing data from active target detectors
AtFilterZero.cxx
Go to the documentation of this file.
1 #include "AtFilterZero.h"
2 
3 #include "AtPad.h"
4 
5 struct AtPadReference;
6 
7 void AtFilterZero::Filter(AtPad *pad, AtPadReference *padReference)
8 {
9  bool inZeroRange = false;
10  int zeroStart = -1;
11 
12  for (int i = 0; i < 512; ++i) {
13 
14  if (pad->GetRawADC(i) == 0 && !inZeroRange) {
15  inZeroRange = true;
16  zeroStart = i;
17  continue;
18  }
19 
20  if (inZeroRange && pad->GetRawADC(i) != 0) {
21  // We just left a zero region fill the missing data
22  fillMissingData(pad, zeroStart, i);
23  // fillMissingDataLine(pad, zeroStart, i);
24  inZeroRange = false;
25  zeroStart = -1;
26  }
27  }
28 }
30 void AtFilterZero::fillMissingData(AtPad *pad, int start, int stop)
31 {
32  double avg = pad->GetRawADC(start - 1) + pad->GetRawADC(stop);
33  avg /= 2.0;
34 
35  double avgSub = pad->GetADC(start - 1) + pad->GetADC(stop);
36  avgSub /= 2.0;
37 
38  double transition = std::abs(pad->GetRawADC(start - 1) - pad->GetRawADC(stop));
39 
40  if (transition > fThreshold) {
41  if (start >= 1) {
42  avg = pad->GetRawADC(start - 1);
43  avgSub = pad->GetADC(start - 1);
44  } else {
45  avg = pad->GetRawADC(stop);
46  avgSub = pad->GetADC(stop);
47  }
48  }
49 
50  // Now we need to fill the missing data
51  for (int i = start; i < stop; ++i) {
52  pad->SetADC(i, avgSub);
53  pad->SetRawADC(i, avg);
54  }
55 }
56 
58 void AtFilterZero::fillMissingDataLine(AtPad *pad, int start, int stop)
59 {
60  double slope = pad->GetADC(stop) - pad->GetADC(start - 1);
61  slope /= (stop - start + 1);
62 
63  auto startVal = pad->GetADC(start - 1);
64  // Now we need to fill the missing data
65  for (int i = start; i < stop; ++i) {
66 
67  pad->SetADC(i, startVal + (i - start + 1) * slope);
68  }
69 }
AtPad.h
AtPad::SetRawADC
void SetRawADC(const rawTrace &val)
Definition: AtPad.h:89
AtPad::SetADC
void SetADC(const trace &val)
Definition: AtPad.h:91
AtFilterZero::Filter
virtual void Filter(AtPad *pad, AtPadReference *padReference) override
Called to filter each pad.
Definition: AtFilterZero.cxx:7
AtPad::GetADC
const trace & GetADC() const
Definition: AtPad.cxx:97
AtPad
Container class for AtPadBase objects.
Definition: AtPad.h:38
AtPad::GetRawADC
const rawTrace & GetRawADC() const
Definition: AtPad.h:104
AtPadReference
Definition: AtPadReference.h:20
AtFilterZero.h