Jpp  master_rocky-43-ge265d140c
the software that should make you happy
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

◆ main()

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;
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 }
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2142
Interface to read input and write output for TObject tests.
Definition: JTest_t.hh:42
Auxiliary class to handle file name, ROOT directory and object name.
Utility class to parse command line options.
Definition: JParser.hh:1698
Range of values.
Definition: JRange.hh:42
const JPolynome f1(1.0, 2.0, 3.0)
Function.
TObject * getObject(const JRootObjectID &id)
Get first TObject with given identifier.
TF1 * getFunction(TH1 *h1, const char *const fcn)
Get function.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Type definition of range.
Definition: JHead.hh:43
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:488
Definition: JRoot.hh:19