#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH2D.h" #include "JROOT/JManager.hh" #include "JLang/JException.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JGIZMO::JManager class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; string outputFile; int debug; try { JParser<> zap("Example program to test histogram manager."); zap['o'] = make_field(outputFile) = "manager.root"; zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; const char wildcard = '%'; const ios::fmtflags format(ios::showpos); typedef JManager JManager_t; JManager_t zmap(new TH2D("H2[%]", NULL, 10, -1.0, +1.0, 10, -1.0, +1.0), wildcard, format); const double x_val = 0.5; for (int i = 0; i != 10; ++i) { zmap[i]->Fill(x_val, 0.0, 1.0); } zmap.Write(outputFile.c_str()); { JManager_t test(zmap); ASSERT(zmap.size() != 0 && test.size() == 0); TFile in(outputFile.c_str(), "exist"); in >> test; ASSERT(zmap.size() == test.size()); ASSERT(zmap[0]->GetMean() == test[0]->GetMean()); in.Close(); } { TFile in(outputFile.c_str(), "exist"); JManager_t test = JManager_t::Read(in, zmap->GetName(), zmap.wc); ASSERT(zmap.size() == test.size()); ASSERT(zmap[0]->GetMean() == test[0]->GetMean()); in.Close(); } return 0; }