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

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

#include <string>
#include <iomanip>
#include <iostream>
#include <set>
#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 print ROOT fit results.

Author
mdejong

Definition in file JPrintFit.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 26 of file JPrintFit.cc.

27 {
28  using namespace std;
29  using namespace JPP;
30 
31  JRootObjectID inputFile;
32  string fcn;
34  int debug;
35 
36  try {
37 
38  JParser<> zap("Auxiliary program to print ROOT fit results.");
39 
40  zap['f'] = make_field(inputFile, "histogram, e.g: <file name>:<object name>");
41  zap['F'] = make_field(fcn, "function name") = "user";
42  zap['@'] = make_field(print, "(parameter)+");
43  zap['d'] = make_field(debug) = 1;
44 
45  zap(argc, argv);
46  }
47  catch(const exception &error) {
48  FATAL(error.what() << endl);
49  }
50 
51 
52  TObject* p = getObject(inputFile);
53 
54  if (p == NULL) {
55  FATAL("No object at " << inputFile << endl);
56  };
57 
58  TF1* f1 = NULL;
59 
60  if (f1 == NULL && dynamic_cast<TF1*> (p) != NULL) { f1 = dynamic_cast<TF1*> (p); }
61  if (f1 == NULL && dynamic_cast<TH1*> (p) != NULL) { f1 = dynamic_cast<TH1*> (p)->GetFunction(fcn.c_str()); };
62  if (f1 == NULL && dynamic_cast<TGraph*>(p) != NULL) { f1 = dynamic_cast<TGraph*>(p)->GetFunction(fcn.c_str()); };
63 
64  if (f1 == NULL) {
65  FATAL("No function at " << inputFile << " " << fcn << endl);
66  };
67 
68  for (int i = 0; i != f1->GetNpar(); ++i) {
69  if (print.count(f1->GetParName(i)) != 0) {
70  cout << FIXED(12,3) << f1->GetParameter(i) << ' '
71  << FIXED(12,3) << f1->GetParError (i) << endl;
72  }
73  }
74 }
Utility class to parse command line options.
Definition: JParser.hh:1493
TObject * getObject(const JRootObjectID &id)
Get TObject.
Definition: JRoot.hh:19
Auxiliary data structure for floating point format specification.
Definition: JPrint.hh:481
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
int debug
debug level
Definition: JSirene.cc:61
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67