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

#include <FembLinearCalibration.h>

Inheritance diagram for FembLinearCalibration:
TpcDataTool AdcChannelTool

Public Member Functions

 FembLinearCalibration (fhicl::ParameterSet const &ps)
 
DataMap view (const AdcChannelData &acd) const override
 
DataMap update (AdcChannelData &acd) const override
 
- Public Member Functions inherited from TpcDataTool
virtual DataMap updateTpcData (TpcData &) const
 
virtual DataMap viewTpcData (const TpcData &) const
 
virtual int forwardTpcData () const
 
- Public Member Functions inherited from AdcChannelTool
virtual ~AdcChannelTool ()=default
 
virtual DataMap updateMap (AdcChannelDataMap &acds) const
 
virtual DataMap viewMap (const AdcChannelDataMap &acds) const
 
virtual bool updateWithView () const
 
virtual bool viewWithUpdate () const
 
virtual DataMap beginEvent (const DuneEventInfo &) const
 
virtual DataMap endEvent (const DuneEventInfo &) const
 
virtual DataMap close (const DataMap *dmin=nullptr)
 

Private Attributes

int m_LogLevel
 
std::string m_Units
 
AdcSignalVector m_Gains
 
AdcCount m_AdcMin
 
AdcCountVector m_AdcMins
 
AdcCount m_AdcMax
 
AdcCountVector m_AdcMaxs
 

Additional Inherited Members

- Public Types inherited from AdcChannelTool
using Index = unsigned int
 
- Static Public Member Functions inherited from AdcChannelTool
static int interfaceNotImplemented ()
 

Detailed Description

Definition at line 51 of file FembLinearCalibration.h.

Constructor & Destructor Documentation

FembLinearCalibration::FembLinearCalibration ( fhicl::ParameterSet const &  ps)

Definition at line 18 of file FembLinearCalibration_tool.cc.

19 : m_LogLevel(ps.get<int>("LogLevel")),
20  m_Units(ps.get<string>("Units")),
21  m_Gains(ps.get<AdcSignalVector>("Gains")),
22  m_AdcMin(ps.get<AdcCount>("AdcMin")),
23  m_AdcMins(ps.get<AdcCountVector>("AdcMins")),
24  m_AdcMax(ps.get<AdcCount>("AdcMax")),
25  m_AdcMaxs(ps.get<AdcCountVector>("AdcMaxs")) {
26  const string myname = "FembLinearCalibration::ctor: ";
27  int w = 28;
28  if ( m_LogLevel >= 1 ) {
29  cout << myname << setw(w) << "Log level: " << m_LogLevel << endl;
30  ostringstream sslab;
31  sslab << "Gains[" << m_Gains.size() << "]" << (m_Gains.size() ? ": " : " ");;
32  cout << myname << setw(w) << sslab.str();
33  for ( Index icha=0; icha<m_Gains.size(); ++icha ) {
34  if ( icha > 0 ) cout << ", ";
35  if ( icha >= 10 ) { cout << "..."; break; }
36  cout << m_Gains[icha];
37  }
38  cout << endl;
39  cout << myname << setw(w) << "Default ADC min: " << m_AdcMin << endl;
40  sslab.str("");
41  sslab << "Channel ADC min[" << m_AdcMins.size() << "]" << (m_AdcMins.size() ? ": " : " ");;
42  cout << myname << setw(w) << sslab.str();
43  for ( Index icha=0; icha<m_AdcMins.size(); ++icha ) {
44  if ( icha > 0 ) cout << ", ";
45  if ( icha >= 10 ) { cout << "..."; break; }
46  cout << m_AdcMins[icha];
47  }
48  cout << endl;
49  cout << myname << setw(w) << "Default ADC max: " << m_AdcMax << endl;
50  sslab.str("");
51  sslab << "Channel ADC max[" << m_AdcMaxs.size() << "]" << (m_AdcMaxs.size() ? ": " : " ");
52  cout << myname << setw(w) << sslab.str();
53  for ( Index icha=0; icha<m_AdcMaxs.size(); ++icha ) {
54  if ( icha > 0 ) cout << ", ";
55  if ( icha >= 10 ) { cout << "..."; break; }
56  cout << m_AdcMaxs[icha];
57  }
58  cout << endl;
59  }
60 }
std::vector< AdcCount > AdcCountVector
Definition: AdcTypes.h:19
unsigned int Index
static constexpr double ps
Definition: Units.h:99
Q_EXPORT QTSManip setw(int w)
Definition: qtextstream.h:331
std::vector< AdcSignal > AdcSignalVector
Definition: AdcTypes.h:22
short AdcCount
Definition: AdcTypes.h:18
QTextStream & endl(QTextStream &s)

