Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Example5.cxx

Go to the documentation of this file.
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 Example N5
00017    This is example how to fit one histogram and then apply fitter for another histogram
00018 */
00019 
00020 #ifndef __CINT__
00021 
00022 #include "TH1.h"
00023 #include "TFile.h"
00024 #include "TApplication.h"
00025 
00026 #include "../Go4Fit/TGo4FitMinuit.h"
00027 #include "../Go4Fit/TGo4Fitter.h"
00028 #include "../Go4Fit/TGo4FitDataHistogram.h"
00029 
00030 void Example5();
00031 
00032 int main(int argc, char **argv)
00033 {
00034    TApplication theApp("Application", 0, 0);
00035 
00036    Example5();
00037 
00038    theApp.Run();
00039 
00040    return 0;
00041 }
00042 
00043 #endif
00044 
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 Example5() {
00055 // create fitter, select fit function and add standard actions list
00056    TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
00057 
00058 // add histogram to fitter, which should be fitted
00059    TGo4FitDataHistogram *data = 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 two gaussians
00065    fitter.AddGauss1( "data1", "Gauss1",2553.,15.);
00066    fitter.AddGauss1( "data1", "Gauss2",2672.,15.);
00067 
00068 // perform all actions
00069    fitter.DoActions();
00070 
00071 // Draw results
00072    fitter.Draw("#data1,Gauss1,Gauss2");
00073 
00074 
00075 // Up to here same as Example1
00076 // Now we modify fitter and data to fit
00077 
00078 // add two mode components (peaks) to fitter
00079    fitter.AddGauss1( "data1", "Gauss3", 2597., 14.);
00080    fitter.AddGauss1( "data1", "Gauss4", 2717., 14.);
00081 
00082 // provide new histogram to data object
00083    data->SetHistogram(GetHistogram("hDeg120_CND"),kTRUE);
00084 
00085 // perform all actions
00086    fitter.DoActions();
00087 
00088 // remove output actions and add new
00089    fitter.Draw("#data1,Gauss1,Gauss2,Gauss3,Gauss4");
00090    fitter.Print("Pars");
00091 }
00092 
00093 
00094 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:13 2008 for Go4-v3.04-1 by  doxygen 1.4.2