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"
23 
24 namespace pmtana
25 {
26 
27  struct pulse_param{
28  public:
30  double t_start, t_max, t_end;
31 
32  //for vic
33  double t_cfdcross;
34 
36  reset_param();
37  }
38 
39  void reset_param(){
40  area = 0;
41  peak = -1;
42  ped_mean = ped_sigma = -1;
43  t_start = t_max = t_end = -1;
44  t_cfdcross = -1;
45  }
46 
47  };
48 
49  typedef std::vector<pmtana::pulse_param> pulse_param_array;
50 
51  /**
52  \class PMTPulseRecoBase
53  The base class of pulse reconstruction algorithms. All algorithms should inherit from this calss
54  to be executed by a manager class, pulse_reco. Note that this class does not depend on the rest
55  of the framework except for the use of constants. In order to reconstruct a pulse, all it requires
56  is a std::vector<short> type object (i.e. raw waveform), waveform pedestal, and its standard
57  deviation. All of these are to be provided by an executer. Reconstructed pulse parameters are
58  stored in the pulse_param struct object.
59 
60  All methods specified as "virtual" should be implemented by the inherit children class.
61 
62  This class provides some basic std::vector calculation algorithms such as integral, derivative,
63  max and min algorithms. Inherit children classes are encouraged to use these provided methods
64  when possible.
65  */
67 
68  public:
69 
70  /// Default constructor with fhicl parameters
71  PMTPulseRecoBase(const std::string name="noname");
72 
73  /// Default destructor
74  virtual ~PMTPulseRecoBase() = default;
75 
76  /// Name getter
77  const std::string& Name() const;
78 
79  /// Status getter
80  bool Status() const;
81 
82  /// A method to be called event-wise to reset parameters
83  virtual void Reset();
84 
85  /** A core method: this executes the algorithm and stores reconstructed parameters
86  in the pulse_param struct object.
87  */
88  bool Reconstruct( const pmtana::Waveform_t&,
90  const pmtana::PedestalSigma_t& );
91 
92  /** A getter for the pulse_param struct object.
93  Reconstruction algorithm may have more than one pulse reconstructed from an input waveform.
94  Note you must, accordingly, provide an index key to specify which pulse_param object to be retrieved.
95  */
96  const pulse_param& GetPulse(size_t index=0) const;
97 
98  /// A getter for the whole array of pulse_param struct object.
99  const pulse_param_array& GetPulses() const;
100 
101  /// A getter for the number of reconstructed pulses from the input waveform
102  size_t GetNPulse() const {return _pulse_v.size();};
103 
104  private:
105 
106  /// Unique name
107  std::string _name;
108 
109  /// Status after pulse reconstruction
110  bool _status;
111 
112  protected:
113 
114  virtual bool RecoPulse( const pmtana::Waveform_t&,
115  const pmtana::PedestalMean_t&,
116  const pmtana::PedestalSigma_t& ) = 0;
117 
118  /// A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s).
119  pulse_param_array _pulse_v;
120 
121  /// A subject pulse_param object to be filled with the last reconstructed pulse parameters
123 
124  protected:
125 
126  /**
127  A method to integrate an waveform from index "begin" to the "end". The result is filled in "result" reference.
128  If the "end" is default (=0), then "end" is set to the last index of the waveform.
129  */
130  bool Integral (const std::vector<short> &wf, double &result, size_t begin=0, size_t end=0) const;
131 
132  /**
133  A method to compute derivative, which is a simple subtraction of previous ADC sample from each sample.
134  The result is stored in the input "diff" reference vector which is int32_t type as a derivative could be negative.
135  */
136  bool Derivative (const std::vector<short> &wf, std::vector<int32_t> &diff, size_t begin=0, size_t end=0) const;
137 
138  /**
139  A method to return the maximum value of ADC sample within the index from "begin" to "end".
140  If the "end" is default (=0), then "end" is set to the last index of the waveform.
141  */
142  size_t Max(const std::vector<short> &wf, double &result, size_t begin=0, size_t end=0) const;
143 
144  /**
145  A method to return the minimum value of ADC sample within the index from "begin" to "end".
146  If the "end" is default (=0), then "end" is set to the last index of the waveform.
147  */
148  size_t Min(const std::vector<short> &wf, double &result, size_t begin=0, size_t end=0) const;
149 
150  };
151 
152 }
153 #endif
154 
155 /** @} */ // end of doxygen group
static QCString name
Definition: declinfo.cpp:673
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
bool _status
Status after pulse reconstruction.
std::vector< double > PedestalSigma_t
static QCString result
std::string string
Definition: nybbler.cc:12
ChannelGroupService::Name Name
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.
std::vector< short > Waveform_t
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
std::vector< pmtana::pulse_param > pulse_param_array
std::vector< double > PedestalMean_t
pulse_param_array _pulse_v
A container array of pulse_param struct objects to store (possibly multiple) reconstructed pulse(s)...