Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 class RooAbsCategoryLValue : public RooAbsCategory, public RooAbsLValue {
23 public:
24  // Constructor, assignment etc.
25  RooAbsCategoryLValue() {
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  virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE) = 0 ;
34  virtual Bool_t setLabel(const char* label, Bool_t printError=kTRUE) = 0 ;
35  RooAbsArg& operator=(int index) ;
36  RooAbsArg& operator=(const char* label) ;
37  RooAbsArg& operator=(const RooAbsCategory& other) ;
38 
39  // Binned fit interface
40  virtual void setBin(Int_t ibin, const char* rangeName=0) ;
41  virtual Int_t getBin(const char* rangeName=0) const ;
42  virtual Int_t numBins(const char* rangeName) const ;
43  virtual Double_t getBinWidth(Int_t /*i*/, const char* /*rangeName*/=0) const {
44  // Return volume of i-th bin (according to binning named rangeName if rangeName!=0)
45  return 1.0 ;
46  }
47  virtual Double_t volume(const char* rangeName) const {
48  // Return span of range with given name (=number of states included in this range)
49  return numTypes(rangeName) ;
50  }
51  virtual void randomize(const char* rangeName=0);
52 
53  virtual const RooAbsBinning* getBinningPtr(const char* /*rangeName*/) const { return 0 ; }
54  virtual std::list<std::string> getBinningNames() const { return std::list<std::string>(1, "") ; }
55  virtual Int_t getBin(const RooAbsBinning* /*ptr*/) const { return getBin((const char*)0) ; }
56 
57 
58  inline void setConstant(Bool_t value= kTRUE) {
59  // Declare category constant
60  setAttribute("Constant",value);
61  }
62 
63  inline virtual Bool_t isLValue() const {
64  // Object is an l-value
65  return kTRUE;
66  }
67 
68  // I/O streaming interface (machine readable)
69  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
70  virtual void writeToStream(std::ostream& os, Bool_t compact) const ;
71 
72 protected:
73 
74  friend class RooSimGenContext ;
75  friend class RooSimSplitGenContext ;
76  virtual void setIndexFast(Int_t index) { _value._value = index ; _value._label[0]=0 ; }
77 
78  Bool_t setOrdinal(UInt_t index, const char* rangeName);
79  void copyCache(const RooAbsArg* source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE) ;
80 
81  ClassDef(RooAbsCategoryLValue,1) // Abstract modifiable index variable
82 };
83 
84 #endif