PulseRecoManager.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // PulseRecoManager source
4 //
5 ////////////////////////////////////////////////////////////////////////
6 
7 #include "PulseRecoManager.h"
8 #include "OpticalRecoException.h"
11 
12 #include <sstream>
13 
14 namespace pmtana{
15 
16  //*******************************************************
17  PulseRecoManager::PulseRecoManager() : _ped_algo(nullptr)
18  //*******************************************************
19  {
20  _reco_algo_v.clear();
21  }
22 
23  //************************************************************************************
25  //************************************************************************************
26  {
27  if(!algo) throw OpticalRecoException("Invalid PulseReco algorithm!");
28 
29  _reco_algo_v.push_back(std::make_pair(algo,ped_algo));
30  }
31 
32  //**************************************************************
34  //**************************************************************
35  {
36  if(!algo) throw OpticalRecoException("Invalid Pedestal algorithm!");
37  _ped_algo = algo;
38  }
39 
40  //**********************************************************************
42  //**********************************************************************
43  {
44  if(_reco_algo_v.empty() && !_ped_algo)
45 
46  throw OpticalRecoException("No Pulse/Pedestal reconstruction to run!");
47 
48  bool ped_status = true;
49 
50  if(_ped_algo)
51 
52  ped_status = _ped_algo->Evaluate(wf);
53 
54  bool pulse_reco_status = ped_status;
55 
56  for(auto& algo_pair : _reco_algo_v) {
57 
58  auto& pulse_algo = algo_pair.first;
59  auto& ped_algo = algo_pair.second;
60 
61  if(ped_algo) {
62 
63  ped_status = ped_status && ped_algo->Evaluate(wf);
64 
65  pulse_reco_status = ( ped_status &&
66  pulse_reco_status &&
67  pulse_algo->Reconstruct( wf, ped_algo->Mean(), ped_algo->Sigma() )
68  );
69 
70  } else {
71 
72  if( !_ped_algo ) {
73  std::stringstream ss;
74  ss << "No pedestal algorithm available for pulse algo " << pulse_algo->Name();
75  throw OpticalRecoException(ss.str());
76  }
77 
78  pulse_reco_status = ( pulse_reco_status &&
79  pulse_algo->Reconstruct( wf, _ped_algo->Mean(), _ped_algo->Sigma() )
80  );
81  }
82  }
83 
84  return pulse_reco_status;
85 
86  }
87 
88 }
Class def header for exception classes in OpticalDetector package.
double Mean(size_t i) const
Getter of the pedestal mean value.
void AddRecoAlgo(pmtana::PMTPulseRecoBase *algo, PMTPedestalBase *ped_algo=nullptr)
A method to set pulse reconstruction algorithm.
Class definition file of PMTPedestalBase.
bool Evaluate(const pmtana::Waveform_t &wf)
Method to compute a pedestal.
double Sigma(size_t i) const
Getter of the pedestal standard deviation.
bool Reconstruct(const pmtana::Waveform_t &) const
Implementation of ana_base::analyze method.
std::vector< short > Waveform_t
PMTPedestalBase * _ped_algo
ped_estimator object
void SetDefaultPedAlgo(pmtana::PMTPedestalBase *algo)
A method to set a choice of pedestal estimation method.
PulseRecoManager()
Default constructor.
Class definition file of PMTPulseRecoBase.
std::vector< std::pair< pmtana::PMTPulseRecoBase *, pmtana::PMTPedestalBase * > > _reco_algo_v
pulse reconstruction algorithm pointer
Class definition file of PulseRecoManager.