Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __CINT__
00018
00019 #include "TH1.h"
00020 #include "TFile.h"
00021 #include "TApplication.h"
00022
00023 #include "TGo4Fitter.h"
00024 #include "TGo4FitModelFunction.h"
00025 #include "TGo4FitModelFormula.h"
00026
00027 void Example2();
00028
00029 int main(int argc, char **argv) {
00030
00031 TApplication theApp("Application", 0, 0);
00032
00033 Example2();
00034
00035 theApp.Run();
00036
00037 return 0;
00038 }
00039
00040 #endif
00041
00042
00043 TH1D* GetHistogram(const char* HistogramName)
00044 {
00045 TFile* f1 = TFile::Open("histograms.root");
00046 if (f1==0) return 0;
00047 TH1D* histo = (TH1D*) f1->Get(HistogramName);
00048 if (histo) histo->SetDirectory(0);
00049 return histo;
00050 }
00051
00052 void Example2()
00053 {
00054
00055 TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
00056
00057
00058 fitter.AddH1("data1", GetHistogram("hDeg120_P_c"), kTRUE, 2200., 2900.);
00059
00060
00061 fitter.AddPolynomX( "data1", "Pol", 1);
00062
00063
00064 TGo4FitModel* model1 = fitter.AddModel( "data1",
00065 new TGo4FitModelFunction("Gauss1","Example2Func.so","gaussian",2,kTRUE) );
00066 TGo4FitModel* model2 = fitter.AddModel( "data1",
00067 new TGo4FitModelFormula("Gauss2", "exp(-0.5*(x-Pos)*(x-Pos)/Width/Width)",2,kTRUE));
00068
00069
00070 model1->SetParsNames("Ampl","Pos","Width");
00071 model2->SetParsNames("Ampl","Pos","Width");
00072
00073
00074 model1->SetParsValues(1.,2553.,15.);
00075 model2->SetParsValues(1.,2672.,15.);
00076
00077
00078 fitter.DoActions();
00079
00080
00081 fitter.Print("Pars");
00082
00083
00084 fitter.Draw("#data1,Background,Gauss1,Gauss2");
00085
00086 }