Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
test
test_AdcKeepAllSignalFinder.cxx
Go to the documentation of this file.
1
// test_AdcKeepAllSignalFinder.cxx
2
//
3
// David Adams
4
// April 2017
5
//
6
// Test AdcKeepAllSignalFinder.
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_AdcKeepAllSignalFinder
(
bool
useExistingFcl =
false
) {
26
const
string
myname =
"test_AdcKeepAllSignalFinder: "
;
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_AdcKeepAllSignalFinder.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: AdcKeepAllSignalFinder"
<<
endl
;
41
fout
<<
" LogLevel: 1"
<<
endl
;
42
fout
<<
" DataPath: \"\""
<<
endl
;
43
fout
<<
" }"
<<
endl
;
44
fout
<<
"}"
<<
endl
;
45
fout
.close();
46
}
else
{
47
cout << myname <<
"Using existing top-level FCL."
<<
endl
;
48
}
49
50
cout << myname << line <<
endl
;
51
cout << myname <<
"Fetching tool manager."
<<
endl
;
52
DuneToolManager
* ptm =
DuneToolManager::instance
(fclfile);
53
assert ( ptm !=
nullptr
);
54
DuneToolManager
&
tm
= *ptm;
55
tm.
print
();
56
assert( tm.
toolNames
().size() == 1 );
57
58
cout << myname << line <<
endl
;
59
cout << myname <<
"Fetching tool."
<<
endl
;
60
auto
psgf = tm.
getPrivate
<
TpcDataTool
>(
"mytool"
);
61
assert( psgf !=
nullptr
);
62
auto
psgfmod = tm.
getPrivate
<
TpcDataTool
>(
"mytool"
);
63
assert( psgfmod !=
nullptr
);
64
65
cout << myname << line <<
endl
;
66
cout << myname <<
"Create data and call tool."
<<
endl
;
67
AdcChannelData
data
;
68
for
(
AdcIndex
itic=0; itic<100; ++itic ) {
69
float
xadc = rand()%20 - 10.0;
70
data.
samples
.push_back(xadc);
71
}
72
data.
samples
[30] = 150.0;
73
assert( data.
signal
.size() == 0 );
74
assert( data.
rois
.size() == 0 );
75
assert( data.
samples
[30] = 150 );
76
77
cout << myname << line <<
endl
;
78
cout << myname <<
"Running tool."
<<
endl
;
79
DataMap
resmod = psgfmod->update(data);
80
resmod.
print
();
81
82
cout << myname << line <<
endl
;
83
cout << myname <<
"Checking results."
<<
endl
;
84
assert( resmod == 0 );
85
assert( resmod.
getInt
(
"nroi"
) == 1 );
86
assert( data.
signal
.size() == 100 );
87
assert( data.
rois
.size() == 1 );
88
assert( data.
rois
[0].first == 0 );
89
assert( data.
rois
[0].second == 99 );
90
91
cout << myname << line <<
endl
;
92
cout << myname <<
"Done."
<<
endl
;
93
return
0;
94
}
95
96
//**********************************************************************
97
98
int
main
(
int
argc,
char
*
argv
[]) {
99
bool
useExistingFcl =
false
;
100
if
( argc > 1 ) {
101
string
sarg(argv[1]);
102
if
( sarg ==
"-h"
) {
103
cout <<
"Usage: "
<< argv[0] <<
" [ARG]"
<<
endl
;
104
cout <<
" If ARG = true, existing FCL file is used."
<<
endl
;
105
return
0;
106
}
107
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
108
}
109
return
test_AdcKeepAllSignalFinder
(useExistingFcl);
110
}
111
112
//**********************************************************************
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
test_AdcKeepAllSignalFinder
int test_AdcKeepAllSignalFinder(bool useExistingFcl=false)
Definition:
test_AdcKeepAllSignalFinder.cxx:25
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
TpcDataTool
Definition:
TpcDataTool.h:17
AdcChannelData::rois
AdcRoiVector rois
Definition:
AdcChannelData.h:137
DuneToolManager.h
main
int main(int argc, char *argv[])
Definition:
test_AdcKeepAllSignalFinder.cxx:98
AdcIndex
unsigned int AdcIndex
Definition:
AdcTypes.h:15
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
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