30 int main(
int argc,
char **argv)
43 JParser<> zap(
"Program to test ROOT fit.");
53 catch(
const exception& error) {
54 FATAL(error.what() << endl);
58 ASSERT(numberOfEvents > 0);
60 TF1 fs(
"fs",
"exp(-0.5 * (x-[0])*(x-[0]) / ([1]*[1]))");
63 fs.FixParameter(0,
gauss.mean);
64 fs.FixParameter(1,
gauss.sigma);
67 const Double_t
xmin = -5.0;
68 const Double_t
xmax = +5.0;
75 TH1D
H[] = { TH1D(
"ha",
"", 101, -0.1, +0.1),
76 TH1D(
"hb",
"", 101, -0.1, +0.1),
77 TH1D(
"hc",
"", 101, -100.0, +100.0),
78 TH1D(
"hd",
"", 101, -100.0, +100.0) };
82 for (
int i = 0; i != numberOfEvents; ++i) {
84 STATUS(
"event: " << setw(10) << i <<
'\r');
DEBUG(endl);
90 h0.FillRandom(
"fs", (Int_t)
gauss.signal);
91 h0.FillRandom(
"fb", (Int_t)
gauss.background);
93 TF1
f1(
"f1",
"[2]*exp(-0.5 * (x-[0])*(x-[0]) / ([1]*[1])) / (TMath::Sqrt(2.0*TMath::Pi())*[1]) + [3]");
95 f1.SetParameter(0, h0.GetMean());
96 f1.SetParameter(1, h0.GetRMS());
97 f1.SetParameter(2, h0.GetEntries() - h0.GetMinimum() * h0.GetNbinsX());
98 f1.SetParameter(3, h0.GetMinimum());
100 f1.SetParError(0, 1.0e-3);
101 f1.SetParError(1, 1.0e-3);
102 f1.SetParError(2, 0.5);
103 f1.SetParError(3, 0.5);
105 string option =
"NWL";
107 if (
debug <
debug_t && option.find(
'Q') == string::npos) {
113 h0.Fit(&
f1, option.c_str());
117 const double Y[] = {
f1.GetParameter(0) -
gauss.mean,
118 f1.GetParameter(1) -
gauss.sigma,
120 f1.GetParameter(3) * nx -
gauss.background };
122 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
128 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
140 for (
int i = 0; i !=
sizeof(
H)/
sizeof(
H[0]); ++i) {
148 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
double getMean(vector< double > &v)
get mean of vector content
std::ostream & shortprint(std::ostream &out)
Set short printing.
std::ostream & longprint(std::ostream &out)
Set long printing.
General purpose messaging.
#define DEBUG(A)
Message macros.
#define ASSERT(A,...)
Assert macro.
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
I/O formatting auxiliaries.
int main(int argc, char **argv)
Auxiliary class for CPU timing and usage.
void print(std::ostream &out, const JScale_t scale=milli_t) const
Print timer data.
Utility class to parse command line options.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
double gauss(const double x, const double sigma)
Gauss function (normalised to 1 at x = 0).
static const double H
Planck constant [eV s].
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).