00001 //------------------------------------------------------------- 00002 // Go4 Release Package v3.04-01 (build 30401) 00003 // 28-November-2008 00004 //--------------------------------------------------------------- 00005 // The GSI Online Offline Object Oriented (Go4) Project 00006 // Experiment Data Processing at EE department, GSI 00007 //--------------------------------------------------------------- 00008 // 00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI 00010 // Planckstr. 1, 64291 Darmstadt, Germany 00011 //Contact: http://go4.gsi.de 00012 //---------------------------------------------------------------- 00013 //This software can be used under the license agreements as stated 00014 //in Go4License.txt file which is part of the distribution. 00015 //---------------------------------------------------------------- 00016 /* Go4Fit Examples 00017 This is small examples how to fit part of histogram 00018 with two gaussian and polynom function 00019 */ 00020 00021 #ifndef __CINT__ 00022 00023 #include "TH1.h" 00024 #include "TFile.h" 00025 #include "TApplication.h" 00026 00027 #include "../Go4Fit/TGo4Fitter.h" 00028 00029 void Example1(); 00030 00031 int main(int argc, char **argv) 00032 { 00033 TApplication theApp("Application", 0, 0); 00034 00035 Example1(); 00036 00037 theApp.Run(); 00038 00039 return 0; 00040 } 00041 00042 #endif 00043 00044 // routine to read histogram from examples file 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 Example1() 00053 { 00054 // create fitter, select fit function and add standard actions list 00055 TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE); 00056 00057 // add histogram to fitter, which should be fitted 00058 fitter.AddH1("data1", GetHistogram("hDeg120_P_c"), kTRUE, 2200., 2900.); 00059 00060 // create polynom of first order 00061 fitter.AddPolynomX("data1", "Pol", 1); 00062 00063 // create two gaussians 00064 fitter.AddGauss1("data1", "Gauss1", 2553., 15.); 00065 fitter.AddGauss1("data1", "Gauss2", 2672., 15.); 00066 00067 // execute all actions 00068 fitter.DoActions(); 00069 00070 // draw data, full model and two gaussains on new canvas 00071 fitter.Draw("#data1,Gauss1,Gauss2"); 00072 } 00073 00074 //----------------------------END OF GO4 SOURCE FILE ---------------------