56 void doFit(
int n,
const char * fitter)
60 std::vector<double>
x(n);
61 std::vector<double>
y(n);
62 std::vector<double>
e(n);
64 double initPar[3] = { 1, 1, 2 };
78 printf(
"fitting with %s",fitter);
87 for (
int i = 0; i <
npass; ++i) {
96 printf(
"%s,: RT=%7.3f s, Cpu=%7.3f s\n",fitter,timer.
RealTime(),timer.
CpuTime());
100 int np = theFitter->GetNumberFreeParameters();
101 std::cout <<
"Number of free parameters " << np <<
"\nCovariance Matrix :\n";
102 double * cv = theFitter->GetCovarianceMatrix();
104 for (
int i = 0; i < np ; ++i) {
105 for (
int j = 0; j < np ; ++j)
106 std::cout << cv[j + i*np] <<
"\t";
107 std::cout << std::endl;
123 leg->
AddEntry(gre3,
"sin(x) + sin(2*x)",
"p");
134 TCanvas *myc =
new TCanvas(
"myc",
"Fitting 3 TGraphErrors with linear functions");
151 int main(
int argc,
char **argv)
157 for (
Int_t i = 1 ; i < argc ; i++) {
158 std::string arg = argv[i] ;
161 std::cout <<
"Running in verbose mode" << std::endl;
167 std::cout <<
"Running showing the graphics" << std::endl;
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
Fit this graph with function with name fname.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetParameters(const Double_t *params)
Random number generator class based on M.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
This class displays a legend box (TPaveText) containing several legend entries.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void doFit(int n, const char *fitter)
TF1 * GetFunction(const char *name) const
Return pointer to function with name.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
R__EXTERN TStyle * gStyle
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
static void SetDefaultFitter(const char *name="")
static: set name of default fitter
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
double fitFunc(double *x, double *p)
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
int main(int argc, char **argv)
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
void Stop()
Stop the stopwatch.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
void makePoints(Int_t n, std::vector< double > &x, std::vector< double > &y, std::vector< double > &e)
A Pave (see TPave) with a text centered in the Pave.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
char * Form(const char *fmt,...)
static TVirtualFitter * GetFitter()
static: return the current Fitter
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
virtual void Draw(Option_t *option="")
Draw this pavelabel with its current attributes.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
Abstract Base Class for Fitting.
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
A TGraphErrors is a TGraph with error bars.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
void testGraphFit(int n=500)
virtual void Update()
Update canvas pad buffers.