Functions
test_SimpleHistogramManager.cxx File Reference
#include <string>
#include <iostream>
#include <fstream>
#include "dunecore/DuneInterface/Tool/HistogramManager.h"
#include "dunecore/ArtSupport/DuneToolManager.h"
#include "TH1F.h"
#include <cassert>

Go to the source code of this file.

Functions

int test_SimpleHistogramManager (bool useExistingFcl=false)
 
int main (int argc, char *argv[])
 

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 80 of file test_SimpleHistogramManager.cxx.

80  {
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 }
int test_SimpleHistogramManager(bool useExistingFcl=false)
QTextStream & endl(QTextStream &s)
int test_SimpleHistogramManager ( bool  useExistingFcl = false)

Definition at line 26 of file test_SimpleHistogramManager.cxx.

26  {
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;
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 }
const std::vector< std::string > & toolNames() const
void print() const
tm
Definition: demo.py:21
std::unique_ptr< T > getPrivate(std::string name)
void line(double t, double *p, double &x, double &y, double &z)
static DuneToolManager * instance(std::string fclname="", int dbg=1)
QTextStream & endl(QTextStream &s)