Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
AdcUnderflowFlagger_tool.cc
Go to the documentation of this file.
1
// AdcUnderflowFlagger_tool.cc
2
3
#include "
AdcUnderflowFlagger.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
using
std::vector
;
19
20
using
Index
=
unsigned
int
;
21
22
//**********************************************************************
23
// Class methods.
24
//**********************************************************************
25
26
AdcUnderflowFlagger::AdcUnderflowFlagger
(
fhicl::ParameterSet
const
&
ps
)
27
: m_LogLevel(ps.
get
<
int
>(
"LogLevel"
)),
28
m_AdcThresholds(ps.
get
<
AdcCountVector
>(
"AdcThresholds"
)),
29
m_DefaultThreshold(ps.
get
<
int
>(
"DefaultThreshold"
)),
30
m_modifyCount(0) {
31
const
string
myname =
"AdcUnderflowFlagger::ctor: "
;
32
if
(
m_LogLevel
>= 1 ) {
33
cout << myname <<
"Configuration parameters:"
<<
endl
;
34
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
35
cout << myname <<
" AdcThresholds: ["
;
36
Index
maxcha = 10;
37
Index
ncha =
m_AdcThresholds
.size();
38
bool
haveMore = ncha > maxcha;
39
if
( ! haveMore ) maxcha = ncha;
40
for
(
Index
icha=0; icha<maxcha; ++icha ) {
41
if
( icha ) cout <<
","
;
42
cout <<
" "
<<
m_AdcThresholds
[icha];
43
}
44
if
( haveMore ) cout <<
",..."
;
45
cout <<
"]"
<<
endl
;
46
}
47
}
48
49
//**********************************************************************
50
51
DataMap
AdcUnderflowFlagger::view
(
const
AdcChannelData
& acd)
const
{
52
const
string
myname =
"AdcUnderflowFlagger::view: "
;
53
AdcChannelData
acdtmp;
54
acdtmp.
setChannelInfo
(acd.
channel
());
55
acdtmp.
raw
= acd.
raw
;
56
return
update
(acdtmp);
57
}
58
59
//**********************************************************************
60
61
DataMap
AdcUnderflowFlagger::update
(
AdcChannelData
& acd)
const
{
62
const
string
myname =
"AdcUnderflowFlagger::update: "
;
63
if
(
m_LogLevel
>= 3 ) cout << myname <<
"Calling "
<<
endl
;
64
DataMap
res(0);
65
AdcChannel
icha = acd.
channel
();
66
res.
setInt
(
"channel"
, icha);
67
res.
setInt
(
"nModify"
,
m_modifyCount
);
68
if
( icha ==
AdcChannelData::badChannel
() ) {
69
if
(
m_LogLevel
>= 2 ) cout << myname <<
"Data does not have an assigned channel."
<<
endl
;
70
return
res.
setStatus
(1);
71
}
72
IntVector::value_type sthr = -1;
73
Index
ncha =
m_AdcThresholds
.size();
74
if
( icha < ncha ) sthr =
m_AdcThresholds
[icha];
75
else
sthr =
m_DefaultThreshold
;
76
if
( sthr < 0 ) {
77
if
(
m_LogLevel
>= 2 ) cout << myname <<
"No threshold set for channel "
<< icha <<
endl
;
78
return
res.
setStatus
(2 + icha >= ncha);
79
}
80
AdcCount
thr
= sthr;
81
Index
nraw = acd.
raw
.size();
82
Index
nflg = acd.
flags
.size();
83
if
( nflg < nraw ) acd.
flags
.resize(nraw,
AdcGood
);
84
Index
nunder = 0;
85
for
(
Index
isam=0; isam<nraw; ++isam ) {
86
if
( acd.
raw
[isam] <= thr ) {
87
++nunder;
88
acd.
flags
[isam] =
AdcUnderflow
;
89
}
90
}
91
res.
setInt
(
"nUnderflow"
, nunder);
92
return
res;
93
}
94
95
//**********************************************************************
96
97
DEFINE_ART_CLASS_TOOL
(
AdcUnderflowFlagger
)
AdcUnderflowFlagger::view
DataMap view(const AdcChannelData &acd) const override
Definition:
AdcUnderflowFlagger_tool.cc:51
AdcUnderflowFlagger::AdcUnderflowFlagger
AdcUnderflowFlagger(fhicl::ParameterSet const &ps)
Definition:
AdcUnderflowFlagger_tool.cc:26
AdcCountVector
std::vector< AdcCount > AdcCountVector
Definition:
AdcTypes.h:19
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
thr
G4double thr[100]
Definition:
G4S2Light.cc:59
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
vector
struct vector vector
AdcUnderflowFlagger::update
DataMap update(AdcChannelData &acd) const override
Definition:
AdcUnderflowFlagger_tool.cc:61
AdcUnderflow
const AdcFlag AdcUnderflow
Definition:
AdcTypes.h:33
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
AdcChannelData
Definition:
AdcChannelData.h:95
AdcUnderflowFlagger::m_AdcThresholds
IntVector m_AdcThresholds
Definition:
AdcUnderflowFlagger.h:59
setprecision
Q_EXPORT QTSManip setprecision(int p)
Definition:
qtextstream.h:343
AdcGood
const AdcFlag AdcGood
Definition:
AdcTypes.h:32
AdcChannelData::setChannelInfo
void setChannelInfo(ChannelInfoPtr pchi)
Definition:
AdcChannelData.h:184
AdcUnderflowFlagger::m_LogLevel
int m_LogLevel
Definition:
AdcUnderflowFlagger.h:58
DataMap::setInt
void setInt(Name name, int val)
Definition:
DataMap.h:131
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
AdcUnderflowFlagger
Definition:
AdcUnderflowFlagger.h:36
AdcChannelData::raw
AdcCountVector raw
Definition:
AdcChannelData.h:130
AdcUnderflowFlagger::m_modifyCount
AdcIndex m_modifyCount
Definition:
AdcUnderflowFlagger.h:63
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
AdcUnderflowFlagger::m_DefaultThreshold
int m_DefaultThreshold
Definition:
AdcUnderflowFlagger.h:60
AdcChannel
unsigned int AdcChannel
Definition:
AdcTypes.h:50
AdcChannelData::badChannel
static Index badChannel()
Definition:
AdcChannelData.h:114
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
AdcCount
short AdcCount
Definition:
AdcTypes.h:18
DataMap
Definition:
DataMap.h:43
AdcUnderflowFlagger.h
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