00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CINT__
00019
00020 #include <iostream.h>
00021
00022 #include "TH1.h"
00023 #include "TFile.h"
00024 #include "TApplication.h"
00025
00026 #include "../Go4Fit/TGo4Fitter.h"
00027 #include "../Go4Fit/TGo4FitModelFunction.h"
00028
00029 void Example3();
00030
00031 int main(int argc, char **argv)
00032 {
00033 TApplication theApp("Application", 0, 0);
00034
00035 Example3();
00036
00037 theApp.Run();
00038
00039 return 0;
00040 }
00041
00042 extern "C" Double_t gaussian_(Double_t *axis, Double_t *pars);
00043
00044
00045 TH1D* GetHistogram(const char* HistogramName) {
00046 TFile f1("histograms.root");
00047 TH1D* histo = (TH1D*) f1.Get(HistogramName);
00048 histo->SetDirectory(0);
00049 return histo;
00050 }
00051
00052 void Example3() {
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 cout << "This example uses linked FORTRAN libraray," << endl;
00084 cout << "therefore it can not be run in CINT" << endl;
00085 }
00086
00087 #endif
00088
00089
00090