Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
ParamHistFunc.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id: cranmer $
2 // Author: George Lewis, Kyle Cranmer
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 
12 #ifndef ROO_PARAMHISTFUNC
13 #define ROO_PARAMHISTFUNC
14 
15 #include <map>
16 #include "RooAbsReal.h"
17 #include "RooRealProxy.h"
18 #include "RooListProxy.h"
19 #include "RooObjCacheManager.h"
20 #include "RooDataHist.h"
21 
22 // Forward Declarations
23 class RooRealVar;
24 class RooArgList ;
25 class RooWorkspace;
26 class RooBinning;
27 
28 class ParamHistFunc : public RooAbsReal {
29 public:
30 
31  ParamHistFunc() ;
32  ParamHistFunc(const char *name, const char *title, const RooArgList& vars, const RooArgList& paramSet );
33  ParamHistFunc(const char *name, const char *title, const RooArgList& vars, const RooArgList& paramSet, const TH1* hist );
34  virtual ~ParamHistFunc() ;
35 
36  ParamHistFunc(const ParamHistFunc& other, const char* name = 0);
37  virtual TObject* clone(const char* newname) const { return new ParamHistFunc(*this, newname); }
38 
39  const RooArgList& paramList() const { return _paramSet ; }
40 
41  Int_t numBins() const { return _dataSet.numEntries(); } // Number of bins (called numEntries in RooDataHist)
42 
43  void setParamConst( Int_t, Bool_t=kTRUE );
44  void setConstant(bool constant);
45 
46  void setShape(TH1* shape);
47 
48  RooRealVar& getParameter() const ;
49  RooRealVar& getParameter( Int_t masterIdx ) const ;
50 
51  const RooArgSet* get(Int_t masterIdx) const { return _dataSet.get( masterIdx ) ; }
52  const RooArgSet* get(const RooArgSet& coord) const { return _dataSet.get( coord ) ; }
53 
54  double binVolume() const { return _dataSet.binVolume(); }
55 
56  virtual Bool_t forceAnalyticalInt(const RooAbsArg&) const { return kTRUE ; }
57 
58  Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& analVars, const RooArgSet* normSet,const char* rangeName=0) const ;
59  Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
60 
61  static RooArgList createParamSet(RooWorkspace& w, const std::string&, const RooArgList& Vars);
62  static RooArgList createParamSet(RooWorkspace& w, const std::string&, const RooArgList& Vars, Double_t, Double_t);
63  static RooArgList createParamSet(const std::string&, Int_t, Double_t, Double_t);
64 
65  virtual std::list<Double_t>* binBoundaries(RooAbsRealLValue& /*obs*/, Double_t /*xlo*/, Double_t /*xhi*/) const ;
66  virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const ;
67  virtual Bool_t isBinnedDistribution(const RooArgSet& /*obs*/) const {return kTRUE;}
68 
69 
70 protected:
71 
72  class CacheElem : public RooAbsCacheElement {
73  public:
74  CacheElem() {} ;
75  virtual ~CacheElem() {} ;
76  virtual RooArgList containedArgs(Action) {
77  RooArgList ret(_funcIntList) ;
78  ret.add(_lowIntList);
79  ret.add(_highIntList);
80  return ret ;
81  }
82  RooArgList _funcIntList ;
83  RooArgList _lowIntList ;
84  RooArgList _highIntList ;
85  // will want std::vector<RooRealVar*> for low and high also
86  } ;
87  mutable RooObjCacheManager _normIntMgr ; // The integration cache manager
88 
89  // Turn into a RooListProxy
90  //RooRealProxy _dataVar; // The RooRealVar
91  RooListProxy _dataVars; // The RooRealVars
92  RooListProxy _paramSet ; // interpolation parameters
93  //RooAbsBinning* _binning; // Holds the binning of the dataVar (at construction time)
94 
95  Int_t _numBins;
96  mutable std::map<Int_t, Int_t> _binMap;
97  mutable RooDataHist _dataSet;
98  //Bool_t _normalized;
99 
100  // std::vector< Double_t > _nominalVals; // The nominal vals when gamma = 1.0 ( = 1.0 by default)
101  RooArgList _ownedList ; // List of owned components
102 
103  Int_t getCurrentBin() const ;
104  Int_t addVarSet( const RooArgList& vars );
105  Int_t addParamSet( const RooArgList& params );
106  static Int_t GetNumBins( const RooArgSet& vars );
107  Double_t evaluate() const;
108 
109  ClassDef(ParamHistFunc,5) // Sum of RooAbsReal objects
110 };
111 
112 #endif