All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IWaveformTool.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file IWaveformTool.h
4 ///
5 /// \brief This is the interface class for tools/algorithms that
6 /// perform various operations on waveforms. Examples include
7 /// smoothing, differentiation, filtering, etc.
8 ///
9 /// \author T. Usher
10 ///
11 ////////////////////////////////////////////////////////////////////////
12 
13 #ifndef IWaveformTool_H
14 #define IWaveformTool_H
15 
16 namespace fhicl { class ParameterSet; }
17 class TProfile;
18 
19 #include <map>
20 #include <tuple>
21 #include <vector>
22 
23 namespace reco_tool
24 {
25  template <class T> using Waveform = std::vector<T>;
26 
27  //< Enumerate some histograms that can be defined in methods below
28  enum HistogramType : int
29  {
39  };
40 
41  using HistogramMap = std::map<int, TProfile*>;
42 
44  {
45  public:
46  virtual ~IWaveformTool() noexcept = default;
47 
48  virtual void configure(const fhicl::ParameterSet& pset) = 0;
49 
50  using PeakTuple = std::tuple<size_t,size_t,size_t>; //< first bin, peak bin, last bin
51  using PeakTupleVec = std::vector<PeakTuple>; //< The collection of candidate peaks
52 
53  virtual void triangleSmooth(const std::vector<float>&, std::vector<float>&, size_t = 0) const = 0;
54  virtual void triangleSmooth(const std::vector<double>&, std::vector<double>&, size_t = 0) const = 0;
55  virtual void medianSmooth( const std::vector<float>&, std::vector<float>&, size_t = 3) const = 0;
56  virtual void medianSmooth( const std::vector<double>&, std::vector<double>&, size_t = 3) const = 0;
57  virtual void getTruncatedMeanRMS(const std::vector<float>&, float&, float&, float&, int&) const = 0;
58  virtual void getTruncatedMeanRMS(const std::vector<double>&, double&, double&, double&, int&) const = 0;
59  virtual void firstDerivative(const std::vector<float>&, std::vector<float>&) const = 0;
60  virtual void firstDerivative(const std::vector<double>&, std::vector<double>&) const = 0;
61  virtual void findPeaks(std::vector<float>::iterator, std::vector<float>::iterator, PeakTupleVec&, float, size_t) const = 0;
62  virtual void findPeaks(std::vector<double>::iterator, std::vector<double>::iterator, PeakTupleVec&, double, size_t) const = 0;
63  virtual void getFFTPower(const std::vector<float>& inputVec, std::vector<float>& outputPowerVec) const = 0;
64  virtual void getFFTPower(const std::vector<double>& inputVec, std::vector<double>& outputPowerVec) const = 0;
65 
66  virtual void getErosionDilationAverageDifference(const Waveform<short>&, //< Input waveform
67  int, //< Structuring element
68  HistogramMap&, //< Map of histograms to fill
69  Waveform<short>&, //< Output erosion vector
70  Waveform<short>&, //< Output dilation vector
71  Waveform<short>&, //< Output ave erosion & dilation
72  Waveform<short>&) const = 0; //< Output diff erosion and dilation
74  int,
75  HistogramMap&,
79  Waveform<float>&) const = 0;
81  int,
82  HistogramMap&,
86  Waveform<double>&) const = 0;
87 
88  virtual void getOpeningAndClosing(const Waveform<short>&, //< Input erosions vector
89  const Waveform<short>&, //< Input dilation vector
90  int, //< Structuring element
91  HistogramMap&, //< Map of histograms to fill
92  Waveform<short>&, //< Output closing vector
93  Waveform<short>&) const = 0; //< Output opening vector
94  virtual void getOpeningAndClosing(const Waveform<float>&, //< Input erosions vector
95  const Waveform<float>&, //< Input dilation vector
96  int, //< Structuring element
97  HistogramMap&, //< Map of histograms to fill
98  Waveform<float>&, //< Output closing vector
99  Waveform<float>&) const = 0; //< Output opening vector
100  virtual void getOpeningAndClosing(const Waveform<double>&, //< Input erosions vector
101  const Waveform<double>&, //< Input dilation vector
102  int, //< Structuring element
103  HistogramMap&, //< Map of histograms to fill
104  Waveform<double>&, //< Output closing vector
105  Waveform<double>&) const = 0; //< Output opening vector
106  };
107 }
108 
109 #endif
std::tuple< size_t, size_t, size_t > PeakTuple
Definition: IWaveformTool.h:50
std::vector< T > Waveform
Definition: IWaveformTool.h:25
virtual void firstDerivative(const std::vector< float > &, std::vector< float > &) const =0
std::vector< PeakTuple > PeakTupleVec
Definition: IWaveformTool.h:51
virtual void triangleSmooth(const std::vector< float > &, std::vector< float > &, size_t=0) const =0
virtual void configure(const fhicl::ParameterSet &pset)=0
virtual void getErosionDilationAverageDifference(const Waveform< short > &, int, HistogramMap &, Waveform< short > &, Waveform< short > &, Waveform< short > &, Waveform< short > &) const =0
virtual void getFFTPower(const std::vector< float > &inputVec, std::vector< float > &outputPowerVec) const =0
std::map< int, TProfile * > HistogramMap
Definition: IWaveformTool.h:41
virtual void findPeaks(std::vector< float >::iterator, std::vector< float >::iterator, PeakTupleVec &, float, size_t) const =0
virtual void getOpeningAndClosing(const Waveform< short > &, const Waveform< short > &, int, HistogramMap &, Waveform< short > &, Waveform< short > &) const =0
virtual void getTruncatedMeanRMS(const std::vector< float > &, float &, float &, float &, int &) const =0
virtual ~IWaveformTool() noexcept=default
virtual void medianSmooth(const std::vector< float > &, std::vector< float > &, size_t=3) const =0