Public Member Functions | Private Attributes | List of all members
MedianPedestalService Class Reference

#include <MedianPedestalService.h>

Inheritance diagram for MedianPedestalService:
PedestalEvaluationService

Public Member Functions

 MedianPedestalService (fhicl::ParameterSet const &pset, art::ActivityRegistry &)
 
int evaluate (const AdcChannelData &data, AdcSignal *pped=nullptr, AdcSignal *prms=nullptr, AdcSignal *ppederr=nullptr, AdcSignal *prmserr=nullptr) const
 
std::ostream & print (std::ostream &out=std::cout, std::string prefix="") const
 
- Public Member Functions inherited from PedestalEvaluationService
virtual ~PedestalEvaluationService ()=default
 

Private Attributes

int m_LogLevel
 
bool m_UseMean
 
bool m_SkipFlaggedSamples
 
bool m_SkipSignals
 
std::vector< std::vector< AdcChannelVector > > m_GroupChannels
 

Detailed Description

Definition at line 30 of file MedianPedestalService.h.

Constructor & Destructor Documentation

MedianPedestalService::MedianPedestalService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry  
)

Definition at line 22 of file MedianPedestalService_service.cc.

23 : m_LogLevel(1),
24  m_SkipFlaggedSamples(false),
25  m_SkipSignals(false) {
26  const string myname = "MedianPedestalService::ctor: ";
27  pset.get_if_present<int>("LogLevel", m_LogLevel);
28  m_UseMean = pset.get<bool>("UseMean");
29  m_SkipFlaggedSamples = pset.get<bool>("SkipFlaggedSamples");
30  m_SkipSignals = pset.get<bool>("SkipSignals");
31  print(cout, myname);
32 }
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const

Member Function Documentation

int MedianPedestalService::evaluate ( const AdcChannelData data,
AdcSignal pped = nullptr,
AdcSignal prms = nullptr,
AdcSignal ppederr = nullptr,
AdcSignal prmserr = nullptr 
) const
virtual

Implements PedestalEvaluationService.

Definition at line 37 of file MedianPedestalService_service.cc.

38  {
39  const string myname = "MedianPedestalService::evaluate: ";
40  AdcSignal ped = 0.0;
41  AdcSignal rms = 0.0;
42  AdcSignal pederr = 0.0;
43  AdcSignal rmserr = 0.0;
44  const AdcSignalVector sigsin = data.samples;
45  const AdcFlagVector flags = data.flags;
46  const AdcFilterVector signal = data.signal;
47  if ( sigsin.size() == 0 ) return 0;
48  AdcSignalVector sigs;
49  unsigned int nsig = sigsin.size();
50  double sigsum = 0.0;
51  unsigned int nsigout = 0;
52  for ( unsigned int isig=0; isig<nsig; ++isig ) {
53  AdcSignal sig = sigsin[isig];
54  if ( m_SkipFlaggedSamples && flags.size() ) {
55  AdcFlag flag = flags[isig];
56  bool skip = flag != AdcGood;
57  if ( skip ) continue;
58  }
59  if ( m_SkipSignals && signal.size() ) {
60  bool isSignal = signal[isig];
61  if ( isSignal ) continue;
62  }
63  if ( m_UseMean ) sigsum += sig;
64  else sigs.push_back(sig);
65  ++nsigout;
66  }
67  if ( nsigout ) {
68  if ( m_UseMean ) {
69  ped = sigsum/nsigout;
70  } else {
71  sort(sigs.begin(), sigs.end());
72  unsigned int isig = sigs.size()/2;
73  bool isodd = sigs.size()%2;
74  ped = isodd ? sigs[isig-1] : 0.5*(sigs[isig-1] + sigs[isig]);
75  }
76  }
77  if ( pped != nullptr ) *pped = ped;
78  if ( prms != nullptr ) *prms = rms;
79  if ( ppederr != nullptr ) *ppederr = pederr;
80  if ( prmserr != nullptr ) *prmserr = rmserr;
81  return 0;
82 }
short AdcFlag
Definition: AdcTypes.h:29
double rms(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:40
float AdcSignal
Definition: AdcTypes.h:21
std::vector< AdcFlag > AdcFlagVector
Definition: AdcTypes.h:30
const AdcFlag AdcGood
Definition: AdcTypes.h:32
AdcFilterVector signal
std::vector< bool > AdcFilterVector
Definition: AdcTypes.h:27
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
AdcSignalVector samples
AdcFlagVector flags
ostream & MedianPedestalService::print ( std::ostream &  out = std::cout,
std::string  prefix = "" 
) const
virtual

Implements PedestalEvaluationService.

Definition at line 87 of file MedianPedestalService_service.cc.

87  {
88  out << prefix << "MedianPedestalService:" << endl;
89  out << prefix << " LogLevel: " << m_LogLevel << endl;
90  out << prefix << " SkipFlaggedSamples: " << m_SkipFlaggedSamples << endl;
91  out << prefix << " SkipSignals: " << m_SkipSignals << endl;
92  return out;
93 }
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::vector<std::vector<AdcChannelVector> > MedianPedestalService::m_GroupChannels
private

Definition at line 55 of file MedianPedestalService.h.

int MedianPedestalService::m_LogLevel
private

Definition at line 45 of file MedianPedestalService.h.

bool MedianPedestalService::m_SkipFlaggedSamples
private

Definition at line 47 of file MedianPedestalService.h.

bool MedianPedestalService::m_SkipSignals
private

Definition at line 48 of file MedianPedestalService.h.

bool MedianPedestalService::m_UseMean
private

Definition at line 46 of file MedianPedestalService.h.


The documentation for this class was generated from the following files: