36 const int nsig = 5.E4;
37 const int nbkg = 1.e6;
42 TF1 *
f_cb =
new TF1(
"MyCrystalBall",
"crystalball", -5., 5.);
43 TF1 *
f_exp =
new TF1(
"MyExponential",
"expo", -5., 5.);
46 f_exp->SetParameters(1., -0.3);
58 f_sum->SetParName(1,
"NBackground");
59 f_sum->SetParName(0,
"NSignal");
60 for (
int i = 2; i <
f_sum->GetNpar(); ++i)
66 TH1D *
h_sum =
new TH1D(
"h_ExpCB",
"Exponential Bkg + CrystalBall function", nBins, -5., 5.);
67 h_sum->FillRandom(
"fsum", nEvents);
68 printf(
"Time to generate %d events: ", nEvents);
73 h_sum->Scale(1.,
"width");
77 new TCanvas(
"Fit",
"Fit", 800, 1000);
82 printf(
"Time to fit using ROOT TF1Normsum: ");
87 for (
unsigned int i = 0; i <
pref.size(); ++i) {
89 Error(
"testFitNormSum",
"Difference found in fitted %s - difference is %g sigma",
f_sum->GetParName(i),
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
R__EXTERN TStyle * gStyle
static void SetDefaultMinimizer(const char *type, const char *algo=nullptr)
Set the default Minimizer type and corresponding algorithms.
Class adding two functions: c1*f1+c2*f2.
1-D histogram with a double per channel (see TH1 documentation)
To draw Mathematical Formula.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Bool_t AreEqualAbs(Double_t af, Double_t bf, Double_t epsilon)
Comparing floating points.