/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooCategory.h,v 1.27 2007/05/11 09:11:30 verkerke Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_CATEGORY
#define ROO_CATEGORY

#include "Riosfwd.h"
#include "RooAbsCategoryLValue.h"

#include "RooSharedPropertiesList.h"
#include "RooCategorySharedProperties.h"

class RooCategory : public RooAbsCategoryLValue {
public:
  // Constructor, assignment etc.
  RooCategory() ;
  RooCategory(const char *name, const char *title);
  RooCategory(const RooCategory& other, const char* name=0) ;
  virtual ~RooCategory();
  virtual TObject* clone(const char* newname) const { return new RooCategory(*this,newname); }

  // Value modifiers
  virtual Int_t getIndex() const { 
    return _value.getVal() ; 
    // Return index value
  }
  
  virtual const char* getLabel() const { 
    const char* ret = _value.GetName() ;
    if (ret==0) {
      _value.SetName(lookupType(_value.getVal())->GetName()) ;    
    }
    return _value.GetName() ;
  }

  virtual Bool_t setIndex(Int_t index, Bool_t printError=kTRUE) ;
  virtual Bool_t setLabel(const char* label, Bool_t printError=kTRUE) ;
  
  // I/O streaming interface (machine readable)
  virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
  virtual void writeToStream(std::ostream& os, Bool_t compact) const ;

  // We implement a fundamental type of AbsArg that can be stored in a dataset
  inline virtual Bool_t isFundamental() const { 
    // Return true as a RooCategory is a fundamental (non-derived) type
    return kTRUE; 
  }

  virtual Bool_t isDerived() const { 
    // Does value or shape of this arg depend on any other arg?
    return kFALSE ;
  }

  Bool_t defineType(const char* label) ;
  Bool_t defineType(const char* label, Int_t index) ;
  void clearTypes() { RooAbsCategory::clearTypes() ; }

  void clearRange(const char* name, Bool_t silent) ;
  void setRange(const char* rangeName, const char* stateNameList) ;
  void addToRange(const char* rangeName, const char* stateNameList) ;
  Bool_t isStateInRange(const char* rangeName, const char* stateName) const ;
  virtual Bool_t inRange(const char* rangeName) const { 
    // Returns true of current value of category is inside given range
    return isStateInRange(rangeName,getLabel()) ; 
  } 
  virtual Bool_t hasRange(const char* rangeName) const { 
    // Returns true if category has range with given name
    return _sharedProp->_altRanges.FindObject(rangeName) ? kTRUE : kFALSE ; 
  }
 
protected:
  
  static RooSharedPropertiesList _sharedPropList; // List of properties shared among clone sets 
  static RooCategorySharedProperties _nullProp ; // Null property
  RooCategorySharedProperties* _sharedProp ; //! Shared properties associated with this instance

  virtual RooCatType evaluate() const { 
    // Dummy implementation
    return RooCatType() ;
  } 

  ClassDef(RooCategory,2) // Discrete valued variable type
};

#endif
 RooCategory.h:1
 RooCategory.h:2
 RooCategory.h:3
 RooCategory.h:4
 RooCategory.h:5
 RooCategory.h:6
 RooCategory.h:7
 RooCategory.h:8
 RooCategory.h:9
 RooCategory.h:10
 RooCategory.h:11
 RooCategory.h:12
 RooCategory.h:13
 RooCategory.h:14
 RooCategory.h:15
 RooCategory.h:16
 RooCategory.h:17
 RooCategory.h:18
 RooCategory.h:19
 RooCategory.h:20
 RooCategory.h:21
 RooCategory.h:22
 RooCategory.h:23
 RooCategory.h:24
 RooCategory.h:25
 RooCategory.h:26
 RooCategory.h:27
 RooCategory.h:28
 RooCategory.h:29
 RooCategory.h:30
 RooCategory.h:31
 RooCategory.h:32
 RooCategory.h:33
 RooCategory.h:34
 RooCategory.h:35
 RooCategory.h:36
 RooCategory.h:37
 RooCategory.h:38
 RooCategory.h:39
 RooCategory.h:40
 RooCategory.h:41
 RooCategory.h:42
 RooCategory.h:43
 RooCategory.h:44
 RooCategory.h:45
 RooCategory.h:46
 RooCategory.h:47
 RooCategory.h:48
 RooCategory.h:49
 RooCategory.h:50
 RooCategory.h:51
 RooCategory.h:52
 RooCategory.h:53
 RooCategory.h:54
 RooCategory.h:55
 RooCategory.h:56
 RooCategory.h:57
 RooCategory.h:58
 RooCategory.h:59
 RooCategory.h:60
 RooCategory.h:61
 RooCategory.h:62
 RooCategory.h:63
 RooCategory.h:64
 RooCategory.h:65
 RooCategory.h:66
 RooCategory.h:67
 RooCategory.h:68
 RooCategory.h:69
 RooCategory.h:70
 RooCategory.h:71
 RooCategory.h:72
 RooCategory.h:73
 RooCategory.h:74
 RooCategory.h:75
 RooCategory.h:76
 RooCategory.h:77
 RooCategory.h:78
 RooCategory.h:79
 RooCategory.h:80
 RooCategory.h:81
 RooCategory.h:82
 RooCategory.h:83
 RooCategory.h:84
 RooCategory.h:85
 RooCategory.h:86
 RooCategory.h:87
 RooCategory.h:88
 RooCategory.h:89
 RooCategory.h:90
 RooCategory.h:91
 RooCategory.h:92
 RooCategory.h:93
 RooCategory.h:94
 RooCategory.h:95
 RooCategory.h:96
 RooCategory.h:97