Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
AdcChannelDumper_tool.cc
Go to the documentation of this file.
1
// AdcChannelDumper_tool.cc
2
3
#include "
AdcChannelDumper.h
"
4
#include <iostream>
5
#include <fstream>
6
#include <sstream>
7
#include <iomanip>
8
9
using
std::string
;
10
using
std::cout;
11
using
std::endl
;
12
using
std::ofstream;
13
using
std::ostream;
14
using
std::ostringstream;
15
using
std::setw
;
16
using
std::fixed;
17
using
std::setprecision
;
18
19
using
Index
=
unsigned
int
;
20
21
//**********************************************************************
22
// Class methods.
23
//**********************************************************************
24
25
AdcChannelDumper::AdcChannelDumper
(
fhicl::ParameterSet
const
&
ps
)
26
: m_FileName(ps.
get
<
string
>(
"FileName"
)),
27
m_Prefix(ps.
get
<
string
>(
"Prefix"
)),
28
m_NewFile(ps.
get
<
bool
>(
"NewFile"
)),
29
m_MaxSample(ps.
get
<
int
>(
"MaxSample"
)),
30
m_pout(nullptr) {
31
if
(
m_FileName
.size() == 0 )
m_pout
= &cout;
32
else
if
( !
m_NewFile
)
m_pout
=
new
ofstream(
m_FileName
.c_str());
33
}
34
35
//**********************************************************************
36
37
AdcChannelDumper::~AdcChannelDumper
() {
38
if
(
m_pout
!=
nullptr
&&
m_pout
!= &cout ) {
39
delete
m_pout
;
40
m_pout
=
nullptr
;
41
}
42
}
43
44
//**********************************************************************
45
46
DataMap
AdcChannelDumper::view
(
const
AdcChannelData
& acd)
const
{
47
DataMap
res;
48
ostream* pout =
m_pout
;
49
bool
newfile = pout ==
nullptr
;
50
// If file is not already set, build the file name and open it.
51
if
( newfile ) {
52
if
( !
m_NewFile
)
return
res.
setStatus
(1);
53
string
fname
=
m_FileName
;
54
pout =
new
ofstream(fname.c_str());
55
}
56
if
( pout ==
nullptr
)
return
res.
setStatus
(2);
57
ostream& out = *pout;
58
string
pre =
m_Prefix
;
59
string
sbad =
"<Unknown>"
;
60
out << pre <<
" Run: "
;
61
if
( acd.
run
() ==
AdcChannelData::badIndex
() ) out << sbad;
62
else
out << acd.
run
();
63
out <<
"-"
;
64
if
( acd.
subRun
() ==
AdcChannelData::badIndex
() ) out << sbad;
65
else
out << acd.
subRun
();
66
out <<
endl
;
67
out << pre <<
" Event: "
;
68
if
( acd.
event
() ==
AdcChannelData::badIndex
() ) out << sbad;
69
else
out << acd.
event
();
70
out <<
endl
;
71
out << pre <<
" Channel: "
;
72
if
( acd.
channel
() ==
AdcChannelData::badChannel
() ) out << sbad;
73
else
out << acd.
channel
();
74
out <<
endl
;
75
out << pre <<
" Pedestal: "
;
76
if
( acd.
pedestal
==
AdcChannelData::badSignal
() ) out << sbad;
77
else
out << acd.
pedestal
;
78
out <<
endl
;
79
Index
nraw = acd.
raw
.size();
80
Index
nflg = acd.
flags
.size();
81
Index
nprp = acd.
samples
.size();
82
Index
nsig = acd.
signal
.size();
83
Index
nkeep = 0;
84
for
(
bool
keep : acd.
signal
)
if
( keep ) ++nkeep;
85
Index
nsam = nraw;
86
if
( nprp > nsam ) nsam = nprp;
87
if
(
m_MaxSample
>= 0 ) {
88
Index
maxsam =
m_MaxSample
;
89
if
( maxsam < nsam ) nsam = maxsam;
90
}
91
Index
widx = 2 + log10(nsam);
92
if
( widx < 6 ) widx = 6;
93
Index
wraw = 6;
94
Index
wflg = 4;
95
Index
wprp = 9;
96
Index
wsig = 2;
97
Index
wcnt = wprp;
98
out << pre <<
" Nraw: "
<<
setw
(wcnt) << nraw <<
endl
;
99
out << pre <<
" Nprep: "
<<
setw
(wcnt) << nprp <<
endl
;
100
out << pre <<
" Nsig: "
<<
setw
(wcnt) << acd.
signal
.size() <<
endl
;
101
out << pre <<
" Nkeep: "
<<
setw
(wcnt) << nkeep <<
endl
;
102
out << pre <<
" Nroi: "
<<
setw
(wcnt) << acd.
rois
.size() <<
endl
;
103
out << pre <<
" Ndftm: "
<<
setw
(wcnt) << acd.
dftmags
.size() <<
endl
;
104
out << pre <<
" Ndftp: "
<<
setw
(wcnt) << acd.
dftphases
.size() <<
endl
;
105
if
( nsam > 0 ) {
106
out << pre
107
<<
setw
(widx) <<
"Data:"
108
<<
setw
(wraw) <<
"Raw"
109
<<
setw
(wflg) <<
"Flg"
110
<<
setw
(wprp) <<
"Prepared"
111
<<
setw
(wsig) <<
"S"
<<
endl
;
112
}
113
for
(
Index
isam=0; isam<nsam; ++isam ) {
114
ostringstream ssline;
115
ssline <<
setw
(widx) << isam;
116
if
( isam < nraw ) ssline <<
setw
(wraw) << acd.
raw
[isam];
117
else
ssline <<
setw
(wraw) <<
""
;
118
if
( isam < nflg ) ssline <<
setw
(wflg) << acd.
flags
[isam];
119
else
ssline <<
setw
(wflg) <<
""
;
120
if
( isam < nprp ) ssline << fixed <<
setprecision
(2) <<
setw
(wprp) << acd.
samples
[isam];
121
else
ssline <<
setw
(wprp) <<
""
;
122
if
( isam < nsig ) ssline <<
setw
(wsig) << acd.
signal
[isam];
123
else
ssline <<
setw
(wsig) <<
""
;
124
out << pre << ssline.str() <<
endl
;
125
}
126
if
( newfile )
delete
pout;
127
return
res;
128
}
129
130
//**********************************************************************
131
132
DEFINE_ART_CLASS_TOOL
(
AdcChannelDumper
)
AdcChannelDumper::view
DataMap view(const AdcChannelData &acd) const override
Definition:
AdcChannelDumper_tool.cc:46
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
AdcChannelDumper::m_Prefix
std::string m_Prefix
Definition:
AdcChannelDumper.h:37
AdcChannelData::subRun
AdcIndex subRun() const
Definition:
AdcChannelData.h:175
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
wirecell.sigproc.paper.noise.fname
fname
Definition:
noise.py:68
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
AdcChannelData
Definition:
AdcChannelData.h:95
setprecision
Q_EXPORT QTSManip setprecision(int p)
Definition:
qtextstream.h:343
AdcChannelDumper::m_FileName
std::string m_FileName
Definition:
AdcChannelDumper.h:36
AdcChannelData::badSignal
static Index badSignal()
Definition:
AdcChannelData.h:115
AdcChannelData::rois
AdcRoiVector rois
Definition:
AdcChannelData.h:137
AdcChannelDumper
Definition:
AdcChannelDumper.h:22
AdcChannelData::run
AdcIndex run() const
Definition:
AdcChannelData.h:174
AdcChannelDumper::AdcChannelDumper
AdcChannelDumper(fhicl::ParameterSet const &ps)
Definition:
AdcChannelDumper_tool.cc:25
AdcChannelData::event
AdcIndex event() const
Definition:
AdcChannelData.h:176
AdcChannelData::dftphases
AdcSignalVector dftphases
Definition:
AdcChannelData.h:139
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
AdcChannelData::raw
AdcCountVector raw
Definition:
AdcChannelData.h:130
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
AdcChannelDumper.h
AdcChannelDumper::m_MaxSample
int m_MaxSample
Definition:
AdcChannelDumper.h:39
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
AdcChannelData::pedestal
AdcSignal pedestal
Definition:
AdcChannelData.h:128
AdcChannelData::signal
AdcFilterVector signal
Definition:
AdcChannelData.h:136
AdcChannelDumper::m_NewFile
bool m_NewFile
Definition:
AdcChannelDumper.h:38
AdcChannelDumper::~AdcChannelDumper
~AdcChannelDumper() override
Definition:
AdcChannelDumper_tool.cc:37
AdcChannelData::badChannel
static Index badChannel()
Definition:
AdcChannelData.h:114
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
AdcChannelDumper::m_pout
std::ostream * m_pout
Definition:
AdcChannelDumper.h:42
bool
int bool
Definition:
qglobal.h:345
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
AdcChannelData::dftmags
AdcSignalVector dftmags
Definition:
AdcChannelData.h:138
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
AdcChannelData::flags
AdcFlagVector flags
Definition:
AdcChannelData.h:135
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11