53 for (
int i = 0; i < 2; ++i)
54 p1[i] = par[iparB[i]];
57 for (
int i = 0; i < 5; ++i)
58 p2[i] = par[iparSB[i]];
60 return (*fChi2_1)(p1) + (*fChi2_2)(p2);
70 TH1D *hB =
new TH1D(
"hB",
"histo B", 100, 0, 100);
71 TH1D *hSB =
new TH1D(
"hSB",
"histo S+B", 100, 0, 100);
107 GlobalChi2 globalChi2(chi2_B, chi2_SB);
112 double par0[Npar] = {5, 5, -0.1, 100, 30, 10};
128 fitter.
FitFCN(6, globalChi2,
nullptr, dataB.Size() + dataSB.Size(),
true);
130 result.
Print(std::cout);
132 std::cout <<
"Combined fit Chi2 = " << result.
Chi2() << std::endl;
134 TCanvas *
c1 =
new TCanvas(
"Simfit",
"Simultaneous fit of two histograms", 10, 10, 700, 700);
140 fB->
SetRange(rangeB().first, rangeB().second);
147 fSB->
SetRange(rangeSB().first, rangeSB().second);
TRObject operator()(const T1 &t1) const
Class describing the binned data sets : vectors of x coordinates, y values and optionally error on y ...
class describing the range in the coordinates it supports multiple range in a coordinate.
void SetRange(unsigned int icoord, double xmin, double xmax)
set a range [xmin,xmax] for the new coordinate icoord If more range exists for other coordinates,...
void SetMinimizer(const char *type, const char *algo=nullptr)
set minimizer type and algorithm
void SetParamsSettings(unsigned int npar, const double *params, const double *vstep=nullptr)
set the parameter settings from number of parameters and a vector of values and optionally step value...
const ParameterSettings & ParSettings(unsigned int i) const
get the parameter settings for the i-th parameter (const method)
ROOT::Math::MinimizerOptions & MinimizerOptions()
access to the minimizer control parameter (non const method)
class containing the result of the fit and all the related information (fitted parameter values,...
double Chi2() const
Return the Chi2 value after fitting In case of unbinned fits (or not defined one, see the documentati...
void Print(std::ostream &os, bool covmat=false) const
print the result and optionally covariance matrix and correlations
Fitter class, entry point for performing all type of fits.
const FitResult & Result() const
get fit result
bool FitFCN(unsigned int npar, Function &fcn, const double *params=nullptr, unsigned int dataSize=0, int fitType=0)
Fit using the a generic FCN function as a C++ callable object implementing double () (const double *)...
const FitConfig & Config() const
access to the fit configuration (const method)
void SetStepSize(double err)
set the step size
void SetLimits(double low, double up)
set a double side limit, if low == up the parameter is fixed if low > up the limits are removed The c...
void Fix()
fix the parameter
void SetPrintLevel(int level)
set print level
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetRange(Double_t xmin, Double_t xmax)
virtual void SetParameters(const Double_t *params)
virtual void SetFitResult(const ROOT::Fit::FitResult &result, const Int_t *indpar=nullptr)
1-D histogram with a double per channel (see TH1 documentation)
virtual void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr)
void Draw(Option_t *option="") override
Draw this histogram with options.
TList * GetListOfFunctions() const
void Add(TObject *obj) override
void FillData(BinData &dv, const TH1 *hist, TF1 *func=nullptr)
fill the data vector from a TH1.
Chi2FCN< ROOT::Math::IMultiGenFunction, ROOT::Math::IParamMultiFunction > Chi2Function
IMultiGenFunctionTempl< double > IMultiGenFunction
WrappedMultiTF1Templ< double > WrappedMultiTF1
DataOptions : simple structure holding the options on how the data are filled.