Jpp  19.0.0
the software that should make you happy
 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 "TGraph2D.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 27 of file JTestFit.cc.

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