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))};
98 RooArgSet const *globalObservables,
const char *globalObservablesTag,
99 bool takeGlobalObservablesFromData)
103 bool doStripDisconnected =
false;
109 if (constrainedParameters) {
110 cPars.
add(*constrainedParameters);
113 doStripDisconnected =
true;
120 auto constraintSetCacheName = std::string(
"CACHE_CONSTR_OF_PDF_") + pdf.
GetName() +
"_FOR_OBS_" + observableNames;
122 if (!cPars.
empty()) {
123 std::unique_ptr<RooArgSet> internalConstraints{
125 allConstraints.
add(*internalConstraints);
127 if (externalConstraints) {
128 allConstraints.
add(*externalConstraints);
131 if (!allConstraints.
empty()) {
133 oocoutI(&pdf, Minimization) <<
" Including the following constraint terms in minimization: " << allConstraints
137 auto glObs = getGlobalObservables(pdf, globalObservables, globalObservablesTag);
138 if (
data.getGlobalObservables() && takeGlobalObservablesFromData) {
143 <<
"The following global observables have been automatically defined according to the dataset "
144 <<
"which also provides their values: " << *
data.getGlobalObservables() << std::endl;
145 glObs = std::make_unique<RooArgSet>(*
data.getGlobalObservables());
150 data.getGlobalObservables()->selectCommon(*glObs, globalsFromDataset);
151 oocoutI(&pdf, Minimization) <<
"The following global observables have been defined: " << *glObs <<
","
152 <<
" with the values of " << globalsFromDataset
153 <<
" obtained from the dataset and the other values from the model."
158 <<
"The following global observables have been defined and their values are taken from the model: "
159 << *glObs << std::endl;
161 takeGlobalObservablesFromData =
false;
165 <<
"The global observables are not defined , normalize constraints with respect to the parameters "
166 << cPars << std::endl;
168 takeGlobalObservablesFromData =
false;
171 return std::make_unique<RooConstraintSum>(
name.c_str(),
"nllCons", allConstraints, glObs ? *glObs : cPars,
172 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)
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) 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=':')