Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Service
ThresholdNoiseRemovalService_service.cc
Go to the documentation of this file.
1
// ThresholdNoiseRemovalService_service.cc
2
3
#include "
ThresholdNoiseRemovalService.h
"
4
#include <iostream>
5
#include <sstream>
6
#include <iomanip>
7
#include <algorithm>
8
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
9
#include "
art/Framework/Services/Registry/ServiceDefinitionMacros.h
"
10
#include "
larcore/Geometry/Geometry.h
"
11
12
using
std::vector
;
13
using
std::string
;
14
using
std::ostream;
15
using
std::cout;
16
using
std::endl
;
17
using
std::ostringstream;
18
using
std::setw
;
19
using
art::ServiceHandle
;
20
21
//**********************************************************************
22
23
ThresholdNoiseRemovalService::
24
ThresholdNoiseRemovalService
(
fhicl::ParameterSet
const
& pset,
art::ActivityRegistry
&)
25
: m_LogLevel(1) {
26
const
string
myname =
"ThresholdNoiseRemovalService::ctor: "
;
27
pset.
get_if_present
<
int
>(
"LogLevel"
,
m_LogLevel
);
28
m_Threshold
= pset.
get
<
AdcSignal
>(
"Threshold"
);
29
print
(cout, myname);
30
}
31
32
//**********************************************************************
33
34
int
ThresholdNoiseRemovalService::update
(
AdcChannelData
&
data
)
const
{
35
const
string
myname =
"ThresholdNoiseRemovalService:update: "
;
36
AdcSignalVector
& sigs = data.
samples
;
37
AdcFlagVector
& flags = data.
flags
;
38
if
( sigs.size() == 0 ) {
39
cout << myname <<
"WARNING: No data found."
<<
endl
;
40
return
1;
41
}
42
if
( flags.size() == 0 ) flags.resize(sigs.size(),
AdcGood
);
43
if
( flags.size() != sigs.size() ) {
44
cout << myname <<
"ERROR: samples and flags vectors have different sizes."
<<
endl
;
45
return
2;
46
}
47
AdcIndex
count
= 0;
48
for
(
unsigned
int
isig=0; isig<sigs.size(); ++isig ) {
49
AdcSignal
& sig = sigs[isig];
50
if
( fabs(sig) <
m_Threshold
) {
51
sig = 0.0;
52
flags[isig] =
AdcSetFixed
;
53
++
count
;
54
}
55
}
56
if
(
m_LogLevel
>= 2 ) cout << myname <<
"Suppressed "
<< count <<
" of "
57
<< sigs.size() <<
" ticks."
<<
endl
;
58
return
0;
59
}
60
61
//**********************************************************************
62
63
ostream&
ThresholdNoiseRemovalService::
64
print
(ostream& out,
string
prefix
)
const
{
65
out << prefix <<
"ThresholdNoiseRemovalService:"
<<
endl
;
66
out << prefix <<
" LogLevel: "
<<
m_LogLevel
<<
endl
;
67
out << prefix <<
" Threshold: "
<<
m_Threshold
<<
endl
;
68
return
out;
69
}
70
71
//**********************************************************************
72
73
DEFINE_ART_SERVICE_INTERFACE_IMPL
(
ThresholdNoiseRemovalService
,
AdcChannelNoiseRemovalService
)
74
75
//**********************************************************************
art::ServiceHandle
Definition:
ServiceHandle.h:37
submit_ppfxjobs.prefix
string prefix
Definition:
submit_ppfxjobs.py:128
string
std::string string
Definition:
nybbler.cc:12
ThresholdNoiseRemovalService::ThresholdNoiseRemovalService
ThresholdNoiseRemovalService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
Definition:
ThresholdNoiseRemovalService_service.cc:24
AdcSignal
float AdcSignal
Definition:
AdcTypes.h:21
AdcFlagVector
std::vector< AdcFlag > AdcFlagVector
Definition:
AdcTypes.h:30
vector
struct vector vector
ThresholdNoiseRemovalService::update
int update(AdcChannelData &data) const
Definition:
ThresholdNoiseRemovalService_service.cc:34
AdcChannelData
Definition:
AdcChannelData.h:95
ThresholdNoiseRemovalService::m_Threshold
AdcSignal m_Threshold
Definition:
ThresholdNoiseRemovalService.h:41
AdcSetFixed
const AdcFlag AdcSetFixed
Definition:
AdcTypes.h:41
Geometry.h
art framework interface to geometry description
AdcGood
const AdcFlag AdcGood
Definition:
AdcTypes.h:32
ServiceHandle.h
ThresholdNoiseRemovalService::print
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const
Definition:
ThresholdNoiseRemovalService_service.cc:64
ThresholdNoiseRemovalService::m_LogLevel
int m_LogLevel
Definition:
ThresholdNoiseRemovalService.h:40
ThresholdNoiseRemovalService
Definition:
ThresholdNoiseRemovalService.h:27
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
AdcChannelNoiseRemovalService
Definition:
AdcChannelNoiseRemovalService.h:15
ThresholdNoiseRemovalService.h
AdcIndex
unsigned int AdcIndex
Definition:
AdcTypes.h:15
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
make_THn_beam_input.data
data
Definition:
make_THn_beam_input.py:80
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
AdcSignalVector
std::vector< AdcSignal > AdcSignalVector
Definition:
AdcTypes.h:22
reco_momentum_tuples.count
int count
Definition:
reco_momentum_tuples.py:202
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
AdcChannelData::flags
AdcFlagVector flags
Definition:
AdcChannelData.h:135
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