Logo ROOT  
Reference Guide
RooCategory Class Referencefinal


RooCategory is an object to represent discrete states.

States have names and index numbers, and the index numbers can be written into datasets and used in calculations. A category is "fundamental", i.e., its value doesn't depend on the value of other objects. (Objects in datasets cannot depend on other objects' values, they need to be self-consistent.)

A category object can be used to e.g. conduct a simultaneous fit of the same observable in multiple categories.

Setting up a category

A category can be set up like this:

RooCategory myCat("myCat", "Lepton multiplicity category", {
{"0Lep", 0},
{"1Lep", 1},
{"2Lep", 2},
{"3Lep", 3}
});

Like this:

RooCategory myCat("myCat", "Asymmetry");
myCat["left"] = -1;
myCat["right"] = 1;

Or like this:

RooCategory myCat("myCat", "Asymmetry");
myCat.defineType("left", -1);
myCat.defineType("right", 1);

Inspect the pairs of state names and state numbers like this:

for (const auto& nameIdx : myCat) {
std::cout << nameIdx.first << " --> " << nameIdx.second << std::endl;
}

Changing category states

Category states can be modified either by using the index state (faster) or state names. For example:

myCat.setIndex(5);
myCat.setLabel("left");
for (const auto& otherNameIdx : otherCat) {
myCat.setIndex(otherNameIdx);
}

Also refer to RooFit Tutorials, especially rf404_categories.C for an introduction, and to rf405_realtocatfuncs.C and rf406_cattocatfuncs.C for advanced uses of categories.

Definition at line 23 of file RooCategory.h.

Public Member Functions

 RooCategory ()
 
 RooCategory (const char *name, const char *title)
 Constructor. Types must be defined using defineType() before variable can be used. More...
 
 RooCategory (const char *name, const char *title, const std::map< std::string, int > &allowedStates)
 Create a new category and define allowed states. More...
 
 RooCategory (const RooCategory &other, const char *name=0)
 Copy constructor. More...
 
virtual ~RooCategory ()
 Destructor. More...
 
void addToRange (const char *rangeName, RooAbsCategory::value_type stateIndex)
 Add the given state to the given range. More...
 
void addToRange (const char *rangeName, const char *stateNameList)
 Add the list of state names to the given range. More...
 
void clear ()
 Clear all defined category states. More...
 
void clearRange (const char *name, Bool_t silent)
 Clear the named range. More...
 
virtual TObjectclone (const char *newname) const override
 
bool defineType (const std::string &label)
 Define a state with given name. More...
 
bool defineType (const std::string &label, Int_t index)
 Define a state with given name and index. More...
 
void defineTypes (const std::map< std::string, int > &allowedStates)
 Define multiple states in a single call. More...
 
virtual value_type getCurrentIndex () const override final
 Return current index. More...
 
RooCategoryoperator= (const RooCategory &)=delete
 
value_typeoperator[] (const std::string &stateName)
 Access a named state. More...
 
virtual Bool_t readFromStream (std::istream &is, Bool_t compact, Bool_t verbose=kFALSE) override
 Read object contents from given stream. More...
 
virtual Bool_t setIndex (Int_t index, bool printError=true) override
 Set value by specifying the index code of the desired state. More...
 
virtual bool setIndex (value_type index, bool printError=true)=0
 Change category state by specifying the index code of the desired state. More...
 
bool setIndex (const std::pair< std::string, value_type > &nameIdxPair, bool printError=true)
 Change category state to state specified by another category state. More...
 
virtual Bool_t setLabel (const char *label, bool printError=true) override
 Set value by specifying the name of the desired state. More...
 
virtual bool setLabel (const char *label, Bool_t printError=kTRUE)=0
 Change category state by specifying a state name. More...
 
bool setLabel (const std::string &label, bool printError=true)
 Set value by specifying the name of the desired state. More...
 
bool setLabel (const std::pair< std::string, value_type > &nameIdxPair, bool printError=true)
 Change category state to the state name of another category. More...
 
void setRange (const char *rangeName, const char *stateNameList)
 
std::map< std::string, RooAbsCategory::value_type > & states ()
 Return a reference to the map of state names to index states. More...
 
virtual void writeToStream (std::ostream &os, Bool_t compact) const override
 compact only at the moment More...
 
RooFit interface
virtual Bool_t isFundamental () const override
 Tell whether we can be stored in a dataset. Always true for RooCategory. More...
 
virtual Bool_t isDerived () const override
 Does our value or shape depend on any other arg? Always false for RooCategory. More...
 
virtual RooSpan< const value_typegetValBatch (std::size_t, std::size_t) const override
 Retrieve a batch of category values for events in the range [begin, begin+batchSize). More...
 
Bool_t isStateInRange (const char *rangeName, RooAbsCategory::value_type stateIndex) const
 Check if the state is in the given range. More...
 
Bool_t isStateInRange (const char *rangeName, const char *stateName) const
 Check if the state is in the given range. More...
 
virtual Bool_t inRange (const char *rangeName) const override
 Check if the currently defined category state is in the range with the given name. More...
 
virtual bool hasRange (const char *rangeName) const override
 Returns true if category has a range with given name defined. More...
 
- Public Member Functions inherited from RooAbsCategoryLValue
 RooAbsCategoryLValue ()
 
 RooAbsCategoryLValue (const char *name, const char *title)
 Constructor. More...
 
 RooAbsCategoryLValue (const RooAbsCategoryLValue &other, const char *name=0)
 Copy constructor. More...
 
virtual ~RooAbsCategoryLValue ()
 Destructor. More...
 
virtual Int_t getBin (const char *) const
 Get index of plot bin for current value this category. More...
 
virtual Int_t getBin (const RooAbsBinning *) const
 
virtual std::list< std::string > getBinningNames () const
 
virtual const RooAbsBinninggetBinningPtr (const char *) const
 
virtual Double_t getBinWidth (Int_t, const char *=0) const
 
virtual Bool_t isLValue () const
 Is this argument an l-value, i.e., can it appear on the left-hand side of an assignment expression? LValues are also special since they can potentially be analytically integrated and generated. More...
 
virtual Int_t numBins (const char *rangeName) const
 Return the number of fit bins ( = number of types ) More...
 
RooAbsArgoperator= (int index)
 Assignment operator from integer index number. More...
 
RooAbsArgoperator= (const char *label)
 Assignment operator from string pointer. More...
 
RooAbsArgoperator= (const RooAbsCategory &other)
 Assignment from another RooAbsCategory. More...
 
virtual void randomize (const char *rangeName=0)
 Randomize current value. More...
 
