MultiChannelNoiseRemovalService_service.cc
Go to the documentation of this file.
1 // MultiChannelNoiseRemovalService_service.cc
2 
5 #include <iostream>
8 
9 using std::cout;
10 using std::endl;
11 using std::ostream;
12 using std::string;
13 using art::ServiceHandle;
14 
15 //**********************************************************************
16 
19 : m_LogLevel(1) {
20  const string myname = "MultiChannelNoiseRemovalService::ctor: ";
21  pset.get_if_present<int>("LogLevel", m_LogLevel);
22  // Get service.
24  print(cout, myname);
25 }
26 
27 //**********************************************************************
28 
30  const string myname = "MultiChannelNoiseRemovalService:update: ";
31  if ( m_pAdcChannelNoiseRemovalService == nullptr ) {
32  cout << myname << "ERROR: AdcChannelNoiseRemovalService not found." << endl;
33  return 1;
34  }
35  if ( m_LogLevel >= 2 ) cout << myname << "Updating " << datamap.size() << " channel"
36  << (datamap.size()!=1 ? "" : "s") << "." << endl;
37  int rstat = 0;
38  for ( AdcChannelDataMap::value_type& chdata : datamap ) {
39  AdcChannelData& data = chdata.second;
40  if ( m_pAdcChannelNoiseRemovalService->update(data) ) ++rstat;
41  }
42  if ( rstat != 0 ) cout << myname << "WARNING: Update failed for " << rstat << " of "
43  << datamap.size() << " channel" << (rstat!=1 ? "" : "s") << "." << endl;
44  return 0;
45 }
46 
47 //**********************************************************************
48 
50 print(ostream& out, string prefix) const {
51  out << prefix << "MultiChannelNoiseRemovalService:" << endl;
52  out << prefix << " LogLevel: " << m_LogLevel << endl;
53  return out;
54 }
55 
56 //**********************************************************************
57 
59 
60 //**********************************************************************
std::string string
Definition: nybbler.cc:12
const AdcChannelNoiseRemovalService * m_pAdcChannelNoiseRemovalService
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const
MultiChannelNoiseRemovalService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:224
int update(AdcChannelDataMap &datamap) const
virtual int update(AdcChannelData &data) const =0
std::map< AdcChannel, AdcChannelData > AdcChannelDataMap
QTextStream & endl(QTextStream &s)
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)