128 if (!
data || !pdf )
return 0;
132 if (!constrainedParams)
return 0;
145 oocoutP(
nullptr,
Minimization) <<
"ProfileLikelihoodCalcultor::DoGLobalFit - find MLE " << std::endl;
154 oocoutW(
nullptr,
Minimization) <<
"ProfileLikelihoodCalcultor::DoGlobalFit - Global fit failed - status = " <<
fFitResult->status() << std::endl;
165 const char * minimType =
"";
182 <<
" / " << minimAlgo <<
" with strategy " << strategy << std::endl;
185 for (
int tries = 1, maxtries = 4; tries <= maxtries; ++tries) {
186 status = minim.
minimize(minimType,minimAlgo);
187 if (status%1000 == 0) {
189 }
else if (tries < maxtries) {
190 cout <<
" ----> Doing a re-scan first" << endl;
193 if (strategy == 0 ) {
194 cout <<
" ----> trying with strategy = 1" << endl;;
201 cout <<
" ----> trying with improve" << endl;;
202 minimType =
"Minuit";
203 minimAlgo =
"migradimproved";
234 if (!nll)
return nullptr;
246 for (
int i = 0; i < fitParams.
getSize(); ++i) {
268 for (
auto const *arg :
fPOI){
297 if (!
data || !pdf)
return 0;
309 if (!nll)
return nullptr;
323 std::vector<double> oldValues(poiList.
getSize() );
324 for (
unsigned int i = 0; i < oldValues.size(); ++i) {
327 oldValues[i] = mytarget->
getVal();
338 RooArgSet nuisParams(*constrainedParams);
344 bool existVarParams =
false;
345 for (
auto const *myarg : static_range_cast<RooRealVar *> (nuisParams)) {
346 if ( !myarg->isConstant() ) {
347 existVarParams =
true;
352 double nLLatCondMLE = nLLatMLE;
353 if (existVarParams) {
354 oocoutP(
nullptr,
Minimization) <<
"ProfileLikelihoodCalcultor::GetHypoTest - do conditional fit " << std::endl;
360 nLLatCondMLE = fit2->minNll();
361 fit2->printStream(
oocoutI(
nullptr,
Minimization), fit2->defaultPrintContents(0), fit2->defaultPrintStyle(0) );
363 if (fit2->status() != 0)
364 oocoutW(
nullptr,
Minimization) <<
"ProfileLikelihoodCalcultor::GetHypotest - Conditional fit failed - status = " << fit2->status() << std::endl;
370 nLLatCondMLE = nll->getVal();
376 double deltaNLL = std::max( nLLatCondMLE-nLLatMLE, 0.);
385 if (ndf == 1) pvalue = 0.5 * pvalue;
391 for (
unsigned int i = 0; i < oldValues.size(); ++i) {
394 mytarget->
setVal(oldValues[i] );
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
static int DefaultPrintLevel()
static double DefaultTolerance()
static const std::string & DefaultMinimizerAlgo()
static int DefaultStrategy()
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooFit::OwningPtr< RooArgSet > getParameters(const RooAbsData *data, bool stripDisconnected=true) const
Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of...
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual RooAbsArg * addClone(const RooAbsArg &var, bool silent=false)
Add a clone of the specified argument to list.
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsData is the common abstract base class for binned and unbinned datasets.
virtual RooFit::OwningPtr< RooAbsReal > createNLL(RooAbsData &data, const RooLinkedList &cmdList={})
Construct representation of -log(L) of PDF with given dataset.
void setConstant(bool value=true)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
virtual RooAbsReal * createProfile(const RooArgSet ¶msOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
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.
std::string const & minimizerType() const
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.
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
void setError(double value)
CombinedCalculator is an interface class for a tools which can produce both RooStats HypoTestResults ...
RooArgSet fNullParams
RooArgSet specifying null parameters for hypothesis test.
RooArgSet fPOI
RooArgSet specifying parameters of interest for interval.
RooAbsData * GetData() const
RooArgSet fGlobalObs
RooArgSet specifying the global observables.
RooAbsPdf * GetPdf() const
double fSize
size of the test (eg. specified rate of Type I error)
RooArgSet fConditionalObs
RooArgSet specifying the conditional observables.
HypoTestResult is a base class for results from hypothesis tests.
LikelihoodInterval is a concrete implementation of the RooStats::ConfInterval interface.
void SetConfidenceLevel(double cl) override
set the confidence level for the interval (e.g 0.682 for a 1-sigma interval)
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
RooAbsPdf * GetPdf() const
get model PDF (return nullptr if pdf has not been specified or does not exist)
The ProfileLikelihoodCalculator is a concrete implementation of CombinedCalculator (the interface cla...
std::unique_ptr< RooFitResult > fFitResult
static RooFit::OwningPtr< RooFitResult > DoMinimizeNLL(RooAbsReal *nll)
minimize likelihood
HypoTestResult * GetHypoTest() const override
Return the hypothesis test result obtained from the likelihood ratio of the maximum likelihood value ...
RooFit::OwningPtr< RooAbsReal > DoGlobalFit() const
perform a global fit
bool fGlobalFitDone
flag to control if a global fit has been done
~ProfileLikelihoodCalculator() override
destructor cannot delete prod pdf because it will delete all the composing pdf's if (fOwnPdf) delete ...
void DoReset() const
clear internal fit result
LikelihoodInterval * GetInterval() const override
Return a likelihood interval.
ProfileLikelihoodCalculator()
Default constructor (needed for I/O)
const char * GetName() const override
Returns name of object.
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.
double chisquared_cdf_c(double x, double r, double x0=0)
Complement of the cumulative distribution function of the distribution with degrees of freedom (upp...
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
Namespace for the RooStats classes.
void RemoveConstantParameters(RooArgSet *set)
RooStatsConfig & GetGlobalRooStatsConfig()
Retrieve the config object which can be used to set flags for things like offsetting the likelihood o...
bool IsNLLOffset()
function returning if the flag to check if the flag to use NLLOffset is set