Jpp  pmt_effective_area_update
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JManager.cc
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <iomanip>
5 
6 #include "TROOT.h"
7 #include "TFile.h"
8 #include "TH2D.h"
9 
10 #include "JROOT/JManager.hh"
11 
12 #include "JLang/JException.hh"
13 
14 #include "Jeep/JParser.hh"
15 #include "Jeep/JMessage.hh"
16 
17 
18 /**
19  * \file
20  *
21  * Example program to test JGIZMO::JManager class.
22  * \author mdejong
23  */
24 int main(int argc, char **argv)
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 
52  typedef JManager<int, TH2D> JManager_t;
53 
54  JManager_t zmap(new TH2D("H2[%]", NULL, 10, -1.0, +1.0, 10, -1.0, +1.0), wildcard, format);
55 
56  const double x_val = 0.5;
57 
58  for (int i = 0; i != 10; ++i) {
59  zmap[i]->Fill(x_val, 0.0, 1.0);
60  }
61 
62  zmap.Write(outputFile.c_str());
63 
64  {
65  JManager_t test(zmap);
66 
67  ASSERT(zmap.size() != 0 && test.size() == 0);
68 
69  TFile in(outputFile.c_str(), "exist");
70 
71  in >> test;
72 
73  ASSERT(zmap.size() == test.size());
74 
75  ASSERT(zmap[0]->GetMean() == test[0]->GetMean());
76 
77  in.Close();
78  }
79 
80 
81  {
82  TFile in(outputFile.c_str(), "exist");
83 
84  JManager_t test = JManager_t::Read(in, zmap->GetName(), zmap.wc);
85 
86  ASSERT(zmap.size() == test.size());
87 
88  ASSERT(zmap[0]->GetMean() == test[0]->GetMean());
89 
90  in.Close();
91  }
92 
93  return 0;
94 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Exceptions.
int main(int argc, char *argv[])
Definition: Main.cc:15
Dynamic ROOT object management.
string outputFile
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40