Jpp  15.0.1-rc.1-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMEstimator.cc File Reference

Example program to plot various M-Estimators. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "JFit/JMEstimator.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

Example program to plot various M-Estimators.

Author
mdejong

Definition in file JMEstimator.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file JMEstimator.cc.

22 {
23  using namespace std;
24 
25  string outputFile;
26  string mestimator;
27  bool debug;
28 
29  try {
30 
31  JParser<> zap("Example program to plot various M-Estimators.");
32 
33  zap['o'] = make_field(outputFile) = "mestimator.root";
34  zap['M'] = make_field(mestimator) = "normal", "lorentzian", "tukey", "linear";
35  zap['d'] = make_field(debug);
36 
37  zap(argc, argv);
38  }
39  catch(const exception &error) {
40  FATAL(error.what() << endl);
41  }
42 
43 
44  using namespace JPP;
45 
46  JMEstimator* me = NULL;
47 
48  if (mestimator == "normal")
49  me = new JMEstimatorNormal();
50  else if (mestimator == "lorentzian")
51  me = new JMEstimatorLorentzian();
52  else if (mestimator == "tukey")
53  me = new JMEstimatorTukey(5.0);
54  else if (mestimator == "linear")
55  me = new JMEstimatorLinear();
56  else
57  FATAL("Missing M-Estimator.");
58 
59 
60  TFile out(outputFile.c_str(), "recreate");
61 
62  TH1D h0("rho", NULL, 4000, -10.0, +10.0);
63  TH1D h1("psi", NULL, 4000, -10.0, +10.0);
64 
65  for (int i = 1; i <= h0.GetNbinsX(); ++i) {
66 
67  const double x = h0.GetBinCenter(i);
68 
69  const double rho = me->getRho(x);
70  const double psi = me->getPsi(x);
71 
72  h0.SetBinContent(i, rho);
73  h1.SetBinContent(i, psi);
74  }
75 
76  delete me;
77 
78  out.Write();
79  out.Close();
80 }
Utility class to parse command line options.
Definition: JParser.hh:1500
mestimator
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
string outputFile
#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