Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
AdcChannelTrimmer_tool.cc
Go to the documentation of this file.
1
// AdcChannelTrimmer_tool.cc
2
3
#include "
AdcChannelTrimmer.h
"
4
#include <iostream>
5
#include <vector>
6
7
using
std::string
;
8
using
std::cout;
9
using
std::endl
;
10
11
//**********************************************************************
12
// Class methods.
13
//**********************************************************************
14
15
AdcChannelTrimmer::AdcChannelTrimmer
(
fhicl::ParameterSet
const
&
ps
)
16
: m_LogLevel(ps.
get
<
int
>(
"LogLevel"
)),
17
m_Length(ps.
get
<
Index
>(
"Length"
)),
18
m_MaxTrim(ps.
get
<
Index
>(
"MaxTrim"
)) {
19
const
string
myname =
"AdcChannelTrimmer::ctor: "
;
20
// Display the configuration.
21
if
(
m_LogLevel
>= 1 ) {
22
cout << myname <<
"Configuration: "
<<
endl
;
23
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
24
cout << myname <<
" Length: "
<<
m_Length
<<
endl
;
25
cout << myname <<
" MaxTrim: "
<<
m_MaxTrim
<<
endl
;
26
}
27
}
28
29
//**********************************************************************
30
31
DataMap
AdcChannelTrimmer::view
(
const
AdcChannelData
& acd)
const
{
32
const
string
myname =
"AdcChannelTrimmer::view: "
;
33
DataMap
ret;
34
Index
nsam = acd.
samples
.size();
35
if
( nsam ==
m_Length
) {
36
ret.
setInt
(
"trimAction"
, 0);
37
if
(
m_LogLevel
>= 3 ) cout <<
"Samples have requested length of "
38
<<
m_Length
<<
"."
<<
endl
;
39
return
ret;
40
}
41
if
( nsam == 0 ) {
42
ret.
setInt
(
"trimAction"
, 3);
43
if
(
m_LogLevel
>= 3 ) cout <<
"WARNING: No samples found."
<<
endl
;
44
return
ret;
45
}
46
int
idsam = nsam <
m_Length
? -
int
(
m_Length
- nsam) :
int
(nsam -
m_Length
);
47
Index
udsam = idsam < 0 ? -idsam : idsam;
48
ret.
setInt
(
"trimLength"
, idsam);
49
if
(
m_MaxTrim
&& udsam >
m_MaxTrim
) {
50
ret.
setInt
(
"trimAction"
, 2);
51
cout << myname <<
"ERROR: Channel "
<< acd.
channel
() <<
" sample length "
<< nsam
52
<<
" is outside of trim range "
<<
m_MaxTrim
<<
"."
<<
endl
;
53
}
else
{
54
ret.
setInt
(
"trimAction"
, -1);
55
if
(
m_LogLevel
>= 2 ) cout << myname <<
"Trimming channel "
<< acd.
channel
() <<
" from "
56
<< nsam <<
" to "
<<
m_Length
<<
" samples."
<<
endl
;
57
}
58
return
ret;
59
}
60
61
//**********************************************************************
62
63
DataMap
AdcChannelTrimmer::update
(
AdcChannelData
& acd)
const
{
64
const
string
myname =
"AdcChannelTrimmer::update: "
;
65
DataMap
ret =
view
(acd);
66
int
action
= ret.
getInt
(
"trimAction"
);
67
if
( action != -1 )
return
ret;
68
Index
nsam = acd.
samples
.size();
69
acd.
samples
.resize(
m_Length
);
70
Index
jsam = 0;
71
for
(
Index
isam=nsam; isam<
m_Length
; ++isam ) {
72
acd.
samples
[isam] = acd.
samples
[jsam++];
73
}
74
ret.
setInt
(
"trimAction"
, 1);
75
return
ret;
76
}
77
78
//**********************************************************************
79
80
DEFINE_ART_CLASS_TOOL
(
AdcChannelTrimmer
)
AdcChannelTrimmer.h
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
AdcChannelTool::Index
unsigned int Index
Definition:
AdcChannelTool.h:58
string
std::string string
Definition:
nybbler.cc:12
ValidateOpDetReco.action
action
Definition:
ValidateOpDetReco.py:26
AdcChannelData
Definition:
AdcChannelData.h:95
AdcChannelTrimmer
Definition:
AdcChannelTrimmer.h:39
AdcChannelTrimmer::m_MaxTrim
Index m_MaxTrim
Definition:
AdcChannelTrimmer.h:58
AdcChannelTrimmer::m_Length
Index m_Length
Definition:
AdcChannelTrimmer.h:57
DataMap::setInt
void setInt(Name name, int val)
Definition:
DataMap.h:131
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
AdcChannelTrimmer::update
DataMap update(AdcChannelData &acd) const override
Definition:
AdcChannelTrimmer_tool.cc:63
AdcChannelTrimmer::m_LogLevel
int m_LogLevel
Definition:
AdcChannelTrimmer.h:56
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
DataMap::getInt
int getInt(Name name, int def=0) const
Definition:
DataMap.h:218
AdcChannelTrimmer::AdcChannelTrimmer
AdcChannelTrimmer(fhicl::ParameterSet const &ps)
Definition:
AdcChannelTrimmer_tool.cc:15
AdcChannelTrimmer::view
DataMap view(const AdcChannelData &acd) const override
Definition:
AdcChannelTrimmer_tool.cc:31
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
Generated by
1.8.11