00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __CINT__
00017
00018 #include "Riostream.h"
00019
00020 #include "TH1.h"
00021 #include "TH2.h"
00022 #include "TFile.h"
00023 #include "TCanvas.h"
00024 #include "TCutG.h"
00025 #include "TApplication.h"
00026
00027 #include "../Go4Fit/TGo4FitMinuit.h"
00028 #include "../Go4Fit/TGo4Fitter.h"
00029 #include "../Go4Fit/TGo4FitDataHistogram.h"
00030 #include "../Go4Fit/TGo4FitModelPolynom.h"
00031 #include "../Go4Fit/TGo4FitModelGauss2.h"
00032 #include "../Go4Fit/TGo4FitModelGaussN.h"
00033
00034 void Example8();
00035
00036 int main(int argc, char **argv)
00037 {
00038 TApplication theApp("Application", 0, 0);
00039
00040 Example8();
00041
00042 theApp.Run();
00043
00044 return 0;
00045 }
00046
00047 #endif
00048
00049 void DrawHistogram(TH1* histo, const char* CanvasName, const char* DrawOption) {
00050 TCanvas *fCanvas = new TCanvas(CanvasName,"Draw of histogram",3);
00051 fCanvas->cd();
00052 histo->Draw(DrawOption);
00053 fCanvas->Update();
00054 }
00055
00056 void AddRangeCut(TGo4FitComponent* comp) {
00057 Double_t x[] = { 2,3,8,7,2 };
00058 Double_t y[] = { 8,3,2,7,8 };
00059 TCutG* cut = new TCutG("cut1",5,x,y);
00060 comp->AddRangeCut(cut);
00061 }
00062
00063 void Example8() {
00064
00065 TGo4Fitter *fitter = new TGo4Fitter("Fitter","Example fitter object");
00066
00067
00068 TH2D *histo = new TH2D("histo","dummy histogram",100,0.,10.,100,0.,10.);
00069 fitter->AddData(new TGo4FitDataHistogram("data",histo,kTRUE));
00070
00071
00072 TGo4FitModel* model = fitter->AddModel( "data", new TGo4FitModelGauss2("Gauss",5.,5.,1.,1.,-0.5) );
00073 model->SetAmplValue(1000.);
00074
00075 AddRangeCut(model);
00076
00077
00078 TH1* res = (TH1*) fitter->CreateDrawObject("GaussModel","data",kTRUE);
00079 delete fitter;
00080
00081
00082
00083 DrawHistogram(res,"Canvas1","SURF1");
00084
00085
00086 fitter = new TGo4Fitter("Fitter2",TGo4Fitter::ff_ML_Poisson,kFALSE);
00087
00088
00089 TGo4FitData* data = fitter->AddData(new TGo4FitDataHistogram("data",res));
00090
00091 AddRangeCut(data);
00092
00093
00094 model = fitter->AddModel( "data", new TGo4FitModelGaussN("Gauss",2) );
00095 model->SetPosition(0,4.5);
00096 model->SetPosition(1,4.5);
00097 model->SetWidth(0,1.7);
00098 model->SetWidth(1,1.7);
00099 model->SetAmplValue(500.);
00100
00101 fitter->AddSimpleMinuit();
00102
00103 fitter->SetMemoryUsage(1);
00104
00105 fitter->DoActions();
00106
00107 fitter->Print("Pars");
00108
00109 delete fitter;
00110 }
00111
00112