1 #include "../interface/ProfiledLikelihoodRatioTestStatExt.h"
2 #include "../interface/BestFitSigmaTestStat.h"
3 #include "../interface/CascadeMinimizer.h"
4 #include "../interface/CloseCoutSentry.h"
5 #include "../interface/utils.h"
7 #include <RooRealVar.h>
8 #include "../interface/RooMinimizerOpt.h"
9 #include <RooFitResult.h>
10 #include <RooSimultaneous.h>
11 #include <RooCategory.h>
12 #include <RooRandom.h>
13 #include <Math/MinimizerOptions.h>
14 #include <RooStats/RooStatsUtils.h>
15 #include "../interface/ProfilingTools.h"
18 #define DEBUG_FIT_STATUS
19 #ifdef DEBUG_FIT_STATUS
20 #define COUNT_ONE(x) PerfCounter::add(x);
27 #define DBG(X,Z) if (X) { Z; }
28 #define DBGV(X,Z) if (X>1) { Z; }
29 #define DBG_TestStat_params 0 // ProfiledLikelihoodRatioTestStatOpt::Evaluate; 1 = dump nlls; 2 = dump params at each eval
30 #define DBG_TestStat_NOFIT 0 // FIXME HACK: if set, don't profile the likelihood, just evaluate it
31 #define DBG_PLTestStat_ctor 0 // dump parameters in c-tor
32 #define DBG_PLTestStat_pars 0 // dump parameters in eval
33 #define DBG_PLTestStat_fit 0 // dump fit result
34 #define DBG_PLTestStat_main 1 // limited debugging (final NLLs, failed fits)
43 const RooArgSet & observables,
45 const RooArgSet *nuisances,
46 const RooArgSet & params,
52 params.snapshot(
snap_,
false);
53 ((RooRealVar*)
snap_.find(params.first()->GetName()))->setConstant(
false);
55 if (nuisances) {
nuisances_.add(*nuisances);
snap_.addClone(*nuisances,
true); }
63 RooArgSet initialState;
params_->snapshot(initialState);
69 RooRealVar *rIn = (RooRealVar *)
poi_.first();
70 RooRealVar *
r = (RooRealVar *)
params_->find(rIn->GetName());
73 double initialR = rIn->getVal();
76 r->setVal(initialR == 0 ? 0.5 : 0.5*initialR);
77 r->setConstant(
false);
79 std::cout <<
"Doing a fit for with " << r->GetName() <<
" in range [ " << r->getMin() <<
" , " << r->getMax() <<
"]" << std::endl;
80 std::cout <<
"Starting point is " << r->GetName() <<
" = " << r->getVal() << std::endl;
82 double bestFitR = r->getVal();
83 std::cout <<
"Fit result was " << r->GetName() <<
" = " << r->getVal() << std::endl;
88 if (!canKeepNLL)
nll_.reset();
110 return nll_->getVal();
bool minimize(int verbose=0, bool cascade=true)
bool createNLL(RooAbsPdf &pdf, RooAbsData &data)
BestFitSigmaTestStat(const RooArgSet &observables, RooAbsPdf &pdf, const RooArgSet *nuisances, const RooArgSet ¶ms, int verbosity=0)
std::auto_ptr< RooArgSet > params_
virtual Double_t Evaluate(RooAbsData &data, RooArgSet &nullPOI)
std::auto_ptr< RooAbsReal > nll_
char data[epos_bytes_allocation]
double minNLL(bool constrained, RooRealVar *r=0)