Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
AdcTimingMitigator_tool.cc
Go to the documentation of this file.
1
// AdcTimingMitigator_tool.cc
2
3
#include "
AdcTimingMitigator.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
AdcTimingMitigator::AdcTimingMitigator
(
fhicl::ParameterSet
const
&
ps
)
17
: m_LogLevel(ps.
get
<
int
>(
"LogLevel"
)),
18
m_SamplingRatio(ps.
get
<
float
>(
"SamplingRatio"
)),
19
m_SamplingOffset(ps.
get
<
float
>(
"SamplingOffset"
)),
20
m_FEMBs(ps.
get
<
IndexVector
>(
"FEMBs"
)) {
21
const
string
myname =
"AdcTimingMitigator::ctor: "
;
22
for
(
Index
ifmb :
m_FEMBs
)
m_fembSet
.insert(ifmb);
23
if
(
m_LogLevel
>= 1 ) {
24
cout << myname <<
"Configuration parameters:"
<<
endl
;
25
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
26
cout << myname <<
" SamplingRatio: "
<<
m_SamplingRatio
<<
endl
;
27
cout << myname <<
" SamplingOffset: "
<<
m_SamplingOffset
<<
endl
;
28
cout << myname <<
" FEMBs: ["
;
29
bool
first =
true
;
30
for
(
Index
ifmb :
m_fembSet
) {
31
if
( first ) first =
false
;
32
else
cout <<
", "
;
33
cout << ifmb;
34
}
35
cout <<
"]"
<<
endl
;
36
}
37
}
38
39
//**********************************************************************
40
41
DataMap
AdcTimingMitigator::update
(
AdcChannelData
& acd)
const
{
42
const
string
myname =
"AdcTimingMitigator::update: "
;
43
DataMap
ret;
44
if
(
m_fembSet
.count(acd.
fembID
()) == 0 ) {
45
if
(
m_LogLevel
>= 2 ) {
46
cout << myname <<
"Skipping channel "
<< acd.
channel
() <<
" in FEMB "
<< acd.
fembID
() <<
endl
;
47
}
48
return
ret;
49
}
50
Index
nsam = acd.
samples
.size();
51
if
( nsam == 0 ) {
52
if
(
m_LogLevel
>= 2 ) {
53
cout << myname <<
"Skipping channel "
<< acd.
channel
() <<
" with no samples."
<<
endl
;
54
}
55
return
ret;
56
}
57
if
(
m_SamplingRatio
< 0.01 )
return
ret;
58
AdcSignalVector
newsams;
59
newsams.reserve(nsam/
m_SamplingRatio
+1);
60
// Loop over indices for new sample.
61
if
(
m_LogLevel
>= 3 ) {
62
cout << myname <<
"Updating samples for channel "
<< acd.
channel
() <<
"."
<<
endl
;
63
}
64
for
(
Index
j=0; ; ++j ) {
65
double
xj = j*
m_SamplingRatio
-
m_SamplingOffset
;
66
double
yj = acd.
samples
[0];
67
if
( xj > 0.0 ) {
68
Index
i1 = xj;
69
Index
i2 = i1 + 1;
70
if
( i2 >= acd.
samples
.size() )
break
;
71
double
y1 = acd.
samples
[i1];
72
double
y2 = acd.
samples
[i2];
73
yj = (y2 - y1)*(xj - i1) + y1;
74
if
(
m_LogLevel
>= 3 ) {
75
cout << myname <<
" "
<< j <<
": "
<< y1 <<
" , "
<< y2 <<
" ==> "
<< yj <<
endl
;
76
}
77
}
else
{
78
if
(
m_LogLevel
>= 3 ) {
79
cout << myname <<
" "
<< j <<
": "
<<
" Keeping first sample: "
<< yj <<
endl
;
80
}
81
}
82
newsams.push_back(yj);
83
}
84
if
(
m_LogLevel
>= 2 ) {
85
cout << myname <<
"Updating samples for channel "
<< acd.
channel
() <<
": size "
86
<< nsam <<
" --> "
<< newsams.size() <<
endl
;
87
}
88
acd.
samples
= newsams;
89
acd.
signal
.clear();
90
acd.
rois
.clear();
91
return
ret;
92
}
93
94
//**********************************************************************
95
96
DEFINE_ART_CLASS_TOOL
(
AdcTimingMitigator
)
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
AdcTimingMitigator::m_SamplingOffset
float m_SamplingOffset
Definition:
AdcTimingMitigator.h:59
AdcTimingMitigator
Definition:
AdcTimingMitigator.h:41
AdcChannelTool::Index
unsigned int Index
Definition:
AdcChannelTool.h:58
reco_momentum_tuples.float
float
Definition:
reco_momentum_tuples.py:12
string
std::string string
Definition:
nybbler.cc:12
AdcTimingMitigator::m_fembSet
IndexSet m_fembSet
Definition:
AdcTimingMitigator.h:62
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
AdcTimingMitigator::m_FEMBs
IndexVector m_FEMBs
Definition:
AdcTimingMitigator.h:60
AdcTimingMitigator::m_SamplingRatio
float m_SamplingRatio
Definition:
AdcTimingMitigator.h:58
AdcChannelData
Definition:
AdcChannelData.h:95
AdcTimingMitigator::AdcTimingMitigator
AdcTimingMitigator(fhicl::ParameterSet const &ps)
Definition:
AdcTimingMitigator_tool.cc:16
AdcChannelData::fembID
Index fembID() const
Definition:
AdcChannelData.h:200
AdcTimingMitigator::m_LogLevel
int m_LogLevel
Definition:
AdcTimingMitigator.h:57
AdcTimingMitigator::IndexVector
std::vector< Index > IndexVector
Definition:
AdcTimingMitigator.h:47
AdcChannelData::rois
AdcRoiVector rois
Definition:
AdcChannelData.h:137
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
AdcChannelData::signal
AdcFilterVector signal
Definition:
AdcChannelData.h:136
AdcSignalVector
std::vector< AdcSignal > AdcSignalVector
Definition:
AdcTypes.h:22
AdcTimingMitigator::update
DataMap update(AdcChannelData &acd) const override
Definition:
AdcTimingMitigator_tool.cc:41
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
DataMap
Definition:
DataMap.h:43
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
AdcTimingMitigator.h
Generated by
1.8.11