LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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...
 
virtual ~PedAlgoEdges ()
 Default destructor. 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 30 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 45 of file PedAlgoEdges.h.

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

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 17 of file PedAlgoEdges.cxx.

References _method, _nsample_front, _nsample_tail, and kHEAD.

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

Alternative ctor.

Definition at line 27 of file PedAlgoEdges.cxx.

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

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

Default destructor.

Definition at line 45 of file PedAlgoEdges.cxx.

47  {}

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 50 of file PedAlgoEdges.cxx.

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

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

35  {
36  _mean_v.resize(wf.size(),0);
37  _sigma_v.resize(wf.size(),0);
38 
39  for(size_t i=0; i<wf.size(); ++i)
40  _mean_v[i] = _sigma_v[i] = 0;
41 
42  const bool res = ComputePedestal(wf, _mean_v, _sigma_v);
43 
44  if(wf.size() != _mean_v.size())
45  throw OpticalRecoException("Internal error: computed pedestal mean array length changed!");
46  if(wf.size() != _sigma_v.size())
47  throw OpticalRecoException("Internal error: computed pedestal sigma array length changed!");
48 
49  return res;
50  }
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 53 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_mean_v, and ss.

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

55  {
56  if(i > _mean_v.size()) {
57  std::stringstream ss;
58  ss << "Invalid index: no pedestal mean exist @ " << i;
59  throw OpticalRecoException(ss.str());
60  }
61  return _mean_v[i];
62  }
Float_t ss
Definition: plot.C:23
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 77 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_mean_v.

79  { return _mean_v; }
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 28 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_name.

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

Getter of the pedestal standard deviation.

Definition at line 65 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_sigma_v, and ss.

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

67  {
68  if(i > _sigma_v.size()) {
69  std::stringstream ss;
70  ss << "Invalid index: no pedestal sigma exist @ " << i;
71  throw OpticalRecoException(ss.str());
72  }
73  return _sigma_v[i];
74  }
Float_t ss
Definition: plot.C:23
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 82 of file PMTPedestalBase.cxx.

References pmtana::PMTPedestalBase::_sigma_v.

84  { return _sigma_v; }
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 60 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 58 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 59 of file PedAlgoEdges.h.

Referenced by ComputePedestal(), and PedAlgoEdges().


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