28 using TMath::PoissonI;
42 const double fs =
gauss.signal *
exp(-0.5*
u*
u) / (sqrt(2.0*PI) *
gauss.sigma);
43 const double fb =
gauss.background;
44 const double f1 = fs + fb;
46 return -log(PoissonI(
point.getY(), f1));
80 catch(
const exception& error) {
84 ASSERT(numberOfEvents > 0);
88 TF1 fs(
"fs",
"exp(-0.5 * (x-[0])*(x-[0]) / ([1]*[1]))");
91 fs.FixParameter(0,
gauss.mean);
92 fs.FixParameter(1,
gauss.sigma);
106 TH1D(
"ha",
"", 101, -0.1, +0.1),
107 TH1D(
"hb",
"", 101, -0.1, +0.1),
108 TH1D(
"hc",
"", 101, -100.0, +100.0),
109 TH1D(
"hd",
"", 101, -100.0, +100.0)
114 for (
int i = 0; i != numberOfEvents; ++i) {
121 h0.FillRandom(
"fb", (
Int_t)
gauss.background);
125 for (
Int_t i = 1; i <= h0.GetNbinsX(); ++i) {
126 data.push_back(JElement_t(h0.GetBinCenter (i),
127 h0.GetBinContent(i)));
134 fit.step[0] =
JGauss(0.1, 0.0, 0.0, 0.0);
135 fit.step[1] =
JGauss(0.0, 0.1, 0.0, 0.0);
136 fit.step[2] =
JGauss(0.0, 0.0,
gauss.signal * 0.01, 0.0);
137 fit.step[3] =
JGauss(0.0, 0.0, 0.0,
gauss.background * 0.01);
139 fit.value =
JGauss(h0.GetMean(),
141 h0.GetEntries() * (xmax - xmin) /
nx - h0.GetMinimum(),
144 DEBUG(
"Start value " << fit.value <<
endl);
146 for (
size_t i = 0; i != fit.step.size(); ++i) {
147 DEBUG(
"Step size " << i <<
' ' << fit.step[i] <<
endl);
152 const double chi2 = fit(
g1, data.begin(), data.end());
156 DEBUG(
"Final value " << fit.value <<
endl);
159 const double Y[] = { fit.value.mean -
gauss.mean,
160 fit.value.sigma -
gauss.sigma,
161 fit.value.signal *
nx / (xmax - xmin) -
gauss.signal,
162 fit.value.background *
nx -
gauss.background };
164 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
170 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
182 for (
int i = 0; i !=
sizeof(
H)/
sizeof(
H[0]); ++i) {
190 for (
int i = 0; i !=
sizeof(Q)/
sizeof(Q[0]); ++i) {
double getMean(vector< double > &v)
get mean of vector content
The elements in a collection are sorted according to their abscissa values and a given distance opera...
std::ostream & longprint(std::ostream &out)
Set long printing.
std::ostream & shortprint(std::ostream &out)
Set short 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.
Double_t g1(const Double_t x)
Function.
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.
Simple fit method based on Powell's algorithm, see reference: Numerical Recipes in C++,...
Template definition of a multi-dimensional oscillation probability interpolation table.
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).