Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __CINT__
00017
00018 #include "Riostream.h"
00019 #include "TH1.h"
00020 #include "TFile.h"
00021 #include "TApplication.h"
00022
00023 #include "TGo4Fitter.h"
00024 #include "TGo4FitModelFunction.h"
00025
00026 void Example3();
00027
00028 int main(int argc, char **argv)
00029 {
00030 TApplication theApp("Application", 0, 0);
00031
00032 Example3();
00033
00034 theApp.Run();
00035
00036 return 0;
00037 }
00038
00039 extern "C" Double_t gaussian_(Double_t *axis, Double_t *pars);
00040
00041
00042 TH1D* GetHistogram(const char* HistogramName)
00043 {
00044 TFile* f1 = TFile::Open("histograms.root");
00045 if (f1==0) return 0;
00046 TH1D* histo = (TH1D*) f1->Get(HistogramName);
00047 if (histo) histo->SetDirectory(0);
00048 return histo;
00049 }
00050
00051 void Example3()
00052 {
00053
00054 TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
00055
00056
00057 fitter.AddH1("data1", GetHistogram("hDeg120_P_c"), kTRUE, 2200., 2900.);
00058
00059
00060 fitter.AddPolynomX( "data1", "Pol", 1);
00061
00062
00063 fitter.AddModel( "data1", new TGo4FitModelFunction("Gauss1",&gaussian_,2,kTRUE) );
00064 fitter.AddModel( "data1", new TGo4FitModelFunction("Gauss2",&gaussian_,2,kTRUE) );
00065
00066
00067 fitter.SetParValue("Gauss1.Par0",2553.);
00068 fitter.SetParValue("Gauss1.Par1",15.);
00069 fitter.SetParValue("Gauss2.Par0",2672.);
00070 fitter.SetParValue("Gauss2.Par1",15.);
00071
00072
00073 fitter.AddOutputAction("Draw","#data1,Gauss1,Gauss2");
00074 fitter.AddOutputAction("Print","Pars");
00075
00076
00077 fitter.DoActions();
00078 }
00079
00080 #else
00081
00082 void Example3()
00083 {
00084 std::cout << "This example uses linked FORTRAN library," << std::endl;
00085 std::cout << "therefore it can not be run in CINT" << std::endl;
00086 }
00087
00088 #endif
00089