Jpp
Functions
JManager.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH2D.h"
#include "JGizmo/JManager.hh"
#include "JLang/JException.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JGIZMO::JManager class.

Author
mdejong

Definition in file JManager.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file JManager.cc.

25 {
26  using namespace std;
27 
28  string outputFile;
29  int debug;
30 
31  try {
32 
33  JParser<> zap("Example program to test histogram manager.");
34 
35  zap['o'] = make_field(outputFile) = "manager.root";
36  zap['d'] = make_field(debug) = 2;
37 
38  zap(argc, argv);
39  }
40  catch(const exception &error) {
41  FATAL(error.what() << endl);
42  }
43 
44 
45  using namespace JPP;
46 
47 
48  const char wildcard = '%';
49  const ios::fmtflags format(ios::showpos);
50 
51  typedef JManager<int, TH2D> JManager_t;
52 
53  JManager_t zmap(new TH2D("H2[%]", NULL, 10, -1.0, +1.0, 10, -1.0, +1.0), wildcard, format);
54 
55  for (int i = 0; i != 10; ++i) {
56  zmap[i]->Fill(0.0, 0.0, 1.0);
57  }
58 
59  zmap.Write(outputFile.c_str());
60 
61  {
62  JManager_t test(zmap);
63 
64  ASSERT(zmap.size() != 0 && test.size() == 0);
65 
66  TFile in(outputFile.c_str(), "exist");
67 
68  in >> test;
69 
70  ASSERT(zmap.size() == test.size());
71 
72  in.Close();
73  }
74 
75 
76  {
77  TFile in(outputFile.c_str(), "exist");
78 
79  JManager_t test = JManager_t::Read(in, zmap->GetName(), zmap.wc);
80 
81  ASSERT(zmap.size() == test.size());
82 
83  in.Close();
84  }
85 
86  return 0;
87 }
JManager
Auxiliary class to manage set of histograms.
Definition: JHistogramToolkit.hh:160
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
debug
int debug
debug level
Definition: JSirene.cc:59
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
std
Definition: jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition: JMessage.hh:67
outputFile
string outputFile
Definition: JDAQTimesliceSelector.cc:37