#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include "TROOT.h"
#include "TFile.h"
#include "TF1.h"
#include "TH1D.h"
#include "TMath.h"
#include "JFit/JSimplex.hh"
#include "JTools/JElement.hh"
#include "JTools/JConstants.hh"
#include "JTools/JQuantile.hh"
#include "JROOT/JRootToolkit.hh"
#include "JMath/JGauss.hh"
#include "Jeep/JTimer.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"
 
Go to the source code of this file.
 | 
| int  | main (int argc, char **argv) | 
|   | 
Program to test JFIT::JSimplex algorithm. 
- Author
 - mdejong 
 
Definition in file JSimplexFitToGauss.cc.
 
◆ main()
      
        
          | int main  | 
          ( | 
          int  | 
          argc,  | 
        
        
           | 
           | 
          char **  | 
          argv  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 57 of file JSimplexFitToGauss.cc.
   70     JParser<> zap(
"Program to test JSimplex algorithm.");
 
   80   catch(
const exception& error) {
 
   81     FATAL(error.what() << endl);
 
   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);
 
   95   const Double_t xmin = -5.0;
 
   96   const Double_t xmax = +5.0;
 
  103   TH1D      
H[] = { TH1D(
"ha", 
"", 101,   -0.1,    +0.1),
 
  104                     TH1D(
"hb", 
"", 101,   -0.1,    +0.1),
 
  105                     TH1D(
"hc", 
"", 101, -100.0,  +100.0),
 
  106                     TH1D(
"hd", 
"", 101, -100.0,  +100.0) };
 
  110   for (
int i = 0; i != numberOfEvents; ++i) {
 
  112     STATUS(
"event: " << setw(10) << i << 
'\r'); 
DEBUG(endl);
 
  114     TH1D h0(
"h0", NULL, nx, xmin, xmax);
 
  116     h0.FillRandom(
"fs", (Int_t) gauss.
signal);
 
  117     h0.FillRandom(
"fb", (Int_t) gauss.
background);
 
  121     for (Int_t i = 1; i <= h0.GetNbinsX(); ++i) {
 
  122       data.push_back(JElement_t(h0.GetBinCenter (i),
 
  123                                 h0.GetBinContent(i)));
 
  137                        h0.GetEntries() * (xmax - xmin) / nx - h0.GetMinimum(),
 
  142     for (
size_t i = 0; i != fit.
step.size(); ++i) {
 
  143       DEBUG(
"Step size " << i << 
' ' << fit.
step[i] << endl);
 
  148     const double chi2 = fit(
g1, data.begin(), data.end());
 
  153     DEBUG(
"Chi2 " << chi2 << endl);
 
  160     for (
int i = 0; i != 
sizeof(Q)/
sizeof(Q[0]); ++i) {
 
  166   for (
int i = 0; i != 
sizeof(Q)/
sizeof(Q[0]); ++i) {
 
  178     for (
int i = 0; i != 
sizeof(
H)/
sizeof(
H[0]); ++i) {
 
  186   for (
int i = 0; i != 
sizeof(Q)/
sizeof(Q[0]); ++i) {