GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Example12.cxx
Go to the documentation of this file.
1 // $Id: Example12.cxx 555 2010-01-27 12:40:54Z linev $
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 für 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 
14 // Go4Fit Example N12
15 
16 
17 #ifndef __CINT__
18 
19 #include "TGraph.h"
20 #include "TApplication.h"
21 
22 #include "TGo4Fitter.h"
23 #include "TGo4FitDataGraph.h"
24 
25 void Example12();
26 
27 int main(int argc, char **argv)
28 {
29  TApplication theApp("Application", 0, 0);
30 
31  Example12();
32 
33  theApp.Run();
34 
35  return 0;
36 }
37 
38 #endif
39 
40 // routine to generate example graph function
41 TGraph* MakeGraph()
42 {
43  TGraph* gr = new TGraph(40);
44  for(Int_t i=0;i<40;i++) {
45  Double_t x = (i+1.)/40.;
46  Double_t y = 5 - 0.5*x + x*x;
47  if ((x>0.3) && (x<0.7))
48  y+= 10.*(1. - 25.*(x-.5)*(x-.5));
49  gr->SetPoint(i, x, y);
50  }
51  return gr;
52 
53 }
54 
55 void Example12()
56 {
57 // create fitter, select fit function and add standard actions list
58  TGo4Fitter fitter("Fitter", TGo4Fitter::ff_ML_Poisson, kTRUE);
59 
60 // add histogram to fitter, which should be fitted
61  fitter.AddGraph("data1", MakeGraph(), kTRUE);
62 
63 // add polynom of 2 order for background approx
64  fitter.AddPolynomX("data1", "BackgrPol", 2);
65 
66 // add polynom of 2 order for background approx
67  fitter.AddPolynomX("data1", "LinePol", 2, 123, 0.3, 0.7);
68 
69 // perform all actions
70  fitter.DoActions();
71 
72 // printing of fitter parameters
73  fitter.Print("Pars");
74 
75 // Draw data ("-" means without full model), Background and line (has group 123)
76  fitter.Draw("#data1-, Background, Group123");
77 }
virtual void Print(Option_t *option) const
Definition: TGo4Fitter.cxx:707
TGo4FitDataGraph * AddGraph(const char *DataName, TGraph *gr, Bool_t Owned=kFALSE, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:142
virtual void Draw(Option_t *option)
Definition: TGo4Fitter.cxx:983
int main(int argc, char **argv)
Definition: Example12.cxx:27
void AddPolynomX(const char *DataName, const char *NamePrefix, Int_t MaxOrder=1, Int_t GroupIndex=0, Double_t lrange=0., Double_t rrange=0.)
Definition: TGo4Fitter.cxx:225
void DoActions(Bool_t AllowFitterChange=kFALSE, TObjArray *Actions=0)
void Example12()
Definition: Example12.cxx:55
TGraph * MakeGraph()
Definition: Example12.cxx:41