Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
26public:
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 {
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
110protected:
111
112 friend class RooSimGenContext ;
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
const Bool_t kFALSE
Definition RtypesCore.h:92
double Double_t
Definition RtypesCore.h:59
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassDef(name, id)
Definition Rtypes.h:325
char name[80]
Definition TGX11.cxx:110
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
Definition RooAbsArg.h:72
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
RooAbsBinning is the abstract base class for RooRealVar binning definitions.
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.
RooSimGenContext is an efficient implementation of the generator context specific for RooSimultaneous...
RooSimSplitGenContext is an efficient implementation of the generator context specific for RooSimulta...