29 int main(
int argc,
char **argv)
34 typedef JRange<Double_t> JRange_t;
50 JParser<> zap(
"Auxiliary program to test contents of 2D histograms.");
52 zap[
'f'] =
make_field(inputFile,
"measurement histogram, e.g: <file name>:<object name>");
53 zap[
'x'] =
make_field(X,
"accepted x-range values") = JRange_t();
54 zap[
'y'] =
make_field(Y,
"accepted y-range values") = JRange_t();
55 zap[
'z'] =
make_field(Z,
"accepted z-range values") = JRange_t();
65 catch(
const exception &error) {
66 FATAL(error.what() << endl);
69 int number_of_failures = 0;
73 DEBUG(
"Input: " << *input << endl);
78 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
82 const TRegexp regexp(input->getObjectName());
84 TIter iter(dir->GetListOfKeys());
86 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
88 const TString tag(key->GetName());
90 DEBUG(
"Key: " << tag <<
" match = " << tag.Index(regexp) <<
" (-1 /= OK)" << endl);
94 if (tag.Index(regexp) != -1) {
101 if (h2 == NULL && dynamic_cast<TH2*>(p) != NULL) { h2 =
dynamic_cast<TH2*
>(p); }
104 FATAL(
"Object at " << *input <<
" is not TH2." << endl);
108 for (map_type::const_iterator i = zmap.begin(); i != zmap.end(); ++i) {
110 const double value =
getResult(i->first, h2);
111 const JRange_t& range = i->second;
113 DEBUG(
"Global test " << i->first <<
' ' << (range(value) ?
"passed" :
"failed") << endl);
119 int number_of_outliers = 0;
121 for (Int_t ix = 1; ix <= h2->GetXaxis()->GetNbins(); ++ix) {
122 for (Int_t iy = 1; iy <= h2->GetYaxis()->GetNbins(); ++iy) {
124 const Double_t x = h2->GetXaxis()->GetBinCenter(ix);
125 const Double_t y = h2->GetYaxis()->GetBinCenter(iy);
126 const Double_t z = h2->GetBinContent(ix, iy);
128 if (X(x) == !invertX &&
131 const bool ok = (Z(z) == !invertZ);
133 DEBUG(
"Test outlier " << h2->GetName() <<
" bin (" << ix <<
"," << iy <<
") " << z <<
' ' << (ok ?
"passed" :
"failed") << endl);
136 ++number_of_outliers;
142 cout << (number_of_outliers > numberOfOutliers ?
RED :
GREEN);
143 NOTICE(
"Number of outliers \"" << h2->GetName() <<
"\" = " << number_of_outliers << endl);
146 if (number_of_outliers > numberOfOutliers) {
147 ++number_of_failures;
153 ASSERT(number_of_failures == 0);
Utility class to parse command line options.
Empty structure for specification of parser element that is initialised (i.e.
#define ASSERT(A)
Assert macro.
I/O coloring auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t getResult(const TString &text, TObject *object=NULL)
Get result of given textual formula.
General purpose messaging.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
const char *const GREEN
print green
const char *const RED
print red
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
#define DEBUG(A)
Message macros.
const char *const RESET
print reset color
int main(int argc, char *argv[])