Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Tool
test
test_FclIndexRangeTool.cxx
Go to the documentation of this file.
1
// test_FclIndexRangeTool.cxx
2
//
3
// David Adams
4
// April 2017
5
//
6
// Test FclIndexRangeTool.
7
8
#include <string>
9
#include <iostream>
10
#include <fstream>
11
#include <sstream>
12
#include "
dunecore/ArtSupport/DuneToolManager.h
"
13
#include "
dunecore/DuneInterface/Tool/IndexRangeTool.h
"
14
#include "TH1F.h"
15
16
#undef NDEBUG
17
#include <cassert>
18
19
using
std::string
;
20
using
std::cout;
21
using
std::endl
;
22
using
std::ofstream;
23
using
std::istringstream;
24
using
fhicl::ParameterSet
;
25
using
Index
=
unsigned
int
;
26
27
//**********************************************************************
28
29
int
test_FclIndexRangeTool
(
bool
useExistingFcl =
false
,
Index
runin =0) {
30
const
string
myname =
"test_FclIndexRangeTool: "
;
31
#ifdef NDEBUG
32
cout << myname <<
"NDEBUG must be off."
<<
endl
;
33
abort();
34
#endif
35
string
line
=
"-----------------------------"
;
36
37
cout << myname << line <<
endl
;
38
string
fclfile =
"test_FclIndexRangeTool.fcl"
;
39
if
( ! useExistingFcl ) {
40
cout << myname <<
"Creating top-level FCL."
<<
endl
;
41
ofstream
fout
(fclfile.c_str());
42
if
( runin == 0 ) {
43
fout
<<
"tools: {"
<<
endl
;
44
fout
<<
" mytool: {"
<<
endl
;
45
fout
<<
" tool_type: FclIndexRangeTool"
<<
endl
;
46
fout
<<
" LogLevel: 2"
<<
endl
;
47
fout
<<
" range1: { labels:[\"Range 1\"] begin:10 end:20}"
<<
endl
;
48
fout
<<
" range2: { labels:[\"Range 2\"] begin:20 end:30}"
<<
endl
;
49
fout
<<
" }"
<<
endl
;
50
fout
<<
"}"
<<
endl
;
51
}
else
{
52
fout
<<
"#include \"dunecommon_tools.fcl\""
<<
endl
;
53
fout
<<
"tools.mytool: @local::tools.protoduneIndexRangeTool"
<<
endl
;
54
}
55
fout
.close();
56
}
else
{
57
cout << myname <<
"Using existing top-level FCL."
<<
endl
;
58
}
59
60
cout << myname << line <<
endl
;
61
cout << myname <<
"Fetching tool manager."
<<
endl
;
62
DuneToolManager
* ptm =
DuneToolManager::instance
(fclfile);
63
assert ( ptm !=
nullptr
);
64
DuneToolManager
&
tm
= *ptm;
65
tm.
print
();
66
assert( tm.
toolNames
().size() >= 1 );
67
68
cout << myname << line <<
endl
;
69
cout << myname <<
"Fetching tool."
<<
endl
;
70
auto
irt = tm.
getPrivate
<
IndexRangeTool
>(
"mytool"
);
71
assert( irt !=
nullptr
);
72
73
cout << myname << line <<
endl
;
74
cout <<
"Fetch range1."
<<
endl
;
75
IndexRange
ir1 = irt->get(
"range1"
);
76
cout << ir1.
rangeString
() <<
endl
;
77
assert( ir1.
isValid
() );
78
assert( ir1.
name
==
"range1"
);
79
assert( ir1.
label
() ==
"Range 1"
);
80
assert( ir1.
begin
== 10 );
81
assert( ir1.
end
== 20 );
82
83
cout << myname << line <<
endl
;
84
cout <<
"Fetch range2."
<<
endl
;
85
IndexRange
ir2 = irt->get(
"range2"
);
86
cout << ir2.
rangeString
() <<
endl
;
87
assert( ir2.
isValid
() );
88
assert( ir2.
name
==
"range2"
);
89
assert( ir2.
label
() ==
"Range 2"
);
90
assert( ir2.
begin
== 20 );
91
assert( ir2.
end
== 30 );
92
93
cout << myname << line <<
endl
;
94
cout <<
"Fetch bad range"
<<
endl
;
95
IndexRange
irb = irt->get(
"rangebad"
);
96
cout << irb.
rangeString
() <<
endl
;
97
assert( ! irb.
isValid
() );
98
99
cout << myname << line <<
endl
;
100
cout << myname <<
"Done."
<<
endl
;
101
return
0;
102
}
103
104
//**********************************************************************
105
106
int
main
(
int
argc,
char
*
argv
[]) {
107
bool
useExistingFcl =
false
;
108
Index
run
= 0;
109
if
( argc > 1 ) {
110
string
sarg(argv[1]);
111
if
( sarg ==
"-h"
) {
112
cout <<
"Usage: "
<< argv[0] <<
" [keepFCL] [RUN]"
<<
endl
;
113
cout <<
" If keepFCL = true, existing FCL file is used."
<<
endl
;
114
cout <<
" If RUN is nonzero, the data for that run are displayed."
<<
endl
;
115
return
0;
116
}
117
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
118
}
119
if
( argc > 2 ) {
120
string
sarg(argv[2]);
121
istringstream ssarg(argv[2]);
122
ssarg >>
run
;
123
}
124
return
test_FclIndexRangeTool
(useExistingFcl, run);
125
}
126
127
//**********************************************************************
test_FclIndexRangeTool
int test_FclIndexRangeTool(bool useExistingFcl=false, Index runin=0)
Definition:
test_FclIndexRangeTool.cxx:29
DuneToolManager::toolNames
const std::vector< std::string > & toolNames() const
Definition:
DuneToolManager.cxx:151
string
std::string string
Definition:
nybbler.cc:12
IndexRange::begin
Index begin
Definition:
IndexRange.h:34
DuneToolManager::print
void print() const
Definition:
DuneToolManager.cxx:157
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
IndexRange::isValid
bool isValid() const
Definition:
IndexRange.h:94
IndexRange::end
Index end
Definition:
IndexRange.h:35
demo.tm
tm
Definition:
demo.py:21
IndexRangeTool.h
main
int main(int argc, char *argv[])
Definition:
test_FclIndexRangeTool.cxx:106
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
filelisting.run
int run
Definition:
filelisting.py:13
IndexRange::name
Name name
Definition:
IndexRange.h:32
DuneToolManager.h
IndexRangeTool
Definition:
IndexRangeTool.h:13
IndexRange::label
Name label(Index ilab=0) const
Definition:
IndexRange.h:106
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
DuneToolManager::getPrivate
std::unique_ptr< T > getPrivate(std::string name)
Definition:
DuneToolManager.h:82
DuneToolManager
Definition:
DuneToolManager.h:34
IndexRange
Definition:
IndexRange.h:23
pduneana::line
void line(double t, double *p, double &x, double &y, double &z)
Definition:
PDSPAnalyzer_module.cc:4741
IndexRange::rangeString
std::string rangeString() const
Definition:
IndexRange.h:97
reco_momentum_tuples.fout
fout
Definition:
reco_momentum_tuples.py:65
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