GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
Example12.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 "TGraph.h"
24#include "TApplication.h"
25
26#include "TGo4Fitter.h"
27#include "TGo4FitDataGraph.h"
28
29void Example12();
30
31int main(int argc, char **argv)
32{
33 TApplication theApp("Application", nullptr, nullptr);
34
35 Example12();
36
37 theApp.Run();
38
39 return 0;
40}
41
42#endif
43
44// routine to generate example graph function
45TGraph *MakeGraph()
46{
47 TGraph *gr = new TGraph(40);
48 for (Int_t i = 0; i < 40; i++) {
49 Double_t x = (i + 1.) / 40.;
50 Double_t y = 5 - 0.5 * x + x * x;
51 if ((x > 0.3) && (x < 0.7))
52 y += 10. * (1. - 25. * (x - .5) * (x - .5));
53 gr->SetPoint(i, x, y);
54 }
55 return gr;
56}
57
59{
60 // create fitter, select fit function and add standard actions list
61 TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
62
63 // add histogram to fitter, which should be fitted
64 fitter.AddGraph("data1", MakeGraph(), kTRUE);
65
66 // add polynom of 2 order for background approx
67 fitter.AddPolynomX("data1", "BackgrPol", 2);
68
69 // add polynom of 2 order for background approx
70 fitter.AddPolynomX("data1", "LinePol", 2, 123, 0.3, 0.7);
71
72 // perform all actions
73 fitter.DoActions();
74
75 // printing of fitter parameters
76 fitter.Print("Pars");
77
78 // Draw data ("-" means without full model), Background and line (has group 123)
79 fitter.Draw("#data1-, Background, Group123");
80}
int main(int argc, char **argv)
Definition Example12.cxx:31
TGraph * MakeGraph()
Definition Example12.cxx:45
void Example12()
Definition Example12.cxx:58
void DoActions(Bool_t AllowFitterChange=kFALSE, TObjArray *Actions=nullptr)
Executes actions list.
Central class of Go4Fit package.
Definition TGo4Fitter.h:38
void Print(Option_t *option="") const override
Print containment of 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.
TGo4FitDataGraph * AddGraph(const char *DataName, TGraph *gr, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Create TGo4FitDataGraph object and adds its to fitter.