31#include <unordered_map>
36std::pair<double, double> getBinningInterval(
RooAbsBinning const &binning)
57 if (rangeName && rlv->hasRange(rangeName)) {
58 return {rlv->
getMin(rangeName), rlv->getMax(rangeName)};
59 }
else if (
auto binning = rlv->getBinningPtr(rangeName)) {
60 return getBinningInterval(*binning);
63 return {-std::numeric_limits<double>::infinity(), +std::numeric_limits<double>::infinity()};
72 std::vector<std::pair<double, double>> limits;
73 limits.reserve(rangeNames.size() * observables.
size());
75 for (
auto const &range : rangeNames) {
76 for (
auto const &obs : observables) {
80 limits.emplace_back(rlv->getMin(range.c_str()), rlv->getMax(range.c_str()));
82 throw std::logic_error(
83 "Classes that represent observables are expected to inherit from RooAbsRealLValue or RooAbsCategory!");
88 auto nRanges = rangeNames.size();
89 auto nObs = limits.size() / nRanges;
92 for (
size_t ir1 = 0; ir1 < nRanges; ++ir1) {
93 for (
size_t ir2 = ir1 + 1; ir2 < nRanges; ++ir2) {
99 for (
size_t io1 = 0; io1 < nObs; ++io1) {
100 auto r1 = limits[ir1 * nObs + io1];
101 auto r2 = limits[ir2 * nObs + io1];
103 (r1.second > r2.first && r1.first < r2.second) || (r2.second > r1.first && r2.first < r1.second);
105 if (overlaps == nObs)
122 for (
auto const &arg :
tmp) {
126 if (!content.empty()) {
140 if (
auto arg = argSet.
find(
name.c_str()))
148 if (splitRange && !rangeName.empty()) {
151 for (std::string
const &token : tokens) {
152 out += token +
"_" + catName +
",";
165 return {
const_cast<RooAbsPdf *
>(&pdf),
true};
169 if (component->getAttribute(
"BinnedLikelihood") && component->IsA()->InheritsFrom(
RooRealSumPdf::Class())) {
170 return {
static_cast<RooAbsPdf *
>(component),
true};
172 if (component->getAttribute(
"MAIN_MEASUREMENT")) {
175 return {
static_cast<RooAbsPdf *
>(component),
false};
179 return {
nullptr,
false};
194 out.sortTopologically();
201using ToCloneList = std::vector<RooAbsArg const *>;
202using ToCloneMap = std::unordered_map<TNamed const *, RooAbsArg const *>;
205void addServerClonesToList(
const RooAbsArg &var, ToCloneList &outlist, ToCloneMap &outmap,
bool deepCopy,
208 if (outmap.find(var.
namePtr()) != outmap.end()) {
217 outlist.push_back(&var);
220 for (
const auto server : var.servers()) {
221 addServerClonesToList(*server, outlist, outmap, deepCopy, observables);
238 ToCloneList toCloneList;
239 ToCloneMap toCloneMap;
241 addServerClonesToList(*orig, toCloneList, toCloneMap, deepCopy, observables);
245 output.reserve(toCloneList.size());
246 for (
RooAbsArg const *arg : toCloneList) {
247 std::unique_ptr<RooAbsArg> serverClone{
static_cast<RooAbsArg *
>(arg->
Clone())};
249 output.addOwned(std::move(serverClone));
279 clonedNodes.
remove(*head);
301 if (std::isdigit(in[0])) {
305 std::transform(
out.begin(),
out.end(),
out.begin(), [](
char c) { return std::isalnum(c) ? c :
'_'; });
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Common abstract base class for objects that represent a value and a "shape" in RooFit.
const TNamed * namePtr() const
De-duplicated pointer to this object's name.
bool addOwnedComponents(const RooAbsCollection &comps)
Take ownership of the contents of 'comps'.
bool redirectServers(const RooAbsCollection &newServerList, bool mustReplaceAll=false, bool nameChange=false, bool isRecursionStep=false)
Replace all direct servers of this object with the new servers in newServerList.
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
virtual bool isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
void treeNodeServerList(RooAbsCollection *list, const RooAbsArg *arg=nullptr, bool doBranch=true, bool doLeaf=true, bool valueOnly=false, bool recurseNonDerived=false) const
Fill supplied list with nodes of the arg tree, following all server links, starting with ourself as t...
Abstract base class for RooRealVar binning definitions.
virtual bool isParameterized() const
Interface function.
virtual double highBound() const =0
virtual double lowBound() const =0
virtual RooAbsReal * highBoundFunc() const
Return pointer to RooAbsReal parameterized upper bound, if any.
virtual RooAbsReal * lowBoundFunc() const
Return pointer to RooAbsReal parameterized lower bound, if any.
A space to attach TBranches.
Abstract container object that can hold multiple RooAbsArg objects.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
Storage_t::const_reverse_iterator rend() const
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::const_reverse_iterator rbegin() const
Storage_t::size_type size() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract interface for all probability density functions.
TClass * IsA() const override
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Efficient implementation of a product of PDFs of the form.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
const char * GetName() const override
Returns name of object.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
std::string makeValidVarName(std::string const &in)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
RooAbsArg * cloneTreeWithSameParametersImpl(RooAbsArg const &arg, RooArgSet const *observables)
bool snapshotImpl(RooAbsCollection const &input, RooAbsCollection &output, bool deepCopy, RooArgSet const *observables)
RooArgSet selectFromArgSet(RooArgSet const &, std::string const &names)
bool checkIfRangesOverlap(RooArgSet const &observables, std::vector< std::string > const &rangeNames)
std::string getRangeNameForSimComponent(std::string const &rangeName, bool splitRange, std::string const &catName)
void getSortedComputationGraph(RooAbsArg const &func, RooArgSet &out)
BinnedLOutput getBinnedL(RooAbsPdf const &pdf)
std::string getColonSeparatedNameString(RooArgSet const &argSet, char delim=':')
std::pair< double, double > getRangeOrBinningInterval(RooAbsArg const *arg, const char *rangeName)