virtual void setBin (Int_t ibin, const char *rangeName=0)
 Set category to i-th fit bin, which is the i-th registered state. More...
 
void setConstant (Bool_t value=kTRUE)
 
bool setIndex (const std::pair< std::string, value_type > &nameIdxPair, bool printError=true)
 Change category state to state specified by another category state. More...
 
bool setLabel (const std::string &label, bool printError=true)
 Change category state by specifying a state name. More...
 
bool setLabel (const std::pair< std::string, value_type > &nameIdxPair, bool printError=true)
 Change category state to the state name of another category. More...
 
bool setOrdinal (unsigned int index)
 Set our state to our nth defined type. More...
 
virtual Double_t volume (const char *rangeName) const
 
- Public Member Functions inherited from RooAbsCategory
 RooAbsCategory ()
 
 RooAbsCategory (const char *name, const char *title)
 Constructor. More...
 
 RooAbsCategory (const RooAbsCategory &other, const char *name=0)
 Copy constructor, copies the registered category states from the original. More...
 
virtual ~RooAbsCategory ()
 Destructor. More...
 
std::map< std::string, value_type >::const_iterator begin () const
 Iterator for category state names. Points to pairs of index and name. More...
 
RooAbsArgcreateFundamental (const char *newname=0) const
 Create a RooCategory fundamental object with our properties. More...
 
Roo1DTablecreateTable (const char *label) const
 Create a table matching the shape of this category. More...
 
std::map< std::string, value_type >::const_iterator end () const
 Iterator for category state names. Points to pairs of index and name. More...
 
virtual const char * getCurrentLabel () const
 Return label string of current state. More...
 
unsigned int getCurrentOrdinalNumber () const
 Return ordinal number of the current state. More...
 
const std::map< std::string, value_type >::value_typegetOrdinal (unsigned int n) const
 Return name and index of the nth defined state. More...
 
bool hasIndex (value_type index) const
 Check if a state with index index exists. More...
 
bool hasLabel (const std::string &label) const
 Check if a state with name label exists. More...
 
virtual Bool_t isIdentical (const RooAbsArg &other, Bool_t assumeSameType=kFALSE) const
 
virtual Bool_t isIntegrationSafeLValue (const RooArgSet *) const
 
Bool_t isSignType (Bool_t mustHaveZero=kFALSE) const
 Determine if category has 2 or 3 states with index values -1,0,1. More...
 
value_type lookupIndex (const std::string &stateName) const
 Find the index number corresponding to the state name. More...
 
const std::string & lookupName (value_type index) const
 Get the name corresponding to the given index. More...
 
Bool_t operator!= (value_type index)
 
Bool_t operator!= (const char *label)
 
Bool_t operator!= (const RooAbsArg &other)
 
Bool_t operator== (value_type index) const
 Equality operator with a integer (compares with state index number) More...
 
Bool_t operator== (const char *label) const
 Equality operator with a string (compares with state label string) More...
 
virtual Bool_t operator== (const RooAbsArg &other) const
 Equality operator with another RooAbsArg. More...
 
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. More...
 
virtual void printValue (std::ostream &os) const
 Print value (label name) More...
 
std::size_t size () const
 Number of states defined. More...
 
const RooCatTypelookupType (value_type index, Bool_t printError=kFALSE) const
 Find our type corresponding to the specified index, or return nullptr for no match. More...
 
const RooCatTypelookupType (const char *label, Bool_t printError=kFALSE) const
 Find our type corresponding to the specified label, or return 0 for no match. More...
 
const RooCatTypelookupType (const RooCatType &type, Bool_t printError=kFALSE) const
 Find our type that matches the specified type, or return 0 for no match. More...
 
TIteratortypeIterator () const
 
Int_t numTypes (const char *=0) const
 Return number of types defined (in range named rangeName if rangeName!=0) More...
 
Int_t getIndex () const
 Retrieve the current index. Use getCurrentIndex() for more clarity. More...
 
const char * getLabel () const
 Retrieve current label. Use getCurrentLabel() for more clarity. More...
 
- Public Member Functions inherited from RooAbsArg
 RooAbsArg ()
 Default constructor. More...
 
 RooAbsArg (const char *name, const char *title)
 Create an object with the specified name and descriptive title. More...
 
 RooAbsArg (const RooAbsArg &other, const char *name=0)
 Copy constructor transfers all boolean and string properties of the original object. More...
 
virtual ~RooAbsArg ()
 Destructor. More...
 
virtual TObjectClone (const char *newname=0) const
 Make a clone of an object using the Streamer facility. More...
 
virtual RooAbsArgcloneTree (const char *newname=0) const
 Clone tree expression of objects. More...
 
