LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
pmtana::PedAlgoEdges Class Referenceabstract

#include "PedAlgoEdges.h"

Inheritance diagram for pmtana::PedAlgoEdges:
pmtana::PMTPedestalBase

Public Types

enum  PED_METHOD { kHEAD = 0, kTAIL, kBOTH }
 enum to define algorithm options More...
 

Public Member Functions

 PedAlgoEdges (const std::string name="PedEdges")
 Default constructor. More...
 
 PedAlgoEdges (const fhicl::ParameterSet &pset, const std::string name="PedEdges")
 Alternative ctor. More...
 
const std::string & Name () const
 Name getter. More...
 
bool Evaluate (const pmtana::Waveform_t &wf)
 Method to compute a pedestal. More...
 
double Mean (size_t i) const
 Getter of the pedestal mean value. More...
 
const pmtana::PedestalMean_tMean () const
 Getter of the pedestal mean value. More...
 
double Sigma (size_t i) const
 Getter of the pedestal standard deviation. More...
 
const pmtana::PedestalSigma_tSigma () const
 Getter of the pedestal standard deviation. More...
 

Protected Member Functions

bool ComputePedestal (const pmtana::Waveform_t &wf, pmtana::PedestalMean_t &mean_v, pmtana::PedestalSigma_t &sigma_v)
 Method to compute a pedestal of the input waveform using "nsample" ADC samples from "start" index. More...
 
virtual bool ComputePedestal (const ::pmtana::Waveform_t &wf, pmtana::PedestalMean_t &mean_v, pmtana::PedestalSigma_t &sigma_v)=0
 

Private Attributes

size_t _nsample_front
 

ADC sample in front to be used

More...
 
size_t _nsample_tail
 

ADC sample in tail to be used

More...
 
PED_METHOD _method
 Methods. More...
 

Detailed Description

A class that calculates pedestal mean & standard deviation (here and elsewhere called as "RMS").

Definition at line 33 of file PedAlgoEdges.h.

Member Enumeration Documentation

enum to define algorithm options

Enumerator
kHEAD 

Use first N samples.

kTAIL 

Use last N samples.

kBOTH 

Calculate both and use the one with smaller RMS.

Definition at line 44 of file PedAlgoEdges.h.

44  {
45  kHEAD = 0,
46  kTAIL,
47  kBOTH
48  };
Use last N samples.
Definition: PedAlgoEdges.h:46
Calculate both and use the one with smaller RMS.
Definition: PedAlgoEdges.h:47
Use first N samples.
Definition: PedAlgoEdges.h:45

Constructor & Destructor Documentation

pmtana::PedAlgoEdges::PedAlgoEdges ( const std::string  name = "PedEdges")

Default constructor.

Definition at line 16 of file PedAlgoEdges.cxx.

References _method, _nsample_front, _nsample_tail, and kHEAD.

16  : PMTPedestalBase(name)
17  //************************************************
18  {
19  _nsample_front = 3;
20  _nsample_tail = 5;
21  _method = kHEAD;
22  }
PMTPedestalBase(std::string name="noname")
Default constructor.
PED_METHOD _method
Methods.
Definition: PedAlgoEdges.h:59
Use first N samples.
Definition: PedAlgoEdges.h:45
size_t _nsample_tail
ADC sample in tail to be used
Definition: PedAlgoEdges.h:58
size_t _nsample_front
ADC sample in front to be used
Definition: PedAlgoEdges.h:57
pmtana::PedAlgoEdges::PedAlgoEdges ( const fhicl::ParameterSet pset,
const std::string  name = "PedEdges" 
)

Alternative ctor.

Definition at line 25 of file PedAlgoEdges.cxx.

References _method, _nsample_front, _nsample_tail, fhicl::ParameterSet::get(), and kBOTH.

