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

#include <NoisyAdcSimulator.h>

Inheritance diagram for NoisyAdcSimulator:
AdcSimulator

Public Member Functions

 NoisyAdcSimulator (double vsen, unsigned int nbit, int noise)
 
 NoisyAdcSimulator (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

int m_noise
 
double m_vsen
 
double m_vmax
 
Count m_adcmax
 
CLHEP::HepRandomEngine * m_random_engine
 

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 27 of file NoisyAdcSimulator.h.

Constructor & Destructor Documentation

NoisyAdcSimulator::NoisyAdcSimulator ( double  vsen,
unsigned int  nbit,
int  noise 
)
explicit

Definition at line 9 of file NoisyAdcSimulator_tool.cc.

10  :m_noise(noise), m_vsen(vsen), m_vmax(0.0), m_adcmax(0), m_random_engine(nullptr) {
11 
13  m_random_engine = new HepJamesRandom;
14  seedSvc->registerEngine(NuRandomService::CLHEPengineSeeder(m_random_engine), "NoisyAdcSimulator");
15 
16  if ( nbit == 0 ) return;
17  unsigned int nbitmax = 8*sizeof(Count);
18  if ( nbit > nbitmax ) return;
19  unsigned int bit = 1;
20  for ( unsigned int ibit=0; ibit<nbit; ++ibit ) {
21  m_adcmax |= bit;
22  bit = bit << 1;
23  }
25 
26 }
CLHEP::HepRandomEngine * m_random_engine
unsigned short Count
Definition: AdcSimulator.h:24
NoisyAdcSimulator::NoisyAdcSimulator ( fhicl::ParameterSet const &  ps)
explicit

Member Function Documentation

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

Implements AdcSimulator.

Definition at line 39 of file NoisyAdcSimulator_tool.cc.

39  {
40  CLHEP::RandBinomial binom(*m_random_engine);
41 
42  //std::cout << "v_sen " << m_vsen << " m_vmax " << m_vmax << " vin " << vin << std::endl;
43  double halfsen = 0.5*m_vsen;
44  if ( m_vsen <= 0.0 ) return 0;
45  if ( vin < halfsen ) return 0;
46  if ( vin > m_vmax - halfsen ) return m_adcmax;
47  Count count = vin/m_vsen + 0.5;
48  if (m_noise>0) {
49  int n = binom.fire(m_noise,0.5)- m_noise/2;
50  count += n;
51  }
52  if ( count > m_adcmax ) return m_adcmax;
53  return count;
54 }
Count count(double vin, Channel chan=0, Tick tick=0) const override
std::void_t< T > n
AdcSimulator::Count Count
CLHEP::HepRandomEngine * m_random_engine

Member Data Documentation

Count NoisyAdcSimulator::m_adcmax
private

Definition at line 44 of file NoisyAdcSimulator.h.

int NoisyAdcSimulator::m_noise
private

Definition at line 41 of file NoisyAdcSimulator.h.

CLHEP::HepRandomEngine* NoisyAdcSimulator::m_random_engine
private

Definition at line 45 of file NoisyAdcSimulator.h.

double NoisyAdcSimulator::m_vmax
private

Definition at line 43 of file NoisyAdcSimulator.h.

double NoisyAdcSimulator::m_vsen
private

Definition at line 42 of file NoisyAdcSimulator.h.


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