Bool_t dependsOn (const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
 Test whether we depend on (ie, are served by) any object in the specified collection. More...
 
Bool_t dependsOn (const RooAbsArg &server, const RooAbsArg *ignoreArg=0, Bool_t valueOnly=kFALSE) const
 Test whether we depend on (ie, are served by) the specified object. More...
 
Bool_t dependsOnValue (const RooAbsCollection &serverList, const RooAbsArg *ignoreArg=0) const
 Check whether this object depends on values from an element in the serverList. More...
 
Bool_t dependsOnValue (const RooAbsArg &server, const RooAbsArg *ignoreArg=0) const
 Check whether this object depends on values served from the object passed as server. More...
 
Bool_t hasClients () const
 
Bool_t isCloneOf (const RooAbsArg &other) const
 Check if this object was created as a clone of 'other'. More...
 
RooAbsArgoperator= (const RooAbsArg &other)
 Assign all boolean and string properties of the original object. More...
 
Bool_t overlaps (const RooAbsArg &testArg, Bool_t valueOnly=kFALSE) const
 Test if any of the nodes of tree are shared with that of the given tree. More...
 
TIteratorclientIterator () const
 Retrieve a client iterator. More...
 
TIteratorvalueClientIterator () const
 
TIteratorshapeClientIterator () const
 
TIteratorserverIterator () const
 
RooFIter valueClientMIterator () const
 
RooFIter shapeClientMIterator () const
 
RooFIter serverMIterator () const
 
RooArgSetgetDependents (const RooArgSet &set) const
 
RooArgSetgetDependents (const RooAbsData *set) const
 
RooArgSetgetDependents (const RooArgSet *depList) const
 
Bool_t dependentOverlaps (const RooAbsData *dset, const RooAbsArg &testArg) const
 
Bool_t dependentOverlaps (const RooArgSet *depList, const RooAbsArg &testArg) const
 
Bool_t checkDependents (const RooArgSet *nset) const
 
Bool_t recursiveCheckDependents (const RooArgSet *nset) const
 
const RefCountList_tclients () const
 List of all clients of this object. More...
 
const RefCountList_tvalueClients () const
 List of all value clients of this object. Value clients receive value updates. More...
 
const RefCountList_tshapeClients () const
 List of all shape clients of this object. More...
 
const RefCountList_tservers () const
 List of all servers of this object. More...
 
RooAbsArgfindServer (const char *name) const
 Return server of this with name name. Returns nullptr if not found. More...
 
RooAbsArgfindServer (const RooAbsArg &arg) const
 Return server of this that has the same name as arg. Returns nullptr if not found. More...
 
RooAbsArgfindServer (Int_t index) const
 Return i-th server from server list. More...
 
Bool_t isValueServer (const RooAbsArg &arg) const
 Check if this is serving values to arg. More...
 
Bool_t isValueServer (const char *name) const
 Check if this is serving values to an object with name name. More...
 
Bool_t isShapeServer (const RooAbsArg &arg) const
 Check if this is serving shape to arg. More...
 
Bool_t isShapeServer (const char *name) const
 Check if this is serving shape to an object with name name. More...
 
void leafNodeServerList (RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t recurseNonDerived=kFALSE) const
 Fill supplied list with all leaf nodes of the arg tree, starting with ourself as top node. More...
 
void branchNodeServerList (RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t recurseNonDerived=kFALSE) const
 Fill supplied list with all branch nodes of the arg tree starting with ourself as top node. More...
 
void treeNodeServerList (RooAbsCollection *list, const RooAbsArg *arg=0, Bool_t doBranch=kTRUE, Bool_t doLeaf=kTRUE, Bool_t valueOnly=kFALSE, Bool_t recurseNonDerived=kFALSE) const
 Fill supplied list with nodes of the arg tree, following all server links, starting with ourself as top node. More...
 
RooArgSetgetVariables (Bool_t stripDisconnected=kTRUE) const
 Return RooArgSet with all variables (tree leaf nodes of expresssion tree) More...
 
RooArgSetgetParameters (const RooAbsData *data, Bool_t stripDisconnected=kTRUE) const
 Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of the names of the variable list of the supplied data set (the dependents). More...
 
RooArgSetgetParameters (const RooAbsData &data, Bool_t stripDisconnected=kTRUE) const
 Return the parameters of this p.d.f when used in conjuction with dataset 'data'. More...
 
RooArgSetgetParameters (const RooArgSet &observables, Bool_t stripDisconnected=kTRUE) const
 Return the parameters of the p.d.f given the provided set of observables. More...
 
virtual RooArgSetgetParameters (const RooArgSet *depList, Bool_t stripDisconnected=kTRUE) const
 Create a list of leaf nodes in the arg tree starting with ourself as top node that don't match any of the names the args in the supplied argset. More...
 
RooArgSetgetObservables (const RooArgSet &set, Bool_t valueOnly=kTRUE) const
 Return the observables of this pdf given a set of observables. More...
 
RooArgSetgetObservables (const RooAbsData *data) const
 Create a list of leaf nodes in the arg tree starting with ourself as top node that match any of the names of the variable list of the supplied data set (the dependents). More...
 
RooArgSetgetObservables (const RooAbsData &data) const
 Return the observables of this pdf given the observables defined by data. More...
 
RooArgSetgetObservables (const RooArgSet *depList, Bool_t valueOnly=kTRUE) const
 Create a list of leaf nodes in the arg tree starting with ourself as top node that match any of the names the args in the supplied argset. More...
 
Bool_t observableOverlaps (const RooAbsData *dset, const RooAbsArg &testArg) const
 Test if any of the dependents of the arg tree (as determined by getObservables) overlaps with those of the testArg. More...
 
Bool_t observableOverlaps (const RooArgSet *depList, const RooAbsArg &testArg) const
 Test if any of the dependents of the arg tree (as determined by getObservables) overlaps with those of the testArg. More...
 
virtual Bool_t checkObservables (const RooArgSet *nset) const
 Overloadable function in which derived classes can implement consistency checks of the variables. More...
 
Bool_t recursiveCheckObservables (const RooArgSet *nset) const
 Recursively call checkObservables on all nodes in the expression tree. More...
 
RooArgSetgetComponents () const
 
void attachDataSet (const RooAbsData &set)
 Replace server nodes with names matching the dataset variable names with those data set variables, making this PDF directly dependent on the dataset. More...
 
void attachDataStore (const RooAbsDataStore &set)
 Replace server nodes with names matching the dataset variable names with those data set variables, making this PDF directly dependent on the dataset. More...
 
virtual void Print (Option_t *options=0) const
 Print the object to the defaultPrintStream(). More...
 
virtual void printName (std::ostream &os) const
 Print object name. More...
 
virtual void printTitle (std::ostream &os) const
 Print object title. More...
 
virtual void printClassName (std::ostream &os) const
 Print object class name. More...
 
virtual void printAddress (std::ostream &os) const
 Print class name of object. More...
 
virtual void printArgs (std::ostream &os) const
 Print object arguments, ie its proxies. More...
 
virtual void printMetaArgs (std::ostream &) const
 
virtual void printTree (std::ostream &os, TString indent="") const
 Print object tree structure. More...
 
virtual Int_t defaultPrintContents (Option_t *opt) const
 Define default contents to print. More...
 
void setAttribute (const Text_t *name, Bool_t value=kTRUE)
 Set (default) or clear a named boolean attribute of this object. More...
 
Bool_t getAttribute (const Text_t *name) const
 Check if a named attribute is set. By default, all attributes are unset. More...
 
const std::set< std::string > & attributes () const
 
void setStringAttribute (const Text_t *key, const Text_t *value)
 Associate string 'value' to this object under key 'key'. More...
 
const Text_tgetStringAttribute (const Text_t *key) const
 Get string attribute mapped under key 'key'. More...
 
const std::map< std::string, std::string > & stringAttributes () const
 
void setTransientAttribute (const Text_t *name, Bool_t value=kTRUE)
 Set (default) or clear a named boolean attribute of this object. More...
 
Bool_t getTransientAttribute (const Text_t *name) const
 Check if a named attribute is set. More...
 
const std::set< std::string > & transientAttributes () const
 
Bool_t isConstant () const
 Check if the "Constant" attribute is set. More...
 
RooLinkedList getCloningAncestors () const
 Return ancestors in cloning chain of this RooAbsArg. More...
 
Int_t Compare (const TObject *other) const
 Utility function used by TCollection::Sort to compare contained TObjects We implement comparison by name, resulting in alphabetical sorting by object name. More...
 
virtual Bool_t IsSortable () const
 
void printDirty (Bool_t depth=kTRUE) const
 Print information about current value dirty state information. More...
 
virtual void optimizeCacheMode (const RooArgSet &observables)
 Activate cache mode optimization with given definition of observables. More...
 
virtual void optimizeCacheMode (const RooArgSet &observables, RooArgSet &optNodes, RooLinkedList &processedNodes)
 Activate cache mode optimization with given definition of observables. More...
 
Bool_t findConstantNodes (const RooArgSet &observables, RooArgSet &cacheList)
 Find branch nodes with all-constant parameters, and add them to the list of nodes that can be cached with a dataset in a test statistic calculation. More...
 
Bool_t findConstantNodes (const RooArgSet &observables, RooArgSet &cacheList, RooLinkedList &processedNodes)
 Find branch nodes with all-constant parameters, and add them to the list of nodes that can be cached with a dataset in a test statistic calculation. More...
 
virtual void constOptimizeTestStatistic (ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE)
 Interface function signaling a request to perform constant term optimization. More...
 
virtual CacheMode canNodeBeCached () const
 
virtual void setCacheAndTrackHints (RooArgSet &)
 
void graphVizTree (const char *fileName, const char *delimiter="\, bool useTitle=false, bool useLatex=false)
 Create a GraphViz .dot file visualizing the expression tree headed by this RooAbsArg object. More...
 
void graphVizTree (std::ostream &os, const char *delimiter="\, bool useTitle=false, bool useLatex=false)
 Write the GraphViz representation of the expression tree headed by this RooAbsArg object to the given ostream. More...
 
void printComponentTree (const char *indent="", const char *namePat=0, Int_t nLevel=999)
 Print tree structure of expression tree on given ostream, only branch nodes are printed. More...
 
void printCompactTree (const char *indent="", const char *fileName=0, const char *namePat=0, RooAbsArg *client=0)
 Print tree structure of expression tree on stdout, or to file if filename is specified. More...
 
void printCompactTree (std::ostream &os, const char *indent="", const char *namePat=0, RooAbsArg *client=0)
 Print tree structure of expression tree on given ostream. More...
 
virtual void printCompactTreeHook (std::ostream &os, const char *ind="")
 Hook function interface for object to insert additional information when printed in the context of a tree structure. More...
 
Bool_t isShapeDirty () const
 
Bool_t isValueDirty () const
 
Bool_t isValueDirtyAndClear () const
 
Bool_t isValueOrShapeDirtyAndClear () const
 
void registerCache (RooAbsCache &cache)
 Register RooAbsCache with this object. More...
 
void unRegisterCache (RooAbsCache &cache)
 Unregister a RooAbsCache. Called from the RooAbsCache destructor. More...
 
Int_t numCaches () const
 Return number of registered caches. More...
 
RooAbsCachegetCache (Int_t index) const
 Return registered cache object by index. More...
 
OperMode operMode () const
 
void setOperMode (OperMode mode, Bool_t recurseADirty=kTRUE)
 Change cache operation mode to given mode. More...
 
Bool_t addOwnedComponents (const RooArgSet &comps)
 Take ownership of the contents of 'comps'. More...
 
const RooArgSetownedComponents () const
 
void setProhibitServerRedirect (Bool_t flag)
 
void setWorkspace (RooWorkspace &ws)
 
void setValueDirty ()
 Mark the element dirty. This forces a re-evaluation when a value is requested. More...
 
void setShapeDirty ()
 Notify that a shape-like property (e.g. binning) has changed. More...
 
const char * aggregateCacheUniqueSuffix () const
 
virtual const char * cacheUniqueSuffix () const
 
void wireAllCaches ()
 
const TNamednamePtr () const
 
void SetName (const char *name)
 Set the name of the TNamed. More...
 
void SetNameTitle (const char *name, const char *title)
 Set all the TNamed parameters (name and title). More...
 
Bool_t redirectServers (const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t isRecursionStep=kFALSE)
 Substitute our servers with those listed in newSet. More...
 
Bool_t recursiveRedirectServers (const RooAbsCollection &newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE)
 
virtual Bool_t redirectServersHook (const RooAbsCollection &, Bool_t, Bool_t, Bool_t)
 
virtual void serverNameChangeHook (const RooAbsArg *, const RooAbsArg *)
 
void addServer (RooAbsArg &server, Bool_t valueProp=kTRUE, Bool_t shapeProp=kFALSE, std::size_t refCount=1)
 Register another RooAbsArg as a server to us, ie, declare that we depend on it. More...
 
void addServerList (RooAbsCollection &serverList, Bool_t valueProp=kTRUE, Bool_t shapeProp=kFALSE)
 Register a list of RooAbsArg as servers to us by calling addServer() for each arg in the list. More...
 
void replaceServer (RooAbsArg &oldServer, RooAbsArg &newServer, Bool_t valueProp, Bool_t shapeProp)
 Replace 'oldServer' with 'newServer'. More...
 
void changeServer (RooAbsArg &server, Bool_t valueProp, Bool_t shapeProp)
 Change dirty flag propagation mask for specified server. More...
 
void removeServer (RooAbsArg &server, Bool_t force=kFALSE)
 Unregister another RooAbsArg as a server to us, ie, declare that we no longer depend on its value and shape. More...
 
RooAbsArgfindNewServer (const RooAbsCollection &newSet, Bool_t nameChange) const
 Find the new server in the specified set that matches the old server. More...
 
RooExpensiveObjectCacheexpensiveObjectCache () const
 
virtual void setExpensiveObjectCache (RooExpensiveObjectCache &cache)
 
virtual Bool_t importWorkspaceHook (RooWorkspace &ws)
 
void setLocalNoDirtyInhibit (Bool_t flag) const
 
Bool_t localNoDirtyInhibit () const
 
- Public Member Functions inherited from TNamed
 TNamed ()
 
 TNamed (const char *name, const char *title)
 
 TNamed (const TString &name, const TString &title)
 
 TNamed (const TNamed &named)
 TNamed copy ctor. More...
 
virtual ~TNamed ()
 TNamed destructor. More...
 
virtual void Clear (Option_t *option="")
 Set name and title to empty strings (""). More...
 
virtual void Copy (TObject &named) const
 Copy this to obj. More...
 
virtual void FillBuffer (char *&buffer)
 Encode TNamed into output buffer. More...
 
virtual const char * GetName () const
 Returns name of object. More...
 
virtual const char * GetTitle () const
 Returns title of object. More...
 
virtual ULong_t Hash () const
 Return hash value for this object. More...
 
virtual void ls (Option_t *option="") const
 List TNamed name and title. More...
 
TNamedoperator= (const TNamed &rhs)
 TNamed assignment operator. More...
 
virtual void SetTitle (const char *title="")
 Set the title of the TNamed. More...
 
virtual Int_t Sizeof () const
 Return size of the TNamed part of the TObject. More...
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor. More...
 
 TObject (const TObject &object)
 TObject copy ctor. More...
 
virtual ~TObject ()
 TObject destructor. More...
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract. More...
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad. More...
 
virtual void Browse (TBrowser *b)
 Browse object. May be overridden for another default action. More...
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object. More...
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs. More...
 
virtual void Delete (Option_t *option="")
 Delete this object. More...
 
virtual Int_t DistancetoPrimitive (Int_t px, Int_t py)
 Computes distance from point (px,py) to the object. More...
 
virtual void Draw (Option_t *option="")
 Default Draw method for all objects. More...
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs. More...
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad for instance with: gROOT->SetSelectedPad(gPad). More...
 
virtual void Dump () const
 Dump contents of object on stdout. More...
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message. More...
 
virtual void Execute (const char *method, const char *params, Int_t *error=0)
 Execute method on this object with the given parameter string, e.g. More...
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=0)
 Execute method on this object with parameters stored in the TObjArray. More...
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py). More...
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message. More...
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes. More...
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes. More...
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object. More...
 
virtual const char * GetIconName () const
 Returns mime type name of object. More...
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py). More...
 
