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();
146 if (firstPOI) fit_favored_mu = attachedSet->getRealValue(firstPOI->
GetName()) ;
149 if( fDetailedOutputEnabled ) {
150 detOutput = DetailedOutputAggregator::GetAsArgSet(result,
"fitUncond_", fDetailedOutputWithErrorsAndPulls);
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 ) {
216 detOutput = DetailedOutputAggregator::GetAsArgSet(result,
"fitCond_", fDetailedOutputWithErrorsAndPulls);
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) {
305 int level = (fPrintLevel == 0) ? -1 : fPrintLevel -2;
310 TString minimizer = fMinimizer;
312 if (algorithm ==
"Migrad") algorithm =
"Minimize";
314 for (
int tries = 1, maxtries = 4; tries <= maxtries; ++tries) {
315 status = minim.
minimize(minimizer,algorithm);
316 if (status%1000 == 0) {
318 }
else if (tries < maxtries) {
319 cout <<
" ----> Doing a re-scan first" << endl;
322 if (fStrategy == 0 ) {
323 cout <<
" ----> trying with strategy = 1" << endl;;
330 cout <<
" ----> trying with improve" << endl;;
331 minimizer =
"Minuit";
332 algorithm =
"migradimproved";
virtual const char * GetName() const
Returns name of object.
RooCmdArg Offset(Bool_t flag=kTRUE)
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void optimizeConst(Int_t flag)
If flag is true, perform constant term optimization on function being minimized.
virtual const RooArgSet * get() const
RooCmdArg CloneData(Bool_t flag)
Double_t getVal(const RooArgSet *set=0) const
static Bool_t fgAlwaysReuseNll
RooFit::MsgLevel globalKillBelow() const
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
virtual Double_t EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet ¶msOfInterest)
internal function to evaluate test statistics can do depending on type:
static RooMsgService & instance()
Return reference to singleton instance.
static void setHideOffset(Bool_t flag)
void setEps(Double_t eps)
Change MINUIT epsilon.
void setStrategy(Int_t strat)
Change MINUIT strategy to istrat.
void Stop()
Stop the stopwatch.
static void SetAlwaysReuseNLL(Bool_t flag)
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
RooRealVar represents a fundamental (non-derived) real valued object.
RooCmdArg GlobalObservables(const RooArgSet &globs)
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
RooAbsArg * first() const
void setConstant(Bool_t value=kTRUE)
RooFitResult * save(const char *name=0, const char *title=0)
Save and return a RooFitResult snaphot of current minimizer status.
void PrintListContent(const RooArgList &l, std::ostream &os=std::cout)
void setGlobalKillBelow(RooFit::MsgLevel level)
RooAbsData is the common abstract base class for binned and unbinned datasets.
static const std::string & DefaultMinimizerAlgo()
Int_t minimize(const char *type, const char *alg=0)
Int_t setPrintLevel(Int_t newLevel)
Change the MINUIT internal printing level.
void RemoveConstantParameters(RooArgSet *set)
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
RooLinkedListIter iterator(Bool_t dir=kIterForward) const
RooFitResult * GetMinNLL()
find minimum of NLL using RooMinimizer
RooCmdArg ConditionalObservables(const RooArgSet &set)
RooLinkedListIter is the TIterator implementation for RooLinkedList.
RooCmdArg Constrain(const RooArgSet ¶ms)
virtual Int_t numEntries() const