36 unsigned int extraTopics,
unsigned int removeTopics,
bool overrideExternalLevel) {
39 if (overrideExternalLevel) msg.setGlobalKillBelow(lvl);
41 for (
int i = 0; i < msg.numStreams(); ++i) {
42 fOldConf.push_back(msg.getStream(i));
43 if (overrideExternalLevel) msg.getStream(i).minLevel = lvl;
45 msg.setStreamStatus(i,
true);
48 if (extraTopics != 0) {
57 for (
int i=0; i < msg.numStreams(); ++i) {
58 if (i <
static_cast<int>(
fOldConf.size()))
76 msg.setGlobalKillBelow(level);
78 std::vector<RooMsgService::StreamConfig> tmpStreams;
79 for (
int i = 0; i < msg.numStreams(); ++i) {
80 _oldConf.push_back(msg.getStream(i));
81 if (msg.getStream(i).match(level, topics,
static_cast<RooAbsArg*
>(
nullptr))) {
82 tmpStreams.push_back(msg.getStream(i));
83 msg.setStreamStatus(i,
false);
93 msg.addStream(st.minLevel,
107 for (
unsigned int i = 0; i <
_oldConf.size(); ++i) {
124 double min,
double max,
bool limitsInAllowedRange, std::string
const& extraMessage) {
125 const char openBr = limitsInAllowedRange ?
'[' :
'(';
126 const char closeBr = limitsInAllowedRange ?
']' :
')';
128 for (
auto parameter : pars) {
131 (par->getMin() < min || par->getMax() > max)
132 || (!limitsInAllowedRange && (par->getMin() == min || par->getMax() == max)) )) {
133 std::stringstream rangeMsg;
135 if (min > -std::numeric_limits<double>::max())
136 rangeMsg << min <<
", ";
138 rangeMsg <<
"-inf, ";
140 if (max < std::numeric_limits<double>::max())
141 rangeMsg << max << closeBr;
143 rangeMsg <<
"inf" << closeBr;
145 oocoutW(callingClass, InputArguments) <<
"The parameter '" << par->GetName() <<
"' with range [" << par->getMin(
"") <<
", "
146 << par->getMax() <<
"] of the " << callingClass->
ClassName() <<
" '" << callingClass->
GetName()
147 <<
"' exceeds the safe range of " << rangeMsg.str() <<
". Advise to limit its range."
148 << (!extraMessage.empty() ?
"\n" :
"") << extraMessage << std::endl;
155 std::pair<double, double> getBinningInterval(
RooAbsBinning const& binning) {
175 if (rangeName && rlv->hasRange(rangeName)) {
176 return {rlv->
getMin(rangeName), rlv->getMax(rangeName)};
177 }
else if (
auto binning = rlv->getBinningPtr(rangeName)) {
178 return getBinningInterval(*binning);
181 return {-std::numeric_limits<double>::infinity(), +std::numeric_limits<double>::infinity()};
191 std::vector<std::pair<double,double>> limits;
192 limits.reserve(rangeNames.size() * observables.
size());
194 for (
auto const& range : rangeNames) {
195 for (
auto const& obs : observables) {
199 limits.emplace_back(rlv->getMin(range.c_str()), rlv->getMax(range.c_str()));
201 throw std::logic_error(
"Classes that represent observables are expected to inherit from RooAbsRealLValue or RooAbsCategory!");
206 auto nRanges = rangeNames.size();
207 auto nObs = limits.size() / nRanges;
210 for(
size_t ir1 = 0; ir1 < nRanges; ++ir1) {
211 for(
size_t ir2 = ir1 + 1; ir2 < nRanges; ++ir2) {
217 for(
size_t io1 = 0; io1 < nObs; ++io1) {
218 auto r1 = limits[ir1 * nObs + io1];
219 auto r2 = limits[ir2 * nObs + io1];
220 overlaps += (r1.second > r2.first && r1.first < r2.second)
221 || (r2.second > r1.first && r2.first < r1.second);
223 if(overlaps == nObs)
return true;
239 for(
auto const& arg : tmp) {
240 content += arg->GetName();
243 if(!content.empty()) {
265 if (splitRange && !rangeName.empty()) {
268 for(std::string
const& token : tokens) {
269 out += token +
"_" + catName +
",";
282 return {
const_cast<RooAbsPdf *
>(&pdf),
true};
286 if (component->getAttribute(
"BinnedLikelihood") && component->IsA()->InheritsFrom(
RooRealSumPdf::Class())) {
287 return {
static_cast<RooAbsPdf *
>(component),
true};
289 if (component->getAttribute(
"MAIN_MEASUREMENT")) {
292 return {
static_cast<RooAbsPdf *
>(component),
false};
296 return {
nullptr,
false};
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
bool getAttribute(const Text_t *name) const
Check if a named attribute is set. By default, all attributes are unset.
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...
RooAbsBinning is the 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.
void sortTopologically()
Sort collection topologically: the servers of any RooAbsArg will be before that RooAbsArg in the coll...
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
void sort(bool reverse=false)
Sort collection using std::sort and name comparison.
RooAbsArg * find(const char *name) const
Find object with given name in list.
TClass * IsA() const override
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
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.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
RooFit::MsgLevel _oldKillBelow
HijackMessageStream(RooFit::MsgLevel level, RooFit::MsgTopic topics, const char *objectName=nullptr)
Hijack all messages with given level and topics while this object is alive.
std::vector< RooMsgService::StreamConfig > _oldConf
~HijackMessageStream()
Deregister the hijacked stream and restore the stream state of all previous streams.
RooFit::MsgLevel fOldKillBelow
LocalChangeMsgLevel(RooFit::MsgLevel lvl=RooFit::DEBUG, unsigned int extraTopics=0u, unsigned int removeTopics=0u, bool overrideExternalLevel=true)
Change message level (and topics) while this object is alive, reset when it goes out of scope.
std::vector< RooMsgService::StreamConfig > fOldConf
static RooMsgService & instance()
Return reference to singleton instance.
RooProdPdf is an 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.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
RooCmdArg ClassName(const char *name)
RooCmdArg OutputStream(std::ostream &os)
RooCmdArg Topic(Int_t topic)
RooCmdArg TagName(const char *name)
RooCmdArg BaseClassName(const char *name)
RooCmdArg ObjectName(const char *name)
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
MsgTopic
Topics for a RooMsgService::StreamConfig in RooMsgService.
void getSortedComputationGraph(RooAbsReal const &func, RooArgSet &out)
Get the topologically-sorted list of all nodes in the computation graph.
void checkRangeOfParameters(const RooAbsReal *callingClass, std::initializer_list< const RooAbsReal * > pars, double min=-std::numeric_limits< double >::max(), double max=std::numeric_limits< double >::max(), bool limitsInAllowedRange=false, std::string const &extraMessage="")
Check if the parameters have a range, and warn if the range extends below / above the set limits.
std::string getRangeNameForSimComponent(std::string const &rangeName, bool splitRange, std::string const &catName)
RooArgSet selectFromArgSet(RooArgSet const &, std::string const &names)
Construct a RooArgSet of objects in a RooArgSet whose names match to those in the names string.
bool checkIfRangesOverlap(RooArgSet const &observables, std::vector< std::string > const &rangeNames)
Check if there is any overlap when a list of ranges is applied to a set of observables.
BinnedLOutput getBinnedL(RooAbsPdf const &pdf)
std::pair< double, double > getRangeOrBinningInterval(RooAbsArg const *arg, const char *rangeName)
Get the lower and upper bound of parameter range if arg can be casted to RooAbsRealLValue.
std::string getColonSeparatedNameString(RooArgSet const &argSet)
Create a string with all sorted names of RooArgSet elements separated by colons.