22{
25
27 string mestimator;
29
30 try {
31
32 JParser<> zap(
"Example program to plot various M-Estimators.");
33
35 zap[
'M'] =
make_field(mestimator) =
"normal",
"lorentzian",
"linear",
"tukey",
"normalwithbackground";
37
38 zap(argc, argv);
39 }
40 catch(const exception &error) {
41 FATAL(error.what() << endl);
42 }
43
44
46
47 if (mestimator == "normal")
49 else if (mestimator == "lorentzian")
51 else if (mestimator == "linear")
53 else if (mestimator == "tukey")
55 else if (mestimator == "normalwithbackground")
57 else
58 FATAL(
"Missing M-Estimator.");
59
60
62
63 TH1D h0("rho", NULL, 4000, -10.0, +10.0);
64 TH1D h1("psi", NULL, 4000, -10.0, +10.0);
65
66 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
67
68 const double x = h0.GetBinCenter(i);
69
70 const double rho = me->
getRho(x);
71 const double psi = me->
getPsi(x);
72
73 h0.SetBinContent(i, rho);
74 h1.SetBinContent(i, psi);
75 }
76
77 delete me;
78
79 out.Write();
80 out.Close();
81}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Normal M-estimator with background.
Tukey's biweight M-estimator.
Interface for maximum likelihood estimator (M-estimator).
virtual double getRho(const double z) const =0
Get maximum likelihood estimate.
virtual double getPsi(const double z) const =0
Get derivative of maximum likelihood estimate.