34 typedef JRange<Double_t> JRange_t;
48 JParser<> zap(
"Auxiliary program to test contents of 1D histograms.");
50 zap[
'f'] =
make_field(inputFile,
"measurement histogram, e.g: <file name>:<object name>");
51 zap[
'x'] =
make_field(X,
"accepted x-range values") = JRange_t();
52 zap[
'y'] =
make_field(Y,
"accepted y-range values") = JRange_t();
61 catch(
const exception &error) {
62 FATAL(error.what() << endl);
66 int number_of_failures = 0;
70 DEBUG(
"Input: " << *input << endl);
75 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
79 const TRegexp regexp(input->getObjectName());
81 TIter iter(dir->GetListOfKeys());
83 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
85 const TString tag(key->GetName());
87 DEBUG(
"Key: " << tag <<
" match = " << tag.Index(regexp) <<
" (-1 /= OK)" << endl);
91 if (tag.Index(regexp) != -1) {
98 if (h1 == NULL && dynamic_cast<TProfile*>(p) != NULL) { h1 =
dynamic_cast<TProfile*
>(p)->ProjectionX(); }
100 if (h1 == NULL && dynamic_cast<TH1*>(p) != NULL) { h1 =
dynamic_cast<TH1*
>(p); }
103 FATAL(
"Object at " << *input <<
" is not TH1." << endl);
107 for (map_type::const_iterator i = zmap.begin(); i != zmap.end(); ++i) {
109 const double value =
getResult(i->first, h1);
110 const JRange_t& range = i->second;
112 DEBUG(
"Global test " << i->first <<
' ' << (range(value) ?
"passed" :
"failed") << endl);
118 int number_of_outliers = 0;
120 for (Int_t i = 1; i <= h1->GetNbinsX(); ++i) {
122 const Double_t x = h1->GetBinCenter (i);
123 const Double_t y = h1->GetBinContent(i);
125 if (X(x) == !invertX) {
127 const bool ok = (Y(y) == !invertY);
129 DEBUG(
"Test outlier " << h1->GetName() <<
" bin (" << i <<
") " << y <<
' ' << (ok ?
"passed" :
"failed") << endl);
132 ++number_of_outliers;
137 cout << (number_of_outliers > numberOfOutliers ?
RED :
GREEN);
138 NOTICE(
"Number of outliers \"" << h1->GetName() <<
"\" = " << number_of_outliers << endl);
141 if (number_of_outliers > numberOfOutliers) {
142 ++number_of_failures;
148 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.
#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.
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