Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Tool
test
test_SimpleHistogramManager.cxx
Go to the documentation of this file.
1
// test_SimpleHistogramManager.cxx
2
//
3
// David Adams
4
// April 2017
5
//
6
// Test SimpleHistogramManager.
7
8
#include <string>
9
#include <iostream>
10
#include <fstream>
11
#include "
dunecore/DuneInterface/Tool/HistogramManager.h
"
12
#include "
dunecore/ArtSupport/DuneToolManager.h
"
13
#include "TH1F.h"
14
15
#undef NDEBUG
16
#include <cassert>
17
18
using
std::string
;
19
using
std::cout;
20
using
std::endl
;
21
using
std::ofstream;
22
using
fhicl::ParameterSet
;
23
24
//**********************************************************************
25
26
int
test_SimpleHistogramManager
(
bool
useExistingFcl =
false
) {
27
const
string
myname =
"test_SimpleHistogramManager: "
;
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_SimpleHistogramManager.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: SimpleHistogramManager"
<<
endl
;
42
fout
<<
" LogLevel: 1"
<<
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
phm = tm.
getPrivate
<
HistogramManager
>(
"mytool"
);
61
assert( phm !=
nullptr
);
62
63
cout << myname << line <<
endl
;
64
cout << myname <<
"Creating histogram."
<<
endl
;
65
TH1* ph =
new
TH1F(
"h1"
,
"h1"
, 10, 0, 10);
66
assert(ph->GetDirectory() !=
nullptr
);
67
68
cout << myname << line <<
endl
;
69
cout << myname <<
"Managing histogram."
<<
endl
;
70
assert(phm->manage(ph) == 0);
71
assert(ph->GetDirectory() ==
nullptr
);
72
73
cout << myname << line <<
endl
;
74
cout << myname <<
"Done."
<<
endl
;
75
return
0;
76
}
77
78
//**********************************************************************
79
80
int
main
(
int
argc,
char
*
argv
[]) {
81
bool
useExistingFcl =
false
;
82
if
( argc > 1 ) {
83
string
sarg(argv[1]);
84
if
( sarg ==
"-h"
) {
85
cout <<
"Usage: "
<< argv[0] <<
" [ARG]"
<<
endl
;
86
cout <<
" If ARG = true, existing FCL file is used."
<<
endl
;
87
return
0;
88
}
89
useExistingFcl = sarg ==
"true"
|| sarg ==
"1"
;
90
}
91
return
test_SimpleHistogramManager
(useExistingFcl);
92
}
93
94
//**********************************************************************
main
int main(int argc, char *argv[])
Definition:
test_SimpleHistogramManager.cxx:80
DuneToolManager::toolNames
const std::vector< std::string > & toolNames() const
Definition:
DuneToolManager.cxx:151
string
std::string string
Definition:
nybbler.cc:12
DuneToolManager::print
void print() const
Definition:
DuneToolManager.cxx:157
HistogramManager
Definition:
HistogramManager.h:20
demo.tm
tm
Definition:
demo.py:21
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
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
DuneToolManager::instance
static DuneToolManager * instance(std::string fclname="", int dbg=1)
Definition:
DuneToolManager.cxx:95
test_SimpleHistogramManager
int test_SimpleHistogramManager(bool useExistingFcl=false)
Definition:
test_SimpleHistogramManager.cxx:26
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
HistogramManager.h
Generated by
1.8.11