#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "JFit/JMEstimator.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to plot various M-Estimators. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; string outputFile; string mestimator; int debug; try { JParser<> zap("Example program to plot various M-Estimators."); zap['o'] = make_field(outputFile) = "mestimator.root"; zap['M'] = make_field(mestimator) = "normal", "lorentzian", "linear", "tukey", "normalwithbackground"; zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JMEstimator* me = NULL; if (mestimator == "normal") me = new JMEstimatorNormal(); else if (mestimator == "lorentzian") me = new JMEstimatorLorentzian(); else if (mestimator == "linear") me = new JMEstimatorLinear(); else if (mestimator == "tukey") me = new JMEstimatorTukey(5.0); else if (mestimator == "normalwithbackground") me = new JMEstimatorNormalWithBackground(1.0e-5); else FATAL("Missing M-Estimator."); TFile out(outputFile.c_str(), "recreate"); TH1D h0("rho", NULL, 4000, -10.0, +10.0); TH1D h1("psi", NULL, 4000, -10.0, +10.0); for (int i = 1; i <= h0.GetNbinsX(); ++i) { const double x = h0.GetBinCenter(i); const double rho = me->getRho(x); const double psi = me->getPsi(x); h0.SetBinContent(i, rho); h1.SetBinContent(i, psi); } delete me; out.Write(); out.Close(); }