Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

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
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
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}
#define ERROR(A)
Definition JMessage.hh:66
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
Dictionary to map different tests to unique integer indices.
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
Auxiliary class for ROOT I/O of application specific meta data.
Definition JMeta.hh:72