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

#include <IdealAdcSimulator.h>

Inheritance diagram for IdealAdcSimulator:
AdcSimulator

Public Member Functions

 IdealAdcSimulator (double vsen, unsigned int nbit=12)
 
 IdealAdcSimulator (fhicl::ParameterSet const &ps)
 
Count count (double vin, Channel chan=0, Tick tick=0) const override
 
- Public Member Functions inherited from AdcSimulator
virtual ~AdcSimulator ()=default
 

Private Attributes

double m_vsen
 
double m_vmax
 
Count m_adcmax
 

Additional Inherited Members

- Public Types inherited from AdcSimulator
using Channel = unsigned int
 
using Count = unsigned short
 
using Tick = unsigned int
 

Detailed Description

Definition at line 23 of file IdealAdcSimulator.h.

Constructor & Destructor Documentation

IdealAdcSimulator::IdealAdcSimulator ( double  vsen,
unsigned int  nbit = 12 
)
explicit

Definition at line 7 of file IdealAdcSimulator_tool.cc.

8 : m_vsen(vsen), m_vmax(0.0), m_adcmax(0) {
9  if ( nbit == 0 ) return;
10  unsigned int nbitmax = 8*sizeof(Count);
11  if ( nbit > nbitmax ) return;
12  unsigned int bit = 1;
13  for ( unsigned int ibit=0; ibit<nbit; ++ibit ) {
14  m_adcmax |= bit;
15  bit = bit << 1;
16  }
18 }
unsigned short Count
Definition: AdcSimulator.h:24
IdealAdcSimulator::IdealAdcSimulator ( fhicl::ParameterSet const &  ps)
explicit

Member Function Documentation

AdcSimulator::Count IdealAdcSimulator::count ( double  vin,
Channel  chan = 0,
Tick  tick = 0 
) const
overridevirtual

Implements AdcSimulator.

Definition at line 28 of file IdealAdcSimulator_tool.cc.

28  {
29  //std::cout << "v_sen " << m_vsen << " m_vmax " << m_vmax << " vin " << vin << std::endl;
30  double halfsen = 0.5*m_vsen;
31  if ( m_vsen <= 0.0 ) return 0;
32  if ( vin < halfsen ) return 0;
33  if ( vin > m_vmax - halfsen ) return m_adcmax;
34  Count count = vin/m_vsen + 0.5;
35  assert( count <= m_adcmax );
36  //std::cout << " count " << count << " m_adcmax " << m_adcmax << std::endl;
37  if ( count > m_adcmax ) return m_adcmax;//
38  return count;
39 }
Count count(double vin, Channel chan=0, Tick tick=0) const override
AdcSimulator::Count Count

Member Data Documentation

Count IdealAdcSimulator::m_adcmax
private

Definition at line 40 of file IdealAdcSimulator.h.

double IdealAdcSimulator::m_vmax
private

Definition at line 39 of file IdealAdcSimulator.h.

double IdealAdcSimulator::m_vsen
private

Definition at line 38 of file IdealAdcSimulator.h.


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