All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
caldata::RawDigitBinAverageAlg Class Reference

#include <RawDigitBinAverageAlg.h>

Public Member Functions

 RawDigitBinAverageAlg (fhicl::ParameterSet const &pset)
 
 ~RawDigitBinAverageAlg ()
 Destructor. More...
 
void doBinAverage (RawDigitVector &, size_t) const
 
void doTwoBinAverage (RawDigitVector &) const
 

Detailed Description

Definition at line 25 of file RawDigitBinAverageAlg.h.

Constructor & Destructor Documentation

caldata::RawDigitBinAverageAlg::RawDigitBinAverageAlg ( fhicl::ParameterSet const &  pset)

Constructor.

Arguments:

pset - Fcl parameters.

Definition at line 19 of file RawDigitBinAverageAlg.cxx.

20 {
21  // Report.
22  mf::LogInfo("RawDigitBinAverageAlg") << "RawDigitBinAverageAlg configured\n";
23 }
caldata::RawDigitBinAverageAlg::~RawDigitBinAverageAlg ( )

Destructor.

Definition at line 27 of file RawDigitBinAverageAlg.cxx.

28 {}

Member Function Documentation

void caldata::RawDigitBinAverageAlg::doBinAverage ( RawDigitVector dataVec,
size_t  binsToAverage 
) const

Definition at line 30 of file RawDigitBinAverageAlg.cxx.

32 {
33  size_t halfBinsToAverage(binsToAverage/2);
34 
35  float runningSum(0.);
36 
37  for(size_t idx = 0; idx < halfBinsToAverage; idx++) runningSum += dataVec[idx];
38 
39  // Declare erosion vector
40  std::vector<float> meanVec;
41 
42  meanVec.resize(dataVec.size(), 0);
43  std::vector<float>::iterator meanVecItr = meanVec.begin();
44 
45  // First pass through to build the erosion vector
46  for(RawDigitVector::iterator dataItr = dataVec.begin(); dataItr != dataVec.end(); dataItr++)
47  {
48  size_t startOffset = std::distance(dataVec.begin(),dataItr);
49  size_t stopOffset = std::distance(dataItr,dataVec.end());
50  size_t count = std::min(2 * halfBinsToAverage, std::min(startOffset + halfBinsToAverage + 1, halfBinsToAverage + stopOffset - 1));
51 
52  if (startOffset >= halfBinsToAverage) runningSum -= *(dataItr - halfBinsToAverage);
53  if (stopOffset > halfBinsToAverage) runningSum += *(dataItr + halfBinsToAverage);
54 
55  *meanVecItr++ = runningSum / float(count);
56  }
57 
58  std::transform(meanVec.begin(),meanVec.end(),dataVec.begin(),[](const float& val){return std::round(val);});
59 
60  return;
61 }
static constexpr Sample_t transform(Sample_t sample)
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
std::size_t count(Cont const &cont)
void caldata::RawDigitBinAverageAlg::doTwoBinAverage ( RawDigitVector dataVec) const

Definition at line 63 of file RawDigitBinAverageAlg.cxx.

64 {
65  // This should be a straightforward transform
66  std::transform(dataVec.begin(),dataVec.end()-1,dataVec.begin()+1,dataVec.begin(),[](const short& first, const short& last){return std::round(float(first+last)/2.);});
67 
68  return;
69 }
static constexpr Sample_t transform(Sample_t sample)

The documentation for this class was generated from the following files: