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
22class RooAbsFunc;
23
24class RooGrid : public TObject, public RooPrintable {
25public:
26 RooGrid() ;
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
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
64public:
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]; }
67protected:
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
72protected:
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
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
bool Bool_t
Definition: RtypesCore.h:59
double Double_t
Definition: RtypesCore.h:55
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
static void indent(ostringstream &buf, int indent_level)
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Definition: RooAbsFunc.h:23
RooGrid is a utility class for RooMCIntegrator which implements an adaptive multi-dimensional Monte C...
Definition: RooGrid.h:24
Double_t coord(Int_t i, Int_t j) const
Definition: RooGrid.h:65
UInt_t getDimension() const
Definition: RooGrid.h:41
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:109
Double_t * _delx
Internal workspace.
Definition: RooGrid.h:80
virtual void printName(std::ostream &os) const
Print name of grid object.
Definition: RooGrid.cxx:298
virtual void printClassName(std::ostream &os) const
Print class name of grid object.
Definition: RooGrid.cxx:316
Double_t * _xin
Internal workspace.
Definition: RooGrid.h:83
Double_t * _xi
Internal workspace.
Definition: RooGrid.h:82
Double_t & newCoord(Int_t i)
Definition: RooGrid.h:70
UInt_t * createIndexVector() const
Definition: RooGrid.h:48
virtual ~RooGrid()
Destructor.
Definition: RooGrid.cxx:92
@ maxBins
Definition: RooGrid.h:61
Bool_t isValid() const
Definition: RooGrid.h:40
Double_t * _d
Internal workspace.
Definition: RooGrid.h:81
UInt_t _dim
Definition: RooGrid.h:75
Double_t * _weight
Internal workspace.
Definition: RooGrid.h:84
UInt_t getNBins() const
Definition: RooGrid.h:43
void refine(Double_t alpha=1.5)
Refine the grid using the values that have been accumulated so far.
Definition: RooGrid.cxx:339
UInt_t _bins
Definition: RooGrid.h:75
virtual void printTitle(std::ostream &os) const
Print title of grid object.
Definition: RooGrid.cxx:307
Double_t * _xu
Internal workspace.
Definition: RooGrid.h:79
UInt_t getNBoxes() const
Definition: RooGrid.h:44
void resetValues()
Reset the values associated with each grid cell.
Definition: RooGrid.cxx:182
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
Definition: RooGrid.h:36
RooGrid()
Default constructor.
Definition: RooGrid.cxx:51
UInt_t _boxes
Definition: RooGrid.h:75
Double_t * _xl
Definition: RooGrid.h:78
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:278
Double_t * createPoint() const
Definition: RooGrid.h:47
Double_t & coord(Int_t i, Int_t j)
Definition: RooGrid.h:68
Double_t getVolume() const
Definition: RooGrid.h:42
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:145
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:199
void setNBoxes(UInt_t boxes)
Definition: RooGrid.h:45
Double_t value(Int_t i, Int_t j) const
Definition: RooGrid.h:66
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:327
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:247
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:259
Double_t & value(Int_t i, Int_t j)
Definition: RooGrid.h:69
Bool_t _valid
Definition: RooGrid.h:74
Double_t _vol
Definition: RooGrid.h:76
RooPlotable is a 'mix-in' base class that define the standard RooFit plotting and printing methods.
Definition: RooPrintable.h:25
virtual StyleOption defaultPrintStyle(Option_t *opt) const
virtual Int_t defaultPrintContents(Option_t *opt) const
Default choice of contents to be printed (name and value)
static std::ostream & defaultPrintStream(std::ostream *os=0)
Return a reference to the current default stream to use in Print().
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,...
Mother of all ROOT objects.
Definition: TObject.h:37
Basic string class.
Definition: TString.h:131
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
Double_t x[n]
Definition: legend1.C:17
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151