38 if( fDetailedOutputEnabled && fDetailedOutput ) {
39 delete fDetailedOutput;
42 if( fDetailedOutputEnabled && !fDetailedOutput ) {
51 double initial_mu_value = 0;
53 if (firstPOI) initial_mu_value = firstPOI->
getVal();
55 if (fPrintLevel > 1) {
56 cout <<
"POIs: " << endl;
57 paramsOfInterest.
Print(
"v");
64 Bool_t reuse=(fReuseNll || fgAlwaysReuseNll) ;
67 if (!reuse || fNll==0) {
68 RooArgSet* allParams = fPdf->getParameters(data);
74 if (fPrintLevel > 0 && fLOffset) cout <<
"ProfileLikelihoodTestStat::Evaluate - Use Offset in creating NLL " << endl ;
78 if (fPrintLevel > 1) cout <<
"creating NLL " << fNll <<
" with data = " << &data << endl ;
80 if (reuse && !created) {
81 if (fPrintLevel > 1) cout <<
"reusing NLL " << fNll <<
" new data = " << &data << endl ;
82 fNll->setData(data,
kFALSE) ;
85 if (fPrintLevel > 1 && data.
numEntries() == 1) {
86 std::cout <<
"Data set used is: ";
92 RooArgSet* attachedSet = fNll->getVariables();
94 *attachedSet = paramsOfInterest;
107 double createTime = tsw.
CpuTime();
112 double fit_favored_mu = 0;
117 fNll->clearEvalErrorLog();
118 if (fPrintLevel>1) std::cout <<
"Do unconditional fit" << std::endl;
121 uncondML = result->
minNll();
122 statusD = result->
status();
128 if( fDetailedOutputEnabled ) {
129 detOutput = DetailedOutputAggregator::GetAsArgSet(result,
"fitUncond_", fDetailedOutputWithErrorsAndPulls);
130 fDetailedOutput->addOwned(*detOutput);
140 double fitTime1 = tsw.
CpuTime();
148 bool doConditionalFit = (type != 1);
151 if (!fSigned && type==0 &&
152 ((fLimitType==oneSided && fit_favored_mu >= initial_mu_value) ||
153 (fLimitType==oneSidedDiscovery && fit_favored_mu <= initial_mu_value))) {
154 doConditionalFit =
false;
158 if (doConditionalFit) {
160 if (fPrintLevel>1) std::cout <<
"Do conditional fit " << std::endl;
164 *attachedSet = *snap;
182 if (allParams.
getSize() == 0 ) {
185 condML = fNll->getVal();
189 fNll->clearEvalErrorLog();
192 condML = result->
minNll();
193 statusN = result->
status();
194 if( fDetailedOutputEnabled ) {
195 detOutput = DetailedOutputAggregator::GetAsArgSet(result,
"fitCond_", fDetailedOutputWithErrorsAndPulls);
196 fDetailedOutput->addOwned(*detOutput);
209 double fitTime2 = tsw.
CpuTime();
217 pll = fNll->getVal();
228 pll = condML-uncondML;
232 if (fPrintLevel > 0) std::cout <<
"pll is negative - setting it to zero " << std::endl;
235 if (fLimitType==oneSidedDiscovery ? (fit_favored_mu < initial_mu_value)
236 : (fit_favored_mu > initial_mu_value))
241 if (fPrintLevel > 0) {
242 std::cout <<
"EvaluateProfileLikelihood - ";
244 std::cout <<
"mu hat = " << fit_favored_mu <<
", uncond ML = " << uncondML;
246 std::cout <<
", cond ML = " << condML;
248 std::cout <<
" pll = " << pll;
249 std::cout <<
" time (create/fit1/2) " << createTime <<
" , " << fitTime1 <<
" , " << fitTime2
255 *attachedSet = *origAttachedSet;
258 delete origAttachedSet;
268 if(statusN!=0 || statusD!=0) {
282 int level = (fPrintLevel == 0) ? -1 : fPrintLevel -2;
287 TString minimizer = fMinimizer;
289 if (algorithm ==
"Migrad") algorithm =
"Minimize";
291 for (
int tries = 1, maxtries = 4; tries <= maxtries; ++tries) {
292 status = minim.
minimize(minimizer,algorithm);
293 if (status%1000 == 0) {
295 }
else if (tries < maxtries) {
296 cout <<
" ----> Doing a re-scan first" << endl;
299 if (fStrategy == 0 ) {
300 cout <<
" ----> trying with strategy = 1" << endl;;
307 cout <<
" ----> trying with improve" << endl;;
308 minimizer =
"Minuit";
309 algorithm =
"migradimproved";
RooCmdArg Offset(Bool_t flag=kTRUE)
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
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.
RooCmdArg CloneData(Bool_t flag)
static Bool_t fgAlwaysReuseNll
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)
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.
RooAbsArg * first() const
void Stop()
Stop the stopwatch.
static void SetAlwaysReuseNLL(Bool_t flag)
Double_t getVal(const RooArgSet *set=0) const
virtual const RooArgSet * get() const
RooFit::MsgLevel globalKillBelow() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
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.
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
virtual Int_t numEntries() const
void PrintListContent(const RooArgList &l, std::ostream &os=std::cout)
void setGlobalKillBelow(RooFit::MsgLevel level)
virtual const char * GetName() const
Returns name of object.
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)
RooFitResult * GetMinNLL()
RooLinkedListIter iterator(Bool_t dir=kIterForward) const
RooCmdArg ConditionalObservables(const RooArgSet &set)
RooCmdArg Constrain(const RooArgSet ¶ms)
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.