24std::unique_ptr<RooArgSet>
25getGlobalObservables(
RooAbsPdf const &pdf,
RooArgSet const *globalObservables,
const char *globalObservablesTag)
28 if (globalObservables && globalObservablesTag) {
30 std::string errMsg =
"RooAbsPdf::fitTo: GlobalObservables and GlobalObservablesTag options mutually exclusive!";
31 oocoutE(&pdf, Minimization) << errMsg << std::endl;
32 throw std::invalid_argument(errMsg);
34 if (globalObservables) {
36 return std::make_unique<RooArgSet>(*globalObservables);
39 if (globalObservablesTag) {
40 oocoutI(&pdf, Minimization) <<
"User-defined specification of global observables definition with tag named '"
41 << globalObservablesTag <<
"'" << std::endl;
46 if (
auto defaultGlobalObservablesTag = pdf.
getStringAttribute(
"DefaultGlobalObservablesTag")) {
47 oocoutI(&pdf, Minimization) <<
"p.d.f. provides built-in specification of global observables definition "
48 <<
"with tag named '" << defaultGlobalObservablesTag <<
"'" << std::endl;
49 globalObservablesTag = defaultGlobalObservablesTag;
53 if (globalObservablesTag) {
55 return std::unique_ptr<RooArgSet>{
static_cast<RooArgSet *
>(allVars->selectByAttrib(globalObservablesTag,
true))};
100 RooArgSet const *globalObservables,
const char *globalObservablesTag,
101 bool takeGlobalObservablesFromData,
bool removeConstraintsFromPdf)
105 bool doStripDisconnected =
false;
111 if (constrainedParameters) {
112 cPars.
add(*constrainedParameters);
115 doStripDisconnected =
true;
122 auto constraintSetCacheName = std::string(
"CACHE_CONSTR_OF_PDF_") + pdf.
GetName() +
"_FOR_OBS_" + observableNames;
124 if (!cPars.
empty()) {
125 std::unique_ptr<RooArgSet> internalConstraints{
126 pdf.
getAllConstraints(observables, cPars, doStripDisconnected, removeConstraintsFromPdf)};
127 allConstraints.
add(*internalConstraints);
129 if (externalConstraints) {
130 allConstraints.
add(*externalConstraints);
133 if (!allConstraints.
empty()) {
135 oocoutI(&pdf, Minimization) <<
" Including the following constraint terms in minimization: " << allConstraints
139 auto glObs = getGlobalObservables(pdf, globalObservables, globalObservablesTag);
140 if (
data.getGlobalObservables() && takeGlobalObservablesFromData) {
145 <<
"The following global observables have been automatically defined according to the dataset "
146 <<
"which also provides their values: " << *
data.getGlobalObservables() << std::endl;
147 glObs = std::make_unique<RooArgSet>(*
data.getGlobalObservables());
152 data.getGlobalObservables()->selectCommon(*glObs, globalsFromDataset);
153 oocoutI(&pdf, Minimization) <<
"The following global observables have been defined: " << *glObs <<
","
154 <<
" with the values of " << globalsFromDataset
155 <<
" obtained from the dataset and the other values from the model."
160 <<
"The following global observables have been defined and their values are taken from the model: "
161 << *glObs << std::endl;
163 takeGlobalObservablesFromData =
false;
167 <<
"The global observables are not defined , normalize constraints with respect to the parameters "
168 << cPars << std::endl;
169 takeGlobalObservablesFromData =
false;
172 return std::make_unique<RooConstraintSum>(
name.c_str(),
"nllCons", allConstraints, glObs ? *glObs : cPars,
173 takeGlobalObservablesFromData);
std::unique_ptr< RooAbsReal > createConstraintTerm(std::string const &name, RooAbsPdf const &pdf, RooAbsData const &data, RooArgSet const *constrainedParameters, RooArgSet const *externalConstraints, RooArgSet const *globalObservables, const char *globalObservablesTag, bool takeGlobalObservablesFromData, bool removeConstraintsFromPdf)
Create the parameter constraint sum to add to the negative log-likelihood.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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...
const Text_t * getStringAttribute(const Text_t *key) const
Get string attribute mapped under key 'key'.
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expression tree)
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Abstract base class for binned and unbinned datasets.
Abstract interface for all probability density functions.
RooArgSet * getAllConstraints(const RooArgSet &observables, RooArgSet &constrainedParams, bool stripDisconnected=true, bool removeConstraintsFromPdf=false) const
This helper function finds and collects all constraints terms of all component p.d....
RooArgSet is a container object that can hold multiple RooAbsArg objects.
const char * GetName() const override
Returns name of object.
std::string getColonSeparatedNameString(RooArgSet const &argSet, char delim=':')