Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
dunecore
dunecore
DuneCommon
Tool
SimpleHistogramManager_tool.cc
Go to the documentation of this file.
1
// SimpleHistogramManager.cxx
2
3
#include "
SimpleHistogramManager.h
"
4
#include "TH1.h"
5
#include <iostream>
6
7
using
std::string
;
8
using
std::cout;
9
using
std::endl
;
10
11
using
NameVector
=
HistogramManager::NameVector
;
12
13
//**********************************************************************
14
15
SimpleHistogramManager::SimpleHistogramManager
(
fhicl::ParameterSet
const
&
ps
)
16
: m_LogLevel(ps.
get
<
int
>(
"LogLevel"
)) {
17
const
string
myname =
"SimpleHistogramManager::ctor: "
;
18
if
(
m_LogLevel
> 0 ) {
19
cout << myname <<
"LogLevel: "
<<
m_LogLevel
<<
endl
;
20
}
21
}
22
23
//**********************************************************************
24
25
SimpleHistogramManager::~SimpleHistogramManager
() {
26
release
(
"*"
);
27
}
28
29
//**********************************************************************
30
31
int
SimpleHistogramManager::manage
(TH1* ph) {
32
const
string
myname =
"SimpleHistogramManager::manage: "
;
33
if
( ph ==
nullptr
) {
34
if
(
m_LogLevel
> 1 ) {
35
cout << myname <<
"Histogram pointer is null."
<<
endl
;
36
}
37
return
1;
38
}
39
string
hname = ph->GetName();
40
//if ( ph->GetDirectory() == nullptr ) {
41
// if ( m_LogLevel > 1 ) {
42
// cout << myname << "Histogram " << hname << " is not in a directory." << endl;
43
// }
44
// return 2;
45
//}
46
if
(
m_hists
.find(hname) !=
m_hists
.end() ) {
47
if
(
m_LogLevel
> 1 ) {
48
cout << myname <<
"Histogram with name "
<< hname <<
" is already managed here."
<<
endl
;
49
}
50
return
3;
51
}
52
ph->SetDirectory(
nullptr
);
53
m_hists
[hname] = ph;
54
m_names
.push_back(hname);
55
return
0;
56
}
57
58
//**********************************************************************
59
60
NameVector
SimpleHistogramManager::names
()
const
{
61
return
m_names
;
62
}
63
64
//**********************************************************************
65
66
TH1*
SimpleHistogramManager::get
(
Name
hname)
const
{
67
std::map<Name, TH1*>::const_iterator
ihst =
m_hists
.find(hname);
68
if
( ihst ==
m_hists
.end() )
return
nullptr
;
69
return
ihst->second;
70
}
71
72
//**********************************************************************
73
74
TH1*
SimpleHistogramManager::last
()
const
{
75
if
(
m_hists
.size() == 0 )
return
nullptr
;
76
return
get
(
names
().back());
77
}
78
79
//**********************************************************************
80
81
int
SimpleHistogramManager::release
(
Name
hname) {
82
if
( hname ==
"*"
) {
83
for
(
auto
ent :
m_hists
)
delete
ent.second;
84
m_names
.clear();
85
m_hists.clear();
86
}
87
std::map<Name, TH1*>::const_iterator
ihst =
m_hists
.find(hname);
88
if
( ihst ==
m_hists
.end() )
return
1;
89
NameVector::iterator
inam = find(
m_names
.begin(),
m_names
.end(), hname );
90
if
( inam ==
m_names
.end() )
return
2;
91
m_names
.erase(inam);
92
m_hists
.erase(ihst);
93
return
0;
94
}
95
96
//**********************************************************************
97
98
DEFINE_ART_CLASS_TOOL
(
SimpleHistogramManager
)
iterator
intermediate_table::iterator iterator
Definition:
intermediate_table.cc:27
HistogramManager::Name
std::string Name
Definition:
HistogramManager.h:24
SimpleHistogramManager::m_hists
std::map< Name, TH1 * > m_hists
Definition:
SimpleHistogramManager.h:43
DEFINE_ART_CLASS_TOOL
#define DEFINE_ART_CLASS_TOOL(tool)
Definition:
ToolMacros.h:42
SimpleHistogramManager::m_LogLevel
int m_LogLevel
Definition:
SimpleHistogramManager.h:39
string
std::string string
Definition:
nybbler.cc:12
SimpleHistogramManager::SimpleHistogramManager
SimpleHistogramManager(fhicl::ParameterSet const &ps)
Definition:
SimpleHistogramManager_tool.cc:15
const_iterator
intermediate_table::const_iterator const_iterator
Definition:
intermediate_table.cc:28
SimpleHistogramManager::release
int release(Name hname) override
Definition:
SimpleHistogramManager_tool.cc:81
SimpleHistogramManager::manage
int manage(TH1 *ph) override
Definition:
SimpleHistogramManager_tool.cc:31
SimpleHistogramManager.h
SimpleHistogramManager::last
TH1 * last() const override
Definition:
SimpleHistogramManager_tool.cc:74
SimpleHistogramManager::names
NameVector names() const override
Definition:
SimpleHistogramManager_tool.cc:60
SimpleHistogramManager::m_names
NameVector m_names
Definition:
SimpleHistogramManager.h:42
genie::units::ps
static constexpr double ps
Definition:
Units.h:99
SimpleHistogramManager::~SimpleHistogramManager
~SimpleHistogramManager() override
Definition:
SimpleHistogramManager_tool.cc:25
keras_to_tensorflow.int
int
Definition:
keras_to_tensorflow.py:69
HistogramManager::NameVector
std::vector< Name > NameVector
Definition:
HistogramManager.h:25
NameVector
std::vector< string > NameVector
Definition:
DuneToolManager.cxx:18
SimpleHistogramManager::get
TH1 * get(Name hname) const override
Definition:
SimpleHistogramManager_tool.cc:66
art::get
auto const & get(AssnsNode< L, R, D > const &r)
Definition:
AssnsNode.h:115
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
fhicl::ParameterSet
Definition:
ParameterSet.h:36
SimpleHistogramManager
Definition:
SimpleHistogramManager.h:16
Generated by
1.8.11