Logo ROOT  
Reference Guide
RooAbsCategoryLValue.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooAbsCategoryLValue.h,v 1.22 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_ABS_CATEGORY_LVALUE
17 #define ROO_ABS_CATEGORY_LVALUE
18 
19 #include "RooAbsCategory.h"
20 #include "RooAbsLValue.h"
21 #include <list>
22 #include <string>
23 #include <utility>
24 
26 public:
27  // Constructor, assignment etc.
29  // Default constructor
30  } ;
31  RooAbsCategoryLValue(const char *name, const char *title);
32  RooAbsCategoryLValue(const RooAbsCategoryLValue& other, const char* name=0) ;
33  virtual ~RooAbsCategoryLValue();
34 
35  // Value modifiers
36  ////////////////////////////////////////////////////////////////////////////////
37  /// Change category state by specifying the index code of the desired state.
38  /// If printError is set, a message will be printed if
39  /// the specified index does not represent a valid state.
40  /// \return bool to signal an error.
41  virtual bool setIndex(value_type index, bool printError = true) = 0;
42  ////////////////////////////////////////////////////////////////////////////////
43  /// Change category state to state specified by another category state.
44  /// If printError is set, a message will be printed if
45  /// the specified index does not represent a valid state.
46  /// \note The state name of the other category is ignored.
47  /// \return bool to signal an error.
48  bool setIndex(const std::pair<std::string,value_type>& nameIdxPair, bool printError = true) {
49  return setIndex(nameIdxPair.second, printError);
50  }
51  bool setOrdinal(unsigned int index);
52 
53  ////////////////////////////////////////////////////////////////////////////////
54  /// Change category state by specifying a state name.
55  /// If printError is set, a message will be printed if
56  /// the specified state name does not represent a valid state.
57  /// \return bool to signal an error.
58  virtual bool setLabel(const char* label, Bool_t printError=kTRUE) = 0;
59  /// \copydoc setLabel(const char*, Bool_t)
60  bool setLabel(const std::string& label, bool printError = true) {
61  return setLabel(label.c_str(), printError);
62  }
63  ////////////////////////////////////////////////////////////////////////////////
64  /// Change category state to the state name of another category.
65  /// If printError is set, a message will be printed if
66  /// the specified state name does not represent a valid state.
67  /// \note The state index of the other category is ignored.
68  /// \return bool to signal an error.
69  bool setLabel(const std::pair<std::string,value_type>& nameIdxPair, bool printError = true) {
70  return setLabel(nameIdxPair.first.c_str(), printError);
71  }
72 
73 
74  RooAbsArg& operator=(int index) ;
75  RooAbsArg& operator=(const char* label) ;
76  RooAbsArg& operator=(const RooAbsCategory& other) ;
77 
78  // Binned fit interface
79  virtual void setBin(Int_t ibin, const char* rangeName=0) ;
80  /// Get index of plot bin for current value this category.
81  virtual Int_t getBin(const char* /*rangeName*/) const {
82  return getCurrentOrdinalNumber();
83  }
84  virtual Int_t numBins(const char* rangeName) const ;
85  virtual Double_t getBinWidth(Int_t /*i*/, const char* /*rangeName*/=0) const {
86  // Return volume of i-th bin (according to binning named rangeName if rangeName!=0)
87  return 1.0 ;
88  }
89  virtual Double_t volume(const char* rangeName) const {
90  // Return span of range with given name (=number of states included in this range)
91  return numTypes(rangeName) ;
92  }
93  virtual void randomize(const char* rangeName=0);
94 
95  virtual const RooAbsBinning* getBinningPtr(const char* /*rangeName*/) const { return 0 ; }
96  virtual std::list<std::string> getBinningNames() const { return std::list<std::string>(1, "") ; }
97  virtual Int_t getBin(const RooAbsBinning* /*ptr*/) const { return getBin((const char*)0) ; }
98 
99 
100  inline void setConstant(Bool_t value= kTRUE) {
101  // Declare category constant
102  setAttribute("Constant",value);
103  }
104 
105  inline virtual Bool_t isLValue() const {
106  // Object is an l-value
107  return kTRUE;
108  }
109 
110 protected:
111 
112  friend class RooSimGenContext ;
113  friend class RooSimSplitGenContext ;
114  /// \cond
115  /// \deprecated This function is useless. Use setIndex() instead.
116  virtual void setIndexFast(Int_t index) {
117  _currentIndex = index;
118  }
119  /// \endcond
120 
121  void copyCache(const RooAbsArg* source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE) ;
122 
123  ClassDef(RooAbsCategoryLValue,1) // Abstract modifiable index variable
124 };
125 
126 #endif
RooAbsCategoryLValue::copyCache
void copyCache(const RooAbsArg *source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE)
Copy the cached value from given source and raise dirty flag.
Definition: RooAbsCategoryLValue.cxx:137
RooAbsCategoryLValue::setBin
virtual void setBin(Int_t ibin, const char *rangeName=0)
Set category to i-th fit bin, which is the i-th registered state.
Definition: RooAbsCategoryLValue.cxx:177
RooAbsCategoryLValue::setConstant
void setConstant(Bool_t value=kTRUE)
Definition: RooAbsCategoryLValue.h:100
RooAbsCategoryLValue::randomize
virtual void randomize(const char *rangeName=0)
Randomize current value.
Definition: RooAbsCategoryLValue.cxx:150
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooSimSplitGenContext
RooSimSplitGenContext is an efficient implementation of the generator context specific for RooSimulta...
Definition: RooSimSplitGenContext.h:27
RooAbsCategoryLValue::setOrdinal
bool setOrdinal(unsigned int index)
Set our state to our nth defined type.
Definition: RooAbsCategoryLValue.cxx:124
RooAbsCategoryLValue::setLabel
virtual bool setLabel(const char *label, Bool_t printError=kTRUE)=0
Change category state by specifying a state name.
RooAbsCategoryLValue::volume
virtual Double_t volume(const char *rangeName) const
Definition: RooAbsCategoryLValue.h:89
RooSimGenContext
RooSimGenContext is an efficient implementation of the generator context specific for RooSimultaneous...
Definition: RooSimGenContext.h:27
RooAbsCategory::numTypes
Int_t numTypes(const char *=0) const
Return number of types defined (in range named rangeName if rangeName!=0)
Definition: RooAbsCategory.h:129
bool
RooAbsCategory
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
Definition: RooAbsCategory.h:38
RooAbsLValue.h
RooAbsCategoryLValue::numBins
virtual Int_t numBins(const char *rangeName) const
Return the number of fit bins ( = number of types )
Definition: RooAbsCategoryLValue.cxx:203
RooAbsCategoryLValue::getBinningPtr
virtual const RooAbsBinning * getBinningPtr(const char *) const
Definition: RooAbsCategoryLValue.h:95
RooAbsCategoryLValue::setIndex
virtual bool setIndex(value_type index, bool printError=true)=0
Change category state by specifying the index code of the desired state.
RooAbsCategoryLValue::operator=
RooAbsArg & operator=(int index)
Assignment operator from integer index number.
Definition: RooAbsCategoryLValue.cxx:80
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooAbsBinning
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
Definition: RooAbsBinning.h:26
RooAbsCategory::_currentIndex
value_type _currentIndex
Definition: RooAbsCategory.h:215
RooAbsCategoryLValue::getBinWidth
virtual Double_t getBinWidth(Int_t, const char *=0) const
Definition: RooAbsCategoryLValue.h:85
RooAbsCategoryLValue::~RooAbsCategoryLValue
virtual ~RooAbsCategoryLValue()
Destructor.
Definition: RooAbsCategoryLValue.cxx:71
RooAbsCategoryLValue::RooAbsCategoryLValue
RooAbsCategoryLValue()
Definition: RooAbsCategoryLValue.h:28
RooAbsCategoryLValue::getBin
virtual Int_t getBin(const RooAbsBinning *) const
Definition: RooAbsCategoryLValue.h:97
RooAbsCategoryLValue::getBin
virtual Int_t getBin(const char *) const
Get index of plot bin for current value this category.
Definition: RooAbsCategoryLValue.h:81
Double_t
double Double_t
Definition: RtypesCore.h:59
RooAbsCategory.h
RooAbsCategoryLValue::isLValue
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?...
Definition: RooAbsCategoryLValue.h:105
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooAbsArg::setAttribute
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Definition: RooAbsArg.cxx:291
name
char name[80]
Definition: TGX11.cxx:110
RooAbsArg
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition: RooAbsArg.h:72
RooAbsLValue
Abstract base class for objects that are lvalues, i.e.
Definition: RooAbsLValue.h:26
RooAbsCategoryLValue
RooAbsCategoryLValue is the common abstract base class for objects that represent a discrete value th...
Definition: RooAbsCategoryLValue.h:25
RooAbsCategoryLValue::getBinningNames
virtual std::list< std::string > getBinningNames() const
Definition: RooAbsCategoryLValue.h:96
RooAbsCategory::getCurrentOrdinalNumber
unsigned int getCurrentOrdinalNumber() const
Return ordinal number of the current state.
Definition: RooAbsCategory.cxx:593
int