virtual Option_tGetOption () const
 
virtual UInt_t GetUniqueID () const
 Return the unique object id. More...
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out. More...
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e. More...
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message. More...
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname". More...
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl. More...
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas. More...
 
void InvertBit (UInt_t f)
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory). More...
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More...
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary). More...
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification. More...
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete. More...
 
void operator delete (void *ptr)
 Operator delete. More...
 
void operator delete[] (void *ptr)
 Operator delete []. More...
 
voidoperator new (size_t sz)
 
voidoperator new (size_t sz, void *vp)
 
voidoperator new[] (size_t sz)
 
voidoperator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator. More...
 
virtual void Paint (Option_t *option="")
 This method must be overridden if a class wants to paint itself. More...
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list. More...
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory. More...
 
virtual void RecursiveRemove (TObject *obj)
 Recursively remove this object from a list. More...
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename. More...
 
virtual void SavePrimitive (std::ostream &out, Option_t *option="")
 Save a primitive as a C++ statement(s) on output stream "out". More...
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f. More...
 
void SetBit (UInt_t f)
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object. More...
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id. More...
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message. More...
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. More...
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message. More...
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory. More...
 
virtual Int_t Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory. More...
 
- Public Member Functions inherited from RooPrintable
 RooPrintable ()
 
