GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
Example1.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
20
21#ifndef __CINT__
22
23#include "TH1.h"
24#include "TFile.h"
25#include "TApplication.h"
26
27#include "TGo4Fitter.h"
28
29void Example1();
30
31int main(int argc, char **argv)
32{
33 TApplication theApp("Application", nullptr, nullptr);
34
35 Example1();
36
37 theApp.Run();
38
39 return 0;
40}
41
42#endif
43
44// routine to read histogram from examples file
45TH1D* GetHistogram(const char *HistogramName)
46{
47 TFile *f = TFile::Open("histograms.root");
48 if (!f) return nullptr;
49 TH1D *histo = nullptr;
50 f->GetObject(HistogramName, histo);
51 if (histo) histo->SetDirectory(nullptr);
52 delete f;
53 return histo;
54}
55
57{
58// create fitter, select fit function and add standard actions list
59 TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
60
61// add histogram to fitter, which should be fitted
62 fitter.AddH1("data1", GetHistogram("hDeg120_P_c"), kTRUE, 2200., 2900.);
63
64// create polynom of first order
65 fitter.AddPolynomX("data1", "Pol", 1);
66
67// create two gaussians
68 fitter.AddGauss1("data1", "Gauss1", 2553., 15.);
69 fitter.AddGauss1("data1", "Gauss2", 2672., 15.);
70
71// execute all actions
72 fitter.DoActions();
73
74// draw data, full model and two gaussains on new canvas
75 fitter.Draw("#data1,Gauss1,Gauss2");
76}
int main(int argc, char **argv)
Definition Example1.cxx:31
TH1D * GetHistogram(const char *HistogramName)
Definition Example1.cxx:45
void Example1()
Definition Example1.cxx:56
void DoActions(Bool_t AllowFitterChange=kFALSE, TObjArray *Actions=nullptr)
Executes actions list.
Central class of Go4Fit package.
Definition TGo4Fitter.h:38
TGo4FitDataHistogram * AddH1(const char *DataName, TH1 *histo, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Create TGo4FitDataHistogram object and adds its to fitter.
TGo4FitModelGauss1 * AddGauss1(const char *DataName, const char *ModelName, Double_t iPosition, Double_t iWidth, Double_t iAmpl=1., Int_t Axis=0)
Add 1-dim gaussian model to fitter.
void AddPolynomX(const char *DataName, const char *NamePrefix, Int_t MaxOrder=1, Int_t GroupIndex=0, Double_t lrange=0., Double_t rrange=0.)
Construct 1-dim polynom for specified data object for x scale.
void Draw(Option_t *option) override
Draw fitter on current canvas.