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

/Go4FitExample/Example11.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 N11
00017 
00018 
00019 #ifndef __CINT__
00020 
00021 #include "TH1.h"
00022 #include "TFile.h"
00023 #include "TApplication.h"
00024 
00025 #include "../Go4Fit/TGo4Fitter.h"
00026 #include "../Go4Fit/TGo4FitPeakFinder.h"
00027 
00028 void Example11();
00029 
00030 int main(int argc, char **argv) {
00031 
00032    TApplication theApp("Application", 0, 0);
00033 
00034    Example11();
00035 
00036    theApp.Run();
00037 
00038    return 0;
00039 }
00040 
00041 #endif
00042 
00043 // routine to read histogram from examples file
00044 TH1D* GetHistogram(const char* HistogramName) {
00045    TFile f1("histograms.root");
00046    TH1D* histo = (TH1D*) f1.Get(HistogramName);
00047    histo->SetDirectory(0);
00048    return histo;
00049 }
00050 
00051 void Example11() {
00052 // create fitter, select fit function and not add standard actions list
00053    TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
00054 
00055 // add histogram to fitter, which should be fitted
00056    fitter.AddH1("data1", GetHistogram("hDeg120_P_c"), kTRUE, 2200., 2900.);
00057 
00058 
00059 // Add peak finder for data1, which not remove previous models and will use 1-order
00060 // polynom for background
00061    TGo4FitPeakFinder* finder = new TGo4FitPeakFinder("Finder", "data1", kFALSE, 1);
00062 
00063 // setup parameters for first peak finder.
00064 // Here first - amplitude threshold relative to amplitude maximum,
00065 // and minimum and maximum line width
00066    finder->SetupForFirst(.3, 5., 30.);
00067 
00068 // add peak finder action at the beginning
00069    fitter.AddActionAt(finder, 0);
00070 
00071 // perform all actions
00072 // kTRUE means, that action is able to add/delete components to fitter
00073    fitter.DoActions(kTRUE);
00074 
00075 // print models parameters in lines sorting
00076    fitter.Print("Lines");
00077 
00078 // Draw data and model
00079    fitter.Draw("#data1");
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