virtual ~RooPrintable ()
 
virtual StyleOption defaultPrintStyle (Option_t *opt) const
 
virtual void printExtras (std::ostream &os) const
 Interface to print extras of object. More...
 
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, which is interpreted as an OR of 'enum ContentsOptions' values and in the style given by 'enum StyleOption'. More...
 
- Public Member Functions inherited from RooAbsLValue
 RooAbsLValue ()
 Constructor. More...
 
virtual ~RooAbsLValue ()
 Destructor. More...
 

Protected Member Functions

virtual value_type evaluate () const override
 Evaluate the category state and return. More...
 
void recomputeShape () override
 This category's shape does not depend on others, and does not need recomputing. More...
 
- Protected Member Functions inherited from RooAbsCategoryLValue
void copyCache (const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)
 Copy the cached value from given source and raise dirty flag. More...
 
- Protected Member Functions inherited from RooAbsCategory
virtual void attachToTree (TTree &t, Int_t bufSize=32000)
 Attach the category index and label as branches to the given TTree. More...
 
virtual void attachToVStore (RooVectorDataStore &vstore)
 Attach the category index and label to as branches to the given vector store. More...
 
void clearTypes ()
 Delete all currently defined states. More...
 
virtual const std::map< std::string, RooAbsCategory::value_type >::value_typedefineState (const std::string &label)
 Define a new state with given label. More...
 
virtual const std::map< std::string, RooAbsCategory::value_type >::value_typedefineState (const std::string &label, value_type index)
 Define new state with given name and index number. More...
 
void defineStateUnchecked (const std::string &label, value_type index)
 Internal version of defineState() that does not check if type already exists. More...
 
virtual void fillTreeBranch (TTree &t)
 Fill tree branches associated with current object with current value. More...
 
virtual bool isValid () const
 WVE (08/21/01) Probably obsolete now. More...
 
value_type nextAvailableStateIndex () const
 
RooCatTyperetrieveLegacyState (value_type index) const
 Return the legacy RooCatType corresponding to index. If it doesn't exist, create one. More...
 
virtual void setTreeBranchStatus (TTree &t, Bool_t active)
 (De)activate associate tree branch More...
 
const std::map< std::string, value_type > & stateNames () const
 Access the map of state names to index numbers. More...
 
std::map< std::string, value_type > & stateNames ()
 Access the map of state names to index numbers. More...
 
virtual void syncCache (const RooArgSet *set=0)
 Explicitly synchronize RooAbsCategory internal cache. More...
 
virtual Bool_t isValid (const RooCatType &value) const
 Check if given state is defined for this object. More...
 
const RooCatTypedefineType (const char *label)
 
const RooCatTypedefineType (const char *label, int index)
 
const RooCatTypedefineTypeUnchecked (const char *label, value_type index)
 
- Protected Member Functions inherited from RooAbsArg
void graphVizAddConnections (std::set< std::pair< RooAbsArg *, RooAbsArg *> > &)
 Utility function that inserts all point-to-point client-server connections between any two RooAbsArgs in the expression tree headed by this object in the linkSet argument. More...
 
virtual void operModeHook ()
 
virtual void optimizeDirtyHook (const RooArgSet *)
 
virtual void getParametersHook (const RooArgSet *, RooArgSet *, Bool_t) const
 
virtual void getObservablesHook (const RooArgSet *, RooArgSet *) const
 
void clearValueAndShapeDirty () const
 
void clearValueDirty () const
 
void clearShapeDirty () const
 
void setValueDirty (const RooAbsArg *source)
 Force element to re-evaluate itself when a value is requested. More...
 
void setShapeDirty (const RooAbsArg *source)
 Notify that a shape-like property (e.g. binning) has changed. More...
 
virtual void ioStreamerPass2 ()
 Method called by workspace container to finalize schema evolution issues that cannot be handled in a single ioStreamer pass. More...
 
