Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTestFit.cc File Reference

Auxiliary program to test ROOT fit results. More...

#include <string>
#include <iomanip>
#include <iostream>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH1.h"
#include "TGraph.h"
#include "TF1.h"
#include "JTools/JRange.hh"
#include "JGizmo/JRootObjectID.hh"
#include "JGizmo/JGizmoToolkit.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Auxiliary program to test ROOT fit results.

Author
mdejong

Definition in file JTestFit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JTestFit.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30 
31  typedef JRange<Double_t> JRange_t;
33 
34  JRootObjectID inputFile;
35  string fcn;
36  JTest_t test;
37  int debug;
38 
39  try {
40 
41  JParser<> zap("Auxiliary program to test ROOT fit results.");
42 
43  zap['f'] = make_field(inputFile, "histogram, e.g: <file name>:<object name>");
44  zap['F'] = make_field(fcn, "function name") = "user";
45  zap['@'] = make_field(test, "<parameter> <min> <max>");
46  zap['d'] = make_field(debug) = 1;
47 
48  zap(argc, argv);
49  }
50  catch(const exception &error) {
51  FATAL(error.what() << endl);
52  }
53 
54 
55  TObject* p = getObject(inputFile);
56 
57  if (p == NULL) {
58  FATAL("No object at " << inputFile << endl);
59  };
60 
61  TF1* f1 = NULL;
62 
63  if (f1 == NULL && dynamic_cast<TF1*> (p) != NULL) { f1 = dynamic_cast<TF1*> (p); }
64  if (f1 == NULL && dynamic_cast<TH1*> (p) != NULL) { f1 = dynamic_cast<TH1*> (p)->GetFunction(fcn.c_str()); };
65  if (f1 == NULL && dynamic_cast<TGraph*>(p) != NULL) { f1 = dynamic_cast<TGraph*>(p)->GetFunction(fcn.c_str()); };
66 
67  if (f1 == NULL) {
68  FATAL("No function at " << inputFile << " " << fcn << endl);
69  };
70 
71 
72  for (int i = 0; i != f1->GetNpar(); ++i) {
73 
74  DEBUG(left << setw(12) << f1->GetParName(i) << ' ');
75  DEBUG(SCIENTIFIC(12,5) << f1->GetParameter(i) << " +/- " << SCIENTIFIC(12,5) << f1->GetParError(i));
76 
77  JTest_t::const_iterator p = test.find(f1->GetParName(i));
78 
79  if (p != test.end()) {
80 
81  DEBUG(" [" << SCIENTIFIC(12,5) << p->second.getLowerLimit() << "," << SCIENTIFIC(12,5) << p->second.getLowerLimit() << "] ");
82  DEBUG((p->second(f1->GetParameter(i)) ? "passed" : "failed"));
83 
84  } else {
85 
86  DEBUG("untested");
87  }
88 
89  DEBUG(endl);
90  }
91 
92 
93  for (int i = 0; i != f1->GetNpar(); ++i) {
94 
95  JTest_t::const_iterator p = test.find(f1->GetParName(i));
96 
97  if (p != test.end()) {
98  ASSERT(p->second(f1->GetParameter(i)));
99  }
100  }
101 
102  return 0;
103 }
Utility class to parse command line options.
Definition: JParser.hh:1500
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
Definition: JRoot.hh:19
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:246
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:483
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62