Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Tool
test
test_ChannelStatusConfigTool.cxx
Go to the documentation of this file.
1
// test_ChannelStatusConfigTool.cxx
2
//
3
// David Adams
4
// April 2020
5
//
6
// Test ChannelStatusConfigTool.
7
8
#include "
dunecore/DuneInterface/Data/AdcTypes.h
"
9
#include "
dunecore/ArtSupport/DuneToolManager.h
"
10
#include "
dunecore/DuneInterface/Tool/IndexMapTool.h
"
11
#include "TH1F.h"
12
#include <string>
13
#include <iostream>
14
#include <fstream>
15
#include <sstream>
16
#include <iomanip>
17
18
#undef NDEBUG
19
#include <cassert>
20
21
using
std::string
;
22
using
std::cout;
23
using
std::endl
;
24
using
std::ofstream;
25
using
std::istringstream;
26
using
std::setw
;
27
using
std::vector
;
28
using
fhicl::ParameterSet
;
29
using
Index
=
unsigned
int
;
30
31
//**********************************************************************
32
33
int
test_ChannelStatusConfigTool
(
bool
useExistingFcl =
false
) {
34
const
string
myname =
"test_ChannelStatusConfigTool: "
;
35
#ifdef NDEBUG
36
cout << myname <<
"NDEBUG must be off."
<<
endl
;
37
abort();
38
#endif
39
string
line
=
"-----------------------------"
;
40
41
cout << myname << line <<
endl
;
42
string
fclfile =
"test_ChannelStatusConfigTool.fcl"
;
43
if
( ! useExistingFcl ) {
44
cout << myname <<
"Creating top-level FCL."
<<
endl
;
45
ofstream
fout
(fclfile.c_str());
46
fout
<<
"tools: {"
<<
endl
;
47
fout
<<
" mytool: {"
<<
endl
;
48
fout
<<
" tool_type: ChannelStatusConfigTool"
<<
endl
;
49
fout
<<
" LogLevel: 1"
<<
endl
;
50
fout
<<
" DefaultIndex: 99"
<<
endl
;
51
fout
<<
" IndexVectors: ["
<<
endl
;
52
fout
<<
" [ 0, 1, 2],"
<<
endl
;
53
fout
<<
" [ 10, 11, 12],"
<<
endl
;
54
fout
<<
" [ 20, 21, 22]"
<<
endl
;
55
fout
<<
" ]"
<<
endl
;
56
fout
<<
" }"
<<
endl
;
57
fout
<<
"}"
<<
endl
;
58
fout
.close();
59
}
else
{
60
cout << myname <<
"Using existing top-level FCL."
<<
endl
;
61
}
62
63
cout << myname << line <<
endl
;
64
cout << myname <<
"Fetching tool manager."
<<
endl
;
65
DuneToolManager
* ptm =
DuneToolManager::instance
(fclfile);
66
assert ( ptm !=
nullptr
);
67
DuneToolManager
&
tm
= *ptm;
68
tm.
print
();
69
assert( tm.
toolNames
().size() >= 1 );
70
71
cout << myname << line <<
endl
;
72
cout << myname <<
"Fetching tool."
<<
endl
;
73
auto
pcs = tm.
getPrivate
<
IndexMapTool
>(
"mytool"
);
74
assert( pcs !=
nullptr
);
75
76
cout << myname << line <<
endl
;
77
cout <<
"Check some channels."
<<
endl
;
78
vector<Index> chks(30, 99);
79
chks[ 0] = 0;
80
chks[ 1] = 0;
81
chks[ 2] = 0;
82
chks[10] = 1;
83
chks[11] = 1;
84
chks[12] = 1;
85
chks[20] = 2;
86
chks[21] = 2;
87
chks[22] = 2;
88
for
(
Index
icha=0; icha<chks.size(); ++icha ) {
89
Index
chanStat = pcs->get(icha);
90
cout <<
setw
(8) << icha <<
": "
<<
setw
(2) << chanStat <<
endl
;
91
assert( chanStat == chks[icha] );
92
}
93
94
cout << myname << line <<
endl
;
95
cout << myname <<
"Done."
<<
endl
;
96
return
0;
97
}
98
99
//**********************************************************************
100
101
int
main
(
int
argc,
char
*
argv
[]) {
102
bool
useExistingFcl =
false
;
103
if
( argc > 1 ) {
104
string
sarg(argv[1]);
105
if
( sarg ==
"-h"
) {
106
cout <<
"Usage: "
<< argv[0] <<
" [keepFCL]"
<<
endl
;
107
cout <<
" If keepFCL = true, existing FCL file is used."
<<
endl
;
108
return
0;
109
}
110
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
111
}
112
return
test_ChannelStatusConfigTool
(useExistingFcl);
113
}
114
115
//**********************************************************************
IndexMapTool
Definition:
IndexMapTool.h:12
DuneToolManager::toolNames
const std::vector< std::string > & toolNames() const
Definition:
DuneToolManager.cxx:151
string
std::string string
Definition:
nybbler.cc:12
IndexMapTool.h
vector
struct vector vector
DuneToolManager::print
void print() const
Definition:
DuneToolManager.cxx:157
Index
unsigned int Index
Definition:
sspmapmaker_v1.c:14
demo.tm
tm
Definition:
demo.py:21
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
DuneToolManager.h
main
int main(int argc, char *argv[])
Definition:
test_ChannelStatusConfigTool.cxx:101
AdcTypes.h
setw
Q_EXPORT QTSManip setw(int w)
Definition:
qtextstream.h:331
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
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
test_ChannelStatusConfigTool
int test_ChannelStatusConfigTool(bool useExistingFcl=false)
Definition:
test_ChannelStatusConfigTool.cxx:33
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