All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
icarus_tool::BaselineMostProbAve Class Reference
Inheritance diagram for icarus_tool::BaselineMostProbAve:
icarus_tool::IBaseline

Public Member Functions

 BaselineMostProbAve (const fhicl::ParameterSet &pset)
 
 ~BaselineMostProbAve ()
 
void configure (const fhicl::ParameterSet &pset) override
 
void outputHistograms (art::TFileDirectory &) const override
 
float GetBaseline (const std::vector< float > &, raw::ChannelID_t, size_t, size_t) const override
 

Private Member Functions

std::pair< float, int > GetBaseline (const std::vector< float > &, int, size_t, size_t) const
 
- Private Member Functions inherited from icarus_tool::IBaseline
virtual ~IBaseline () noexcept=default
 

Private Attributes

size_t fMaxROILength
 Maximum length for calculating Most Probable Value. More...
 
icarus_signal_processing::WaveformTools
< double > 
fWaveformTool
 
art::ServiceHandle
< icarusutil::SignalShapingICARUSService
fSignalShaping
 

Detailed Description

Definition at line 24 of file BaselineMostProbAve_tool.cc.

Constructor & Destructor Documentation

icarus_tool::BaselineMostProbAve::BaselineMostProbAve ( const fhicl::ParameterSet &  pset)
explicit

Definition at line 48 of file BaselineMostProbAve_tool.cc.

49 {
50  configure(pset);
51 }
void configure(const fhicl::ParameterSet &pset) override
icarus_tool::BaselineMostProbAve::~BaselineMostProbAve ( )

Definition at line 53 of file BaselineMostProbAve_tool.cc.

54 {
55 }

Member Function Documentation

void icarus_tool::BaselineMostProbAve::configure ( const fhicl::ParameterSet &  pset)
overridevirtual

Implements icarus_tool::IBaseline.

Definition at line 57 of file BaselineMostProbAve_tool.cc.

58 {
59  // Recover our fhicl variable
60  fMaxROILength = pset.get<size_t>("MaxROILength", 100);
61 
62  // Get signal shaping service.
63  fSignalShaping = art::ServiceHandle<icarusutil::SignalShapingICARUSService>();
64 
65  return;
66 }
size_t fMaxROILength
Maximum length for calculating Most Probable Value.
art::ServiceHandle< icarusutil::SignalShapingICARUSService > fSignalShaping
float icarus_tool::BaselineMostProbAve::GetBaseline ( const std::vector< float > &  holder,
raw::ChannelID_t  channel,
size_t  roiStart,
size_t  roiLen 
) const
overridevirtual

Implements icarus_tool::IBaseline.

Definition at line 69 of file BaselineMostProbAve_tool.cc.

73 {
74  float base(0.);
75 
76  if (roiLen > 1)
77  {
78  // Recover the expected electronics noise on this channel
79  float deconNoise = 1.26491 * fSignalShaping->GetDeconNoise(channel);
80  int binRange = std::max(1, int(std::round(deconNoise)));
81  size_t halfLen = std::min(fMaxROILength,roiLen/2);
82  size_t roiStop = roiStart + roiLen;
83 
84  // This returns back the mean value and the spread from which it was calculated
85  std::pair<float,int> baseFront = GetBaseline(holder, binRange, roiStart, roiStart + halfLen);
86  std::pair<float,int> baseBack = GetBaseline(holder, binRange, roiStop - halfLen, roiStop );
87 
88 // std::cout << "-Baseline size: " << holder.size() << ", front/back: " << baseFront.first << "/" << baseBack.first << ", ranges: " << baseFront.second << "/" << baseBack.second;
89 
90  // Check for a large spread between the two estimates
91  if (std::abs(baseFront.first - baseBack.first) > 1.5 * deconNoise)
92  {
93  // We're going to favor the front, generally, unless the spread on the back is lower
94  if (baseFront.second < 3 * baseBack.second / 2) base = baseFront.first;
95  else base = baseBack.first;
96  }
97  else
98  {
99  // Otherwise we take a weighted average between the two
100  float rangeFront = baseFront.second;
101  float rangeBack = baseBack.second;
102 
103  base = (baseFront.first/rangeFront + baseBack.first/rangeBack)*(rangeFront*rangeBack)/(rangeFront+rangeBack);
104  }
105 
106 // std::cout << ", base: " << base << std::endl;
107  }
108 
109  return base;
110 }
float GetBaseline(const std::vector< float > &, raw::ChannelID_t, size_t, size_t) const override
size_t fMaxROILength
Maximum length for calculating Most Probable Value.
T abs(T value)
art::ServiceHandle< icarusutil::SignalShapingICARUSService > fSignalShaping
std::pair< float, int > icarus_tool::BaselineMostProbAve::GetBaseline ( const std::vector< float > &  holder,
int  binRange,
size_t  roiStart,
size_t  roiStop 
) const
private

Definition at line 112 of file BaselineMostProbAve_tool.cc.

116 {
117  std::pair<double,int> base(0.,1);
118  int nTrunc;
119 
120  if (roiStop > roiStart)
121  {
122  // Get the truncated mean and rms
123  icarusutil::TimeVec temp(roiStop - roiStart + 1,0.);
124 
125  std::copy(holder.begin() + roiStart,holder.begin() + roiStop,temp.begin());
126 
127  fWaveformTool.getTruncatedMean(temp, base.first, nTrunc, base.second);
128  }
129 
130  return base;
131 }
std::vector< SigProcPrecision > TimeVec
icarus_signal_processing::WaveformTools< double > fWaveformTool
T copy(T const &v)
void icarus_tool::BaselineMostProbAve::outputHistograms ( art::TFileDirectory &  histDir) const
overridevirtual

Implements icarus_tool::IBaseline.

Definition at line 133 of file BaselineMostProbAve_tool.cc.

134 {
135  // It is assumed that the input TFileDirectory has been set up to group histograms into a common
136  // folder at the calling routine's level. Here we create one more level of indirection to keep
137  // histograms made by this tool separate.
138 /*
139  std::string dirName = "BaselinePlane_" + std::to_string(fPlane);
140 
141  art::TFileDirectory dir = histDir.mkdir(dirName.c_str());
142 
143  auto const* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
144  double samplingRate = detprop->SamplingRate();
145  double numBins = fBaselineVec.size();
146  double maxFreq = 500. / samplingRate;
147  std::string histName = "BaselinePlane_" + std::to_string(fPlane);
148 
149  TH1D* hist = dir.make<TH1D>(histName.c_str(), "Baseline;Frequency(MHz)", numBins, 0., maxFreq);
150 
151  for(int bin = 0; bin < numBins; bin++)
152  {
153  double freq = maxFreq * double(bin + 0.5) / double(numBins);
154 
155  hist->Fill(freq, fBaselineVec.at(bin).Re());
156  }
157 */
158 
159  return;
160 }

Member Data Documentation

size_t icarus_tool::BaselineMostProbAve::fMaxROILength
private

Maximum length for calculating Most Probable Value.

Definition at line 39 of file BaselineMostProbAve_tool.cc.

art::ServiceHandle<icarusutil::SignalShapingICARUSService> icarus_tool::BaselineMostProbAve::fSignalShaping
private

Definition at line 43 of file BaselineMostProbAve_tool.cc.

icarus_signal_processing::WaveformTools<double> icarus_tool::BaselineMostProbAve::fWaveformTool
private

Definition at line 41 of file BaselineMostProbAve_tool.cc.


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