Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4FitExample/Example4.cxx

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 Example N4
00017    Same as small Example1, but for gaussian modelling new model component was constructed
00018    First way is to define user function and assign it to in TGo4FitModelFunction class
00019    In TModelTemplate class UserFunction method was redefined
00020 */
00021 
00022 #ifndef __CINT__
00023 
00024 #include "TH1.h"
00025 #include "TFile.h"
00026 #include "TApplication.h"
00027 
00028 #include "../Go4Fit/TGo4Fitter.h"
00029 #include "TModelTemplate.h"
00030 
00031 void Example4();
00032 
00033 int main(int argc, char **argv)
00034 {
00035    TApplication theApp("Application", 0, 0);
00036 
00037    Example4();
00038 
00039    theApp.Run();
00040 
00041    return 0;
00042 }
00043 
00044 #endif
00045 
00046 // routine to read histogram from examples file
00047 TH1D* GetHistogram(const char* HistogramName) {
00048    TFile f1("histograms.root");
00049    TH1D* histo = (TH1D*) f1.Get(HistogramName);
00050    histo->SetDirectory(0);
00051    return histo;
00052 }
00053 
00054 void Example4() {
00055 // create fitter, select fit function and add standard actions
00056   TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
00057 
00058 // add histogram to fitter, which should be fitted
00059    fitter.AddH1("data1", GetHistogram("hDeg120_P_c"), kTRUE, 2200., 2900.);
00060 
00061 // create polynom of first order
00062    fitter.AddPolynomX( "data1", "Pol", 1);
00063 
00064 // create model components, which uses new model class to calculate gaussian shape
00065    fitter.AddModel( "data1", new TModelTemplate("Gauss1",2,kTRUE) );
00066    fitter.AddModel( "data1", new TModelTemplate("Gauss2",2,kTRUE) );
00067 
00068 // set initial values of user model parameters
00069    fitter.SetParValue("Gauss1.Par0",2553.);
00070    fitter.SetParValue("Gauss1.Par1",15.);
00071    fitter.SetParValue("Gauss2.Par0",2672.);
00072    fitter.SetParValue("Gauss2.Par1",15.);
00073 
00074 // perform all actions
00075    fitter.DoActions();
00076 
00077 // add output actions
00078    fitter.Draw ("#data1,Gauss1,Gauss2");
00079    fitter.Print("Pars");
00080 }
00081 
00082 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:55:57 2005 for Go4-v2.10-5 by doxygen1.2.15