44using std::endl, std::ostream;
59 for (
const auto arg : inputCategories) {
61 coutE(InputArguments) <<
"RooMultiCategory::RooMultiCategory(" <<
GetName() <<
"): input argument " << arg->
GetName()
62 <<
" is not a RooAbsCategory" << endl ;
88 for (
const auto arg :
_catSet) {
91 label += first ?
'{' :
';';
92 label += cat->getCurrentLabel();
110 for (
const auto arg :
_catSet) {
113 coutW(InputArguments) << __func__ <<
" Trying to build a multi-category state based on "
114 "a category with zero states. Fix '" << cat->
GetName() <<
"'." << std::endl;
117 computedStateIndex += cat->getCurrentOrdinalNumber() * multiplier;
118 multiplier *= cat->size();
121 return computedStateIndex;
134 os <<
indent <<
"--- RooMultiCategory ---" << endl;
135 os <<
indent <<
" Input category list:" << endl ;
158 return item.first.c_str();
173 unsigned int totalSize = 1;
174 for (
const auto arg :
_catSet) {
176 totalSize *= cat->size();
179 for (
unsigned int i=0; i < totalSize; ++i) {
180 unsigned int workingIndex = i;
181 std::string catName =
"{";
182 for (
const auto arg :
_catSet) {
184 unsigned int thisStateOrdinal = workingIndex % cat->size();
185 const auto& thisState = cat->getOrdinal(thisStateOrdinal);
186 catName += thisState.first +
';';
187 workingIndex = (workingIndex - thisStateOrdinal) / cat->size();
189 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.
A space to attach TBranches.
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.
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to ostream.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print info about this object to the specified stream.
std::vector< std::string > _insertionOrder
Keeps track in which order state numbers have been inserted. Make sure this is updated in recomputeSh...
std::map< std::string, value_type > _stateNames
Map state names to index numbers. Make sure state names are updated in recomputeShape().
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.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
Connects several RooAbsCategory objects into a single category.
value_type evaluate() const override
Calculate the current value.
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Print the state of this object to the specified output stream.
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}.
RooSetProxy _catSet
Set of input category.
void writeToStream(std::ostream &os, bool compact) const override
Write object contents to given stream.
void recomputeShape() override
Inspect all the subcategories, and enumerate and name their states.
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,...
const char * GetName() const override
Returns name of object.
const char * Data() const
TString & Append(const char *cs)