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
22#include <list>
23#include <string>
24#include <utility> // for std::pair
25
27public:
28 // Constructor, assignment etc.
30 // Default constructor
31 }
32 RooAbsCategoryLValue(const char *name, const char *title);
33 RooAbsCategoryLValue(const RooAbsCategoryLValue& other, const char* name=nullptr) ;
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 printError=true) = 0;
59 /// \copydoc setLabel(const char*, bool)
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
75 RooAbsArg& operator=(const char* label) ;
76 RooAbsArg& operator=(const RooAbsCategory& other) ;
77
78 // Binned fit interface
79 void setBin(Int_t ibin, const char* rangeName=nullptr) override ;
80 /// Get the index of the plot bin for the current value of this category.
81 Int_t getBin(const char* /*rangeName*/=nullptr) const override {
83 }
84 Int_t numBins(const char* rangeName=nullptr) const override ;
85 double getBinWidth(Int_t /*i*/, const char* /*rangeName*/=nullptr) const override {
86 // Return volume of i-th bin (according to binning named rangeName if rangeName!=nullptr)
87 return 1.0 ;
88 }
89 double volume(const char* rangeName) const override {
90 // Return span of range with given name (=number of states included in this range)
91 return numTypes(rangeName) ;
92 }
93 void randomize(const char* rangeName=nullptr) override;
94
95 const RooAbsBinning* getBinningPtr(const char* /*rangeName*/) const override { return nullptr ; }
96 std::list<std::string> getBinningNames() const override { return std::list<std::string>(1, "") ; }
97 Int_t getBin(const RooAbsBinning* /*ptr*/) const override { return getBin((const char*)nullptr) ; }
98
99
100 inline void setConstant(bool value= true) {
101 // Declare category constant
102 setAttribute("Constant",value);
103 }
104
105 inline bool isLValue() const override {
106 // Object is an l-value
107 return true;
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) {
118 }
119 /// \endcond
120
121 void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDirty=true) override ;
122
123 ClassDefOverride(RooAbsCategoryLValue,1) // Abstract modifiable index variable
124};
125
126#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
Abstract base class for RooRealVar binning definitions.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
void randomize(const char *rangeName=nullptr) override
Randomize current value.
virtual bool setIndex(value_type index, bool printError=true)=0
Change category state by specifying the index code of the desired state.
bool isLValue() const override
Is this argument an l-value, i.e., can it appear on the left-hand side of an assignment expression?...
void copyCache(const RooAbsArg *source, bool valueOnly=false, bool setValDirty=true) override
Copy the cached value from given source and raise dirty flag.
Int_t getBin(const RooAbsBinning *) const override
Int_t numBins(const char *rangeName=nullptr) const override
Return the number of fit bins ( = number of types )
bool setOrdinal(unsigned int index)
Set our state to our nth defined type.
std::list< std::string > getBinningNames() const override
bool setIndex(const std::pair< std::string, value_type > &nameIdxPair, bool printError=true)
Change category state to state specified by another category state.
bool setLabel(const std::string &label, bool printError=true)
Change category state by specifying a state name.
bool setLabel(const std::pair< std::string, value_type > &nameIdxPair, bool printError=true)
Change category state to the state name of another category.
double getBinWidth(Int_t, const char *=nullptr) const override
void setConstant(bool value=true)
double volume(const char *rangeName) const override
RooAbsArg & operator=(int index)
Assignment operator from integer index number.
void setBin(Int_t ibin, const char *rangeName=nullptr) override
Set category to i-th fit bin, which is the i-th registered state.
const RooAbsBinning * getBinningPtr(const char *) const override
virtual bool setLabel(const char *label, bool printError=true)=0
Change category state by specifying a state name.
Int_t getBin(const char *=nullptr) const override
Get the index of the plot bin for the current value of this category.
A space to attach TBranches.
unsigned int getCurrentOrdinalNumber() const
Return ordinal number of the current state.
value_type _currentIndex
Current category state.
Int_t numTypes(const char *=nullptr) const
Return number of types defined (in range named rangeName if rangeName!=nullptr)
Abstract base class for objects that are lvalues, i.e.
Efficient implementation of the generator context specific for RooSimultaneous PDFs when generating m...
Efficient implementation of the generator context specific for RooSimultaneous PDFs when generating m...