Logo ROOT   6.07/09
Reference Guide
RooCategory.h
Go to the documentation of this file.
1 /*****************************************************************************
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
18 
19 #include "Riosfwd.h"
20 #include "RooAbsCategoryLValue.h"
21 
24 
26 public:
27  // Constructor, assignment etc.
28  RooCategory() ;
29  RooCategory(const char *name, const char *title);
30  RooCategory(const RooCategory& other, const char* name=0) ;
31  virtual ~RooCategory();
32  virtual TObject* clone(const char* newname) const { return new RooCategory(*this,newname); }
33 
34  // Value modifiers
35  virtual Int_t getIndex() const {
36  return _value.getVal() ;
37  // Return index value
38  }
39 
40  virtual const char* getLabel() const {
41  const char* ret = _value.GetName() ;
42  if (ret==0) {
44  }
45  return _value.GetName() ;
46  }
47 
48  virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE) ;
49  virtual Bool_t setLabel(const char* label, Bool_t printError=kTRUE) ;
50 
51  // I/O streaming interface (machine readable)
52  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
53  virtual void writeToStream(std::ostream& os, Bool_t compact) const ;
54 
55  // We implement a fundamental type of AbsArg that can be stored in a dataset
56  inline virtual Bool_t isFundamental() const {
57  // Return true as a RooCategory is a fundamental (non-derived) type
58  return kTRUE;
59  }
60 
61  virtual Bool_t isDerived() const {
62  // Does value or shape of this arg depend on any other arg?
63  return kFALSE ;
64  }
65 
66  Bool_t defineType(const char* label) ;
67  Bool_t defineType(const char* label, Int_t index) ;
69 
70  void clearRange(const char* name, Bool_t silent) ;
71  void setRange(const char* rangeName, const char* stateNameList) ;
72  void addToRange(const char* rangeName, const char* stateNameList) ;
73  Bool_t isStateInRange(const char* rangeName, const char* stateName) const ;
74  virtual Bool_t inRange(const char* rangeName) const {
75  // Returns true of current value of category is inside given range
76  return isStateInRange(rangeName,getLabel()) ;
77  }
78  virtual Bool_t hasRange(const char* rangeName) const {
79  // Returns true if category has range with given name
80  return _sharedProp->_altRanges.FindObject(rangeName) ? kTRUE : kFALSE ;
81  }
82 
83 protected:
84 
85  static RooSharedPropertiesList _sharedPropList; // List of properties shared among clone sets
86  static RooCategorySharedProperties _nullProp ; // Null property
87  RooCategorySharedProperties* _sharedProp ; //! Shared properties associated with this instance
88 
89  virtual RooCatType evaluate() const {
90  // Dummy implementation
91  return RooCatType() ;
92  }
93 
94  ClassDef(RooCategory,2) // Discrete valued variable type
95 };
96 
97 #endif
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.
virtual Int_t getIndex() const
Return index number of current state.
Definition: RooCategory.h:35
void clearTypes()
Definition: RooCategory.h:68
virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE)
Set value by specifying the index code of the desired state.
RooCatType _value
Transient cache for byte values from tree branches.
virtual RooCatType evaluate() const
Shared properties associated with this instance.
Definition: RooCategory.h:89
void clearRange(const char *name, Bool_t silent)
Check that both input arguments are not null pointers.
void clearTypes()
Delete all currently defined states.
virtual TObject * clone(const char *newname) const
Definition: RooCategory.h:32
virtual Bool_t hasRange(const char *rangeName) const
Definition: RooCategory.h:78
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
RooCategorySharedProperties is the container for all properties that are shared between instance of R...
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from given stream.
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...
#define ClassDef(name, id)
Definition: Rtypes.h:254
static RooSharedPropertiesList _sharedPropList
Definition: RooCategory.h:85
RooCatType is an auxilary class for RooAbsCategory and defines a a single category state...
Definition: RooCatType.h:23
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
void addToRange(const char *rangeName, const char *stateNameList)
Check that both input arguments are not null pointers.
RooCategorySharedProperties * _sharedProp
Definition: RooCategory.h:87
virtual Bool_t isDerived() const
Definition: RooCategory.h:61
bool verbose
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
TObject * FindObject(const char *name) const
Return pointer to obejct with given name.
virtual Bool_t isFundamental() const
Definition: RooCategory.h:56
RooCategory represents a fundamental (non-derived) discrete value object.
Definition: RooCategory.h:25
static RooCategorySharedProperties _nullProp
Definition: RooCategory.h:86
Int_t getVal() const
Definition: RooCatType.h:80
Class RooSharedPropertiesList maintains the properties of RooRealVars and RooCategories that are clon...
virtual void SetName(const Text_t *name)
Constructor with name argument.
Definition: RooCatType.cxx:47
Mother of all ROOT objects.
Definition: TObject.h:44
virtual ~RooCategory()
Destructor.
Definition: RooCategory.cxx:89
virtual void writeToStream(std::ostream &os, Bool_t compact) const
compact only at the moment
Bool_t defineType(const char *label)
Define a state with given name, the lowest available positive integer is assigned as index...
virtual Bool_t inRange(const char *rangeName) const
Definition: RooCategory.h:74
const Bool_t kTRUE
Definition: Rtypes.h:91
void setRange(const char *rangeName, const char *stateNameList)
virtual const Text_t * GetName() const
Returns name of object.
Definition: RooCatType.h:45
char name[80]
Definition: TGX11.cxx:109
virtual const char * getLabel() const
Return label string of current state.
Definition: RooCategory.h:40
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.