Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
AdcChannelSplitter_tool.cc
Go to the documentation of this file.
1
// AdcChannelSplitter_tool.cc
2
3
#include "
AdcChannelSplitter.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
AdcChannelSplitter::AdcChannelSplitter
(
fhicl::ParameterSet
const
&
ps
)
16
: m_LogLevel(ps.
get
<
int
>(
"LogLevel"
)),
17
m_Length(ps.
get
<
Index
>(
"Length"
)),
18
m_DataPath(ps.
get
<
Name
>(
"DataPath"
)),
19
m_DataView(ps.
get
<
Name
>(
"DataView"
)) {
20
const
string
myname =
"AdcChannelSplitter::ctor: "
;
21
// Display the configuration.
22
if
(
m_LogLevel
>= 1 ) {
23
cout << myname <<
"Configuration: "
<<
endl
;
24
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
25
cout << myname <<
" Length: "
<<
m_Length
<<
endl
;
26
cout << myname <<
" DataPath: "
<<
m_DataPath
<<
endl
;
27
cout << myname <<
" DataView: "
<<
m_DataView
<<
endl
;
28
}
29
}
30
31
//**********************************************************************
32
33
DataMap
AdcChannelSplitter::update
(
AdcChannelData
& acd)
const
{
34
const
string
myname =
"AdcChannelSplitter::update: "
;
35
DataMap
ret;
36
Index
dtck =
m_Length
;
37
if
( dtck == 0 ) {
38
cout <<
"ERROR: Length is zero."
<<
endl
;
39
return
ret.
setStatus
(1);
40
}
41
Index
nvie = acd.
viewSize
(
m_DataPath
);
42
Index
nobj = 0;
43
if
(
m_LogLevel
>= 2 ) cout << myname <<
"Channel "
<< acd.
channel
()
44
<<
" input object count: "
<< nvie <<
endl
;
45
Index
nrawCopied = 0;
46
Index
nsamCopied = 0;
47
// Loop over input objects.
48
for
(
Index
ivie=0; ivie<nvie; ++ivie ) {
49
AdcChannelData
* pacd = acd.
mutableViewEntry
(
m_DataPath
, ivie);
50
Index
nraw = pacd->
raw
.size();
51
Index
nsam = pacd->
samples
.size();
52
// Create the new view. It might be left empty.
53
AdcChannelData::View
& acds = pacd->
updateView
(
m_DataView
);
54
Index
itck = 0;
// Start copy at this tick
55
while
(
true
) {
56
Index
jtck = itck + dtck;
// End copy at this tick
57
bool
copyRaw = nraw >= jtck;
58
bool
copySam = nsam >= jtck;
59
if
( !copyRaw && !copySam )
break
;
60
acds.push_back(*pacd);
61
AdcChannelData
& acdNew = acds.back();
62
acdNew.
viewParent
= pacd;
63
acdNew.
tick0
= pacd->
tick0
+ itck;
64
if
( copyRaw ) {
65
for
(
Index
iraw=itck; iraw<jtck; ++iraw ) {
66
acdNew.
raw
.push_back(pacd->
raw
[iraw]);
67
++nrawCopied;
68
}
69
}
70
if
( copySam ) {
71
for
(
Index
isam=itck; isam<jtck; ++isam ) {
72
acdNew.
samples
.push_back(pacd->
samples
[isam]);
73
++nsamCopied;
74
}
75
}
76
if
( acdNew.
samples
.size() ) acdNew.
sampleUnit
= pacd->
sampleUnit
;
77
++nobj;
78
itck = jtck;
79
}
80
}
81
if
(
m_LogLevel
>= 2 ) cout << myname <<
"Channel "
<< acd.
channel
()
82
<<
" output object count: "
<< nobj <<
endl
;
83
ret.
setInt
(
"splitInputCount"
, nvie);
84
ret.
setInt
(
"splitOutputCount"
, nobj);
85
ret.
setInt
(
"splitRawCopyCount"
, nrawCopied);
86
ret.
setInt
(
"splitSampleCopyCount"
, nsamCopied);
87
return
ret;
88
}
89
90
//**********************************************************************
91
92
DEFINE_ART_CLASS_TOOL
(
AdcChannelSplitter
)
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
string
std::string string
Definition:
nybbler.cc:12
AdcChannelSplitter::AdcChannelSplitter
AdcChannelSplitter(fhicl::ParameterSet const &ps)
Definition:
AdcChannelSplitter_tool.cc:15
AdcChannelData::sampleUnit
Name sampleUnit
Definition:
AdcChannelData.h:133
AdcChannelSplitter::m_Length
Index m_Length
Definition:
AdcChannelSplitter.h:53
AdcChannelSplitter::m_DataView
Name m_DataView
Definition:
AdcChannelSplitter.h:55
AdcChannelData
Definition:
AdcChannelData.h:95
AdcChannelSplitter::m_LogLevel
int m_LogLevel
Definition:
AdcChannelSplitter.h:52
AdcChannelSplitter::m_DataPath
Name m_DataPath
Definition:
AdcChannelSplitter.h:54
AdcChannelData::viewParent
AdcChannelData * viewParent
Definition:
AdcChannelData.h:141
AdcChannelSplitter::Name
std::string Name
Definition:
AdcChannelSplitter.h:40
AdcChannelSplitter.h
AdcChannelSplitter
Definition:
AdcChannelSplitter.h:35
DataMap::setInt
void setInt(Name name, int val)
Definition:
DataMap.h:131
AdcChannelSplitter::update
DataMap update(AdcChannelData &acd) const override
Definition:
AdcChannelSplitter_tool.cc:33
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
AdcChannelData::mutableViewEntry
AdcChannelData * mutableViewEntry(Name vpnam, AdcIndex ient)
Definition:
AdcChannelData.h:518
AdcChannelData::updateView
View & updateView(Name vnam)
Definition:
AdcChannelData.h:466
AdcChannelData::viewSize
size_t viewSize() const
Definition:
AdcChannelData.h:340
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
AdcChannelData::tick0
AdcInt tick0
Definition:
AdcChannelData.h:127
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