Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunesim
dunesim
DetSim
Service
Legacy35tZeroSuppressService_service.cc
Go to the documentation of this file.
1
// Legacy35tZeroSuppressService.cxx
2
3
#include "
dunesim/DetSim/Service/Legacy35tZeroSuppressService.h
"
4
#include "
art/Framework/Services/Registry/ServiceDefinitionMacros.h
"
5
#include <cmath>
6
#include "
fhiclcpp/ParameterSet.h
"
7
#include "
dunesim/DetSim/Utility/AdcCodeHelper.h
"
8
9
using
std::string
;
10
using
std::ostream;
11
using
std::endl
;
12
13
namespace
{
14
15
string
sbool(
bool
arg) {
16
if
( arg )
return
"true"
;
17
return
"false"
;
18
}
19
20
}
// end unnamed namespace.
21
22
typedef
unsigned
int
Index
;
23
24
//**********************************************************************
25
26
Legacy35tZeroSuppressService::
27
Legacy35tZeroSuppressService
(
const
fhicl::ParameterSet
& pset,
art::ActivityRegistry
&) {
28
m_AdcThreshold
= pset.
get
<
float
>(
"AdcThreshold"
);
29
m_TickRange
= pset.
get
<
unsigned
int
>(
"TickRange"
);
30
m_MinTickGap
= pset.
get
<
unsigned
int
>(
"MinTickGap"
);
31
m_SuppressStickyBits
= pset.
get
<
bool
>(
"SuppressStickyBits"
);
32
}
33
34
//**********************************************************************
35
36
Legacy35tZeroSuppressService::
37
Legacy35tZeroSuppressService
(
float
aAdcThreshold,
38
unsigned
int
aTickRange,
39
unsigned
int
aMinTickGap,
40
bool
aSuppressStickyBits)
41
:
m_AdcThreshold
(aAdcThreshold),
42
m_TickRange
(aTickRange),
43
m_MinTickGap
(aMinTickGap),
44
m_SuppressStickyBits
(aSuppressStickyBits) { }
45
46
//**********************************************************************
47
48
int
Legacy35tZeroSuppressService::
49
filter
(
const
AdcCountVector
& sigs,
Channel
,
AdcPedestal
ped,
AdcFilterVector
& keep)
const
{
50
const
unsigned
int
nsig = sigs.size();
51
keep.clear();
52
keep.resize(nsig,
false
);
53
if
( nsig == 0 )
return
0;
54
AdcCodeHelper
ach(64);
55
for
(
unsigned
int
isig=0; isig<nsig; ++isig ) {
56
AdcCount
rawsig = sigs[isig];
57
AdcSignal
pedsig = ach.
subtract
(ped, rawsig);
58
if
(
m_SuppressStickyBits
) {
59
if
( ach.
hasStickyBits
(rawsig) && ach.
isSmall
(pedsig) ) {
60
std::cout <<
"Legacy35tZeroSuppressService::filter: Suppressing sticky ADC value "
<< pedsig
61
<<
" (raw="
<< rawsig <<
", ped="
<< ped <<
")"
<<
endl
;
62
pedsig = 0.0;
63
}
64
}
65
if
( fabs(pedsig) >
m_AdcThreshold
) {
66
Index isig1 = 0;
67
if
(
m_TickRange
< isig ) isig1 = isig -
m_TickRange
;
68
Index isig2 = isig +
m_TickRange
;
69
if
( isig2 > nsig ) isig2 = nsig;
70
for
( Index jsig=isig1; jsig<=isig2; ++jsig ) keep[jsig] =
true
;
71
}
72
}
73
// Make gaps between unsupressed blocks < MinTickGap.
74
bool
inGap =
false
;
75
unsigned
int
jsig1 = 0;
// Start of gap.
76
unsigned
int
jsig2 = 0;
// End of gap.
77
for
(
unsigned
int
isig=0; isig<nsig; ++isig ) {
78
// End of a gap;
79
if
( inGap && (isig+1==nsig || keep[isig]) ) {
80
inGap =
false
;
81
if
( (jsig2 - jsig1 + 1) <
m_MinTickGap
) {
82
for
(
unsigned
int
jsig=jsig1; jsig<=jsig2; ++jsig ) {
83
keep[jsig] =
true
;
84
}
85
}
86
// In a gap.
87
}
else
if
( inGap ) {
88
jsig2 = isig;
89
// Start of gap.
90
}
else
if
( !inGap && !keep[isig] ) {
91
inGap =
true
;
92
jsig1 = isig;
93
jsig2 = jsig1;
94
}
95
}
96
return
0;
97
}
98
99
//**********************************************************************
100
101
ostream&
Legacy35tZeroSuppressService::print
(ostream& out,
string
prefix
)
const
{
102
out << prefix <<
"Legacy35tZeroSuppressService:"
<<
endl
;
103
out << prefix <<
" AdcThreshold: "
<<
m_AdcThreshold
<<
endl
;
104
out << prefix <<
" MinTickGap: "
<<
m_MinTickGap
<<
endl
;
105
out << prefix <<
" TickRange: "
<<
m_TickRange
<<
endl
;
106
out << prefix <<
" SuppressStickyBits: "
<< sbool(
m_SuppressStickyBits
);
107
return
out;
108
}
109
110
//**********************************************************************
111
112
DEFINE_ART_SERVICE_INTERFACE_IMPL
(
Legacy35tZeroSuppressService
,
AdcSuppressService
)
113
114
//**********************************************************************
AdcCountVector
std::vector< AdcCount > AdcCountVector
Definition:
AdcTypes.h:19
submit_ppfxjobs.prefix
string prefix
Definition:
submit_ppfxjobs.py:128
string
std::string string
Definition:
nybbler.cc:12
AdcSignal
float AdcSignal
Definition:
AdcTypes.h:21
AdcCodeHelper.h
Legacy35tZeroSuppressService::m_TickRange
unsigned int m_TickRange
Definition:
Legacy35tZeroSuppressService.h:60
ParameterSet.h
Legacy35tZeroSuppressService::m_AdcThreshold
float m_AdcThreshold
Definition:
Legacy35tZeroSuppressService.h:59
AdcCodeHelper::subtract
AdcSignal subtract(AdcCount sig, AdcSignal ped) const
Definition:
AdcCodeHelper.cxx:39
AdcCodeHelper
Definition:
AdcCodeHelper.h:20
AdcSuppressService::Channel
unsigned int Channel
Definition:
AdcSuppressService.h:31
Index
unsigned int Index
Definition:
Legacy35tZeroSuppressService_service.cc:22
fhicl::ParameterSet::get
T get(std::string const &key) const
Definition:
ParameterSet.h:271
Legacy35tZeroSuppressService.h
Legacy35tZeroSuppressService::print
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const
Definition:
Legacy35tZeroSuppressService_service.cc:101
Legacy35tZeroSuppressService
Definition:
Legacy35tZeroSuppressService.h:36
AdcCodeHelper::isSmall
bool isSmall(AdcCount sig, AdcSignal ped=0.0)
Definition:
AdcCodeHelper.cxx:23
AdcFilterVector
std::vector< bool > AdcFilterVector
Definition:
AdcTypes.h:27
AdcPedestal
float AdcPedestal
Definition:
AdcTypes.h:25
art::ActivityRegistry
Definition:
ActivityRegistry.h:52
Legacy35tZeroSuppressService::m_MinTickGap
unsigned int m_MinTickGap
Definition:
Legacy35tZeroSuppressService.h:61
ServiceDefinitionMacros.h
AdcCodeHelper::hasStickyBits
bool hasStickyBits(AdcCount sig)
Definition:
AdcCodeHelper.cxx:13
Legacy35tZeroSuppressService::Legacy35tZeroSuppressService
Legacy35tZeroSuppressService(fhicl::ParameterSet const &pset, art::ActivityRegistry &)
AdcCount
short AdcCount
Definition:
AdcTypes.h:18
Legacy35tZeroSuppressService::filter
int filter(const AdcCountVector &sigs, Channel chan, AdcPedestal ped, AdcFilterVector &keep) const
Definition:
Legacy35tZeroSuppressService_service.cc:49
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
AdcSuppressService
Definition:
AdcSuppressService.h:27
Legacy35tZeroSuppressService::m_SuppressStickyBits
bool m_SuppressStickyBits
Definition:
Legacy35tZeroSuppressService.h:62
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