All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PedAlgoEdges.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // PedAlgoEdges source
4 //
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include "PedAlgoEdges.h"
8 #include "UtilFunc.h"
9 #include "OpticalRecoException.h"
10 
11 #include "fhiclcpp/ParameterSet.h"
12 
13 namespace pmtana{
14 
15  //************************************************
16  PedAlgoEdges::PedAlgoEdges(const std::string name)
17  : PMTPedestalBase(name)
18  //************************************************
19  {
20  _nsample_front = 3;
21  _nsample_tail = 5;
22  _method = kHEAD;
23  }
24 
25  //*************************************************************
26  PedAlgoEdges::PedAlgoEdges(const fhicl::ParameterSet &pset,
27  //PedAlgoEdges::PedAlgoEdges(const ::fcllite::PSet &pset,
28  const std::string name)
29  : PMTPedestalBase(name)
30  //*************************************************************
31  {
32 
33  _nsample_front = pset.get< size_t > ( "NumSampleFront" );
34  _nsample_tail = pset.get< size_t > ( "NumSampleTail" );
35  int method = pset.get< int > ( "Method" );
36 
37  if(method < 0 || method > kBOTH) throw OpticalRecoException("PedAlgoEdges received invalid \"Method\" parameter value!");
38 
39  _method = (PED_METHOD)method;
40 
41  }
42 
43  //*********************************************************************
45  pmtana::PedestalMean_t& mean_v,
46  pmtana::PedestalSigma_t& sigma_v)
47  //*********************************************************************
48  {
49 
50  double ped_mean=0;
51  double ped_sigma=0;
52  switch(_method) {
53  case kHEAD:
54  ped_mean = mean ( wf, 0, _nsample_front);
55  ped_sigma = std ( wf, ped_mean, 0, _nsample_front);
56  for( auto &v : mean_v ) v = ped_mean;
57  for( auto &v : sigma_v ) v = ped_sigma;
58  break;
59  case kTAIL:
60  ped_mean = mean ( wf, (wf.size() - _nsample_tail), _nsample_tail);
61  ped_sigma = std ( wf, ped_mean, (wf.size() - _nsample_tail), _nsample_tail);
62  for( auto &v : mean_v ) v = ped_mean;
63  for( auto &v : sigma_v ) v = ped_sigma;
64  break;
65  case kBOTH:
66  double ped_mean_head = mean ( wf, 0, _nsample_front);
67  double ped_sigma_head = std ( wf, ped_mean_head, 0, _nsample_front);
68  double ped_mean_tail = mean ( wf, (wf.size() - _nsample_tail), _nsample_tail);
69  double ped_sigma_tail = std ( wf, ped_mean_tail, (wf.size() - _nsample_tail), _nsample_tail);
70 
71  ped_mean = ped_mean_head;
72  ped_sigma = ped_sigma_head;
73  if(ped_sigma_tail < ped_sigma) {
74  ped_mean = ped_mean_tail;
75  ped_sigma = ped_sigma_tail;
76  }
77  for( auto &v : mean_v ) v = ped_mean;
78  for( auto &v : sigma_v ) v = ped_sigma;
79  break;
80  }
81  return true;
82 
83  }
84 
85 }
Use last N samples.
Definition: PedAlgoEdges.h:46
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:42
std::vector< double > PedestalSigma_t
PED_METHOD _method
Methods.
Definition: PedAlgoEdges.h:59
PedAlgoEdges(const std::string name="PedEdges")
Default constructor.
std::vector< short > Waveform_t
PED_METHOD
enum to define algorithm options
Definition: PedAlgoEdges.h:44
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
Definition: UtilFunc.cxx:13
BEGIN_PROLOG method
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
then echo fcl name
Class definition file of PedAlgoEdges.
size_t _nsample_front
ADC sample in front to be used
Definition: PedAlgoEdges.h:57
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 &quot;nsample&quot; ADC samples from &quot;start&quot; index...