LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PedAlgoEdges.cxx
Go to the documentation of this file.
1 //
3 // PedAlgoEdges source
4 //
6 
7 #ifndef larana_OPTICALDETECTOR_PEDALGOEDGES_CXX
8 #define larana_OPTICALDETECTOR_PEDALGOEDGES_CXX
9 
10 #include "PedAlgoEdges.h"
11 #include "UtilFunc.h"
12 #include "OpticalRecoException.h"
13 
14 namespace pmtana{
15 
16  //************************************************
17  PedAlgoEdges::PedAlgoEdges(const std::string name)
18  : PMTPedestalBase(name)
19  //************************************************
20  {
21  _nsample_front = 3;
22  _nsample_tail = 5;
23  _method = kHEAD;
24  }
25 
26  //*************************************************************
28  //PedAlgoEdges::PedAlgoEdges(const ::fcllite::PSet &pset,
29  const std::string name)
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  }
43 
44  //***************************
46  //***************************
47  {}
48 
49  //*********************************************************************
51  pmtana::PedestalMean_t& mean_v,
52  pmtana::PedestalSigma_t& sigma_v)
53  //*********************************************************************
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  }
90 
91 }
92 
93 #endif
Use last N samples.
Definition: PedAlgoEdges.h:47
Class def header for exception classes in OpticalDetector package.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:44
virtual ~PedAlgoEdges()
Default destructor.
std::vector< double > PedestalSigma_t
PED_METHOD _method
Methods.
Definition: PedAlgoEdges.h:60
PedAlgoEdges(const std::string name="PedEdges")
Default constructor.
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::vector< short > Waveform_t
PED_METHOD
enum to define algorithm options
Definition: PedAlgoEdges.h:45
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
Class definition file of PedAlgoEdges.
size_t _nsample_front
ADC sample in front to be used
Definition: PedAlgoEdges.h:58
std::vector< double > PedestalMean_t
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...