AdcSampleFiller_tool.cc
Go to the documentation of this file.
1 // AdcSampleFiller_tool.cc
2 
3 #include "AdcSampleFiller.h"
4 #include <iostream>
5 
6 using std::string;
7 using std::cout;
8 using std::endl;
9 
10 //**********************************************************************
11 // Class methods.
12 //**********************************************************************
13 
15 : m_LogLevel(ps.get<int>("LogLevel")),
16  m_AdcUnderflow(ps.get<unsigned int>("AdcUnderflow")),
17  m_AdcOverflow(ps.get<unsigned int>("AdcOverflow")) {
18  const string myname = "AdcSampleFiller::ctor: ";
19  if ( m_LogLevel >= 1 ) {
20  cout << myname << "Configuration parameters:" << endl;
21  cout << myname << " LogLevel: " << m_LogLevel << endl;
22  cout << myname << " AdcUnderflow: " << m_AdcUnderflow << endl;
23  cout << myname << " AdcOverflow: " << m_AdcOverflow << endl;
24  }
25 }
26 
27 //**********************************************************************
28 
30  const string myname = "AdcSampleFiller::update: ";
31  AdcIndex nsam = acd.raw.size();
32  acd.samples.resize(nsam, AdcChannelData::badSignal());
33  acd.flags.resize(nsam, AdcGood);
34  AdcPedestal ped = acd.pedestal;
35  if ( m_LogLevel >= 2 ) {
36  cout << myname << "# samples: " << nsam << endl;
37  cout << myname << " Pedestal: " << ped << endl;
38  }
39  if ( ped == AdcChannelData::badSignal() ) {
40  cout << myname << "Pedestal is not set." << endl;
41  return DataMap(1);
42  }
43  AdcIndex nlo = 0;
44  AdcIndex nhi = 0;
45  AdcIndex nbad = 0;
46  for ( AdcIndex isam=0; isam<nsam; ++isam ) {
47  AdcIndex adc = acd.raw[isam];
48  acd.samples[isam] = adc - ped;
49  if ( adc <= m_AdcUnderflow ) {
50  acd.flags[isam] = AdcUnderflow;
51  ++nlo;
52  } else if ( adc >= m_AdcOverflow ) {
53  acd.flags[isam] = AdcOverflow;
54  ++nhi;
55  }
56  if ( adc < m_AdcUnderflow || adc > m_AdcOverflow ) ++nbad;
57  }
58  acd.sampleUnit = "ADC count";
59  DataMap res(0);
60  res.setInt("nSample", nsam);
61  res.setInt("nUnderflow", nlo);
62  res.setInt("nOverflow", nhi);
63  res.setInt("nOutOfRange", nbad);
64  return res;
65 }
66 
67 //**********************************************************************
68 
70  AdcChannelData acdtmp;
71  acdtmp.samples = acd.samples;
72  return update(acdtmp);
73 }
74 
75 //**********************************************************************
76 
#define DEFINE_ART_CLASS_TOOL(tool)
Definition: ToolMacros.h:42
DataMap update(AdcChannelData &acd) const override
DataMap view(const AdcChannelData &acd) const override
std::string string
Definition: nybbler.cc:12
int16_t adc
Definition: CRTFragment.hh:202
const AdcFlag AdcUnderflow
Definition: AdcTypes.h:33
AdcIndex m_AdcOverflow
const AdcFlag AdcGood
Definition: AdcTypes.h:32
static Index badSignal()
const AdcFlag AdcOverflow
Definition: AdcTypes.h:34
void setInt(Name name, int val)
Definition: DataMap.h:131
AdcIndex m_AdcUnderflow
static constexpr double ps
Definition: Units.h:99
AdcCountVector raw
unsigned int AdcIndex
Definition: AdcTypes.h:15
AdcSampleFiller(fhicl::ParameterSet const &ps)
AdcSignal pedestal
float AdcPedestal
Definition: AdcTypes.h:25
auto const & get(AssnsNode< L, R, D > const &r)
Definition: AssnsNode.h:115
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags