LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
PedAlgoEdges.cxx
Go to the documentation of this file.
1 //
3 // PedAlgoEdges source
4 //
6 
7 #include "PedAlgoEdges.h"
8 #include "OpticalRecoException.h"
9 #include "UtilFunc.h"
10 
11 #include "fhiclcpp/ParameterSet.h"
12 
13 namespace pmtana {
14 
15  //************************************************
16  PedAlgoEdges::PedAlgoEdges(const std::string name) : PMTPedestalBase(name)
17  //************************************************
18  {
19  _nsample_front = 3;
20  _nsample_tail = 5;
21  _method = kHEAD;
22  }
23 
24  //*************************************************************
26  //PedAlgoEdges::PedAlgoEdges(const ::fcllite::PSet &pset,
27  const std::string name)
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  }
41 
42  //*********************************************************************
44  pmtana::PedestalMean_t& mean_v,
45  pmtana::PedestalSigma_t& sigma_v)
46  //*********************************************************************
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  }
88 
89 }
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:43
std::vector< double > PedestalSigma_t
PED_METHOD _method
Methods.
Definition: PedAlgoEdges.h:59
PedAlgoEdges(const std::string name="PedEdges")
Default constructor.
T get(std::string const &key) const
Definition: ParameterSet.h:314
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
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
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 "nsample" ADC samples from "start" index...