Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
test
test_DuneAdcSignalFinder.cxx
Go to the documentation of this file.
1
// test_DuneAdcSignalFinder.cxx
2
//
3
// David Adams
4
// April 2017
5
//
6
// Test DuneAdcSignalFinder.
7
8
#include <string>
9
#include <iostream>
10
#include <fstream>
11
#include "
dunecore/DuneInterface/Tool/TpcDataTool.h
"
12
#include "
dunecore/ArtSupport/DuneToolManager.h
"
13
14
#undef NDEBUG
15
#include <cassert>
16
17
using
std::string
;
18
using
std::cout;
19
using
std::endl
;
20
using
std::ofstream;
21
using
fhicl::ParameterSet
;
22
23
//**********************************************************************
24
25
int
test_DuneAdcSignalFinder
(
bool
useExistingFcl =
false
) {
26
const
string
myname =
"test_DuneAdcSignalFinder: "
;
27
#ifdef NDEBUG
28
cout << myname <<
"NDEBUG must be off."
<<
endl
;
29
abort();
30
#endif
31
string
line
=
"-----------------------------"
;
32
33
cout << myname << line <<
endl
;
34
string
fclfile =
"test_DuneAdcSignalFinder.fcl"
;
35
if
( ! useExistingFcl ) {
36
cout << myname <<
"Creating top-level FCL."
<<
endl
;
37
ofstream
fout
(fclfile.c_str());
38
fout
<<
"tools: {"
<<
endl
;
39
fout
<<
" mytool: {"
<<
endl
;
40
fout
<<
" tool_type: DuneAdcSignalFinder"
<<
endl
;
41
fout
<<
" LogLevel: 1"
<<
endl
;
42
fout
<<
" NoiseSigma: 0.0"
<<
endl
;
43
fout
<<
" NSigmaStart: 3.0"
<<
endl
;
44
fout
<<
" NSigmaEnd: 1.0"
<<
endl
;
45
fout
<<
" TicksAfter: 10"
<<
endl
;
46
fout
<<
" TicksBefore: 5"
<<
endl
;
47
fout
<<
" }"
<<
endl
;
48
fout
<<
"}"
<<
endl
;
49
fout
.close();
50
}
else
{
51
cout << myname <<
"Using existing top-level FCL."
<<
endl
;
52
}
53
54
cout << myname << line <<
endl
;
55
cout << myname <<
"Fetching tool manager."
<<
endl
;
56
DuneToolManager
* ptm =
DuneToolManager::instance
(fclfile);
57
assert ( ptm !=
nullptr
);
58
DuneToolManager
&
tm
= *ptm;
59
tm.
print
();
60
assert( tm.
toolNames
().size() == 1 );
61
62
cout << myname << line <<
endl
;
63
cout << myname <<
"Fetching tool."
<<
endl
;
64
auto
psgf = tm.
getPrivate
<
TpcDataTool
>(
"mytool"
);
65
assert( psgf !=
nullptr
);
66
auto
psgfmod = tm.
getPrivate
<
TpcDataTool
>(
"mytool"
);
67
assert( psgfmod !=
nullptr
);
68
69
cout << myname << line <<
endl
;
70
cout << myname <<
"Create data and call tool."
<<
endl
;
71
AdcChannelData
data
;
72
for
(
AdcIndex
itic=0; itic<100; ++itic ) {
73
float
xadc = rand()%20 - 10.0;
74
data.
samples
.push_back(xadc);
75
}
76
data.
sampleNoise
= 40.0;
77
data.
samples
[30] = 150.0;
78
assert( data.
signal
.size() == 0 );
79
assert( data.
rois
.size() == 0 );
80
assert( data.
samples
[30] = 150 );
81
assert( data.
samples
[31] = 130 );
82
assert( data.
samples
[32] = 90 );
83
assert( data.
samples
[33] = 70 );
84
assert( data.
samples
[34] = 45 );
85
assert( data.
samples
[35] = 30 );
86
assert( data.
samples
[36] = 20 );
87
assert( data.
samples
[37] = 15 );
88
89
cout << myname << line <<
endl
;
90
cout << myname <<
"Running tool."
<<
endl
;
91
DataMap
resmod = psgfmod->update(data);
92
resmod.
print
();
93
94
cout << myname << line <<
endl
;
95
cout << myname <<
"Checking results."
<<
endl
;
96
assert( resmod == 0 );
97
assert( resmod.
getInt
(
"nroi"
) == 1 );
98
assert( data.
signal
.size() == 100 );
99
assert( data.
rois
.size() == 1 );
100
assert( data.
rois
[0].first == 25 );
101
assert( data.
rois
[0].second == 44 );
102
103
cout << myname << line <<
endl
;
104
cout << myname <<
"Done."
<<
endl
;
105
return
0;
106
}
107
108
//**********************************************************************
109
110
int
main
(
int
argc,
char
*
argv
[]) {
111
bool
useExistingFcl =
false
;
112
if
( argc > 1 ) {
113
string
sarg(argv[1]);
114
if
( sarg ==
"-h"
) {
115
cout <<
"Usage: "
<< argv[0] <<
" [ARG]"
<<
endl
;
116
cout <<
" If ARG = true, existing FCL file is used."
<<
endl
;
117
return
0;
118
}
119
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
120
}
121
return
test_DuneAdcSignalFinder
(useExistingFcl);
122
}
123
124
//**********************************************************************
DuneToolManager::toolNames
const std::vector< std::string > & toolNames() const
Definition:
DuneToolManager.cxx:151
string
std::string string
Definition:
nybbler.cc:12
TpcDataTool.h
DuneToolManager::print
void print() const
Definition:
DuneToolManager.cxx:157
AdcChannelData
Definition:
AdcChannelData.h:95
DataMap::print
void print(std::ostream *pout) const
Definition:
DataMap.h:245
demo.tm
tm
Definition:
demo.py:21
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
TpcDataTool
Definition:
TpcDataTool.h:17
AdcChannelData::sampleNoise
AdcSignal sampleNoise
Definition:
AdcChannelData.h:134
AdcChannelData::rois
AdcRoiVector rois
Definition:
AdcChannelData.h:137
DuneToolManager.h
AdcIndex
unsigned int AdcIndex
Definition:
AdcTypes.h:15
main
int main(int argc, char *argv[])
Definition:
test_DuneAdcSignalFinder.cxx:110
make_THn_beam_input.data
data
Definition:
make_THn_beam_input.py:80
DuneToolManager::getPrivate
std::unique_ptr< T > getPrivate(std::string name)
Definition:
DuneToolManager.h:82
DuneToolManager
Definition:
DuneToolManager.h:34
AdcChannelData::signal
AdcFilterVector signal
Definition:
AdcChannelData.h:136
DataMap::getInt
int getInt(Name name, int def=0) const
Definition:
DataMap.h:218
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
test_DuneAdcSignalFinder
int test_DuneAdcSignalFinder(bool useExistingFcl=false)
Definition:
test_DuneAdcSignalFinder.cxx:25
reco_momentum_tuples.fout
fout
Definition:
reco_momentum_tuples.py:65
DataMap
Definition:
DataMap.h:43
DuneToolManager::instance
static DuneToolManager * instance(std::string fclname="", int dbg=1)
Definition:
DuneToolManager.cxx:95
AdcChannelData::samples
AdcSignalVector samples
Definition:
AdcChannelData.h:131
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11