Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunedataprep
dunedataprep
DataPrep
Tool
test
test_AdcResultDumper.cxx
Go to the documentation of this file.
1
// test_AdcResultDumper.cxx
2
//
3
// David Adams
4
// April 2018
5
//
6
// Test AdcResultDumper.
7
8
#include <string>
9
#include <iostream>
10
#include <fstream>
11
#include <sstream>
12
#include <vector>
13
#include "
dunecore/DuneInterface/Tool/TpcDataTool.h
"
14
#include "
dunecore/ArtSupport/DuneToolManager.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
24
//**********************************************************************
25
26
int
test_AdcResultDumper
(
bool
useExistingFcl =
false
) {
27
const
string
myname =
"test_AdcResultDumper: "
;
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_AdcResultDumper.fcl"
;
36
string
gname =
"protodune_geo"
;
37
if
( ! useExistingFcl ) {
38
cout << myname <<
"Creating top-level FCL."
<<
endl
;
39
ofstream
fout
(fclfile.c_str());
40
fout
<<
"tools: {"
<<
endl
;
41
fout
<<
" mytool1: {"
<<
endl
;
42
fout
<<
" tool_type: AdcResultDumper"
<<
endl
;
43
fout
<<
" LogLevel: 2"
<<
endl
;
44
fout
<<
" Tool: \"NoSuchTool\""
<<
endl
;
45
fout
<<
" }"
<<
endl
;
46
fout
<<
" mytool2: {"
<<
endl
;
47
fout
<<
" tool_type: AdcResultDumper"
<<
endl
;
48
fout
<<
" LogLevel: 2"
<<
endl
;
49
fout
<<
" Tool: \"mytool1\""
<<
endl
;
50
fout
<<
" }"
<<
endl
;
51
fout
<<
"}"
<<
endl
;
52
fout
.close();
53
}
else
{
54
cout << myname <<
"Using existing top-level FCL."
<<
endl
;
55
}
56
57
cout << myname << line <<
endl
;
58
cout << myname <<
"Fetching tool manager."
<<
endl
;
59
DuneToolManager
* ptm =
DuneToolManager::instance
(fclfile);
60
assert ( ptm !=
nullptr
);
61
DuneToolManager
&
tm
= *ptm;
62
tm.
print
();
63
assert( tm.
toolNames
().size() == 2 );
64
65
cout << myname << line <<
endl
;
66
cout << myname <<
"Fetching tool 1."
<<
endl
;
67
auto
pard1 = tm.
getPrivate
<
TpcDataTool
>(
"mytool1"
);
68
assert( pard1 !=
nullptr
);
69
70
cout << myname << line <<
endl
;
71
cout << myname <<
"Fetching tool 2."
<<
endl
;
72
auto
pard2 = tm.
getPrivate
<
TpcDataTool
>(
"mytool2"
);
73
assert( pard2 !=
nullptr
);
74
75
cout << myname << line <<
endl
;
76
cout << myname <<
"Calling tool 1."
<<
endl
;
77
AdcChannelData
acd;
78
DataMap
dm1 = pard1->view(acd);
79
dm1.
print
();
80
assert( dm1.
status
() == 101 );
81
82
cout << myname << line <<
endl
;
83
cout << myname <<
"Calling tool 2."
<<
endl
;
84
DataMap
dm2 = pard2->view(acd);
85
dm2.
print
();
86
assert( dm2.
status
() == 101 );
87
88
cout << myname << line <<
endl
;
89
cout << myname <<
"Done."
<<
endl
;
90
return
0;
91
}
92
93
//**********************************************************************
94
95
int
main
(
int
argc,
char
*
argv
[]) {
96
bool
useExistingFcl =
false
;
97
if
( argc > 1 ) {
98
string
sarg(argv[1]);
99
if
( sarg ==
"-h"
) {
100
cout <<
"Usage: "
<< argv[0] <<
" [ARG]"
<<
endl
;
101
cout <<
" If ARG = true, existing FCL file is used."
<<
endl
;
102
return
0;
103
}
104
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
105
}
106
return
test_AdcResultDumper
(useExistingFcl);
107
}
108
109
//**********************************************************************
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
DataMap::status
int status() const
Definition:
DataMap.h:202
main
int main(int argc, char *argv[])
Definition:
test_AdcResultDumper.cxx:95
DuneToolManager.h
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
DataMap
Definition:
DataMap.h:43
test_AdcResultDumper
int test_AdcResultDumper(bool useExistingFcl=false)
Definition:
test_AdcResultDumper.cxx:26
DuneToolManager::instance
static DuneToolManager * instance(std::string fclname="", int dbg=1)
Definition:
DuneToolManager.cxx:95
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11