Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
DuneAdcSignalFinder_tool.cc
Go to the documentation of this file.
1
// DuneAdcSignalFinder_tool.cc
2
3
#include "
DuneAdcSignalFinder.h
"
4
#include <iostream>
5
#include <iomanip>
6
7
using
std::string
;
8
using
std::cout;
9
using
std::endl
;
10
using
std::setw
;
11
12
//**********************************************************************
13
// Class methods.
14
//**********************************************************************
15
16
DuneAdcSignalFinder::DuneAdcSignalFinder
(
fhicl::ParameterSet
const
&
ps
)
17
: m_LogLevel(ps.
get
<
int
>(
"LogLevel"
)),
18
m_NoiseSigma(ps.
get
<
float
>(
"NoiseSigma"
)),
19
m_NSigmaStart(ps.
get
<
float
>(
"NSigmaStart"
)),
20
m_NSigmaEnd(ps.
get
<
float
>(
"NSigmaEnd"
)),
21
m_TicksBefore(ps.
get
<
AdcIndex
>(
"TicksBefore"
)),
22
m_TicksAfter(ps.
get
<
AdcIndex
>(
"TicksAfter"
))
23
{
24
const
string
myname =
"DuneAdcSignalFinder::ctor: "
;
25
if
(
m_LogLevel
>= 1 ) {
26
cout << myname <<
"Configuration parameters:"
<<
endl
;
27
cout << myname <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
28
cout << myname <<
" NoiseSigma: "
<<
m_NoiseSigma
<<
endl
;
29
cout << myname <<
" NSigmaStart: "
<<
m_NSigmaStart
<<
endl
;
30
cout << myname <<
" NSigmaEnd: "
<<
m_NSigmaEnd
<<
endl
;
31
cout << myname <<
" TicksBefore: "
<<
m_TicksBefore
<<
endl
;
32
cout << myname <<
" TicksAfter: "
<<
m_TicksAfter
<<
endl
;
33
}
34
}
35
36
//**********************************************************************
37
38
DataMap
DuneAdcSignalFinder::update
(
AdcChannelData
& acd)
const
{
39
const
string
myname =
"DuneAdcSignalFinder::update: "
;
40
DataMap
ret;
41
if
(
m_LogLevel
>= 2 ) {
42
cout << myname <<
"Finding ROIs for channel "
<< acd.
channel
() <<
endl
;
43
}
44
AdcIndex
nsam = acd.
samples
.size();
45
if
( nsam == 0 ) {
46
cout << myname <<
"ERROR: No samples found in channel "
<< acd.
channel
() <<
endl
;
47
acd.
signal
.clear();
48
acd.
rois
.clear();
49
return
ret.
setStatus
(1);
50
}
51
AdcSignal
sigma =
m_NoiseSigma
> 0 ?
m_NoiseSigma
: acd.
sampleNoise
;
52
if
( sigma <= 0 ) {
53
cout << myname <<
"ERROR: Unable to determine noise level."
<<
endl
;
54
return
ret.
setStatus
(2);
55
}
56
if
(
m_LogLevel
>= 3 ) cout << myname <<
"Noise level: "
<< sigma <<
endl
;
57
// Build ROIS before padding and merging.
58
const
AdcSignalVector
& sams = acd.
samples
;
59
AdcFilterVector
& signal = acd.
signal
;
60
AdcRoiVector
& rois = acd.
rois
;
61
signal.clear();
62
signal.resize(sams.size(),
false
);
63
bool
inroi =
false
;
64
AdcSignal
siglow =
m_NSigmaEnd
*sigma;
65
AdcSignal
sighigh =
m_NSigmaStart
*sigma;
66
for
(
AdcIndex
isam=0; isam<nsam; ++isam ) {
67
AdcSignal
sig = sams[isam];
68
if
( inroi ) {
69
if
( sig > siglow ) {
70
signal[isam] =
true
;
71
}
else
{
72
inroi =
false
;
73
}
74
}
else
{
75
if
( sig > sighigh ) {
76
signal[isam] =
true
;
77
inroi =
true
;
78
}
79
}
80
}
81
// Fill the unpadded ROIs.
82
acd.
roisFromSignal
();
83
if
( rois.size() == 0 ) {
84
if
(
m_LogLevel
>= 3 ) cout << myname <<
" No ROIs found."
<<
endl
;
85
}
else
{
86
// Display ROIs before padding and merging.
87
if
(
m_LogLevel
>= 3 ) {
88
cout << myname <<
" ROIs before merge (size = "
<< rois.size() <<
"):"
<<
endl
;
89
for
(
const
AdcRoi
& roi : rois ) {
90
cout << myname <<
setw
(8) << roi.first <<
" "
<<
setw
(8) << roi.second <<
endl
;
91
}
92
}
else
if
(
m_LogLevel
>= 2 ) {
93
cout << myname <<
" ROI count before merge: "
<< acd.
rois
.size() <<
endl
;
94
}
95
// Pad ROIs.
96
unsigned
int
isam1 = 0;
97
unsigned
int
isam2 = 0;
98
for
(
AdcRoi
roi : rois ) {
99
isam2 = roi.first;
100
isam1 = isam2 >
m_TicksBefore
? isam2 -
m_TicksBefore
: 0;
101
for
(
unsigned
int
isam=isam1; isam<isam2; ++isam ) signal[isam] =
true
;
102
isam1 = roi.second + 1;
103
isam2 = isam1 +
m_TicksAfter
;
104
if
( isam2 > nsam ) isam2 = nsam;
105
for
(
unsigned
int
isam=isam1; isam<isam2; ++isam ) signal[isam] =
true
;
106
}
107
// Fill the final ROIs.
108
acd.
roisFromSignal
();
109
// Display final ROIs.
110
if
(
m_LogLevel
>= 3 ) {
111
cout << myname <<
" ROIs after merge (size = "
<< rois.size() <<
"):"
<<
endl
;
112
for
(
const
AdcRoi
& roi : rois ) {
113
cout << myname <<
setw
(8) << roi.first <<
" "
<<
setw
(8) << roi.second <<
endl
;
114
}
115
}
else
if
(
m_LogLevel
>= 2 ) {
116
cout << myname <<
" ROI count after merge: "
<< acd.
rois
.size() <<
endl
;
117
}
118
}
119
ret.
setInt
(
"nroi"
, acd.
rois
.size());
120
return
ret;
121
}
122
123
//**********************************************************************
124
125
DataMap
DuneAdcSignalFinder::view
(
const
AdcChannelData
& acd)
const
{
126
AdcChannelData
acdtmp;
127
acdtmp.
samples
= acd.
samples
;
128
return
update
(acdtmp);
129
}
130
131
//**********************************************************************
132
133
DEFINE_ART_CLASS_TOOL
(
DuneAdcSignalFinder
)
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
reco_momentum_tuples.float
float
Definition:
reco_momentum_tuples.py:12
DataMap::setStatus
DataMap & setStatus(int stat)
Definition:
DataMap.h:130
string
std::string string
Definition:
nybbler.cc:12
AdcSignal
float AdcSignal
Definition:
AdcTypes.h:21
AdcRoi
std::pair< AdcIndex, AdcIndex > AdcRoi
Definition:
AdcTypes.h:54
AdcChannelData
Definition:
AdcChannelData.h:95
DuneAdcSignalFinder::m_NSigmaEnd
AdcSignal m_NSigmaEnd
Definition:
DuneAdcSignalFinder.h:52
DuneAdcSignalFinder::DuneAdcSignalFinder
DuneAdcSignalFinder(fhicl::ParameterSet const &ps)
Definition:
DuneAdcSignalFinder_tool.cc:16
DuneAdcSignalFinder::m_TicksAfter
AdcIndex m_TicksAfter
Definition:
DuneAdcSignalFinder.h:54
AdcChannelData::sampleNoise
AdcSignal sampleNoise
Definition:
AdcChannelData.h:134
AdcChannelData::rois
AdcRoiVector rois
Definition:
AdcChannelData.h:137
DataMap::setInt
void setInt(Name name, int val)
Definition:
DataMap.h:131
AdcChannelData::roisFromSignal
void roisFromSignal()
Definition:
AdcChannelData.h:413
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
DuneAdcSignalFinder::m_NoiseSigma
AdcSignal m_NoiseSigma
Definition:
DuneAdcSignalFinder.h:50
AdcIndex
unsigned int AdcIndex
Definition:
AdcTypes.h:15
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
DuneAdcSignalFinder
Definition:
DuneAdcSignalFinder.h:33
AdcRoiVector
std::vector< AdcRoi > AdcRoiVector
Definition:
AdcTypes.h:55
DuneAdcSignalFinder::view
DataMap view(const AdcChannelData &acd) const override
Definition:
DuneAdcSignalFinder_tool.cc:125
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
DuneAdcSignalFinder::m_LogLevel
int m_LogLevel
Definition:
DuneAdcSignalFinder.h:49
AdcChannelData::signal
AdcFilterVector signal
Definition:
AdcChannelData.h:136
AdcFilterVector
std::vector< bool > AdcFilterVector
Definition:
AdcTypes.h:27
DuneAdcSignalFinder::m_NSigmaStart
AdcSignal m_NSigmaStart
Definition:
DuneAdcSignalFinder.h:51
AdcSignalVector
std::vector< AdcSignal > AdcSignalVector
Definition:
AdcTypes.h:22
DuneAdcSignalFinder::m_TicksBefore
AdcIndex m_TicksBefore
Definition:
DuneAdcSignalFinder.h:53
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
DataMap
Definition:
DataMap.h:43
DuneAdcSignalFinder.h
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
DuneAdcSignalFinder::update
DataMap update(AdcChannelData &acd) const override
Definition:
DuneAdcSignalFinder_tool.cc:38
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11