void registerProxy (RooArgProxy &proxy)
 Register an RooArgProxy in the proxy list. More...
 
void registerProxy (RooSetProxy &proxy)
 Register an RooSetProxy in the proxy list. More...
 
void registerProxy (RooListProxy &proxy)
 Register an RooListProxy in the proxy list. More...
 
void unRegisterProxy (RooArgProxy &proxy)
 Remove proxy from proxy list. More...
 
void unRegisterProxy (RooSetProxy &proxy)
 Remove proxy from proxy list. More...
 
void unRegisterProxy (RooListProxy &proxy)
 Remove proxy from proxy list. More...
 
RooAbsProxygetProxy (Int_t index) const
 Return the nth proxy from the proxy list. More...
 
void setProxyNormSet (const RooArgSet *nset)
 Forward a change in the cached normalization argset to all the registered proxies. More...
 
Int_t numProxies () const
 Return the number of registered proxies. More...
 
void printAttribList (std::ostream &os) const
 Transient boolean attributes (not copied in ctor) More...
 
void attachToStore (RooAbsDataStore &store)
 Attach this argument to the data store such that it reads data from there. More...
 
TString cleanBranchName () const
 Construct a mangled name from the actual name that is free of any math symbols that might be interpreted by TTree. More...
 
Bool_t inhibitDirty () const
 Delete watch flag. More...
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected). More...
 
void MakeZombie ()
 

Private Types

using RangeMap_t = std::map< std::string, std::vector< value_type > >
 

Private Member Functions

void installLegacySharedProp (const RooCategorySharedProperties *sp)
 When reading old versions of the class, we get instances of shared properties. More...
 
void installSharedRange (std::unique_ptr< RangeMap_t > &&rangeMap)
 In current versions of the class, a map with ranges can be shared between instances. More...
 

Private Attributes

std::shared_ptr< RangeMap_t_ranges {new RangeMap_t()}
 Map range names to allowed category states. More...
 
RangeMap_t_rangesPointerForIO {nullptr}
 

Static Private Attributes

static std::map< std::string, std::weak_ptr< RangeMap_t > > _sharedRangeIOHelper
 
static std::map< std::string, std::weak_ptr< RangeMap_t > > _uuidToSharedRangeIOHelper
 

Additional Inherited Members

- Public Types inherited from RooAbsCategory
using value_type = int
 The type used to denote a specific category state. More...
 
- Public Types inherited from RooAbsArg
using RefCountList_t = RooSTLRefCountList< RooAbsArg >
 
using RefCountListLegacyIterator_t = TIteratorToSTLInterface< RefCountList_t::Container_t >
 
enum  ConstOpCode { Activate =0, DeActivate =1, ConfigChange =2, ValueChange =3 }
 
enum  CacheMode { Always =0, NotAdvised =1, Never =2 }
 
enum  OperMode { Auto =0, AClean =1, ADirty =2 }
 
- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000, kNotDeleted = 0x02000000, kZombie = 0x04000000, kInconsistent = 0x08000000,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = BIT(0), kOverwrite = BIT(1), kWriteDelete = BIT(2) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = BIT(3) }
 
enum  EStatusBits {
  kCanDelete = BIT(0), kMustCleanup = BIT(3), kIsReferenced = BIT(4), kHasUUID = BIT(5),
  kCannotPick = BIT(6), kNoContextMenu = BIT(8), kInvalidObject = BIT(13)
}
 
- Public Types inherited from RooPrintable
enum  ContentsOption {
  kName =1, kClassName =2, kValue =4, kArgs =8,
  kExtras =16, kAddress =32, kTitle =64, kCollectionHeader =128
}
 
enum  StyleOption {
  kInline =1, kSingleLine =2, kStandard =3, kVerbose =4,
  kTreeStructure =5
}
 
- Static Public Member Functions inherited from RooAbsArg
static void verboseDirty (Bool_t flag)
 Activate verbose messaging related to dirty flag propagation. More...
 
static void setDirtyInhibit (Bool_t flag)
 Control global dirty inhibit mode. More...
 
- Static Public Member Functions inherited from TObject
static Long_t GetDtorOnly ()
 Return destructor only flag. More...
 
static Bool_t GetObjectStat ()
 Get status of object stat flag. More...
 
static void SetDtorOnly (void *obj)
 Set destructor only flag. More...
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable. More...
 
- Static Public Member Functions inherited from RooPrintable
static std::ostream & defaultPrintStream (std::ostream *os=0)
 Return a reference to the current default stream to use in Print(). More...
 
static void nameFieldLength (Int_t newLen)
 Set length of field reserved from printing name of RooAbsArgs in multi-line collection printing to given amount. More...
 
- Static Protected Member Functions inherited from RooAbsCategory
static decltype(_stateNames) const ::value_typeinvalidCategory ()
 Is this category attached to a tree? More...
 
- Static Protected Member Functions inherited from RooAbsArg
static void ioStreamerPass2Finalize ()
 Method called by workspace container to finalize schema evolution issues that cannot be handled in a single ioStreamer pass. More...
 
- Protected Attributes inherited from RooAbsCategory
UChar_t _byteValue {0}
 Keeps track in which order state numbers have been inserted. Make sure this is updated in recomputeShape(). More...
 
value_type _currentIndex {std::numeric_limits<int>::min()}
 
std::vector< std::string > _insertionOrder
 Map state names to index numbers. Make sure state names are updated in recomputeShape(). More...
 
std::map< value_type, std::unique_ptr< RooCatType, std::function< void(RooCatType *)> > > _legacyStates
 Transient cache for byte values from tree branches. More...
 
std::map< std::string, value_type_stateNames
 Current category state. More...
 
bool _treeVar {false}
 Map holding pointers to RooCatType instances. Only for legacy interface. Don't use if possible. More...
 
- Protected Attributes inherited from RooAbsArg
RefCountList_t _serverList
 
RefCountList_t _clientList
 
RefCountList_t _clientListShape
 
RefCountList_t _clientListValue
 
RooRefArray _proxyList
 
std::deque< RooAbsCache * > _cacheList
 
std::set< std::string > _boolAttrib
 
std::map< std::string, std::string > _stringAttrib
 
std::set< std::string > _boolAttribTransient
 
Bool_t _deleteWatch
 
Bool_t _valueDirty
 
Bool_t _shapeDirty
 
bool _allBatchesDirty {true}
 
OperMode _operMode
 Mark batches as dirty (only meaningful for RooAbsReal). More...
 
Bool_t _fast
 
RooArgSet_ownedComponents
 