Member Function Documentation

DataMap FembLinearCalibration::update ( AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 72 of file FembLinearCalibration_tool.cc.

72  {
73  const string myname = "FembLinearCalibration::update: ";
74  DataMap res;
75  AdcChannel icha = acd.channel();
76  if ( icha == AdcChannelData::badChannel() ) {
77  if ( m_LogLevel >= 2 ) {
78  cout << myname << "Data does not have a channel ID." << endl;
79  }
80  return res.setStatus(2);
81  }
82  if ( icha >= m_Gains.size() ) {
83  if ( m_LogLevel >= 2 ) {
84  cout << myname << "Gain not found for channel " << icha << endl;
85  }
86  return res.setStatus(4);
87  }
88  if ( m_AdcMins.size() && icha >= m_AdcMins.size() ) {
89  if ( m_LogLevel >= 2 ) {
90  cout << myname << "ADC min not found for channel " << icha << endl;
91  }
92  return res.setStatus(5);
93  }
94  if ( m_AdcMaxs.size() && icha >= m_AdcMaxs.size() ) {
95  if ( m_LogLevel >= 2 ) {
96  cout << myname << "ADC max not found for channel " << icha << endl;
97  }
98  return res.setStatus(6);
99  }
100  AdcSignal gain = m_Gains[icha];
101  if ( gain > 0.0 ) {
102  acd.samples.resize(acd.raw.size(), 0.0);
103  acd.flags.resize(acd.raw.size(), AdcGood);
104  AdcCount adcmin = m_AdcMins.size() ? m_AdcMins[icha] : m_AdcMin;
105  AdcCount adcmax = m_AdcMaxs.size() ? m_AdcMaxs[icha] : m_AdcMax;
106  Index nunder = 0;
107  Index nover = 0;
108  Index nsam = acd.raw.size();
109  for ( Index isam=0; isam<nsam; ++isam ) {
110  acd.samples[isam] = gain*(acd.raw[isam] - acd.pedestal);
111  if ( acd.raw[isam] <= adcmin ) {
112  acd.flags[isam] = AdcUnderflow;
113  ++nunder;
114  } else if ( acd.raw[isam] >= adcmax ) {
115  acd.flags[isam] = AdcOverflow;
116  ++nover;
117  }
118  }
119  acd.sampleUnit = m_Units;
120  res.setInt("calibSampleCount", nsam);
121  res.setInt("calibUnderflowCount", nunder);
122  res.setInt("calibOverflowCount", nover);
123  res.setInt("calibAdcMin", adcmin);
124  res.setInt("calibAdcMax", adcmax);
125  } else {
126  acd.samples.resize(0);
127  }
128  res.setFloat("calibGain", gain);
129  return res;
130 }
void setFloat(Name name, float val)
Definition: DataMap.h:133
DataMap & setStatus(int stat)
Definition: DataMap.h:130
float AdcSignal
Definition: AdcTypes.h:21
const AdcFlag AdcUnderflow
Definition: AdcTypes.h:33
unsigned int Index
const AdcFlag AdcGood
Definition: AdcTypes.h:32
const AdcFlag AdcOverflow
Definition: AdcTypes.h:34
void setInt(Name name, int val)
Definition: DataMap.h:131
AdcCountVector raw
Channel channel() const
AdcSignal pedestal
unsigned int AdcChannel
Definition: AdcTypes.h:50
static Index badChannel()
short AdcCount
Definition: AdcTypes.h:18
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags
DataMap FembLinearCalibration::view ( const AdcChannelData acd) const
overridevirtual

Reimplemented from AdcChannelTool.

Definition at line 64 of file FembLinearCalibration_tool.cc.

64  {
66  AdcChannelData acdtmp(acd);
67  return update(acdtmp);
68 }
static QCString result
DataMap update(AdcChannelData &acd) const override

Member Data Documentation

AdcCount FembLinearCalibration::m_AdcMax
private

Definition at line 70 of file FembLinearCalibration.h.

AdcCountVector FembLinearCalibration::m_AdcMaxs
private

Definition at line 71 of file FembLinearCalibration.h.

AdcCount FembLinearCalibration::m_AdcMin
private

Definition at line 68 of file FembLinearCalibration.h.

AdcCountVector FembLinearCalibration::m_AdcMins
private

Definition at line 69 of file FembLinearCalibration.h.

AdcSignalVector FembLinearCalibration::m_Gains
private

Definition at line 67 of file FembLinearCalibration.h.

int FembLinearCalibration::m_LogLevel
private

Definition at line 65 of file FembLinearCalibration.h.

std::string FembLinearCalibration::m_Units
private

Definition at line 66 of file FembLinearCalibration.h.


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