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

/Go4FitExample/Example10.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 N10
00017    This is examples of using histogram as model component for another histogram
00018 */
00019 
00020 #ifndef __CINT__
00021 
00022 #include "TH1.h"
00023 #include "TFile.h"
00024 #include "TCanvas.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/TGo4FitModelGauss1.h"
00032 #include "../Go4Fit/TGo4FitModelFromData.h"
00033 
00034 void Example10();
00035 
00036 int main(int argc, char **argv)
00037 {
00038    TApplication theApp("Application", 0, 0);
00039 
00040    Example10();
00041 
00042    theApp.Run();
00043 
00044    return 0;
00045 }
00046 
00047 #endif
00048 
00049 // routine to read histogram from examples file
00050 TH1D* GetHistogram(const char* HistogramName) {
00051    TFile f1("histograms.root");
00052    TH1D* histo = (TH1D*) f1.Get(HistogramName);
00053    histo->SetDirectory(0);
00054    return histo;
00055 }
00056 
00057 void Example10() {
00058 // create fitter and select function to fit
00059    TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
00060 
00061    TH1D* histo1 = GetHistogram("hDeg120_P_c");            // get histogram from file
00062    TH1D* histo2 = GetHistogram("hDeg120_CND");            // get histogram from file
00063 
00064 // add histogram to fitter, which should be fitted
00065    fitter.AddH1("data2", histo2, kTRUE, 2200., 2900.);
00066 
00067 // create polynom of first order
00068    fitter.AddPolynomX("data2", "Pol", 1);
00069 
00070 // add first histogram as component of second histogram
00071    fitter.AddModel("data2", new TGo4FitModelFromData("Model1",histo1,kTRUE) );
00072 
00073 // create two gaussians
00074    fitter.AddGauss1("data2", "Gauss3", 2597., 14.);
00075    fitter.AddGauss1("data2", "Gauss4", 2717., 14.);
00076 
00077 // perform all actions
00078    fitter.DoActions();
00079 
00080    // call fitter Draw method with options #data1,Gauss1,Gauss2
00081    fitter.Draw("#data2,Model1,Gauss3,Gauss4");
00082    fitter.Print("Pars");
00083 }
00084 
00085 //----------------------------END OF GO4 SOURCE FILE ---------------------

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