Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Service
test
test_AdcSuppressSignalFindingService.cxx
Go to the documentation of this file.
1
// test_AdcSuppressSignalFindingService.cxx
2
//
3
// David Adams
4
// June 2016
5
//
6
// Test AdcSuppressSignalFindingService.
7
8
#include <string>
9
#include <iostream>
10
#include <sstream>
11
#include <fstream>
12
#include <iomanip>
13
#include "
art/Framework/Services/Registry/ServiceHandle.h
"
14
#include "
lardataobj/RawData/RawDigit.h
"
15
#include "
dunecore/ArtSupport/ArtServiceHelper.h
"
16
#include "
dunecore/DuneInterface/Data/AdcTypes.h
"
17
#include "
dunecore/DuneInterface/Service/AdcSignalFindingService.h
"
18
19
#undef NDEBUG
20
#include <cassert>
21
22
using
std::string
;
23
using
std::cout;
24
using
std::endl
;
25
using
std::istringstream;
26
using
std::ofstream;
27
using
std::setw
;
28
using
std::setprecision
;
29
using
std::fixed;
30
using
art::ServiceHandle
;
31
32
//**********************************************************************
33
34
int
test_AdcSuppressSignalFindingService
() {
35
const
string
myname =
"test_AdcSuppressSignalFindingService: "
;
36
#ifdef NDEBUG
37
cout << myname <<
"NDEBUG must be off."
<<
endl
;
38
abort();
39
#endif
40
string
line
=
"-----------------------------"
;
41
42
cout << myname << line <<
endl
;
43
cout << myname <<
"Create top-level FCL."
<<
endl
;
44
std::ostringstream oss;
45
oss <<
"services.AdcSuppressService: {"
<<
endl
;
46
oss <<
" service_provider: Legacy35tZeroSuppressService"
<<
endl
;
47
oss <<
" AdcThreshold: 30.0"
<<
endl
;
48
oss <<
" TickRange: 4"
<<
endl
;
49
oss <<
" MinTickGap: 2"
<<
endl
;
50
oss <<
" SuppressStickyBits: false"
<<
endl
;
51
oss <<
"}"
<<
endl
;
52
oss <<
"services.AdcSignalFindingService: {"
<<
endl
;
53
oss <<
" service_provider: AdcSuppressSignalFindingService"
<<
endl
;
54
oss <<
"}"
<<
endl
;
55
ArtServiceHelper::load_services
(oss.str());
56
57
cout << myname << line <<
endl
;
58
cout << myname <<
"Create data."
<<
endl
;
59
AdcChannelData
data
;
60
data.
setChannelInfo
(1234);
61
data.
pedestal
= 1000.0;
62
for
(
unsigned
int
tic=0; tic<50; ++tic ) {
63
AdcSignal
sig = tic%10 - 5.0;
64
if
( tic > 10 && tic < 20 ) sig += 100;
65
AdcCount
cnt = sig + data.
pedestal
;
66
data.
raw
.push_back(cnt);
67
data.
samples
.push_back(sig);
68
data.
flags
.push_back(
AdcGood
);
69
}
70
unsigned
int
nsig = data.
samples
.size();
71
72
cout << myname << line <<
endl
;
73
cout << myname <<
"Fetch signal finding service."
<<
endl
;
74
ServiceHandle<AdcSignalFindingService>
hsfs;
75
hsfs->
print
();
76
77
AdcFilterVector
exp(50,
false
);
78
for
(
unsigned
int
isig=7; isig<24; ++isig ) exp[isig] =
true
;
79
80
cout << myname << line <<
endl
;
81
cout << myname <<
"Find signal."
<<
endl
;
82
assert( hsfs->
find
(data) == 0 );
83
assert( data.
raw
.size() == nsig );
84
assert( data.
samples
.size() == nsig );
85
assert( data.
flags
.size() == nsig );
86
assert( data.
signal
.size() == nsig );
87
for
(
unsigned
int
isig=0; isig<nsig; ++isig ) {
88
cout <<
setw
(4) << isig <<
": "
<<
setw
(6) << data.
raw
[isig]
89
<< fixed <<
setprecision
(1) <<
setw
(8) << data.
samples
[isig]
90
<<
" "
<< ( data.
signal
[isig] ?
"*"
:
" "
) << endl;
91
assert( data.
signal
[isig] == exp[isig] );
92
}
93
94
return
0;
95
}
96
97
//**********************************************************************
98
99
int
main
(
int
argc,
char
*
argv
[]) {
100
int
logLevel = 1;
101
if
( argc > 1 ) {
102
istringstream ssarg(argv[1]);
103
ssarg >> logLevel;
104
}
105
return
test_AdcSuppressSignalFindingService
();
106
}
107
108
//**********************************************************************
art::ServiceHandle
Definition:
ServiceHandle.h:37
AdcSignalFindingService::find
virtual int find(AdcChannelData &data) const =0
ArtServiceHelper.h
string
std::string string
Definition:
nybbler.cc:12
AdcSignal
float AdcSignal
Definition:
AdcTypes.h:21
AdcChannelData
Definition:
AdcChannelData.h:95
ArtServiceHelper::load_services
static void load_services(std::string const &config)
Definition:
ArtServiceHelper.cxx:15
setprecision
Q_EXPORT QTSManip setprecision(int p)
Definition:
qtextstream.h:343
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
AdcGood
const AdcFlag AdcGood
Definition:
AdcTypes.h:32
ServiceHandle.h
main
int main(int argc, char *argv[])
Definition:
test_AdcSuppressSignalFindingService.cxx:99
AdcChannelData::setChannelInfo
void setChannelInfo(ChannelInfoPtr pchi)
Definition:
AdcChannelData.h:184
AdcSignalFindingService.h
AdcTypes.h
AdcChannelData::raw
AdcCountVector raw
Definition:
AdcChannelData.h:130
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
make_THn_beam_input.data
data
Definition:
make_THn_beam_input.py:80
AdcChannelData::pedestal
AdcSignal pedestal
Definition:
AdcChannelData.h:128
AdcChannelData::signal
AdcFilterVector signal
Definition:
AdcChannelData.h:136
AdcFilterVector
std::vector< bool > AdcFilterVector
Definition:
AdcTypes.h:27
AdcSignalFindingService::print
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
test_AdcSuppressSignalFindingService
int test_AdcSuppressSignalFindingService()
Definition:
test_AdcSuppressSignalFindingService.cxx:34
RawDigit.h
AdcCount
short AdcCount
Definition:
AdcTypes.h:18
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
Generated by
1.8.11