34 unsigned int extraTopics,
unsigned int removeTopics,
bool overrideExternalLevel) {
37 if (overrideExternalLevel) msg.setGlobalKillBelow(lvl);
39 for (
int i = 0; i < msg.numStreams(); ++i) {
40 fOldConf.push_back(msg.getStream(i));
41 if (overrideExternalLevel) msg.getStream(i).minLevel = lvl;
43 msg.setStreamStatus(i,
true);
46 if (extraTopics != 0) {
55 for (
int i=0; i < msg.numStreams(); ++i) {
56 if (i <
static_cast<int>(
fOldConf.size()))
74 msg.setGlobalKillBelow(level);
76 std::vector<RooMsgService::StreamConfig> tmpStreams;
77 for (
int i = 0; i < msg.numStreams(); ++i) {
78 _oldConf.push_back(msg.getStream(i));
79 if (msg.getStream(i).match(level, topics,
static_cast<RooAbsArg*
>(
nullptr))) {
80 tmpStreams.push_back(msg.getStream(i));
81 msg.setStreamStatus(i,
false);
91 msg.addStream(st.minLevel,
105 for (
unsigned int i = 0; i <
_oldConf.size(); ++i) {
122 double min,
double max,
bool limitsInAllowedRange, std::string
const& extraMessage) {
123 const char openBr = limitsInAllowedRange ?
'[' :
'(';
124 const char closeBr = limitsInAllowedRange ?
']' :
')';
126 for (
auto parameter : pars) {
129 (par->getMin() < min || par->getMax() > max)
130 || (!limitsInAllowedRange && (par->getMin() == min || par->getMax() == max)) )) {
131 std::stringstream rangeMsg;
133 if (min > -std::numeric_limits<double>::max())
134 rangeMsg << min <<
", ";
136 rangeMsg <<
"-inf, ";
138 if (max < std::numeric_limits<double>::max())
139 rangeMsg << max << closeBr;
141 rangeMsg <<
"inf" << closeBr;
143 oocoutW(callingClass, InputArguments) <<
"The parameter '" << par->
GetName() <<
"' with range [" << par->getMin(
"") <<
", "
144 << par->getMax() <<
"] of the " << callingClass->IsA()->
GetName() <<
" '" << callingClass->
GetName()
145 <<
"' exceeds the safe range of " << rangeMsg.str() <<
". Advise to limit its range."
146 << (!extraMessage.empty() ?
"\n" :
"") << extraMessage << std::endl;
153 std::pair<double, double> getBinningInterval(
RooAbsBinning const& binning) {
173 if (rangeName && rlv->hasRange(rangeName)) {
174 return {rlv->
getMin(rangeName), rlv->getMax(rangeName)};
175 }
else if (
auto binning = rlv->getBinningPtr(rangeName)) {
176 return getBinningInterval(*binning);
179 return {-std::numeric_limits<double>::infinity(), +std::numeric_limits<double>::infinity()};
194 std::vector<std::string>
const& rangeNames,
202 bool hasOverlap =
false;
203 std::vector<std::string> rangeNamesSplit;
204 for (
const auto& catState : simPdf.indexCat()) {
205 const std::string& catName = catState.first;
206 for(std::string
const& rangeName : rangeNames) {
207 rangeNamesSplit.emplace_back(rangeName +
"_" + catName);
209 hasOverlap |=
checkIfRangesOverlap(*simPdf.getPdf(catName.c_str()), data, rangeNamesSplit,
false);
211 rangeNamesSplit.clear();
224 return getBinningInterval(*binning);
233 return std::pair<double, double>{rlv.
getMin(rangeName), rlv.
getMax(rangeName)};
236 return std::pair<double, double>{rlv.
getMin(), rlv.
getMax()};
240 std::vector<std::pair<double,double>> limits;
241 limits.reserve(rangeNames.size() * observables.size());
243 for (
auto const& range : rangeNames) {
244 for (
auto const& obs : observables) {
248 limits.push_back(getLimits(*rlv, range.c_str()));
250 throw std::logic_error(
"Classes that represent observables are expected to inherit from RooAbsRealLValue or RooAbsCategory!");
255 auto nRanges = rangeNames.size();
256 auto nObs = limits.size() / nRanges;
259 for(
size_t ir1 = 0; ir1 < nRanges; ++ir1) {
260 for(
size_t ir2 = ir1 + 1; ir2 < nRanges; ++ir2) {
266 for(
size_t io1 = 0; io1 < nObs; ++io1) {
267 auto r1 = limits[ir1 * nObs + io1];
268 auto r2 = limits[ir2 * nObs + io1];
269 overlaps += (r1.second > r2.first && r1.first < r2.second)
270 || (r2.second > r1.first && r2.first < r1.second);
272 if(overlaps == nObs)
return true;
288 for(
auto const& arg : tmp) {
289 content += arg->GetName();
292 if(!content.empty()) {
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooArgSet * getObservables(const RooArgSet &set, Bool_t valueOnly=kTRUE) const
Given a set of possible observables, return the observables that this PDF depends on.
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
virtual Bool_t isParameterized() const
Interface function.
virtual Double_t highBound() const =0
virtual RooAbsReal * highBoundFunc() const
Return pointer to RooAbsReal parameterized upper bound, if any.
virtual Double_t lowBound() const =0
virtual RooAbsReal * lowBoundFunc() const
Return pointer to RooAbsReal parameterized lower bound, if any.
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
void sort(Bool_t reverse=false)
Sort collection using std::sort and name comparison.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add 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.
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual Double_t getMax(const char *name=0) const
Get maximum of currently defined range.
virtual Bool_t hasRange(const char *name) const
Check if variable has a binning with given name.
virtual const RooAbsBinning * getBinningPtr(const char *rangeName) const
virtual Double_t getMin(const char *name=0) const
Get miniminum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t 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...
The RooDataHist is a container class to hold N-dimensional binned data.
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.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
virtual const char * GetName() const
Returns name of object.
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 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.
bool checkIfRangesOverlap(RooAbsPdf const &pdf, RooAbsData const &data, std::vector< std::string > const &rangeNames, bool splitRange)
Check if there is any overlap when a list of ranges is applied to a set of observables.
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.
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.
static void output(int code)