00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __CINT__
00014 #include "RooGlobalFunc.h"
00015 #endif
00016 #include "RooRealVar.h"
00017 #include "RooDataSet.h"
00018 #include "RooGaussian.h"
00019 #include "RooConstVar.h"
00020 #include "RooPolynomial.h"
00021 #include "RooAddPdf.h"
00022 #include "TCanvas.h"
00023 #include "TAxis.h"
00024 #include "RooPlot.h"
00025 using namespace RooFit ;
00026
00027
00028 void rf505_asciicfg()
00029 {
00030
00031
00032
00033
00034 RooRealVar x("x","x",-10,10) ;
00035 RooRealVar m("m","m",0,-10,10) ;
00036 RooRealVar s("s","s",1,-10,10) ;
00037 RooGaussian gauss("g","g",x,m,s) ;
00038
00039
00040 RooRealVar p0("p0","p0",0.01,0.,1.) ;
00041 RooPolynomial poly("p","p",x,p0) ;
00042
00043
00044 RooRealVar f("f","f",0.5,0.,1.) ;
00045 RooAddPdf model("model","model",RooArgSet(gauss,poly),f) ;
00046
00047
00048
00049
00050
00051
00052 RooDataSet* d = model.generate(x,1000) ;
00053 model.fitTo(*d) ;
00054
00055
00056
00057
00058
00059
00060 RooArgSet* params = model.getParameters(x) ;
00061
00062
00063 params->writeToFile("rf505_asciicfg_example.txt") ;
00064
00065
00066
00067
00068
00069
00070
00071 params->readFromFile("rf505_asciicfg_example.txt") ;
00072 params->Print("v") ;
00073
00074
00075 params->readFromFile("rf505_asciicfg.txt",0,"Section2") ;
00076 params->Print("v") ;
00077
00078
00079
00080 params->readFromFile("rf505_asciicfg.txt","READ","Section3") ;
00081
00082
00083 cout << "The following parameters of the were _not_ read from Section3: "
00084 << (*params->selectByAttrib("READ",kFALSE)) << endl ;
00085
00086
00087
00088
00089
00090 params->readFromFile("rf505_asciicfg.txt",0,"Section4") ;
00091 params->Print("v") ;
00092
00093
00094
00095 }