Jpp  test_elongated_shower_pde
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMantisShrimp.cc File Reference

Program to compare root histograms. More...

#include <iostream>
#include <fstream>
#include "TFile.h"
#include "TString.h"
#include "TRegexp.h"
#include "Jeep/JParser.hh"
#include "JSupport/JMeta.hh"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "JCompareHistograms/JTest_t.hh"
#include "JCompareHistograms/JTestDictionary.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to compare root histograms.


The input histograms and the test to be applied for each histogram are specified
through the command line.

The histogram names are treated as regular expressions. Therefore, multiple histograms could be tested on one shot.
The command line argument specifies the test to be performed, and the corresponding parameters. See JTestDictionary()

Author
rgruiz

Definition in file JMantisShrimp.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 78 of file JMantisShrimp.cc.

78  {
79 
80  using namespace JPP;
81  using namespace std;
82 
83  string steeringFile;
84 
85  vector<JRootObjectID> input_a;
86  vector<JRootObjectID> input_b;
87  string test;
88  string output;
89  string ascii;
90  bool onlyFailures;
91 
92  try {
93 
94  JParser<> zap("\nProgram to compare root histograms. See the link below this usage for further details.\n");
95 
96  zap['a'] = make_field(input_a, "Histogram a");
97  zap['b'] = make_field(input_b, "Histogram b");
98  zap['t'] = make_field(test, "Test parameters");
99  zap['o'] = make_field(output, "output file") = "out.root";
100  zap['t'] = make_field(ascii , "output file txt" ) = "";
101  zap['w'] = make_field(onlyFailures , "write only failed tests" );
102 
103  zap(argc,argv);
104  }
105  catch(const exception &error) {
106  ERROR(error.what() << endl);
107  }
108 
109  JTestDictionary d;
110 
111  int testID;
112 
113  istringstream iss(test);
114  iss >> testID;
115  d[testID]->read(iss);
116 
117  vector<TObject*> listOfObjects_a = getListOfObjects(input_a);
118  vector<TObject*> listOfObjects_b = getListOfObjects(input_b);
119 
120  for(vector<TObject*>::const_iterator object_a = listOfObjects_a.begin() ; object_a != listOfObjects_a.end() ; ++object_a){
121  for(vector<TObject*>::const_iterator object_b = listOfObjects_b.begin() ; object_b != listOfObjects_b.end() ; ++object_b){
122 
123  d[testID]->test(*object_a,*object_b);
124  }
125  }
126 
127  TFile out(output.c_str(),"recreate");
128  out.cd();
129 
130  d[testID]->write(cout);
131  d[testID]->save(&out, "", onlyFailures);
132 
133  if(!ascii.empty()){
134 
135  ofstream results;
136 
137  results.open (ascii);
138 
139  d[testID]->write(results, ';', onlyFailures);
140 
141  results.close();
142  }
143 
144  putObject(&out, JMeta(argc, argv));
145 
146  out.Close();
147 
148  return 0;
149 }
Utility class to parse command line options.
Definition: JParser.hh:1500
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define ERROR(A)
Definition: JMessage.hh:66
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition: JMuonPath.sh:47