All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RiseTimeThreshold_tool.cc
Go to the documentation of this file.
1 /**
2  * \file RiseTimeThreshold_tool.cc
3  *
4  * \brief Rise time is defined as the time slot in which the pulse
5  * goes above a certain fraction of the maximum ADC peak value
6  * given by the "PeakRatio" fhicl parameter
7  *
8  * @author Fran Nicolas, June 2022
9  */
10 
11 #include "fhiclcpp/types/Atom.h"
12 #include "art/Utilities/ToolMacros.h"
13 #include "art/Utilities/ToolConfigTable.h"
14 
15 #include "RiseTimeCalculatorBase.h"
16 
17 namespace pmtana{
18 
20  {
21 
22  public:
23 
24  //Configuration parameters
25  struct Config {
26 
27  fhicl::Atom<double> PeakRatio {
28  fhicl::Name("PeakRatio")
29  };
30 
31  };
32 
33  // Default constructor
34  explicit RiseTimeThreshold(art::ToolConfigTable<Config> const& config);
35 
36  // Method to calculate the OpFlash t0
37  double RiseTime(const pmtana::Waveform_t& wf_pulse,
38  const pmtana::PedestalMean_t& ped_pulse,
39  bool _positive) const override;
40 
41  private:
42 
43  double fPeakRatio;
44 
45  };
46 
47  RiseTimeThreshold::RiseTimeThreshold(art::ToolConfigTable<Config> const& config)
48  : fPeakRatio { config().PeakRatio() }
49  {
50  }
51 
53  const pmtana::PedestalMean_t& ped_pulse,
54  bool _positive) const{
55 
56  // Pedestal-subtracted pulse
57  std::vector<double> wf_aux (ped_pulse);
58  if(_positive){
59  for(size_t ix=0; ix<wf_aux.size(); ix++){
60  wf_aux[ix]=((double)wf_pulse[ix])-wf_aux[ix];
61  }
62  }
63  else{
64  for(size_t ix=0; ix<wf_aux.size(); ix++){
65  wf_aux[ix]=wf_aux[ix]-((double)wf_pulse[ix]);
66  }
67  }
68 
69  auto it_max = max_element(wf_aux.begin(), wf_aux.end());
70  size_t rise = std::lower_bound( wf_aux.begin(), it_max, fPeakRatio*(*it_max) ) - wf_aux.begin();
71 
72  return rise;
73  }
74 
75 }
76 
77 DEFINE_ART_CLASS_TOOL(pmtana::RiseTimeThreshold)
double RiseTime(const pmtana::Waveform_t &wf_pulse, const pmtana::PedestalMean_t &ped_pulse, bool _positive) const override
RiseTimeThreshold(art::ToolConfigTable< Config > const &config)
Interfacce class for a tool to calculate the pulse rise time.
std::vector< short > Waveform_t
BEGIN_PROLOG vertical distance to the surface Name
std::vector< double > PedestalMean_t