Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
FembLinearCalibration_tool.cc
Go to the documentation of this file.
1
// FembLinearCalibration_tool.cc
2
3
#include "
FembLinearCalibration.h
"
4
#include <iostream>
5
#include <sstream>
6
#include <iomanip>
7
8
using
std::string
;
9
using
std::cout;
10
using
std::endl
;
11
using
std::ostringstream;
12
using
std::setw
;
13
14
using
Index
=
unsigned
int
;
15
16
//**********************************************************************
17
18
FembLinearCalibration::FembLinearCalibration
(
fhicl::ParameterSet
const
&
ps
)
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
}
61
62
//**********************************************************************
63
64
DataMap
FembLinearCalibration::view
(
const
AdcChannelData
& acd)
const
{
65
DataMap
result
;
66
AdcChannelData
acdtmp(acd);
67
return
update
(acdtmp);
68
}
69
70
//**********************************************************************
71
72
DataMap
FembLinearCalibration::update
(
AdcChannelData
& acd)
const
{
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
}
131
132
//**********************************************************************
133
134
DEFINE_ART_CLASS_TOOL
(
FembLinearCalibration
)
AdcCountVector
std::vector< AdcCount > AdcCountVector
Definition:
AdcTypes.h:19
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
FembLinearCalibration::FembLinearCalibration
FembLinearCalibration(fhicl::ParameterSet const &ps)
Definition:
FembLinearCalibration_tool.cc:18
result
static QCString result
Definition:
fortranscanner.cpp:56614
DataMap::setFloat
void setFloat(Name name, float val)
Definition:
DataMap.h:133
AdcChannelTool::Index
unsigned int Index
Definition:
AdcChannelTool.h:58
DataMap::setStatus
DataMap & setStatus(int stat)
Definition:
DataMap.h:130
string
std::string string
Definition:
nybbler.cc:12
AdcChannelData::sampleUnit
Name sampleUnit
Definition:
AdcChannelData.h:133
AdcSignal
float AdcSignal
Definition:
AdcTypes.h:21
AdcUnderflow
const AdcFlag AdcUnderflow
Definition:
AdcTypes.h:33
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
AdcChannelData
Definition:
AdcChannelData.h:95
AdcGood
const AdcFlag AdcGood
Definition:
AdcTypes.h:32
FembLinearCalibration::update
DataMap update(AdcChannelData &acd) const override
Definition:
FembLinearCalibration_tool.cc:72
FembLinearCalibration
Definition:
FembLinearCalibration.h:51
AdcOverflow
const AdcFlag AdcOverflow
Definition:
AdcTypes.h:34
FembLinearCalibration::m_AdcMins
AdcCountVector m_AdcMins
Definition:
FembLinearCalibration.h:69
FembLinearCalibration::m_LogLevel
int m_LogLevel
Definition:
FembLinearCalibration.h:65
DataMap::setInt
void setInt(Name name, int val)
Definition:
DataMap.h:131
FembLinearCalibration::m_Units
std::string m_Units
Definition:
FembLinearCalibration.h:66
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
AdcChannelData::raw
AdcCountVector raw
Definition:
AdcChannelData.h:130
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
AdcChannelData::pedestal
AdcSignal pedestal
Definition:
AdcChannelData.h:128
FembLinearCalibration::m_Gains
AdcSignalVector m_Gains
Definition:
FembLinearCalibration.h:67
FembLinearCalibration::m_AdcMax
AdcCount m_AdcMax
Definition:
FembLinearCalibration.h:70
AdcChannel
unsigned int AdcChannel
Definition:
AdcTypes.h:50
AdcSignalVector
std::vector< AdcSignal > AdcSignalVector
Definition:
AdcTypes.h:22
FembLinearCalibration.h
AdcChannelData::badChannel
static Index badChannel()
Definition:
AdcChannelData.h:114
projectgui.w
w
Definition:
projectgui.py:20
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
AdcCount
short AdcCount
Definition:
AdcTypes.h:18
DataMap
Definition:
DataMap.h:43
FembLinearCalibration::m_AdcMaxs
AdcCountVector m_AdcMaxs
Definition:
FembLinearCalibration.h:71
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
FembLinearCalibration::view
DataMap view(const AdcChannelData &acd) const override
Definition:
FembLinearCalibration_tool.cc:64
FembLinearCalibration::m_AdcMin
AdcCount m_AdcMin
Definition:
FembLinearCalibration.h:68
AdcChannelData::flags
AdcFlagVector flags
Definition:
AdcChannelData.h:135
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11