28  : PMTPedestalBase(name)
29  //*************************************************************
30  {
31 
32  _nsample_front = pset.get<size_t>("NumSampleFront");
33  _nsample_tail = pset.get<size_t>("NumSampleTail");
34  int method = pset.get<int>("Method");
35 
36  if (method < 0 || method > kBOTH)
37  throw OpticalRecoException("PedAlgoEdges received invalid \"Method\" parameter value!");
38 
39  _method = (PED_METHOD)method;
40  }
PMTPedestalBase(std::string name="noname")
Default constructor.
PED_METHOD _method
Methods.
Definition: PedAlgoEdges.h:59
T get(std::string const &key) const
Definition: ParameterSet.h:314
PED_METHOD
enum to define algorithm options
Definition: PedAlgoEdges.h:44
Calculate both and use the one with smaller RMS.
Definition: PedAlgoEdges.h:47
size_t _nsample_tail
ADC sample in tail to be used
Definition: PedAlgoEdges.h:58
size_t _nsample_front
ADC sample in front to be used
Definition: PedAlgoEdges.h:57

Member Function Documentation

bool pmtana::PedAlgoEdges::ComputePedestal ( const pmtana::Waveform_t wf,
pmtana::PedestalMean_t mean_v,
pmtana::PedestalSigma_t sigma_v 
)
protected

Method to compute a pedestal of the input waveform using "nsample" ADC samples from "start" index.

Definition at line 43 of file PedAlgoEdges.cxx.

References _method, _nsample_front, _nsample_tail, kBOTH, kHEAD, kTAIL, pmtana::mean(), and pmtana::std().

47  {
48 
49  double ped_mean = 0;
50  double ped_sigma = 0;
51  switch (_method) {
52  case kHEAD:
53  ped_mean = mean(wf, 0, _nsample_front);
54  ped_sigma = std(wf, ped_mean, 0, _nsample_front);
55  for (auto& v : mean_v)
56  v = ped_mean;
57  for (auto& v : sigma_v)
58  v = ped_sigma;
59  break;
60  case kTAIL:
61  ped_mean = mean(wf, (wf.size() - _nsample_tail), _nsample_tail);
62  ped_sigma = std(wf, ped_mean, (wf.size() - _nsample_tail), _nsample_tail);
63  for (auto& v : mean_v)
64  v = ped_mean;
65  for (auto& v : sigma_v)
66  v = ped_sigma;
67  break;
68  case kBOTH:
69  double ped_mean_head = mean(wf, 0, _nsample_front);
70  double ped_sigma_head = std(wf, ped_mean_head, 0, _nsample_front);
71  double ped_mean_tail = mean(wf, (wf.size() - _nsample_tail), _nsample_tail);
72  double ped_sigma_tail = std(wf, ped_mean_tail, (wf.size() - _nsample_tail), _nsample_tail);
73 
74  ped_mean = ped_mean_head;
75  ped_sigma = ped_sigma_head;
76  if (ped_sigma_tail < ped_sigma) {
77  ped_mean = ped_mean_tail;
78  ped_sigma = ped_sigma_tail;
79  }
80  for (auto& v : mean_v)
81  v = ped_mean;
82  for (auto& v : sigma_v)
83  v = ped_sigma;
84  break;
85  }
86  return true;
87  }
Use last N samples.
Definition: PedAlgoEdges.h:46
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:43
PED_METHOD _method
Methods.
Definition: PedAlgoEdges.h:59
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
Calculate both and use the one with smaller RMS.
Definition: PedAlgoEdges.h:47
Use first N samples.
Definition: PedAlgoEdges.h:45
size_t _nsample_tail
ADC sample in tail to be used
Definition: PedAlgoEdges.h:58
size_t _nsample_front
ADC sample in front to be used
Definition: PedAlgoEdges.h:57
virtual bool pmtana::PMTPedestalBase::ComputePedestal ( const ::pmtana::Waveform_t wf,
pmtana::PedestalMean_t mean_v,
pmtana::PedestalSigma_t sigma_v 
)
protectedpure virtualinherited

Method to compute pedestal: mean and sigma array should be filled per ADC. The length of each array is guaranteed to be same.

Referenced by pmtana::PMTPedestalBase::Evaluate().

bool pmtana::PMTPedestalBase::Evaluate ( const pmtana::Waveform_t wf)
inherited

Method to compute a pedestal.

