Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPrintFit.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iomanip>
3 #include <iostream>
4 #include <set>
5 
6 #include "TROOT.h"
7 #include "TFile.h"
8 #include "TH1.h"
9 #include "TGraph.h"
10 #include "TF1.h"
11 
12 #include "JTools/JRange.hh"
13 #include "JGizmo/JRootObjectID.hh"
14 #include "JGizmo/JGizmoToolkit.hh"
15 
16 #include "Jeep/JPrint.hh"
17 #include "Jeep/JParser.hh"
18 #include "Jeep/JMessage.hh"
19 
20 
21 /**
22  * \file
23  * Auxiliary program to print ROOT fit results.
24  * \author mdejong
25  */
26 int main(int argc, char **argv)
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
I/O formatting auxiliaries.
#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
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Auxiliary class to define a range between two values.
Utility class to parse command line options.
int main(int argc, char *argv[])
Definition: Main.cpp:15