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