Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
AdcRangeSampleScaler_tool.cc
Go to the documentation of this file.
1
// AdcRangeSampleScaler_tool.cc
2
3
#include "
AdcRangeSampleScaler.h
"
4
#include <iostream>
5
6
using
std::string
;
7
using
std::cout;
8
using
std::endl
;
9
10
using
Index
=
unsigned
int
;
11
12
//**********************************************************************
13
// Class methods.
14
//**********************************************************************
15
16
AdcRangeSampleScaler::AdcRangeSampleScaler
(
fhicl::ParameterSet
const
&
ps
)
17
: m_LogLevel(ps.
get
<
int
>(
"LogLevel"
)),
18
m_RangeLimits(ps.
get
<
IndexVector
>(
"RangeLimits"
)),
19
m_RangeModulus(ps.
get
<
Index
>(
"RangeModulus"
)),
20
m_ScaleFactors(ps.
get
<
FloatVector
>(
"ScaleFactors"
)) {
21
const
string
myname =
"AdcRangeSampleScaler::ctor: "
;
22
if
(
m_LogLevel
>= 1 ) {
23
cout << myname <<
"Parameters:"
<<
endl
;
24
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
25
Index
imin = 0;
26
cout << myname <<
" Modulus: "
<<
m_RangeModulus
<<
endl
;
27
cout << myname <<
" Range: Scale: "
<<
endl
;
28
Index
imod =
m_RangeModulus
;
29
for
(
Index
iran=0; ; ++iran ) {
30
// No more ranges.
31
// Unless protected with a modulus, we need one more scale factor.
32
Index
imax
= 0;
33
bool
haveMax =
true
;
34
if
( iran >=
m_RangeLimits
.size() ) {
35
if
( imod && imin >= imod ) {
36
break
;
37
}
38
haveMax =
false
;
39
}
else
{
40
imax =
m_RangeLimits
[iran];
41
if
( imod > 0 && imax >= imod ) {
42
cout << myname <<
"WARNING: Index exceeds modulus: "
<< imax <<
" >= "
<< imod <<
endl
;
43
break
;
44
}
45
}
46
if
(
m_ScaleFactors
.size() < iran + 1 ) {
47
cout << myname <<
"ERROR: Too few scale factors."
<<
endl
;
48
break
;
49
}
50
float
sfac =
m_ScaleFactors
[iran];
51
cout << myname <<
" ["
<< imin <<
", "
;
52
if
( haveMax ) cout <<
imax
;
53
else
cout <<
"..."
;
54
cout <<
"): "
<< sfac <<
endl
;
55
if
( haveMax ) imin =
imax
;
56
else
break
;
57
}
58
59
}
60
}
61
62
//**********************************************************************
63
64
DataMap
AdcRangeSampleScaler::update
(
AdcChannelData
& acd)
const
{
65
const
string
myname =
"AdcRangeSampleScaler::update: "
;
66
if
(
m_LogLevel
>= 2 ) cout <<
"Processing run "
<< acd.
run
() <<
" event "
<< acd.
event
()
67
<<
" channel "
<< acd.
channel
() <<
endl
;
68
DataMap
ret;
69
70
// Find the index for the scale factor.
71
if
( acd.
channel
() ==
AdcChannelData::badIndex
() ) {
72
cout << myname <<
"ERROR: Invalid channel."
<<
endl
;
73
return
ret.
setStatus
(1);
74
}
75
Index
icha = acd.
channel
();
76
Index
ichaMod =
m_RangeModulus
? icha%
m_RangeModulus
: icha;
77
Index
iran = 0;
78
for
( iran=0; iran<
m_RangeLimits
.size(); ++iran ) {
79
Index
imax
=
m_RangeLimits
[iran];
80
if
( ichaMod < imax ) {
81
break
;
82
}
83
}
84
85
if
( iran >=
m_ScaleFactors
.size() ) {
86
cout << myname <<
"ERROR: No scale factor for channel "
<< icha;
87
if
( ichaMod != icha ) cout <<
" ("
<< ichaMod <<
")"
;
88
cout <<
endl
;
89
return
ret.
setStatus
(2);
90
}
91
float
sfac =
m_ScaleFactors
[iran];
92
93
// Scale samples.
94
for
(
float
&
sam
: acd.
samples
) sam *= sfac;
95
96
ret.
setFloat
(
"arssScaleFactor"
, sfac);
97
98
return
ret;
99
}
100
101
//**********************************************************************
102
103
DEFINE_ART_CLASS_TOOL
(
AdcRangeSampleScaler
)
AdcRangeSampleScaler.h
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
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
AdcRangeSampleScaler::m_RangeLimits
IndexVector m_RangeLimits
Definition:
AdcRangeSampleScaler.h:42
AdcRangeSampleScaler::update
DataMap update(AdcChannelData &acd) const override
Definition:
AdcRangeSampleScaler_tool.cc:64
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
AdcChannelData
Definition:
AdcChannelData.h:95
AdcRangeSampleScaler::AdcRangeSampleScaler
AdcRangeSampleScaler(fhicl::ParameterSet const &ps)
Definition:
AdcRangeSampleScaler_tool.cc:16
cache_state.sam
sam
Definition:
cache_state.py:334
AdcRangeSampleScaler
Definition:
AdcRangeSampleScaler.h:24
AdcChannelData::run
AdcIndex run() const
Definition:
AdcChannelData.h:174
AdcChannelData::event
AdcIndex event() const
Definition:
AdcChannelData.h:176
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
AdcRangeSampleScaler::IndexVector
std::vector< Index > IndexVector
Definition:
AdcRangeSampleScaler.h:37
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
AdcRangeSampleScaler::m_ScaleFactors
FloatVector m_ScaleFactors
Definition:
AdcRangeSampleScaler.h:44
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
AdcRangeSampleScaler::FloatVector
std::vector< float > FloatVector
Definition:
AdcRangeSampleScaler.h:38
tracks.imax
int imax
Definition:
tracks.py:195
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
DataMap
Definition:
DataMap.h:43
AdcChannelData::badIndex
static Index badIndex()
Definition:
AdcChannelData.h:112
AdcRangeSampleScaler::m_RangeModulus
Index m_RangeModulus
Definition:
AdcRangeSampleScaler.h:43
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
AdcRangeSampleScaler::m_LogLevel
int m_LogLevel
Definition:
AdcRangeSampleScaler.h:41
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11