58 if( fDetailedOutputEnabled && fDetailedOutput ) {
59 delete fDetailedOutput;
62 if( fDetailedOutputEnabled && !fDetailedOutput ) {
71 double initial_mu_value = 0;
73 if (firstPOI) initial_mu_value = firstPOI->
getVal();
75 if (fPrintLevel > 1) {
76 cout <<
"POIs: " << endl;
77 paramsOfInterest.
Print(
"v");
84 Bool_t reuse=(fReuseNll || fgAlwaysReuseNll) ;
87 if (!reuse || fNll==0) {
88 RooArgSet* allParams = fPdf->getParameters(data);
95 if (fPrintLevel > 0 && fLOffset) cout <<
"ProfileLikelihoodTestStat::Evaluate - Use Offset in creating NLL " << endl ;
99 if (fPrintLevel > 1) cout <<
"creating NLL " << fNll <<
" with data = " << &data << endl ;
101 if (reuse && !created) {
102 if (fPrintLevel > 1) cout <<
"reusing NLL " << fNll <<
" new data = " << &data << endl ;
103 fNll->setData(data,
kFALSE) ;
106 if (fPrintLevel > 1 && data.
numEntries() == 1) {
107 std::cout <<
"Data set used is: ";
113 RooArgSet* attachedSet = fNll->getVariables();
115 *attachedSet = paramsOfInterest;
128 double createTime = tsw.
CpuTime();
133 double fit_favored_mu = 0;
138 fNll->clearEvalErrorLog();
139 if (fPrintLevel>1) std::cout <<
"Do unconditional fit" << std::endl;
142 uncondML = result->
minNll();
143 statusD = result->
status();
149 if( fDetailedOutputEnabled ) {
151 fDetailedOutput->addOwned(*detOutput);
161 double fitTime1 = tsw.
CpuTime();
169 bool doConditionalFit = (
type != 1);
172 if (!fSigned &&
type==0 &&
173 ((fLimitType==oneSided && fit_favored_mu >= initial_mu_value) ||
174 (fLimitType==oneSidedDiscovery && fit_favored_mu <= initial_mu_value))) {
175 doConditionalFit =
false;
179 if (doConditionalFit) {
181 if (fPrintLevel>1) std::cout <<
"Do conditional fit " << std::endl;
185 *attachedSet = *snap;
203 if (allParams.
getSize() == 0 ) {
206 condML = fNll->getVal();
210 fNll->clearEvalErrorLog();
213 condML = result->
minNll();
214 statusN = result->
status();
215 if( fDetailedOutputEnabled ) {
217 fDetailedOutput->addOwned(*detOutput);
230 double fitTime2 = tsw.
CpuTime();
238 pll = fNll->getVal();
249 pll = condML-uncondML;
253 if (fPrintLevel > 0) std::cout <<
"pll is negative - setting it to zero " << std::endl;
256 if (fLimitType==oneSidedDiscovery ? (fit_favored_mu < initial_mu_value)
257 : (fit_favored_mu > initial_mu_value))
262 if (fPrintLevel > 0) {
263 std::cout <<
"EvaluateProfileLikelihood - ";
265 std::cout <<
"mu hat = " << fit_favored_mu <<
", uncond ML = " << uncondML;
267 std::cout <<
", cond ML = " << condML;
269 std::cout <<
" pll = " << pll;
270 std::cout <<
" time (create/fit1/2) " << createTime <<
" , " << fitTime1 <<
" , " << fitTime2
276 *attachedSet = *origAttachedSet;
279 delete origAttachedSet;
289 if(statusN!=0 || statusD!=0) {
307 int level = (fPrintLevel == 0) ? -1 : fPrintLevel -2;
312 TString minimizer = fMinimizer;
314 if (algorithm ==
"Migrad") algorithm =
"Minimize";
316 for (
int tries = 1, maxtries = 4; tries <= maxtries; ++tries) {
317 status = minim.
minimize(minimizer,algorithm);
318 if (status%1000 == 0) {
320 }
else if (tries < maxtries) {
321 cout <<
" ----> Doing a re-scan first" << endl;
324 if (fStrategy == 0 ) {
325 cout <<
" ----> trying with strategy = 1" << endl;;
332 cout <<
" ----> trying with improve" << endl;;
333 minimizer =
"Minuit";
334 algorithm =
"migradimproved";
static const std::string & DefaultMinimizerAlgo()
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
RooAbsArg * first() const
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
RooLinkedListIter iterator(Bool_t dir=kIterForward) const
TIterator-style iteration over contained elements.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
virtual Int_t numEntries() const
void setConstant(Bool_t value=kTRUE)
static void setHideOffset(Bool_t flag)
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
A wrapper around TIterator derivatives.
TObject * Next() override
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
void setEvalErrorWall(Bool_t flag)
RooFitResult * save(const char *name=0, const char *title=0)
Save and return a RooFitResult snaphot of current minimizer status.
Int_t minimize(const char *type, const char *alg=0)
Minimise the function passed in the constructor.
void setEps(Double_t eps)
Change MINUIT epsilon.
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
RooFit::MsgLevel globalKillBelow() const
RooRealVar represents a variable that can be changed from the outside.
static RooArgSet * GetAsArgSet(RooFitResult *result, TString prefix="", bool withErrorsAndPulls=false)
static function to translate the given fit result to a RooArgSet in a generic way.
static Bool_t fgAlwaysReuseNll
virtual Double_t EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet ¶msOfInterest)
internal function to evaluate test statistics can do depending on type:
static void SetAlwaysReuseNLL(Bool_t flag)
RooFitResult * GetMinNLL()
find minimum of NLL using RooMinimizer
virtual const char * GetName() const
Returns name of object.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
void Stop()
Stop the stopwatch.
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg GlobalObservables(const RooArgSet &globs)
RooCmdArg CloneData(Bool_t flag)
RooCmdArg ConditionalObservables(const RooArgSet &set)
RooCmdArg Offset(Bool_t flag=kTRUE)
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
void RemoveConstantParameters(RooArgSet *set)
RooStatsConfig & GetGlobalRooStatsConfig()
Retrieve the config object which can be used to set flags for things like offsetting the likelihood o...
void PrintListContent(const RooArgList &l, std::ostream &os=std::cout)
Double_t SignalingNaN()
Returns a signaling NaN as defined by IEEE 754](http://en.wikipedia.org/wiki/NaN#Signaling_NaN)