Logo ROOT  
Reference Guide
Go to the documentation of this file.
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
19#include "TObject.h"
20#include "RooPrintable.h"
22class RooAbsFunc;
24class RooGrid : public TObject, public RooPrintable {
26 RooGrid() ;
28 ~RooGrid() override;
30 // Printing interface
31 void printName(std::ostream& os) const override ;
32 void printTitle(std::ostream& os) const override ;
33 void printClassName(std::ostream& os) const override ;
34 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override;
36 inline void Print(Option_t *options= 0) const override {
38 }
40 inline bool isValid() const { return _valid; }
41 inline UInt_t getDimension() const { return _dim; }
42 inline double 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; }
47 inline double *createPoint() const { return _valid ? new double[_dim] : 0; }
48 inline UInt_t *createIndexVector() const { return _valid ? new UInt_t[_dim] : 0; }
50 bool initialize(const RooAbsFunc &function);
51 void resize(UInt_t bins);
52 void resetValues();
53 void generatePoint(const UInt_t box[], double x[], UInt_t bin[],
54 double &vol, bool useQuasiRandom= true) const;
55 void accumulate(const UInt_t bin[], double amount);
56 void refine(double alpha= 1.5);
58 void firstBox(UInt_t box[]) const;
59 bool nextBox(UInt_t box[]) const;
61 enum { maxBins = 50 }; // must be even
63 // Accessor for the j-th normalized grid point along the i-th dimension
65 inline double coord(Int_t i, Int_t j) const { return _xi[i*_dim + j]; }
66 inline double value(Int_t i,Int_t j) const { return _d[i*_dim + j]; }
68 inline double& coord(Int_t i, Int_t j) { return _xi[i*_dim + j]; }
69 inline double& value(Int_t i,Int_t j) { return _d[i*_dim + j]; }
70 inline double& newCoord(Int_t i) { return _xin[i]; }
74 bool _valid; ///< Is configuration valid
75 UInt_t _dim,_bins,_boxes; ///< Number of dimensions, bins and boxes
76 double _vol; ///< Volume
78 double *_xl; ///<! Internal workspace
79 double *_xu; ///<! Internal workspace
80 double *_delx; ///<! Internal workspace
81 double *_d; ///<! Internal workspace
82 double *_xi; ///<! Internal workspace
83 double *_xin; ///<! Internal workspace
84 double *_weight; ///<! Internal workspace
86 ClassDefOverride(RooGrid,1) // Utility class for RooMCIntegrator holding a multi-dimensional grid
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
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:27
RooGrid is a utility class for RooMCIntegrator which implements an adaptive multi-dimensional Monte C...
Definition: RooGrid.h:24
@ maxBins
Definition: RooGrid.h:61
UInt_t getDimension() const
Definition: RooGrid.h:41
double * _xl
! Internal workspace
Definition: RooGrid.h:78
double value(Int_t i, Int_t j) const
Definition: RooGrid.h:66
void Print(Option_t *options=0) const override
This method must be overridden when a class wants to print itself.
Definition: RooGrid.h:36
double & value(Int_t i, Int_t j)
Definition: RooGrid.h:69
double * _xi
! Internal workspace
Definition: RooGrid.h:82
bool initialize(const RooAbsFunc &function)
Calculate and store the grid dimensions and volume using the specified function, and initialize the g...
Definition: RooGrid.cxx:106
double _vol
Definition: RooGrid.h:76
double * _delx
! Internal workspace
Definition: RooGrid.h:80
void generatePoint(const UInt_t box[], double x[], UInt_t bin[], double &vol, bool useQuasiRandom=true) const
Generate a random vector in the specified box and and store its coordinates in the x[] array provided...
Definition: RooGrid.cxx:196
double getVolume() const
Definition: RooGrid.h:42
UInt_t * createIndexVector() const
Definition: RooGrid.h:48
bool isValid() const
Definition: RooGrid.h:40
double * _weight
! Internal workspace
Definition: RooGrid.h:84
double * _d
! Internal workspace
Definition: RooGrid.h:81
UInt_t _dim
Definition: RooGrid.h:75
UInt_t getNBins() const
Definition: RooGrid.h:43
UInt_t _bins
Definition: RooGrid.h:75
double * createPoint() const
Definition: RooGrid.h:47
void printClassName(std::ostream &os) const override
Print class name of grid object.
Definition: RooGrid.cxx:313
bool _valid
Is configuration valid.
Definition: RooGrid.h:74
UInt_t getNBoxes() const
Definition: RooGrid.h:44
double * _xu
! Internal workspace
Definition: RooGrid.h:79
void resetValues()
Reset the values associated with each grid cell.
Definition: RooGrid.cxx:179
double & coord(Int_t i, Int_t j)
Definition: RooGrid.h:68
double * _xin
! Internal workspace
Definition: RooGrid.h:83
~RooGrid() override
Definition: RooGrid.cxx:89
Default constructor.
Definition: RooGrid.cxx:48
UInt_t _boxes
Number of dimensions, bins and boxes.
Definition: RooGrid.h:75
void accumulate(const UInt_t bin[], double amount)
Add the specified amount to bin[j] of the 1D histograms associated with each axis j.
Definition: RooGrid.cxx:324
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print info about this object to the specified stream.
Definition: RooGrid.cxx:275
void printName(std::ostream &os) const override
Print name of grid object.
Definition: RooGrid.cxx:295
double coord(Int_t i, Int_t j) const
Definition: RooGrid.h:65
bool 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:256
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:142
void setNBoxes(UInt_t boxes)
Definition: RooGrid.h:45
void refine(double alpha=1.5)
Refine the grid using the values that have been accumulated so far.
Definition: RooGrid.cxx:336
void printTitle(std::ostream &os) const override
Print title of grid object.
Definition: RooGrid.cxx:304
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:244
double & newCoord(Int_t i)
Definition: RooGrid.h:70
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:136
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:167