Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
AdcRoiSlicer_tool.cc
Go to the documentation of this file.
1
// AdcRoiSlicer_tool.cc
2
3
#include "
AdcRoiSlicer.h
"
4
#include <iostream>
5
6
using
Name
=
AdcRoiSlicer::Name
;
7
using
Index
=
unsigned
int
;
8
using
std::cout;
9
using
std::endl
;
10
11
//**********************************************************************
12
// Class methods.
13
//**********************************************************************
14
15
AdcRoiSlicer::AdcRoiSlicer
(
fhicl::ParameterSet
const
&
ps
)
16
: m_LogLevel(ps.
get
<
int
>(
"LogLevel"
)),
17
m_OutViewName(ps.
get
<
Name
>(
"OutViewName"
)),
18
m_SliceOpt(ps.
get
<
int
>(
"SliceOpt"
)),
19
m_CopyRaw(ps.
get
<
bool
>(
"CopyRaw"
)) {
20
const
Name
myname =
"AdcRoiSlicer::ctor: "
;
21
if
(
m_LogLevel
>= 1 ) {
22
cout << myname <<
"Configuration parameters:"
<<
endl
;
23
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
24
cout << myname <<
" OutViewName: "
<<
m_OutViewName
<<
endl
;
25
cout << myname <<
" SliceOpt: "
<<
m_SliceOpt
<<
endl
;
26
cout << myname <<
" CopyRaw: "
<< (
m_CopyRaw
?
"true"
:
"false"
) << endl;
27
}
28
}
29
30
//**********************************************************************
31
32
DataMap
AdcRoiSlicer::update
(
AdcChannelData
& acd)
const
{
33
const
Name
myname =
"AdcRoiSlicer::update: "
;
34
DataMap
ret;
35
bool
keepRoi =
m_SliceOpt
== 1 ||
m_SliceOpt
== 3;
36
bool
keepNot =
m_SliceOpt
== 2 ||
m_SliceOpt
== 3;
37
bool
copyRaw =
m_CopyRaw
;
38
if
( ! keepRoi && ! keepNot ) {
39
cout <<
"ERROR: Invalid slice option: "
<<
m_SliceOpt
<<
endl
;
40
return
ret.
setStatus
(1);
41
}
42
Index
nsam = acd.
samples
.size();
43
if
( acd.
signal
.size() != nsam ) {
44
cout <<
"ERROR: Signal size does not match samples: "
<< acd.
signal
.size()
45
<<
" != "
<< nsam <<
endl
;
46
return
ret.
setStatus
(2);
47
}
48
if
( acd.
hasView
(
m_OutViewName
) ) {
49
cout <<
"ERROR: Data for channel "
<< acd.
channel
() <<
" already has view "
<<
m_OutViewName
<<
endl
;
50
return
ret.
setStatus
(3);
51
}
52
if
( copyRaw && acd.
raw
.size() < nsam ) {
53
cout <<
"ERROR: Insufficient raw data for channel "
<< acd.
channel
() <<
": "
54
<< acd.
raw
.size() <<
" < "
<< nsam <<
"."
<<
endl
;
55
copyRaw =
false
;
56
}
57
AdcChannelData::View
&
view
= acd.
updateView
(
m_OutViewName
);
58
Index
nsamKeep = 0;
59
Index
nsamSkip = 0;
60
if
(
m_LogLevel
>= 3 ) {
61
cout << myname <<
"Looping over "
<< nsam <<
" samples for channel "
62
<< acd.
channel
() <<
endl
;
63
}
64
for
(
Index
isam=0; isam<nsam; ++isam ) {
65
bool
isRoi = acd.
signal
[isam];
66
bool
keep = (isRoi && keepRoi) || (!isRoi && keepNot);
67
bool
changeRoi = isam==0 || acd.
signal
[isam] != acd.
signal
[isam-1];
68
bool
startData = keep && changeRoi;
69
if
( startData ) {
70
if
(
m_LogLevel
>= 3 ) cout << myname <<
"Creating data view at tick "
<< isam <<
endl
;
71
view.push_back(acd);
72
AdcChannelData
& acdout = view.back();
73
acdout.
viewParent
= ∿
74
acdout.
tick0
= isam;
75
}
76
if
( keep ) {
77
AdcChannelData
& acdout = view.back();
78
if
( copyRaw ) acdout.
raw
.push_back(acd.
raw
[isam]);
79
acdout.
samples
.push_back(acd.
samples
[isam]);
80
acdout.
signal
.push_back(acd.
signal
[isam]);
81
++nsamKeep;
82
}
else
{
83
++nsamSkip;
84
}
85
}
86
if
(
m_LogLevel
>= 2 ) {
87
cout << myname <<
"End of update. Nview="
<< view.size()
88
<<
". # sample keep/skip/tot: "
<< nsamKeep <<
"/"
<< nsamSkip
89
<<
"/"
<< nsam <<
endl
;
90
}
91
ret.
setInt
(
"nRoiView"
, view.size());
92
return
ret;
93
}
94
95
//**********************************************************************
96
97
DEFINE_ART_CLASS_TOOL
(
AdcRoiSlicer
)
AdcChannelData::View
std::vector< AdcChannelData > View
Definition:
AdcChannelData.h:102
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
AdcChannelTool::Index
unsigned int Index
Definition:
AdcChannelTool.h:58
DataMap::setStatus
DataMap & setStatus(int stat)
Definition:
DataMap.h:130
Name
ChannelGroupService::Name Name
Definition:
FixedChannelGroupService_service.cc:19
AdcRoiSlicer.h
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
AdcChannelData
Definition:
AdcChannelData.h:95
AdcRoiSlicer::update
DataMap update(AdcChannelData &acd) const override
Definition:
AdcRoiSlicer_tool.cc:32
AdcRoiSlicer::m_LogLevel
int m_LogLevel
Definition:
AdcRoiSlicer.h:35
AdcChannelTool::view
virtual DataMap view(const AdcChannelData &acd) const
Definition:
AdcChannelTool.h:127
AdcRoiSlicer::m_OutViewName
Name m_OutViewName
Definition:
AdcRoiSlicer.h:36
AdcChannelData::viewParent
AdcChannelData * viewParent
Definition:
AdcChannelData.h:141
AdcRoiSlicer::m_SliceOpt
int m_SliceOpt
Definition:
AdcRoiSlicer.h:37
DataMap::setInt
void setInt(Name name, int val)
Definition:
DataMap.h:131
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
AdcChannelData::raw
AdcCountVector raw
Definition:
AdcChannelData.h:130
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
AdcRoiSlicer::AdcRoiSlicer
AdcRoiSlicer(fhicl::ParameterSet const &ps)
Definition:
AdcRoiSlicer_tool.cc:15
AdcChannelData::signal
AdcFilterVector signal
Definition:
AdcChannelData.h:136
AdcRoiSlicer::m_CopyRaw
bool m_CopyRaw
Definition:
AdcRoiSlicer.h:38
AdcRoiSlicer
Definition:
AdcRoiSlicer.h:21
AdcChannelData::updateView
View & updateView(Name vnam)
Definition:
AdcChannelData.h:466
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
AdcChannelData::hasView
bool hasView(Name vnam) const
Definition:
AdcChannelData.h:442
AdcChannelData::tick0
AdcInt tick0
Definition:
AdcChannelData.h:127
AdcRoiSlicer::Name
std::string Name
Definition:
AdcRoiSlicer.h:26
DataMap
Definition:
DataMap.h:43
bool
int bool
Definition:
qglobal.h:345
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