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);
94 if (fPrintLevel > 0 && fLOffset) cout <<
"ProfileLikelihoodTestStat::Evaluate - Use Offset in creating NLL " << endl ;
98 if (fPrintLevel > 1) cout <<
"creating NLL " << fNll <<
" with data = " << &data << endl ;
100 if (reuse && !created) {
101 if (fPrintLevel > 1) cout <<
"reusing NLL " << fNll <<
" new data = " << &data << endl ;
102 fNll->setData(data,
kFALSE) ;
105 if (fPrintLevel > 1 && data.
numEntries() == 1) {
106 std::cout <<
"Data set used is: ";
112 RooArgSet* attachedSet = fNll->getVariables();
114 *attachedSet = paramsOfInterest;
127 double createTime = tsw.
CpuTime();
132 double fit_favored_mu = 0;
137 fNll->clearEvalErrorLog();
138 if (fPrintLevel>1) std::cout <<
"Do unconditional fit" << std::endl;
141 uncondML = result->
minNll();
142 statusD = result->
status();
145 if (firstPOI) fit_favored_mu = attachedSet->getRealValue(firstPOI->
GetName()) ;
148 if( fDetailedOutputEnabled ) {
149 detOutput = DetailedOutputAggregator::GetAsArgSet(result,
"fitUncond_", fDetailedOutputWithErrorsAndPulls);
150 fDetailedOutput->addOwned(*detOutput);
160 double fitTime1 = tsw.
CpuTime();
168 bool doConditionalFit = (type != 1);
171 if (!fSigned && type==0 &&
172 ((fLimitType==oneSided && fit_favored_mu >= initial_mu_value) ||
173 (fLimitType==oneSidedDiscovery && fit_favored_mu <= initial_mu_value))) {
174 doConditionalFit =
false;
178 if (doConditionalFit) {
180 if (fPrintLevel>1) std::cout <<
"Do conditional fit " << std::endl;
184 *attachedSet = *snap;
202 if (allParams.
getSize() == 0 ) {
205 condML = fNll->getVal();
209 fNll->clearEvalErrorLog();
212 condML = result->
minNll();
213 statusN = result->
status();
214 if( fDetailedOutputEnabled ) {
215 detOutput = DetailedOutputAggregator::GetAsArgSet(result,
"fitCond_", fDetailedOutputWithErrorsAndPulls);
216 fDetailedOutput->addOwned(*detOutput);
229 double fitTime2 = tsw.
CpuTime();
237 pll = fNll->getVal();
248 pll = condML-uncondML;
252 if (fPrintLevel > 0) std::cout <<
"pll is negative - setting it to zero " << std::endl;
255 if (fLimitType==oneSidedDiscovery ? (fit_favored_mu < initial_mu_value)
256 : (fit_favored_mu > initial_mu_value))
261 if (fPrintLevel > 0) {
262 std::cout <<
"EvaluateProfileLikelihood - ";
264 std::cout <<
"mu hat = " << fit_favored_mu <<
", uncond ML = " << uncondML;
266 std::cout <<
", cond ML = " << condML;
268 std::cout <<
" pll = " << pll;
269 std::cout <<
" time (create/fit1/2) " << createTime <<
" , " << fitTime1 <<
" , " << fitTime2
275 *attachedSet = *origAttachedSet;
278 delete origAttachedSet;
288 if(statusN!=0 || statusD!=0) {
304 int level = (fPrintLevel == 0) ? -1 : fPrintLevel -2;
309 TString minimizer = fMinimizer;
311 if (algorithm ==
"Migrad") algorithm =
"Minimize";
313 for (
int tries = 1, maxtries = 4; tries <= maxtries; ++tries) {
314 status = minim.
minimize(minimizer,algorithm);
315 if (status%1000 == 0) {
317 }
else if (tries < maxtries) {
318 cout <<
" ----> Doing a re-scan first" << endl;
321 if (fStrategy == 0 ) {
322 cout <<
" ----> trying with strategy = 1" << endl;;
329 cout <<
" ----> trying with improve" << endl;;
330 minimizer =
"Minuit";
331 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.
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