Logo ROOT  
Reference Guide
Go to the documentation of this file.
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooCategory.h,v 1.27 2007/05/11 09:11:30 verkerke Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_CATEGORY
17#define ROO_CATEGORY
26 // Constructor, assignment etc.
27 RooCategory() ;
28 RooCategory(const char *name, const char *title);
29 RooCategory(const RooCategory& other, const char* name=0) ;
30 virtual ~RooCategory();
31 virtual TObject* clone(const char* newname) const { return new RooCategory(*this,newname); }
33 // Value modifiers
34 virtual Int_t getIndex() const {
35 return _value.getVal() ;
36 // Return index value
37 }
39 virtual const char* getLabel() const {
40 const char* ret = _value.GetName() ;
41 if (ret==0) {
43 }
44 return _value.GetName() ;
45 }
47 virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE) ;
48 virtual Bool_t setLabel(const char* label, Bool_t printError=kTRUE) ;
50 // I/O streaming interface (machine readable)
51 virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
52 virtual void writeToStream(std::ostream& os, Bool_t compact) const ;
54 // We implement a fundamental type of AbsArg that can be stored in a dataset
55 inline virtual Bool_t isFundamental() const {
56 // Return true as a RooCategory is a fundamental (non-derived) type
57 return kTRUE;
58 }
60 virtual Bool_t isDerived() const {
61 // Does value or shape of this arg depend on any other arg?
62 return kFALSE ;
63 }
65 Bool_t defineType(const char* label) ;
66 Bool_t defineType(const char* label, Int_t index) ;
69 void clearRange(const char* name, Bool_t silent) ;
70 void setRange(const char* rangeName, const char* stateNameList) ;
71 void addToRange(const char* rangeName, const char* stateNameList) ;
72 Bool_t isStateInRange(const char* rangeName, const char* stateName) const ;
73 virtual Bool_t inRange(const char* rangeName) const {
74 // Returns true of current value of category is inside given range
75 return isStateInRange(rangeName,getLabel()) ;
76 }
77 virtual Bool_t hasRange(const char* rangeName) const {
78 // Returns true if category has range with given name
79 return _sharedProp->_altRanges.FindObject(rangeName) ? kTRUE : kFALSE ;
80 }
84 static RooSharedPropertiesList _sharedPropList; // List of properties shared among clone sets
85 static RooCategorySharedProperties _nullProp ; // Null property
86 RooCategorySharedProperties* _sharedProp ; //! Shared properties associated with this instance
88 virtual RooCatType evaluate() const {
89 // Dummy implementation
90 return RooCatType() ;
91 }
93 ClassDef(RooCategory,2) // Discrete valued variable type
int Int_t
Definition: RtypesCore.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kTRUE
Definition: RtypesCore.h:87
#define ClassDef(name, id)
Definition: Rtypes.h:326
char name[80]
Definition: TGX11.cxx:109
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
RooCatType _value
Transient cache for byte values from tree branches.
const RooCatType * lookupType(Int_t index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return 0 for no match.
void clearTypes()
Delete all currently defined states.
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state.
Definition: RooCatType.h:22
virtual const Text_t * GetName() const
Returns name of object.
Definition: RooCatType.h:44
void SetName(const Text_t *name)
Constructor with name argument.
Definition: RooCatType.cxx:46
Int_t getVal() const
Definition: RooCatType.h:79
RooCategorySharedProperties is the container for all properties that are shared between instance of R...
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:24
RooCategorySharedProperties * _sharedProp
Definition: RooCategory.h:86
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from given stream.
void setRange(const char *rangeName, const char *stateNameList)
void clearTypes()
Definition: RooCategory.h:67
virtual Bool_t inRange(const char *rangeName) const
Definition: RooCategory.h:73
virtual Bool_t isDerived() const
Does value or shape of this arg depend on any other arg?
Definition: RooCategory.h:60
virtual ~RooCategory()
Definition: RooCategory.cxx:88
static RooSharedPropertiesList _sharedPropList
Definition: RooCategory.h:84
void addToRange(const char *rangeName, const char *stateNameList)
Check that both input arguments are not null pointers.
virtual const char * getLabel() const
Return label string of current state.
Definition: RooCategory.h:39
virtual void writeToStream(std::ostream &os, Bool_t compact) const
compact only at the moment
virtual Bool_t hasRange(const char *rangeName) const
Definition: RooCategory.h:77
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set value by specifying the name of the desired state If printError is set, a message will be printed...
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index.
void clearRange(const char *name, Bool_t silent)
Check that both input arguments are not null pointers.
virtual TObject * clone(const char *newname) const
Definition: RooCategory.h:31
virtual RooCatType evaluate() const
Shared properties associated with this instance.
Definition: RooCategory.h:88
virtual Bool_t isFundamental() const
Is this object a fundamental type that can be added to a dataset? Fundamental-type subclasses overrid...
Definition: RooCategory.h:55
virtual Int_t getIndex() const
Return index number of current state.
Definition: RooCategory.h:34
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
Bool_t isStateInRange(const char *rangeName, const char *stateName) const
If no range is specified [ i.e. the default range ] all category states are in range.
static RooCategorySharedProperties _nullProp
Definition: RooCategory.h:85
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
Class RooSharedPropertiesList maintains the properties of RooRealVars and RooCategories that are clon...
Mother of all ROOT objects.
Definition: TObject.h:37