57 if( fDetailedOutputEnabled && fDetailedOutput ) {
58 delete fDetailedOutput;
61 if( fDetailedOutputEnabled && !fDetailedOutput ) {
70 double initial_mu_value = 0;
72 if (firstPOI) initial_mu_value = firstPOI->
getVal();
74 if (fPrintLevel > 1) {
75 cout <<
"POIs: " << endl;
76 paramsOfInterest.
Print(
"v");
83 bool reuse=(fReuseNll || fgAlwaysReuseNll) ;
86 if (!reuse || fNll==0) {
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,
false) ;
105 if (fPrintLevel > 1 &&
data.numEntries() == 1) {
106 std::cout <<
"Data set used is: ";
112 RooArgSet* attachedSet = fNll->getVariables();
114 attachedSet->
assign(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();
148 if( fDetailedOutputEnabled ) {
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->
assign(*snap);
188 for (
auto *tmpPar : paramsOfInterest) {
200 if (allParams.
empty() ) {
203 condML = fNll->getVal();
207 fNll->clearEvalErrorLog();
210 condML =
result->minNll();
211 statusN =
result->status();
212 if( fDetailedOutputEnabled ) {
214 fDetailedOutput->addOwned(*detOutput);
227 double fitTime2 = tsw.
CpuTime();
235 pll = fNll->getVal();
246 pll = condML-uncondML;
250 if (fPrintLevel > 0) std::cout <<
"pll is negative - setting it to zero " << std::endl;
253 if (fLimitType==oneSidedDiscovery ? (fit_favored_mu < initial_mu_value)
254 : (fit_favored_mu > initial_mu_value))
259 if (fPrintLevel > 0) {
260 std::cout <<
"EvaluateProfileLikelihood - ";
262 std::cout <<
"mu hat = " << fit_favored_mu <<
", uncond ML = " << uncondML;
264 std::cout <<
", cond ML = " << condML;
266 std::cout <<
" pll = " << pll;
267 std::cout <<
" time (create/fit1/2) " << createTime <<
" , " << fitTime1 <<
" , " << fitTime2
273 attachedSet->
assign(*origAttachedSet);
276 delete origAttachedSet;
286 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";
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
static const std::string & DefaultMinimizerAlgo()
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
RooAbsArg * first() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
RooAbsData is the common abstract base class for binned and unbinned datasets.
void setConstant(bool value=true)
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
static void setHideOffset(bool flag)
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.
RooMinimizer is a wrapper class around ROOT::Fit:Fitter that provides a seamless interface between th...
void optimizeConst(int flag)
If flag is true, perform constant term optimization on function being minimized.
RooFitResult * save(const char *name=nullptr, const char *title=nullptr)
Save and return a RooFitResult snapshot of current minimizer status.
void setEvalErrorWall(bool flag)
void setEps(double eps)
Change MINUIT epsilon.
void setPrintLevel(int newLevel)
Change the MINUIT internal printing level.
int minimize(const char *type, const char *alg=nullptr)
Minimise the function passed in the constructor.
void setStrategy(int 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)
Translate the given fit result to a RooArgSet in a generic way.
static void SetAlwaysReuseNLL(bool flag)
static bool fgAlwaysReuseNll
virtual double EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet ¶msOfInterest)
evaluate the profile likelihood ratio (type = 0) or the minimum of likelihood (type=1) or the conditi...
RooFitResult * GetMinNLL()
find minimum of NLL using RooMinimizer
const char * GetName() const override
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 Offset(std::string const &mode)
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg GlobalObservables(Args_t &&... argsOrArgSet)
RooCmdArg CloneData(bool flag)
RooCmdArg ConditionalObservables(Args_t &&... argsOrArgSet)
Create a RooCmdArg to declare conditional observables.
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)
useful function to print in one line the content of a set with their values
Double_t SignalingNaN()
Returns a signaling NaN as defined by IEEE 754](http://en.wikipedia.org/wiki/NaN#Signaling_NaN).