Bool_t _prohibitServerRedirect
 Set of owned component. More...
 
RooExpensiveObjectCache_eocache
 Prohibit server redirects – Debugging tool. More...
 
TNamed_namePtr
 
Bool_t _isConstant
 Do not persist. Pointer to global instance of string that matches object named. More...
 
Bool_t _localNoInhibitDirty
 Cached isConstant status. More...
 
RooWorkspace_myws
 Prevent 'AlwaysDirty' mode for this node. More...
 
- Protected Attributes inherited from TNamed
TString fName
 
TString fTitle
 
- Static Protected Attributes inherited from RooAbsArg
static Bool_t _verboseDirty
 
static Bool_t _inhibitDirty
 
- Static Protected Attributes inherited from RooPrintable
static Int_t _nameLength
 

#include <RooCategory.h>

Inheritance diagram for RooCategory:
[legend]

Member Typedef Documentation

◆ RangeMap_t

using RooCategory::RangeMap_t = std::map<std::string, std::vector<value_type> >
private

Definition at line 127 of file RooCategory.h.

Constructor & Destructor Documentation

◆ RooCategory() [1/4]

RooCategory::RooCategory ( )

Definition at line 103 of file RooCategory.cxx.

◆ RooCategory() [2/4]

RooCategory::RooCategory ( const char *  name,
const char *  title 
)

Constructor. Types must be defined using defineType() before variable can be used.

Definition at line 112 of file RooCategory.cxx.

◆ RooCategory() [3/4]

RooCategory::RooCategory ( const char *  name,
const char *  title,
const std::map< std::string, int > &  allowedStates 
)

Create a new category and define allowed states.