Definition at line 30 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_mean_v, pmtana::PMTPedestalBase::_sigma_v, and pmtana::PMTPedestalBase::ComputePedestal().

Referenced by pmtana::PedAlgoUB::ComputePedestal(), and pmtana::PulseRecoManager::Reconstruct().

32  {
33  _mean_v.resize(wf.size(), 0);
34  _sigma_v.resize(wf.size(), 0);
35 
36  for (size_t i = 0; i < wf.size(); ++i)
37  _mean_v[i] = _sigma_v[i] = 0;
38 
39  const bool res = ComputePedestal(wf, _mean_v, _sigma_v);
40 
41  if (wf.size() != _mean_v.size())
42  throw OpticalRecoException("Internal error: computed pedestal mean array length changed!");
43  if (wf.size() != _sigma_v.size())
44  throw OpticalRecoException("Internal error: computed pedestal sigma array length changed!");
45 
46  return res;
47  }
pmtana::PedestalMean_t _mean_v
A variable holder for pedestal mean value.
virtual bool ComputePedestal(const ::pmtana::Waveform_t &wf, pmtana::PedestalMean_t &mean_v, pmtana::PedestalSigma_t &sigma_v)=0
pmtana::PedestalSigma_t _sigma_v
A variable holder for pedestal standard deviation.
double pmtana::PMTPedestalBase::Mean ( size_t  i) const
inherited

Getter of the pedestal mean value.

Definition at line 50 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_mean_v.

Referenced by pmtana::PedAlgoUB::ComputePedestal(), and pmtana::PulseRecoManager::Reconstruct().

52  {
53  if (i > _mean_v.size()) {
54  std::stringstream ss;
55  ss << "Invalid index: no pedestal mean exist @ " << i;
56  throw OpticalRecoException(ss.str());
57  }
58  return _mean_v[i];
59  }
pmtana::PedestalMean_t _mean_v
A variable holder for pedestal mean value.
const PedestalMean_t & pmtana::PMTPedestalBase::Mean ( ) const
inherited

Getter of the pedestal mean value.

Definition at line 74 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_mean_v.

76  {
77  return _mean_v;
78  }
pmtana::PedestalMean_t _mean_v
A variable holder for pedestal mean value.
const std::string & pmtana::PMTPedestalBase::Name ( ) const
inherited

Name getter.

Definition at line 23 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_name.

25  {
26  return _name;
27  }
std::string _name
Name.
double pmtana::PMTPedestalBase::Sigma ( size_t  i) const
inherited

Getter of the pedestal standard deviation.

Definition at line 62 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_sigma_v.

Referenced by pmtana::PedAlgoUB::ComputePedestal(), and pmtana::PulseRecoManager::Reconstruct().

64  {
65  if (i > _sigma_v.size()) {
66  std::stringstream ss;
67  ss << "Invalid index: no pedestal sigma exist @ " << i;
68  throw OpticalRecoException(ss.str());
69  }
70  return _sigma_v[i];
71  }
pmtana::PedestalSigma_t _sigma_v
A variable holder for pedestal standard deviation.
const PedestalSigma_t & pmtana::PMTPedestalBase::Sigma ( ) const
inherited

Getter of the pedestal standard deviation.

Definition at line 81 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_sigma_v.

83  {
84  return _sigma_v;
85  }
pmtana::PedestalSigma_t _sigma_v
A variable holder for pedestal standard deviation.

Member Data Documentation

PED_METHOD pmtana::PedAlgoEdges::_method
private

Methods.

Definition at line 59 of file PedAlgoEdges.h.

Referenced by ComputePedestal(), and PedAlgoEdges().

size_t pmtana::PedAlgoEdges::_nsample_front
private

ADC sample in front to be used

Definition at line 57 of file PedAlgoEdges.h.

Referenced by ComputePedestal(), and PedAlgoEdges().

size_t pmtana::PedAlgoEdges::_nsample_tail
private

ADC sample in tail to be used

Definition at line 58 of file PedAlgoEdges.h.

Referenced by ComputePedestal(), and PedAlgoEdges().


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