Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Service
DuneRoiBuildingService_service.cc
Go to the documentation of this file.
1
// DuneRoiBuildingService_service.cc
2
3
#include "
DuneRoiBuildingService.h
"
4
#include <iostream>
5
#include <sstream>
6
#include <iomanip>
7
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
8
#include "
dunecore/Utilities/SignalShapingServiceDUNE.h
"
9
#include "
art/Framework/Services/Registry/ServiceDefinitionMacros.h
"
10
11
using
std::vector
;
12
using
std::string
;
13
using
std::ostream;
14
using
std::cout;
15
using
std::endl
;
16
using
std::setw
;
17
using
art::ServiceHandle
;
18
19
//**********************************************************************
20
21
DuneRoiBuildingService::
22
DuneRoiBuildingService
(
fhicl::ParameterSet
const
& pset,
art::ActivityRegistry
&)
23
: m_LogLevel(1) {
24
const
string
myname =
"DuneRoiBuildingService::ctor: "
;
25
pset.
get_if_present
<
int
>(
"LogLevel"
,
m_LogLevel
);
26
m_NSigmaStart
= pset.
get
<
AdcSignal
>(
"NSigmaStart"
);
27
m_NSigmaEnd
= pset.
get
<
AdcSignal
>(
"NSigmaEnd"
);
28
m_PadLow
= pset.
get
<
AdcSignal
>(
"PadLow"
);
29
m_PadHigh
= pset.
get
<
AdcSignal
>(
"PadHigh"
);
30
if
(
m_LogLevel
> 0 )
print
(cout, myname);
31
}
32
33
34
//**********************************************************************
35
36
int
DuneRoiBuildingService::build
(
AdcChannelData
&
data
)
const
{
37
const
string
myname =
"DuneRoiBuildingService:build: "
;
38
if
(
m_LogLevel
>= 2 ) cout << myname <<
"Building ROIs for channel "
39
<< data.
channel
() <<
"."
<<
endl
;
40
data.
rois
.clear();
41
// Get signal shaping service.
42
art::ServiceHandle<util::SignalShapingServiceDUNE>
hsss;
43
AdcSignal
sigma = hsss->
GetDeconNoise
(data.
channel
());
44
if
(
m_LogLevel
>= 3 ) {
45
cout << myname <<
" Noise level: "
<< sigma <<
" "
<< data.
sampleUnit
<<
endl
;
46
}
47
const
AdcSignalVector
& sigs = data.
samples
;
48
// Build ROIS before padding and merging.
49
AdcFilterVector
& signal = data.
signal
;
50
AdcRoiVector
& rois = data.
rois
;
51
signal.clear();
52
signal.resize(sigs.size(),
false
);
53
bool
inroi =
false
;
54
AdcSignal
siglow =
m_NSigmaEnd
*sigma;
55
AdcSignal
sighigh =
m_NSigmaStart
*sigma;
56
AdcIndex
nsig = sigs.size();
57
if
( nsig < 1 ) {
58
if
(
m_LogLevel
>= 2 ) cout << myname <<
"Channel "
<< data.
channel
()
59
<<
" has no samples."
<<
endl
;
60
return
0;
61
}
62
for
(
AdcIndex
isig=0; isig<sigs.size(); ++isig ) {
63
AdcSignal
sig = sigs[isig];
64
if
( inroi ) {
65
if
( sig > siglow ) {
66
signal[isig] =
true
;
67
}
else
{
68
inroi =
false
;
69
}
70
}
else
{
71
if
( sig > sighigh ) {
72
signal[isig] =
true
;
73
inroi =
true
;
74
}
75
}
76
}
77
// Fill the unpadded ROIs.
78
data.
roisFromSignal
();
79
// Display ROIs before padding and merging.
80
if
(
m_LogLevel
>= 3 ) {
81
cout << myname <<
" ROIs before merge (size = "
<< rois.size() <<
"):"
<<
endl
;
82
for
(
const
AdcRoi
& roi : rois ) {
83
cout << myname <<
setw
(8) << roi.first <<
" "
<<
setw
(8) << roi.second <<
endl
;
84
}
85
}
else
if
(
m_LogLevel
>= 2 ) {
86
cout << myname <<
" ROI count before merge: "
<< data.
rois
.size() <<
endl
;
87
}
88
if
( rois.size() == 0 )
return
0;
89
// Pad ROIs.
90
unsigned
int
isig1 = 0;
91
unsigned
int
isig2 = 0;
92
for
(
AdcRoi
roi : rois ) {
93
isig2 = roi.first;
94
isig1 = isig2 >
m_PadLow
? isig2 -
m_PadLow
: 0;
95
for
(
unsigned
int
isig=isig1; isig<isig2; ++isig ) signal[isig] =
true
;
96
isig1 = roi.second + 1;
97
isig2 = isig1 +
m_PadHigh
;
98
if
( isig2 > nsig ) isig2 = nsig;
99
for
(
unsigned
int
isig=isig1; isig<isig2; ++isig ) signal[isig] =
true
;
100
}
101
// Fill the final ROIs.
102
data.
roisFromSignal
();
103
// Display final ROIs.
104
if
(
m_LogLevel
>= 3 ) {
105
cout << myname <<
" ROIs after merge (size = "
<< rois.size() <<
"):"
<<
endl
;
106
for
(
const
AdcRoi
& roi : rois ) {
107
cout << myname <<
setw
(8) << roi.first <<
" "
<<
setw
(8) << roi.second <<
endl
;
108
}
109
}
else
if
(
m_LogLevel
>= 2 ) {
110
cout << myname <<
" ROI count after merge: "
<< data.
rois
.size() <<
endl
;
111
}
112
return
0;
113
}
114
115
//**********************************************************************
116
117
ostream&
DuneRoiBuildingService::
118
print
(ostream& out,
string
prefix
)
const
{
119
out << prefix <<
"DuneRoiBuildingService:"
<<
endl
;
120
out << prefix <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
121
out << prefix <<
" NSigmaStart: "
<<
m_NSigmaStart
<<
endl
;
122
out << prefix <<
" NSigmaEnd: "
<<
m_NSigmaEnd
<<
endl
;
123
out << prefix <<
" PadLow: "
<<
m_PadLow
<<
endl
;
124
out << prefix <<
" PadHigh: "
<<
m_PadHigh
<<
endl
;
125
return
out;
126
}
127
128
//**********************************************************************
129
130
DEFINE_ART_SERVICE_INTERFACE_IMPL
(
DuneRoiBuildingService
,
AdcRoiBuildingService
)
131
132
//**********************************************************************
art::ServiceHandle
Definition:
ServiceHandle.h:37
DuneRoiBuildingService::build
int build(AdcChannelData &data) const
Definition:
DuneRoiBuildingService_service.cc:36
DuneRoiBuildingService
Definition:
DuneRoiBuildingService.h:39
AdcRoiBuildingService
Definition:
AdcRoiBuildingService.h:14
submit_ppfxjobs.prefix
string prefix
Definition:
submit_ppfxjobs.py:128
string
std::string string
Definition:
nybbler.cc:12
AdcChannelData::sampleUnit
Name sampleUnit
Definition:
AdcChannelData.h:133
AdcSignal
float AdcSignal
Definition:
AdcTypes.h:21
DuneRoiBuildingService::DuneRoiBuildingService
DuneRoiBuildingService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
Definition:
DuneRoiBuildingService_service.cc:22
vector
struct vector vector
AdcRoi
std::pair< AdcIndex, AdcIndex > AdcRoi
Definition:
AdcTypes.h:54
DuneRoiBuildingService::m_NSigmaStart
AdcSignal m_NSigmaStart
Definition:
DuneRoiBuildingService.h:53
util::SignalShapingServiceDUNE::GetDeconNoise
double GetDeconNoise(Channel channel) const override
Definition:
SignalShapingServiceDUNE_service.cc:332
AdcChannelData
Definition:
AdcChannelData.h:95
SignalShapingServiceDUNE.h
Service to provide microboone-specific signal shaping for simulation (convolution) and reconstruction...
ServiceHandle.h
DuneRoiBuildingService::m_NSigmaEnd
AdcSignal m_NSigmaEnd
Definition:
DuneRoiBuildingService.h:54
DuneRoiBuildingService::print
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const
Definition:
DuneRoiBuildingService_service.cc:118
DuneRoiBuildingService.h
AdcChannelData::rois
AdcRoiVector rois
Definition:
AdcChannelData.h:137
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
AdcChannelData::roisFromSignal
void roisFromSignal()
Definition:
AdcChannelData.h:413
AdcIndex
unsigned int AdcIndex
Definition:
AdcTypes.h:15
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
AdcRoiVector
std::vector< AdcRoi > AdcRoiVector
Definition:
AdcTypes.h:55
make_THn_beam_input.data
data
Definition:
make_THn_beam_input.py:80
AdcChannelData::channel
Channel channel() const
Definition:
AdcChannelData.h:199
AdcChannelData::signal
AdcFilterVector signal
Definition:
AdcChannelData.h:136
AdcFilterVector
std::vector< bool > AdcFilterVector
Definition:
AdcTypes.h:27
art::ActivityRegistry
Definition:
ActivityRegistry.h:52
fhicl::ParameterSet::get_if_present
std::optional< T > get_if_present(std::string const &key) const
Definition:
ParameterSet.h:224
ServiceDefinitionMacros.h
DuneRoiBuildingService::m_LogLevel
int m_LogLevel
Definition:
DuneRoiBuildingService.h:52
AdcSignalVector
std::vector< AdcSignal > AdcSignalVector
Definition:
AdcTypes.h:22
DuneRoiBuildingService::m_PadLow
AdcIndex m_PadLow
Definition:
DuneRoiBuildingService.h:55
DuneRoiBuildingService::m_PadHigh
AdcIndex m_PadHigh
Definition:
DuneRoiBuildingService.h:56
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
DEFINE_ART_SERVICE_INTERFACE_IMPL
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)
Definition:
ServiceDefinitionMacros.h:42
Generated by
1.8.11