Logo ROOT  
Reference Guide
RooGrid.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id: RooGrid.h,v 1.10 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_GRID
17 #define ROO_GRID
18 
19 #include "TObject.h"
20 #include "RooPrintable.h"
21 
22 class RooAbsFunc;
23 
24 class RooGrid : public TObject, public RooPrintable {
25 public:
26  RooGrid() ;
27  RooGrid(const RooAbsFunc &function);
28  virtual ~RooGrid();
29 
30  // Printing interface
31  virtual void printName(std::ostream& os) const ;
32  virtual void printTitle(std::ostream& os) const ;
33  virtual void printClassName(std::ostream& os) const ;
34  virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const;
35 
36  inline virtual void Print(Option_t *options= 0) const {
38  }
39 
40  inline Bool_t isValid() const { return _valid; }
41  inline UInt_t getDimension() const { return _dim; }
42  inline Double_t getVolume() const { return _vol; }
43  inline UInt_t getNBins() const { return _bins; }
44  inline UInt_t getNBoxes() const { return _boxes; }
45  inline void setNBoxes(UInt_t boxes) { _boxes= boxes; }
46 
47  inline Double_t *createPoint() const { return _valid ? new Double_t[_dim] : 0; }
48  inline UInt_t *createIndexVector() const { return _valid ? new UInt_t[_dim] : 0; }
49 
50  Bool_t initialize(const RooAbsFunc &function);
51  void resize(UInt_t bins);
52  void resetValues();
53  void generatePoint(const UInt_t box[], Double_t x[], UInt_t bin[],
54  Double_t &vol, Bool_t useQuasiRandom= kTRUE) const;
55  void accumulate(const UInt_t bin[], Double_t amount);
56  void refine(Double_t alpha= 1.5);
57 
58  void firstBox(UInt_t box[]) const;
59  Bool_t nextBox(UInt_t box[]) const;
60 
61  enum { maxBins = 50 }; // must be even
62 
63  // Accessor for the j-th normalized grid point along the i-th dimension
64 public:
65  inline Double_t coord(Int_t i, Int_t j) const { return _xi[i*_dim + j]; }
66  inline Double_t value(Int_t i,Int_t j) const { return _d[i*_dim + j]; }
67 protected:
68  inline Double_t& coord(Int_t i, Int_t j) { return _xi[i*_dim + j]; }
69  inline Double_t& value(Int_t i,Int_t j) { return _d[i*_dim + j]; }
70  inline Double_t& newCoord(Int_t i) { return _xin[i]; }
71 
72 protected:
73 
74  Bool_t _valid; // Is configuration valid
75  UInt_t _dim,_bins,_boxes; // Number of dimensions, bins and boxes
76  Double_t _vol; // Volume
77 
78  Double_t *_xl; //! Internal workspace
79  Double_t *_xu; //! Internal workspace
80  Double_t *_delx; //! Internal workspace
81  Double_t *_d; //! Internal workspace
82  Double_t *_xi; //! Internal workspace
83  Double_t *_xin; //! Internal workspace
84  Double_t *_weight; //! Internal workspace
85 
86  ClassDef(RooGrid,1) // Utility class for RooMCIntegrator holding a multi-dimensional grid
87 };
88 
89 #endif
90 
91 
RooGrid::_valid
Bool_t _valid
Definition: RooGrid.h:74
RooGrid::value
Double_t value(Int_t i, Int_t j) const
Definition: RooGrid.h:66
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooGrid::newCoord
Double_t & newCoord(Int_t i)
Definition: RooGrid.h:70
RooGrid::accumulate
void accumulate(const UInt_t bin[], Double_t amount)
Add the specified amount to bin[j] of the 1D histograms associated with each axis j.
Definition: RooGrid.cxx:326
RooGrid::getDimension
UInt_t getDimension() const
Definition: RooGrid.h:41
RooGrid::_delx
Double_t * _delx
Internal workspace.
Definition: RooGrid.h:80
RooGrid::resetValues
void resetValues()
Reset the values associated with each grid cell.
Definition: RooGrid.cxx:181
RooGrid::_d
Double_t * _d
Internal workspace.
Definition: RooGrid.h:81
RooGrid::_xu
Double_t * _xu
Internal workspace.
Definition: RooGrid.h:79
RooGrid::nextBox
Bool_t nextBox(UInt_t box[]) const
Update the specified array of box indices to refer to the next box in the standard traversal order an...
Definition: RooGrid.cxx:258
RooGrid::createIndexVector
UInt_t * createIndexVector() const
Definition: RooGrid.h:48
RooPrintable.h
box
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
x
Double_t x[n]
Definition: legend1.C:17
indent
static void indent(ostringstream &buf, int indent_level)
Definition: TClingCallFunc.cxx:87
RooGrid::getNBoxes
UInt_t getNBoxes() const
Definition: RooGrid.h:44
RooGrid::_bins
UInt_t _bins
Definition: RooGrid.h:75
TString
Definition: TString.h:136
RooPrintable
Definition: RooPrintable.h:25
RooGrid::isValid
Bool_t isValid() const
Definition: RooGrid.h:40
RooGrid::createPoint
Double_t * createPoint() const
Definition: RooGrid.h:47
bool
RooAbsFunc
Definition: RooAbsFunc.h:23
RooGrid::initialize
Bool_t initialize(const RooAbsFunc &function)
Calculate and store the grid dimensions and volume using the specified function, and initialize the g...
Definition: RooGrid.cxx:108
RooGrid::_xi
Double_t * _xi
Internal workspace.
Definition: RooGrid.h:82
RooPrintable::defaultPrintContents
virtual Int_t defaultPrintContents(Option_t *opt) const
Default choice of contents to be printed (name and value)
Definition: RooPrintable.cxx:233
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
RooGrid::_xin
Double_t * _xin
Internal workspace.
Definition: RooGrid.h:83
RooGrid::_xl
Double_t * _xl
Definition: RooGrid.h:78
RooPrintable::defaultPrintStream
static std::ostream & defaultPrintStream(std::ostream *os=0)
Return a reference to the current default stream to use in Print().
Definition: RooPrintable.cxx:272
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
RooGrid::printMultiline
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print info about this object to the specified stream.
Definition: RooGrid.cxx:277
RooGrid::coord
Double_t coord(Int_t i, Int_t j) const
Definition: RooGrid.h:65
RooGrid::firstBox
void firstBox(UInt_t box[]) const
Reset the specified array of box indices to refer to the first box in the standard traversal order.
Definition: RooGrid.cxx:246
RooGrid::refine
void refine(Double_t alpha=1.5)
Refine the grid using the values that have been accumulated so far.
Definition: RooGrid.cxx:338
RooGrid::getNBins
UInt_t getNBins() const
Definition: RooGrid.h:43
RooGrid::printName
virtual void printName(std::ostream &os) const
Print name of grid object.
Definition: RooGrid.cxx:297
RooGrid::generatePoint
void generatePoint(const UInt_t box[], Double_t x[], UInt_t bin[], Double_t &vol, Bool_t useQuasiRandom=kTRUE) const
Generate a random vector in the specified box and and store its coordinates in the x[] array provided...
Definition: RooGrid.cxx:198
unsigned int
RooGrid::resize
void resize(UInt_t bins)
Adjust the subdivision of each axis to give the specified number of bins, using an algorithm that pre...
Definition: RooGrid.cxx:144
RooGrid::~RooGrid
virtual ~RooGrid()
Destructor.
Definition: RooGrid.cxx:91
RooGrid::_vol
Double_t _vol
Definition: RooGrid.h:76
RooGrid::coord
Double_t & coord(Int_t i, Int_t j)
Definition: RooGrid.h:68
Double_t
double Double_t
Definition: RtypesCore.h:59
TObject.h
RooGrid::printTitle
virtual void printTitle(std::ostream &os) const
Print title of grid object.
Definition: RooGrid.cxx:306
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
RooGrid::RooGrid
RooGrid()
Default constructor.
Definition: RooGrid.cxx:50
RooGrid::_boxes
UInt_t _boxes
Definition: RooGrid.h:75
RooPrintable::printStream
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
Definition: RooPrintable.cxx:75
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooGrid
Definition: RooGrid.h:24
RooGrid::getVolume
Double_t getVolume() const
Definition: RooGrid.h:42
RooPrintable::defaultPrintStyle
virtual StyleOption defaultPrintStyle(Option_t *opt) const
Definition: RooPrintable.cxx:241
RooGrid::maxBins
@ maxBins
Definition: RooGrid.h:61
RooGrid::_weight
Double_t * _weight
Internal workspace.
Definition: RooGrid.h:84
RooGrid::value
Double_t & value(Int_t i, Int_t j)
Definition: RooGrid.h:69
RooGrid::printClassName
virtual void printClassName(std::ostream &os) const
Print class name of grid object.
Definition: RooGrid.cxx:315
RooGrid::setNBoxes
void setNBoxes(UInt_t boxes)
Definition: RooGrid.h:45
RooGrid::Print
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
Definition: RooGrid.h:36
int
RooGrid::_dim
UInt_t _dim
Definition: RooGrid.h:75