60 for (
const auto arg : inputCategories) {
62 coutE(InputArguments) <<
"RooMultiCategory::RooMultiCategory(" <<
GetName() <<
"): input argument " << arg->
GetName()
63 <<
" is not a RooAbsCategory" << endl ;
99 for (
const auto arg :
_catSet) {
102 label +=
first ?
'{' :
';';
103 label += cat->getCurrentLabel();
117std::string computeLabelOldStyle(
const RooArgSet& catSet,
unsigned int index) {
120 for (
unsigned int i=0; (obj=(
TObjString*)iter.Next()); ++i) {
141 for (
const auto arg :
_catSet) {
143 if (cat->size() == 0) {
144 coutW(InputArguments) << __func__ <<
" Trying to build a multi-category state based on "
145 "a category with zero states. Fix '" << cat->
GetName() <<
"'." << std::endl;
148 computedStateIndex += cat->getCurrentOrdinalNumber() * multiplier;
149 multiplier *= cat->size();
153 assert(
hasIndex(computedStateIndex));
158 return computedStateIndex;
171 os <<
indent <<
"--- RooMultiCategory ---" << endl;
172 os <<
indent <<
" Input category list:" << endl ;
195 return item.first.c_str();
210 unsigned int totalSize = 1;
211 for (
const auto arg :
_catSet) {
213 totalSize *= cat->size();
216 for (
unsigned int i=0; i < totalSize; ++i) {
217 unsigned int workingIndex = i;
218 std::string catName =
"{";
219 for (
const auto arg :
_catSet) {
221 unsigned int thisStateOrdinal = workingIndex % cat->size();
222 const auto& thisState = cat->getOrdinal(thisStateOrdinal);
223 catName += thisState.first +
';';
224 workingIndex = (workingIndex - thisStateOrdinal) / cat->size();
226 catName[catName.size()-1] =
'}';
static void indent(ostringstream &buf, int indent_level)
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
virtual value_type getCurrentIndex() const
Return index number of current state.
void defineStateUnchecked(const std::string &label, value_type index)
Internal version of defineState() that does not check if type already exists.
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to ostream.
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print info about this object to the specified stream.
bool hasIndex(value_type index) const
Check if a state with index index exists.
std::vector< std::string > _insertionOrder
Map state names to index numbers. Make sure state names are updated in recomputeShape().
std::map< std::string, value_type > _stateNames
Current category state.
const std::map< std::string, value_type > & stateNames() const
Access the map of state names to index numbers.
void clearTypes()
Delete all currently defined states.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooMultiCategory connects several RooAbsCategory objects into a single category.
value_type evaluate() const override
Calculate the current value.
const char * getCurrentLabel() const override
Get current label.
std::string createLabel() const
Compile a string with all the labels of the serving categories, such as {1Jet;1Lepton;2Tag}.
virtual ~RooMultiCategory()
Destructor.
void recomputeShape() override
Inspect all the subcategories, and enumerate and name their states.
virtual void writeToStream(std::ostream &os, Bool_t compact) const override
Write object contents to given stream.
virtual void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const override
Print the state of this object to the specified output stream.
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Overloaded RooArgSet::add() method inserts 'var' into set and registers 'var' as server to owner with...
virtual const char * GetName() const
Returns name of object.
Collectable string class.
const char * Data() const
TString & Append(const char *cs)