57 if( fDetailedOutputEnabled && fDetailedOutput ) {
58 delete fDetailedOutput;
59 fDetailedOutput =
nullptr;
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==
nullptr) {
87 std::unique_ptr<RooArgSet> allParams{fPdf->getParameters(
data)};
94 if (fPrintLevel > 0 && fLOffset) cout <<
"ProfileLikelihoodTestStat::Evaluate - Use Offset in creating NLL " << endl ;
97 if (fPrintLevel > 1) cout <<
"creating NLL " << &*fNll <<
" with data = " << &
data << endl ;
99 if (reuse && !created) {
100 if (fPrintLevel > 1) cout <<
"reusing NLL " << &*fNll <<
" new data = " << &
data << endl ;
101 fNll->setData(
data,
false) ;
104 if (fPrintLevel > 1 &&
data.numEntries() == 1) {
105 std::cout <<
"Data set used is: ";
111 std::unique_ptr<RooArgSet> attachedSet{fNll->getVariables()};
113 attachedSet->assign(paramsOfInterest);
126 double createTime = tsw.
CpuTime();
131 double fit_favored_mu = 0;
136 fNll->clearEvalErrorLog();
137 if (fPrintLevel>1) std::cout <<
"Do unconditional fit" << std::endl;
138 std::unique_ptr<RooFitResult>
result{GetMinNLL()};
140 uncondML =
result->minNll();
141 statusD =
result->status();
144 if (firstPOI) fit_favored_mu = attachedSet->getRealValue(firstPOI->
GetName()) ;
147 if( fDetailedOutputEnabled ) {
149 fDetailedOutput->addOwned(*detOutput);
158 double fitTime1 = tsw.
CpuTime();
166 bool doConditionalFit = (
type != 1);
169 if (!fSigned &&
type==0 &&
170 ((fLimitType==oneSided && fit_favored_mu >= initial_mu_value) ||
171 (fLimitType==oneSidedDiscovery && fit_favored_mu <= initial_mu_value))) {
172 doConditionalFit =
false;
176 if (doConditionalFit) {
178 if (fPrintLevel>1) std::cout <<
"Do conditional fit " << std::endl;
182 attachedSet->assign(*snap);
186 for (
auto *tmpPar : paramsOfInterest) {
198 if (allParams.
empty() ) {
201 condML = fNll->getVal();
205 fNll->clearEvalErrorLog();
206 std::unique_ptr<RooFitResult>
result{GetMinNLL()};
208 condML =
result->minNll();
209 statusN =
result->status();
210 if( fDetailedOutputEnabled ) {
212 fDetailedOutput->addOwned(*detOutput);
224 double fitTime2 = tsw.
CpuTime();
232 pll = fNll->getVal();
243 pll = condML-uncondML;
247 if (fPrintLevel > 0) std::cout <<
"pll is negative - setting it to zero " << std::endl;
250 if (fLimitType==oneSidedDiscovery ? (fit_favored_mu < initial_mu_value)
251 : (fit_favored_mu > initial_mu_value))
256 if (fPrintLevel > 0) {
257 std::cout <<
"EvaluateProfileLikelihood - ";
259 std::cout <<
"mu hat = " << fit_favored_mu <<
", uncond ML = " << uncondML;
261 std::cout <<
", cond ML = " << condML;
263 std::cout <<
" pll = " << pll;
264 std::cout <<
" time (create/fit1/2) " << createTime <<
" , " << fitTime1 <<
" , " << fitTime2
270 attachedSet->assign(*origAttachedSet);
272 delete origAttachedSet;
281 if(statusN!=0 || statusD!=0) {
299 int level = (fPrintLevel == 0) ? -1 : fPrintLevel -2;
304 TString minimizer = fMinimizer;
306 if (algorithm ==
"Migrad") algorithm =
"Minimize";
308 for (
int tries = 1, maxtries = 4; tries <= maxtries; ++tries) {
309 status = minim.
minimize(minimizer,algorithm);
310 if (status%1000 == 0) {
312 }
else if (tries < maxtries) {
313 cout <<
" ----> Doing a re-scan first" << endl;
316 if (fStrategy == 0 ) {
317 cout <<
" ----> trying with strategy = 1" << endl;;
324 cout <<
" ----> trying with improve" << endl;;
325 minimizer =
"Minuit";
326 algorithm =
"migradimproved";
332 return std::unique_ptr<RooFitResult>{minim.
save()};
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()
RooAbsArg * first() const
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
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.
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.
RooFit::OwningPtr< 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 istrat)
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...
std::unique_ptr< 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).