Parameters
[in]nameName used to refer to this object.
[in]titleTitle for e.g. plotting.
[in]allowedStatesMap of allowed states. Pass e.g. { {"0Lep", 0}, {"1Lep:, 1} }

Definition at line 127 of file RooCategory.cxx.

◆ RooCategory() [4/4]

RooCategory::RooCategory ( const RooCategory other,
const char *  name = 0 
)

Copy constructor.

Definition at line 139 of file RooCategory.cxx.

◆ ~RooCategory()

RooCategory::~RooCategory ( )
virtual

Destructor.

Definition at line 150 of file RooCategory.cxx.

Member Function Documentation

◆ addToRange() [1/2]

void RooCategory::addToRange ( const char *  name,
RooAbsCategory::value_type  stateIndex 
)

Add the given state to the given range.

Note
This creates or accesses a shared map with allowed ranges. All copies of this category will share this range such that a category inside a dataset and its counterpart on the outside will both see a modification of the range.

Definition at line 342 of file RooCategory.cxx.

◆ addToRange() [2/2]

void RooCategory::addToRange ( const char *  name,
const char *  stateNameList 
)

Add the list of state names to the given range.

State names can be separated with ','.

Note
This creates or accesses a shared map with allowed ranges. All copies of this category will share this range such that a category inside a dataset and its counterpart on the outside will both see a modification of the range.

Definition at line 366 of file RooCategory.cxx.

◆ clear()

void RooCategory::clear ( )
inline

Clear all defined category states.

Definition at line 64 of file RooCategory.h.

◆ clearRange()

void RooCategory::clearRange ( const char *  name,
Bool_t  silent 
)

Clear the named range.

Note
This affects all copies of this category, because they are sharing range definitions. This ensures that categories inside a dataset and their counterparts on the outside will both see a modification of the range.

Definition at line 315 of file RooCategory.cxx.

◆ clone()

virtual TObject* RooCategory::clone ( const char *  newname) const
inlineoverridevirtual

Implements RooAbsArg.

Definition at line 32 of file RooCategory.h.

◆ defineType() [1/2]

bool RooCategory::defineType ( const std::string &  label)

Define a state with given name.

The lowest available positive integer is assigned as index. Category state labels may not contain semicolons.

Returns
True in case of an error.

Definition at line 208 of file RooCategory.cxx.

◆ defineType() [2/2]

bool RooCategory::defineType ( const std::string &  label,
Int_t  index 
)

Define a state with given name and index.

Category state labels may not contain semicolons.

Returns
True in case of error.

Definition at line 224 of file RooCategory.cxx.

◆ defineTypes()

void RooCategory::defineTypes ( const std::map< std::string, int > &  allowedStates)

Define multiple states in a single call.

Use like:

myCat.defineTypes({ {"0Lep", 0}, {"1Lep", 1}, {"2Lep", 2}, {"3Lep", 3} });

Note: When labels or indices are defined multiple times, an error message is printed, and the corresponding state is ignored.

Definition at line 243 of file RooCategory.cxx.

◆ evaluate()

virtual value_type RooCategory::evaluate ( ) const
inlineoverrideprotectedvirtual

Evaluate the category state and return.

The returned state index should correspond to a state name that has been defined via e.g. defineType(). Returns the currently set state index. If this is invalid, returns the first-set index.

Implements RooAbsCategory.

Definition at line 109 of file RooCategory.h.

◆ getCurrentIndex()

virtual value_type RooCategory::getCurrentIndex ( ) const
inlinefinaloverridevirtual

Return current index.

Reimplemented from RooAbsCategory.

Definition at line 35 of file RooCategory.h.

◆ getValBatch()

virtual RooSpan<const value_type> RooCategory::getValBatch ( std::size_t  ,
std::size_t   
) const
inlineoverridevirtual

Retrieve a batch of category values for events in the range [begin, begin+batchSize).

Reimplemented from RooAbsCategory.

Definition at line 87 of file RooCategory.h.

◆ hasRange()

virtual bool RooCategory::hasRange ( const char *  rangeName) const
inlineoverridevirtual

Returns true if category has a range with given name defined.

Reimplemented from RooAbsArg.

Definition at line 99 of file RooCategory.h.

◆ inRange()

virtual Bool_t RooCategory::inRange ( const char *  rangeName) const
inlineoverridevirtual

Check if the currently defined category state is in the range with the given name.

If no ranges are defined, the state counts as being in range.

Reimplemented from RooAbsArg.

Definition at line 95 of file RooCategory.h.

◆ installLegacySharedProp()

void RooCategory::installLegacySharedProp ( const RooCategorySharedProperties props)
private

When reading old versions of the class, we get instances of shared properties.

Since these only contain ranges with numbers, just convert to vectors of numbers.

Definition at line 474 of file RooCategory.cxx.

◆ installSharedRange()

void RooCategory::installSharedRange ( std::unique_ptr< RangeMap_t > &&  rangeMap)
private

In current versions of the class, a map with ranges can be shared between instances.

If an instance with the same name alreday uses the same map, the instances will start sharing. Otherwise, this instance will be registered, and future copies being read will share with this one.

Definition at line 509 of file RooCategory.cxx.

◆ isDerived()

virtual Bool_t RooCategory::isDerived ( ) const
inlineoverridevirtual

Does our value or shape depend on any other arg? Always false for RooCategory.

Reimplemented from RooAbsArg.

Definition at line 83 of file RooCategory.h.

◆ isFundamental()

virtual Bool_t RooCategory::isFundamental ( ) const
inlineoverridevirtual

Tell whether we can be stored in a dataset. Always true for RooCategory.

Reimplemented from RooAbsArg.

Definition at line 78 of file RooCategory.h.

◆ isStateInRange() [1/2]

bool RooCategory::isStateInRange ( const char *  rangeName,
RooAbsCategory::value_type  stateIndex 
) const

Check if the state is in the given range.

If no range is specified either as argument or if no range has been defined for this category (i.e., the default range is meant), all category states count as being in range.

Definition at line 390 of file RooCategory.cxx.

◆ isStateInRange() [2/2]

bool RooCategory::isStateInRange ( const char *  rangeName,
const char *  stateName 
) const

Check if the state is in the given range.

If no range is specified (i.e., the default range), all category states count as being in range. This overload requires a name lookup. Recommend to use the category index with RooCategory::isStateInRange(const char*, RooAbsCategory::value_type) const.

Definition at line 408 of file RooCategory.cxx.

◆ operator=()

RooCategory& RooCategory::operator= ( const RooCategory )
delete

◆ operator[]()

RooAbsCategory::value_type & RooCategory::operator[] ( const std::string &  stateName)

Access a named state.

If a state with this name doesn't exist yet, the state is assigned the next available positive integer.

Parameters
[in]stateNameName of the state to be accessed.
Returns
Reference to the category index. If no state exists, it will be created on the fly.

Definition at line 255 of file RooCategory.cxx.

◆ readFromStream()

Bool_t RooCategory::readFromStream ( std::istream &  is,
Bool_t  compact,
Bool_t  verbose = kFALSE 
)
overridevirtual

Read object contents from given stream.

Reimplemented from RooAbsCategory.

Definition at line 286 of file RooCategory.cxx.

◆ recomputeShape()

void RooCategory::recomputeShape ( )
inlineoverrideprotectedvirtual

This category's shape does not depend on others, and does not need recomputing.

Implements RooAbsCategory.

Definition at line 123 of file RooCategory.h.

◆ setIndex() [1/3]

Bool_t RooCategory::setIndex ( Int_t  index,
bool  printError = true 
)
overridevirtual

Set value by specifying the index code of the desired state.

If printError is set, a message will be printed if the specified index does not represent a valid state.

Returns
bool signalling if an error occurred.

Implements RooAbsCategoryLValue.

Definition at line 163 of file RooCategory.cxx.

◆ setIndex() [2/3]

bool RooAbsCategoryLValue::setIndex
inline

Change category state to state specified by another category state.

If printError is set, a message will be printed if the specified index does not represent a valid state.

Note
The state name of the other category is ignored.
Returns
bool to signal an error.

Definition at line 45 of file RooAbsCategoryLValue.h.

◆ setIndex() [3/3]

virtual bool RooAbsCategoryLValue::setIndex

Change category state by specifying the index code of the desired state.

If printError is set, a message will be printed if the specified index does not represent a valid state.

Returns
bool to signal an error.

◆ setLabel() [1/4]

Bool_t RooCategory::setLabel ( const char *  label,
bool  printError = true 
)
overridevirtual

Set value by specifying the name of the desired state.

If printError is set, a message will be printed if the specified label does not represent a valid state.

Returns
false on success.

Implements RooAbsCategoryLValue.

Definition at line 185 of file RooCategory.cxx.

◆ setLabel() [2/4]

virtual bool RooAbsCategoryLValue::setLabel

Change category state by specifying a state name.

If printError is set, a message will be printed if the specified state name does not represent a valid state.

Returns
bool to signal an error.

◆ setLabel() [3/4]

bool RooAbsCategoryLValue::setLabel
inline

Change category state to the state name of another category.

If printError is set, a message will be printed if the specified state name does not represent a valid state.

Note
The state index of the other category is ignored.
Returns
bool to signal an error.

Definition at line 66 of file RooAbsCategoryLValue.h.

◆ setLabel() [4/4]

bool RooAbsCategoryLValue::setLabel
inline

Set value by specifying the name of the desired state.

If printError is set, a message will be printed if the specified label does not represent a valid state.

Returns
false on success.

Definition at line 57 of file RooAbsCategoryLValue.h.

◆ setRange()

void RooCategory::setRange ( const char *  rangeName,
const char *  stateNameList 
)

Definition at line 330 of file RooCategory.cxx.

◆ states()

std::map< std::string, RooAbsCategory::value_type > & RooCategory::states ( )

Return a reference to the map of state names to index states.

This can be used to manipulate the category.

Note
Calling this function will always trigger recomputations of of everything that depends on this category, since in case the map gets manipulated, names or indices might change. Also, the order that states have been inserted in gets lost. This changes what is returned by getOrdinal().

Definition at line 274 of file RooCategory.cxx.

◆ writeToStream()

void RooCategory::writeToStream ( std::ostream &  os,
Bool_t  compact 
) const
overridevirtual

compact only at the moment

Reimplemented from RooAbsCategory.

Definition at line 300 of file RooCategory.cxx.

Member Data Documentation

◆ _ranges

std::shared_ptr<RangeMap_t> RooCategory::_ranges {new RangeMap_t()}
private

Map range names to allowed category states.

Note that this must be shared between copies, so categories in datasets have the same ranges as their counterparts outside of the dataset.

Definition at line 130 of file RooCategory.h.

◆ _rangesPointerForIO

RangeMap_t* RooCategory::_rangesPointerForIO {nullptr}
private

Definition at line 131 of file RooCategory.h.

◆ _sharedRangeIOHelper

std::map< std::string, std::weak_ptr< RooCategory::RangeMap_t > > RooCategory::_sharedRangeIOHelper
staticprivate

Definition at line 138 of file RooCategory.h.

◆ _uuidToSharedRangeIOHelper

std::map< std::string, std::weak_ptr< RooCategory::RangeMap_t > > RooCategory::_uuidToSharedRangeIOHelper
staticprivate

Definition at line 136 of file RooCategory.h.

Libraries for RooCategory:
[legend]

The documentation for this class was generated from the following files: