Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunesim
dunesim
DetSim
Tool
IdealAdcSimulator_tool.cc
Go to the documentation of this file.
1
// IdealAdcSimulator_tool.cc
2
3
#include "
IdealAdcSimulator.h
"
4
5
//**********************************************************************
6
7
IdealAdcSimulator::IdealAdcSimulator
(
double
vsen,
unsigned
int
nbit)
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
}
17
m_vmax
=
m_vsen
*
m_adcmax
;
18
}
19
20
//**********************************************************************
21
22
IdealAdcSimulator::IdealAdcSimulator
(
const
fhicl::ParameterSet
&
ps
)
23
:
IdealAdcSimulator
(ps.
get
<
double
>(
"Vsen"
), ps.
get
<
unsigned
int
>(
"Nbit"
)) { }
24
25
//**********************************************************************
26
27
AdcSimulator::Count
28
IdealAdcSimulator::count
(
double
vin,
Channel
,
Tick
)
const
{
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
}
40
41
//**********************************************************************
42
43
DEFINE_ART_CLASS_TOOL
(
IdealAdcSimulator
)
IdealAdcSimulator::count
Count count(double vin, Channel chan=0, Tick tick=0) const override
Definition:
IdealAdcSimulator_tool.cc:28
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
IdealAdcSimulator
Definition:
IdealAdcSimulator.h:23
IdealAdcSimulator::IdealAdcSimulator
IdealAdcSimulator(double vsen, unsigned int nbit=12)
Definition:
IdealAdcSimulator_tool.cc:7
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
AdcSimulator::Tick
unsigned int Tick
Definition:
AdcSimulator.h:25
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
IdealAdcSimulator.h
IdealAdcSimulator::m_adcmax
Count m_adcmax
Definition:
IdealAdcSimulator.h:40
AdcSimulator::Channel
unsigned int Channel
Definition:
AdcSimulator.h:23
AdcSimulator::Count
unsigned short Count
Definition:
AdcSimulator.h:24
IdealAdcSimulator::m_vsen
double m_vsen
Definition:
IdealAdcSimulator.h:38
IdealAdcSimulator::m_vmax
double m_vmax
Definition:
IdealAdcSimulator.h:39
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11