00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00015
00016
00017
00018
00019
00020
00021 #include "RooRarFit/rarVersion.hh"
00022
00023 #include "Riostream.h"
00024 #include "TH1.h"
00025 #include "TH2.h"
00026 #include "TMarker.h"
00027 #include "TGraph.h"
00028 #include "TStopwatch.h"
00029 #include "TFitter.h"
00030 #include "TMinuit.h"
00031 #include "TDirectory.h"
00032 #include "RooFitCore/RooMinuit.hh"
00033 #include "RooFitCore/RooArgSet.hh"
00034 #include "RooFitCore/RooArgList.hh"
00035 #include "RooFitCore/RooAbsReal.hh"
00036 #include "RooFitCore/RooRealVar.hh"
00037 #include "RooFitCore/RooPlot.hh"
00038 #include "RooRarFit/rarMinuit.hh"
00039
00040 rarMinuit::rarMinuit(RooAbsReal& function) : RooMinuit(function)
00041 {
00042
00043 _func = &function ;
00044
00045 RooArgSet* paramSet = function.getParameters(RooArgSet()) ;
00046 RooArgList paramList(*paramSet) ;
00047 delete paramSet ;
00048
00049 _floatParamList = (RooArgList*) paramList.selectByAttrib("Constant",kFALSE) ;
00050 if (_floatParamList->getSize()>1) {
00051 _floatParamList->sort() ;
00052 }
00053 _floatParamList->setName("floatParamList") ;
00054
00055 }
00056
00057 RooPlot* rarMinuit::contour(RooRealVar& var1, RooRealVar& var2,
00058 Double_t n1, Double_t n2, Double_t n3,
00059 Double_t n4, Double_t n5, Double_t n6)
00060 {
00061
00062 Int_t index1= _floatParamList->index(&var1);
00063 if(index1 < 0) {
00064 cout << "rarMinuit::contour(" << GetName()
00065 << ") ERROR: " << var1.GetName()
00066 << " is not a floating parameter of " << _func->GetName() << endl ;
00067 return 0;
00068 }
00069
00070 Int_t index2= _floatParamList->index(&var2);
00071 if(index2 < 0) {
00072 cout << "rarMinuit::contour(" << GetName()
00073 << ") ERROR: " << var2.GetName()
00074 << " is not a floating parameter of PDF "
00075 << _func->GetName() << endl ;
00076 return 0;
00077 }
00078
00079
00080 RooPlot *frame = new RooPlot(var1, var2) ;
00081 frame->SetStats(kFALSE);
00082
00083
00084 TMarker *point= new TMarker(var1.getVal(), var2.getVal(), 8);
00085
00086
00087 Double_t errdef= gMinuit->fUp;
00088
00089 TGraph* graph1 = 0;
00090 if(n1 > 0) {
00091
00092 gMinuit->SetErrorDef(n1*n1*errdef);
00093
00094 graph1= (TGraph*)gMinuit->Contour(25, index1, index2);
00095 fixGraph(graph1);
00096 }
00097
00098 TGraph* graph2 = 0;
00099 if(n2 > 0) {
00100
00101 gMinuit->SetErrorDef(n2*n2*errdef);
00102
00103 graph2= (TGraph*)gMinuit->Contour(25, index1, index2);
00104 fixGraph(graph2,2);
00105 }
00106
00107 TGraph* graph3 = 0;
00108 if(n3 > 0) {
00109
00110 gMinuit->SetErrorDef(n3*n3*errdef);
00111
00112 graph3= (TGraph*)gMinuit->Contour(25, index1, index2);
00113 fixGraph(graph3,3);
00114 }
00115
00116 TGraph* graph4 = 0;
00117 if(n4 > 0) {
00118
00119 gMinuit->SetErrorDef(n4*n4*errdef);
00120
00121 graph4= (TGraph*)gMinuit->Contour(25, index1, index2);
00122 fixGraph(graph4,4);
00123 }
00124
00125 TGraph* graph5 = 0;
00126 if(n5 > 0) {
00127
00128 gMinuit->SetErrorDef(n5*n5*errdef);
00129
00130 graph5= (TGraph*)gMinuit->Contour(25, index1, index2);
00131 fixGraph(graph5,5);
00132 }
00133
00134 TGraph* graph6 = 0;
00135 if(n6 > 0) {
00136
00137 gMinuit->SetErrorDef(n6*n6*errdef);
00138
00139 graph6= (TGraph*)gMinuit->Contour(25, index1, index2);
00140 fixGraph(graph6,6);
00141 }
00142
00143 gMinuit->SetErrorDef(errdef);
00144
00145
00146
00147 frame->addObject(point);
00148 if (graph1) frame->addObject(graph1, "C");
00149 if (graph2) frame->addObject(graph2, "C");
00150 if (graph3) frame->addObject(graph3, "C");
00151 if (graph4) frame->addObject(graph4, "C");
00152 if (graph5) frame->addObject(graph5, "C");
00153 if (graph6) frame->addObject(graph6, "C");
00154
00155 return frame;
00156 }
00157
00159 void rarMinuit::fixGraph(TGraph *graph, Int_t lineStyle) {
00160 if (!graph) return;
00161
00162 graph->SetLineStyle(lineStyle);
00163
00164 Int_t nPoint=graph->GetN();
00165 graph->Set(nPoint+1);
00166 Double_t x, y;
00167 graph->GetPoint(0, x, y);
00168 graph->SetPoint(nPoint, x, y);
00169 return;
00170 }
00171