All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PMTPulseRecoBase.h
Go to the documentation of this file.
1 /**
2  * \file PMTPulseRecoBase.h
3  *
4  * \ingroup PulseReco
5  *
6  * \brief Class definition file of PMTPulseRecoBase
7  *
8  * @author Kazu - Nevis 2013
9  */
10 
11 /** \addtogroup PulseReco
12 
13 @{*/
14 
15 #ifndef PMTPULSERECOBASE_H
16 #define PMTPULSERECOBASE_H
17 
18 // STL
19 #include <string>
20 #include <vector>
21 
22 #include "OpticalRecoTypes.h"
24 
25 #include <memory>
26 
27 
28 namespace pmtana
29 {
30 
31  struct pulse_param{
32  public:
35 
36  //for vic
37  double t_cfdcross;
38 
40  reset_param();
41  }
42 
43  void reset_param(){
44  area = 0;
45  peak = -1;
46  ped_mean = ped_sigma = -1;
47  t_start = t_max = t_end = t_rise = -1;
48  t_cfdcross = -1;
49  }
50 
51  };
52 
53  typedef std::vector<pmtana::pulse_param> pulse_param_array;
54 
55  /**
56  \class PMTPulseRecoBase
57  The base class of pulse reconstruction algorithms. All algorithms should inherit from this calss
58  to be executed by a manager class, pulse_reco. Note that this class does not depend on the rest
59  of the framework except for the use of constants. In order to reconstruct a pulse, all it requires
60  is a std::vector<short> type object (i.e. raw waveform), waveform pedestal, and its standard
61  deviation. All of these are to be provided by an executer. Reconstructed pulse parameters are
62  stored in the pulse_param struct object.
63 
64  All methods specified as "virtual" should be implemented by the inherit children class.
65 
66  This class provides some basic std::vector calculation algorithms such as integral, derivative,
67  max and min algorithms. Inherit children classes are encouraged to use these provided methods
68  when possible.
69  */
71 
72  public:
73 
74  /// Default constructor with fhicl parameters
75  PMTPulseRecoBase(const std::string name="noname");
76 
77  /// Default destructor
78  virtual ~PMTPulseRecoBase() = default;
79 
80  /// Name getter
81  const std::string& Name() const;
82 
83  /// Status getter
84  bool Status() const;
85 
86  /// A method to be called event-wise to reset parameters
87  virtual void Reset();
88 
89  /** A core method: this executes the algorithm and stores reconstructed parameters
90  in the pulse_param struct object.
91  */
92  bool Reconstruct( const pmtana::Waveform_t&,
94  const pmtana::PedestalSigma_t& );
95 
96  /** A getter for the pulse_param struct object.
97  Reconstruction algorithm may have more than one pulse reconstructed from an input waveform.
98  Note you must, accordingly, provide an index key to specify which pulse_param object to be retrieved.
99  */
100  const pulse_param& GetPulse(size_t index=0) const;
101 
102  /// A getter for the whole array of pulse_param struct object.
103  const pulse_param_array& GetPulses() const;
104 
105  /// A getter for the number of reconstructed pulses from the input waveform
106  size_t GetNPulse() const {return _pulse_v.size();};
107 
108  private:
109 
110  /// Unique name
111  std::string _name;
112 
113  /// Status after pulse reconstruction
114  bool _status;
115 
116  protected:
117 
118  virtual bool RecoPulse( const pmtana::Waveform_t&,
119  const pmtana::PedestalMean_t&,
120  const pmtana::PedestalSigma_t& ) = 0;
121 
122  /// A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s).
124 
125  /// A subject pulse_param object to be filled with the last reconstructed pulse parameters
127 
128  /// Tool for rise time calculation
129  std::unique_ptr<pmtana::RiseTimeCalculatorBase> _risetime_calc_ptr = nullptr;
130 
131  protected:
132 
133  /**
134  A method to integrate an waveform from index "begin" to the "end". The result is filled in "result" reference.
135  If the "end" is default (=0), then "end" is set to the last index of the waveform.
136  */
137  bool Integral (const std::vector<short> &wf, double &result, size_t begin=0, size_t end=0) const;
138 
139  /**
140  A method to compute derivative, which is a simple subtraction of previous ADC sample from each sample.
141  The result is stored in the input "diff" reference vector which is int32_t type as a derivative could be negative.
142  */
143  bool Derivative (const std::vector<short> &wf, std::vector<int32_t> &diff, size_t begin=0, size_t end=0) const;
144 
145  /**
146  A method to return the maximum value of ADC sample within the index from "begin" to "end".
147  If the "end" is default (=0), then "end" is set to the last index of the waveform.
148  */
149  size_t Max(const std::vector<short> &wf, double &result, size_t begin=0, size_t end=0) const;
150 
151  /**
152  A method to return the minimum value of ADC sample within the index from "begin" to "end".
153  If the "end" is default (=0), then "end" is set to the last index of the waveform.
154  */
155  size_t Min(const std::vector<short> &wf, double &result, size_t begin=0, size_t end=0) const;
156 
157  };
158 
159 }
160 #endif
161 
162 /** @} */ // end of doxygen group
bool _status
Status after pulse reconstruction.
bool Integral(const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
bool Status() const
Status getter.
std::vector< double > PedestalSigma_t
virtual void Reset()
A method to be called event-wise to reset parameters.
Interfacce class for a tool to calculate the pulse rise time.
std::string _name
Unique name.
virtual ~PMTPulseRecoBase()=default
Default destructor.
size_t Min(const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
const std::string & Name() const
Name getter.
size_t GetNPulse() const
A getter for the number of reconstructed pulses from the input waveform.
pulse_param _pulse
A subject pulse_param object to be filled with the last reconstructed pulse parameters.
size_t Max(const std::vector< short > &wf, double &result, size_t begin=0, size_t end=0) const
const pulse_param_array & GetPulses() const
A getter for the whole array of pulse_param struct object.
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
std::vector< short > Waveform_t
virtual bool RecoPulse(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)=0
auto begin(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:573
std::unique_ptr< pmtana::RiseTimeCalculatorBase > _risetime_calc_ptr
Tool for rise time calculation.
bool Reconstruct(const pmtana::Waveform_t &, const pmtana::PedestalMean_t &, const pmtana::PedestalSigma_t &)
then echo fcl name
std::vector< pmtana::pulse_param > pulse_param_array
std::vector< double > PedestalMean_t
const pulse_param & GetPulse(size_t index=0) const
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...
bool Derivative(const std::vector< short > &wf, std::vector< int32_t > &diff, size_t begin=0, size_t end=0) const
PMTPulseRecoBase(const std::string name="noname")
Default constructor with fhicl parameters.