All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PedAlgoRmsSlider.h
Go to the documentation of this file.
1 /**
2  * \file PedAlgoRmsSlider.h
3  *
4  * \ingroup PulseReco
5  *
6  * \brief Class definition file of PedAlgoRmsSlider
7  *
8  * @author Marco - Oxford 2017
9  */
10 
11 /** \addtogroup PulseReco
12 
13 @{*/
14 
15 #ifndef larana_OPTICALDETECTOR_PEDALGORMSSLIDER_H
16 #define larana_OPTICALDETECTOR_PEDALGORMSSLIDER_H
17 
19 
20 #include "PMTPedestalBase.h"
21 namespace fhicl { class ParameterSet; }
22 
23 #include <fstream>
24 #include <string>
25 #include <vector>
26 
27 namespace pmtana
28 {
29 
30  /**
31  \class PedAlgoRmsSlider
32  A class that calculates pedestal mean & standard deviation (here and elsewhere called as "RMS").
33  */
35 
36  public:
37 
38  /// Default constructor
39  PedAlgoRmsSlider(const std::string name="PedRmsSlider");
40 
41  /// Alternative ctor
42  PedAlgoRmsSlider(const fhicl::ParameterSet &pset,const std::string name="PedRmsSlider");
43 
44  /// Print settings
45  void PrintInfo();
46 
47 
48  protected:
49 
50  /// Method to compute a pedestal of the input waveform using "nsample" ADC samples from "start" index.
51  bool ComputePedestal( const pmtana::Waveform_t& wf,
52  pmtana::PedestalMean_t& mean_v,
53  pmtana::PedestalSigma_t& sigma_v);
54 
55  private:
56 
57  size_t _sample_size; ///< How many samples are used to calculate local rms and mean
58  double _threshold; ///< Threshold applied to local rms to claim a pulse
59 
60  float _max_sigma; ///< Max sigma to consider adc as 'sane'
61  float _ped_range_max; ///< Max value of adc to consider adc as 'sane'
62  float _ped_range_min; ///< Min value of adc to consider adc as 'sane'
63 
64  bool _verbose; ///< For debugging
65  int _n_wf_to_csvfile; ///< If greater than zero saves firsts waveforms with pedestal to csv file
66  int _wf_saved = 0;
67  int _num_presample; ///< number of ADCs to sample before the gap
68  int _num_postsample; ///< number of ADCs to sample after the gap
69  std::ofstream _csvfile;
70 
71  /// Returns the mean of the elements of the vector from start to start+nsample
72  double CalcMean(const std::vector<double>& wf, size_t start, size_t nsample);
73 
74  /// Returns the std of the elements of the vector from start to start+nsample
75  double CalcStd(const std::vector<double>& wf, const double ped_mean, size_t start, size_t nsample);
76 
77  /// Checks the sanity of the estimated pedestal, returns false if not sane
79  };
80 }
81 #endif
82 
83 /** @} */ // end of doxygen group
void PrintInfo()
Print settings.
bool CheckSanity(pmtana::PedestalMean_t &mean_v, pmtana::PedestalSigma_t &sigma_v)
Checks the sanity of the estimated pedestal, returns false if not sane.
std::vector< double > PedestalSigma_t
float _ped_range_min
Min value of adc to consider adc as &#39;sane&#39;.
int _num_postsample
number of ADCs to sample after the gap
float _max_sigma
Max sigma to consider adc as &#39;sane&#39;.
PedAlgoRmsSlider(const std::string name="PedRmsSlider")
Default constructor.
Class definition file of PMTPedestalBase.
int _num_presample
number of ADCs to sample before the gap
double CalcStd(const std::vector< double > &wf, const double ped_mean, size_t start, size_t nsample)
Returns the std of the elements of the vector from start to start+nsample.
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 &quot;nsample&quot; ADC samples from &quot;start&quot; index...
double _threshold
Threshold applied to local rms to claim a pulse.
float _ped_range_max
Max value of adc to consider adc as &#39;sane&#39;.
std::vector< short > Waveform_t
int _n_wf_to_csvfile
If greater than zero saves firsts waveforms with pedestal to csv file.
size_t _sample_size
How many samples are used to calculate local rms and mean.
then echo fcl name
double CalcMean(const std::vector< double > &wf, size_t start, size_t nsample)
Returns the mean of the elements of the vector from start to start+nsample.
std::vector< double > PedestalMean_t
bool _verbose
For debugging.