Public Member Functions | Private Attributes | List of all members
SimpleHistogramManager Class Reference

#include <SimpleHistogramManager.h>

Inheritance diagram for SimpleHistogramManager:
HistogramManager

Public Member Functions

 SimpleHistogramManager (fhicl::ParameterSet const &ps)
 
 ~SimpleHistogramManager () override
 
int manage (TH1 *ph) override
 
NameVector names () const override
 
TH1 * get (Name hname) const override
 
TH1 * last () const override
 
int release (Name hname) override
 
- Public Member Functions inherited from HistogramManager
virtual ~HistogramManager ()=default
 

Private Attributes

int m_LogLevel
 
NameVector m_names
 
std::map< Name, TH1 * > m_hists
 

Additional Inherited Members

- Public Types inherited from HistogramManager
using Name = std::string
 
using NameVector = std::vector< Name >
 

Detailed Description

Definition at line 16 of file SimpleHistogramManager.h.

Constructor & Destructor Documentation

SimpleHistogramManager::SimpleHistogramManager ( fhicl::ParameterSet const &  ps)

Definition at line 15 of file SimpleHistogramManager_tool.cc.

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 }
static constexpr double ps
Definition: Units.h:99
QTextStream & endl(QTextStream &s)
SimpleHistogramManager::~SimpleHistogramManager ( )
override

Definition at line 25 of file SimpleHistogramManager_tool.cc.

25  {
26  release("*");
27 }
int release(Name hname) override

Member Function Documentation

TH1 * SimpleHistogramManager::get ( Name  hname) const
overridevirtual

Implements HistogramManager.

Definition at line 66 of file SimpleHistogramManager_tool.cc.

66  {
68  if ( ihst == m_hists.end() ) return nullptr;
69  return ihst->second;
70 }
std::map< Name, TH1 * > m_hists
intermediate_table::const_iterator const_iterator
TH1 * SimpleHistogramManager::last ( ) const
overridevirtual

Implements HistogramManager.

Definition at line 74 of file SimpleHistogramManager_tool.cc.

74  {
75  if ( m_hists.size() == 0 ) return nullptr;
76  return get(names().back());
77 }
std::map< Name, TH1 * > m_hists
NameVector names() const override
int SimpleHistogramManager::manage ( TH1 *  ph)
overridevirtual

Implements HistogramManager.

Definition at line 31 of file SimpleHistogramManager_tool.cc.

31  {
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 }
std::map< Name, TH1 * > m_hists
QTextStream & endl(QTextStream &s)
NameVector SimpleHistogramManager::names ( ) const
overridevirtual

Implements HistogramManager.

Definition at line 60 of file SimpleHistogramManager_tool.cc.

60  {
61  return m_names;
62 }
int SimpleHistogramManager::release ( Name  hname)
overridevirtual

Implements HistogramManager.

Definition at line 81 of file SimpleHistogramManager_tool.cc.

81  {
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 }
intermediate_table::iterator iterator
std::map< Name, TH1 * > m_hists
intermediate_table::const_iterator const_iterator

Member Data Documentation

std::map<Name, TH1*> SimpleHistogramManager::m_hists
private

Definition at line 43 of file SimpleHistogramManager.h.

int SimpleHistogramManager::m_LogLevel
private

Definition at line 39 of file SimpleHistogramManager.h.

NameVector SimpleHistogramManager::m_names
private

Definition at line 42 of file SimpleHistogramManager.h.


The documentation for this class was generated from the following files: