Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
test
test_AdcRoiShifter.cxx
Go to the documentation of this file.
1
// test_AdcRoiShifter.cxx
2
//
3
// David Adams
4
// March 2019
5
//
6
// Test AdcRoiShifter.
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::vector
;
21
using
std::ofstream;
22
using
fhicl::ParameterSet
;
23
24
//**********************************************************************
25
26
int
test_AdcRoiShifter
(
bool
useExistingFcl =
false
) {
27
const
string
myname =
"test_AdcRoiShifter: "
;
28
#ifdef NDEBUG
29
cout << myname <<
"NDEBUG must be off."
<<
endl
;
30
abort();
31
#endif
32
string
line
=
"-----------------------------"
;
33
34
cout << myname << line <<
endl
;
35
string
fclfile =
"test_AdcRoiShifter.fcl"
;
36
if
( ! useExistingFcl ) {
37
cout << myname <<
"Creating top-level FCL."
<<
endl
;
38
ofstream
fout
(fclfile.c_str());
39
fout
<<
"tools: {"
<<
endl
;
40
fout
<<
" mytool: {"
<<
endl
;
41
fout
<<
" tool_type: AdcRoiShifter"
<<
endl
;
42
fout
<<
" LogLevel: 1"
<<
endl
;
43
fout
<<
" BinOffset: 3"
<<
endl
;
44
fout
<<
" }"
<<
endl
;
45
fout
<<
"}"
<<
endl
;
46
fout
.close();
47
}
else
{
48
cout << myname <<
"Using existing top-level FCL."
<<
endl
;
49
}
50
51
cout << myname << line <<
endl
;
52
cout << myname <<
"Fetching tool manager."
<<
endl
;
53
DuneToolManager
* ptm =
DuneToolManager::instance
(fclfile);
54
assert ( ptm !=
nullptr
);
55
DuneToolManager
&
tm
= *ptm;
56
tm.
print
();
57
assert( tm.
toolNames
().size() == 1 );
58
59
cout << myname << line <<
endl
;
60
cout << myname <<
"Fetching tool."
<<
endl
;
61
auto
psgf = tm.
getPrivate
<
TpcDataTool
>(
"mytool"
);
62
assert( psgf !=
nullptr
);
63
auto
psgfmod = tm.
getPrivate
<
TpcDataTool
>(
"mytool"
);
64
assert( psgfmod !=
nullptr
);
65
66
cout << myname << line <<
endl
;
67
cout << myname <<
"Create data and call tool."
<<
endl
;
68
AdcChannelData
data
;
69
vector<bool>
sigdat = {
false
,
true
,
false
,
false
,
true
,
false
,
false
,
false
,
true
};
70
vector<bool>
sigchk = {
false
,
false
,
false
,
false
,
true
,
false
,
false
,
true
,
false
};
71
data.
signal
= sigdat;
72
assert( data.
signal
== sigdat );
73
assert( data.
signal
!= sigchk );
74
75
cout << myname << line <<
endl
;
76
cout << myname <<
"Running tool."
<<
endl
;
77
DataMap
resmod = psgfmod->update(data);
78
resmod.
print
();
79
80
cout << myname << line <<
endl
;
81
cout << myname <<
"Checking results."
<<
endl
;
82
assert( resmod == 0 );
83
assert( data.
signal
!= sigdat );
84
assert( data.
signal
== sigchk );
85
86
cout << myname << line <<
endl
;
87
cout << myname <<
"Done."
<<
endl
;
88
return
0;
89
}
90
91
//**********************************************************************
92
93
int
main
(
int
argc,
char
*
argv
[]) {
94
bool
useExistingFcl =
false
;
95
if
( argc > 1 ) {
96
string
sarg(argv[1]);
97
if
( sarg ==
"-h"
) {
98
cout <<
"Usage: "
<< argv[0] <<
" [ARG]"
<<
endl
;
99
cout <<
" If ARG = true, existing FCL file is used."
<<
endl
;
100
return
0;
101
}
102
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
103
}
104
return
test_AdcRoiShifter
(useExistingFcl);
105
}
106
107
//**********************************************************************
vector< bool >
DuneToolManager::toolNames
const std::vector< std::string > & toolNames() const
Definition:
DuneToolManager.cxx:151
string
std::string string
Definition:
nybbler.cc:12
TpcDataTool.h
vector
struct vector vector
main
int main(int argc, char *argv[])
Definition:
test_AdcRoiShifter.cxx:93
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
DuneToolManager.h
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
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
test_AdcRoiShifter
int test_AdcRoiShifter(bool useExistingFcl=false)
Definition:
test_AdcRoiShifter.cxx:26
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
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
Generated by
1.8.11