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