35 TCanvas *
c1 =
new TCanvas(
"pol3",
"pol3",800,1000);
39 TF1 *
f =
new TF1(
"TRY",
"pol3",-5.,5.);
48 double anaInt = f->Integral(-5.,5.);
50 std::cout<<
"analytical integral for " << f->GetTitle() <<
" = " << anaInt << std::endl;
51 std::cout<<
"numerical integral for " << f->GetTitle() <<
" = " << numInt << std::endl;
54 Error(
"TestAnalyticalIntegral",
"Different integral value for %s num = %f ana = %f diff = %f",f->GetTitle(),numInt,anaInt,numInt-anaInt);
59 TF1 *
f =
new TF1(
"MyExp",
"expo",-5.,5.);
66 double anaInt = f->Integral(-5.,5.);
67 double numInt = ig.
Integral(wf,-5.,5.);
69 std::cout<<
"analytical integral for " << f->GetTitle() <<
" = " << anaInt << std::endl;
70 std::cout<<
"numerical integral for " << f->GetTitle() <<
" = " << numInt << std::endl;
73 Error(
"TestAnalyticalIntegral",
"Different integral value for %s num = %f ana = %f diff = %f",f->GetTitle(),numInt,anaInt,numInt-anaInt);
77 TF1 *
f =
new TF1(
"MyCrystalBall",
"crystalball",-5.,5.);
84 double anaInt = f->Integral(-5.,5.);
85 double numInt = ig.
Integral(wf,-5.,5.);
87 std::cout<<
"analytical integral for " << f->GetTitle() <<
" = " << anaInt << std::endl;
88 std::cout<<
"numerical integral for " << f->GetTitle() <<
" = " << numInt << std::endl;
91 Error(
"TestAnalyticalIntegral",
"Different integral value for %s num = %f ana = %f diff = %f",f->GetTitle(),numInt,anaInt,numInt-anaInt);
96 TF1 *
f =
new TF1(
"MyCrystalBall",
"crystalball",-5.,5.);
103 double anaInt = f->Integral(-5.,5.);
104 double numInt = ig.
Integral(wf,-5.,5.);
106 std::cout<<
"analytical integral for " << f->GetTitle() <<
" = " << anaInt << std::endl;
107 std::cout<<
"numerical integral for " << f->GetTitle() <<
" = " << numInt << std::endl;
110 Error(
"TestAnalyticalIntegral",
"Different integral value for %s num = %f ana = %f diff = %f",f->GetTitle(),numInt,anaInt,numInt-anaInt);
113 TF1 *
f =
new TF1(
"MyGauss",
"gaus",-5.,5.);
119 double anaInt = f->Integral(-5.,5.);
120 double numInt = ig.
Integral(wf,-5.,5.);
122 std::cout<<
"analytical integral for " << f->GetTitle() <<
" = " << anaInt << std::endl;
123 std::cout<<
"numerical integral for " << f->GetTitle() <<
" = " << numInt << std::endl;
126 Error(
"TestAnalyticalIntegral",
"Different integral value for %s num = %f ana = %f diff = %f",f->GetTitle(),numInt,anaInt,numInt-anaInt);
129 TF1 *
f =
new TF1(
"MyGauss",
"gausn",-5.,5.);
136 double anaInt = f->Integral(-5.,5.);
137 double numInt = ig.
Integral(wf,-5.,5.);
139 std::cout<<
"analytical integral for " << f->GetTitle() <<
" = " << anaInt << std::endl;
140 std::cout<<
"numerical integral for " << f->GetTitle() <<
" = " << numInt << std::endl;
143 Error(
"TestAnalyticalIntegral",
"Different integral value for %s num = %20.10f ana = %20.10f diff = %20.10f",f->GetTitle(),numInt,anaInt,numInt-anaInt);
148 TF1 *
f =
new TF1(
"MyExp",
"landau",-5.,5.);
155 double anaInt = f->Integral(-5.,5.);
156 double numInt = ig.
Integral(wf,-5.,5.);
158 std::cout<<
"analytical integral for " << f->GetTitle() <<
" = " << anaInt << std::endl;
159 std::cout<<
"numerical integral for " << f->GetTitle() <<
" = " << numInt << std::endl;
162 Error(
"TestAnalyticalIntegral",
"Different integral value for %s num = %f ana = %f diff = %f",f->GetTitle(),numInt,anaInt,numInt-anaInt);
166 TF1 *
f =
new TF1(
"MyExp",
"landaun",-5.,5.);
172 double anaInt = f->Integral(-5.,5.);
173 double numInt = ig.
Integral(wf,-5.,5.);
175 std::cout<<
"analytical integral for " << f->GetTitle() <<
" = " << anaInt << std::endl;
176 std::cout<<
"numerical integral for " << f->GetTitle() <<
" = " << numInt << std::endl;
179 Error(
"TestAnalyticalIntegral",
"Different integral value for %s num = %f ana = %f diff = %f",f->GetTitle(),numInt,anaInt,numInt-anaInt);
184 int main(
int argc,
char **argv)
188 for (
Int_t i=1 ; i<argc ; i++) {
189 std::string arg = argv[i] ;
194 cerr <<
"Usage: " << argv[0] <<
" [-g] [-v]\n";
196 cerr <<
" -g : graphics mode\n";
197 cerr <<
" -v : verbose mode";
Class to Wrap a ROOT Function class (like TF1) in a IParamFunction interface of one dimensions to be ...
void SetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Restore the parameters from pars into the function.
virtual void Run(Bool_t retrn=kFALSE)
Main application eventloop. Calls system dependent eventloop via gSystem.
int main(int argc, char **argv)
void Error(const char *location, const char *msgfmt,...)
Bool_t AreEqualAbs(Double_t af, Double_t bf, Double_t epsilon)
double Integral(Function &f, double a, double b)
evaluate the Integral of a function f over the defined interval (a,b)
User Class for performing numerical integration of a function in one dimension.
void testAnalyticalIntegrals()
void SetFunction(Function &f)
method to set the a generic integration function
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...