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 ~RooAbsCategoryLValue() override = default;
35
36 // Value modifiers
37 ////////////////////////////////////////////////////////////////////////////////
38 /// Change category state by specifying the index code of the desired state.
39 /// If printError is set, a message will be printed if
40 /// the specified index does not represent a valid state.
41 /// \return bool to signal an error.
42 virtual bool setIndex(value_type index, bool printError = true) = 0;
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Change category state to state specified by another category state.
45 /// If printError is set, a message will be printed if
46 /// the specified index does not represent a valid state.
47 /// \note The state name of the other category is ignored.
48 /// \return bool to signal an error.
49 bool setIndex(const std::pair<std::string,value_type>& nameIdxPair, bool printError = true) {
50 return setIndex(nameIdxPair.second, printError);
51 }
52 bool setOrdinal(unsigned int index);
53
54 ////////////////////////////////////////////////////////////////////////////////
55 /// Change category state by specifying a state name.
56 /// If printError is set, a message will be printed if
57 /// the specified state name does not represent a valid state.
58 /// \return bool to signal an error.
59 virtual bool setLabel(const char* label, bool printError=true) = 0;
60 /// \copydoc setLabel(const char*, bool)
61 bool setLabel(const std::string& label, bool printError = true) {
62 return setLabel(label.c_str(), printError);
63 }
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Change category state to the state name of another category.
66 /// If printError is set, a message will be printed if
67 /// the specified state name does not represent a valid state.
68 /// \note The state index of the other category is ignored.
69 /// \return bool to signal an error.
70 bool setLabel(const std::pair<std::string,value_type>& nameIdxPair, bool printError = true) {
71 return setLabel(nameIdxPair.first.c_str(), printError);
72 }
73
74
76 RooAbsArg& operator=(const char* label) ;
77 RooAbsArg& operator=(const RooAbsCategory& other) ;
78
79 // Binned fit interface
80 void setBin(Int_t ibin, const char* rangeName=nullptr) override ;
81 /// Get the index of the plot bin for the current value of this category.
82 Int_t getBin(const char* /*rangeName*/=nullptr) const override {
84 }
85 Int_t numBins(const char* rangeName=nullptr) const override ;
86 double getBinWidth(Int_t /*i*/, const char* /*rangeName*/=nullptr) const override {
87 // Return volume of i-th bin (according to binning named rangeName if rangeName!=nullptr)
88 return 1.0 ;
89 }
90 double volume(const char* rangeName) const override {
91 // Return span of range with given name (=number of states included in this range)
92 return numTypes(rangeName) ;
93 }
94 void randomize(const char* rangeName=nullptr) override;
95
96 const RooAbsBinning* getBinningPtr(const char* /*rangeName*/) const override { return nullptr ; }
97 std::list<std::string> getBinningNames() const override { return std::list<std::string>(1, "") ; }
98 Int_t getBin(const RooAbsBinning* /*ptr*/) const override { return getBin((const char*)nullptr) ; }
99
100
101 inline void setConstant(bool value= true) {
102 // Declare category constant
103 setAttribute("Constant",value);
104 }
105
106 inline bool isLValue() const override {
107 // Object is an l-value
108 return true;
109 }
110
111protected:
112
113 friend class RooSimGenContext ;
115 /// \cond
116 /// \deprecated This function is useless. Use setIndex() instead.
117 virtual void setIndexFast(Int_t index) {
119 }
120 /// \endcond
121
122 void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDirty=true) override ;
123
124 ClassDefOverride(RooAbsCategoryLValue,1) // Abstract modifiable index variable
125};
126
127#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:79
void setAttribute(const Text_t *name, bool value=true)
Set (default) or clear a named boolean attribute of this object.
RooAbsBinning is the 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.
~RooAbsCategoryLValue() override=default
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.
RooSimGenContext is an efficient implementation of the generator context specific for RooSimultaneous...
RooSimSplitGenContext is an efficient implementation of the generator context specific for RooSimulta...