Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 <RtypesCore.h>
20
21#include <ostream>
22#include <vector>
23
24class RooAbsFunc;
25
26// Utility class for RooMCIntegrator holding a multi-dimensional grid
27class RooGrid {
28public:
30 RooGrid(const RooAbsFunc &function);
31
32 // Printing interface
33 void print(std::ostream& os, bool verbose=false, std::string const& indent="") const;
34
35 inline bool isValid() const { return _valid; }
36 inline UInt_t getDimension() const { return _dim; }
37 inline double getVolume() const { return _vol; }
38 inline UInt_t getNBins() const { return _bins; }
39 inline UInt_t getNBoxes() const { return _boxes; }
40 inline void setNBoxes(UInt_t boxes) { _boxes= boxes; }
41
42 bool initialize(const RooAbsFunc &function);
43 void resize(UInt_t bins);
44 void resetValues();
45 void generatePoint(const UInt_t box[], double x[], UInt_t bin[],
46 double &vol, bool useQuasiRandom= true) const;
47 void accumulate(const UInt_t bin[], double amount);
48 void refine(double alpha= 1.5);
49
50 void firstBox(UInt_t box[]) const;
51 bool nextBox(UInt_t box[]) const;
52
53 enum { maxBins = 50 }; // must be even
54
55 // Accessor for the j-th normalized grid point along the i-th dimension
56 inline double coord(Int_t i, Int_t j) const { return _xi[i*_dim + j]; }
57 inline double value(Int_t i,Int_t j) const { return _d[i*_dim + j]; }
58
59protected:
60 inline double& coord(Int_t i, Int_t j) { return _xi[i*_dim + j]; }
61 inline double& value(Int_t i,Int_t j) { return _d[i*_dim + j]; }
62 inline double& newCoord(Int_t i) { return _xin[i]; }
63
64 bool _valid = false; ///< Is configuration valid
65 UInt_t _dim = 0; ///< Number of dimensions, bins and boxes
66 UInt_t _bins = 0; ///< Number of bins
67 UInt_t _boxes = 0; ///<Numbser of boxes
68 double _vol = 0.0; ///< Volume
69
70 std::vector<double> _xl; ///<! Internal workspace
71 std::vector<double> _xu; ///<! Internal workspace
72 std::vector<double> _delx; ///<! Internal workspace
73 std::vector<double> _d; ///<! Internal workspace
74 std::vector<double> _xi; ///<! Internal workspace
75 std::vector<double> _xin; ///<! Internal workspace
76 std::vector<double> _weight; ///<! Internal workspace
77
78};
79
80#endif
81
82
unsigned int UInt_t
Definition RtypesCore.h:46
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:27
UInt_t getDimension() const
Definition RooGrid.h:36
std::vector< double > _xl
! Internal workspace
Definition RooGrid.h:70
double value(Int_t i, Int_t j) const
Definition RooGrid.h:57
@ maxBins
Definition RooGrid.h:53
double & value(Int_t i, Int_t j)
Definition RooGrid.h:61
bool initialize(const RooAbsFunc &function)
Calculate and store the grid dimensions and volume using the specified function, and initialize the g...
Definition RooGrid.cxx:72
double _vol
Volume.
Definition RooGrid.h:68
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 store its coordinates in the x[] array provided,...
Definition RooGrid.cxx:162
double getVolume() const
Definition RooGrid.h:37
bool isValid() const
Definition RooGrid.h:35
std::vector< double > _weight
! Internal workspace
Definition RooGrid.h:76
std::vector< double > _xu
! Internal workspace
Definition RooGrid.h:71
UInt_t _dim
Number of dimensions, bins and boxes.
Definition RooGrid.h:65
UInt_t getNBins() const
Definition RooGrid.h:38
UInt_t _bins
Number of bins.
Definition RooGrid.h:66
bool _valid
Is configuration valid.
Definition RooGrid.h:64
UInt_t getNBoxes() const
Definition RooGrid.h:39
void resetValues()
Reset the values associated with each grid cell.
Definition RooGrid.cxx:145
double & coord(Int_t i, Int_t j)
Definition RooGrid.h:60
RooGrid()
Definition RooGrid.h:29
UInt_t _boxes
Numbser of boxes.
Definition RooGrid.h:67
std::vector< double > _xi
! Internal workspace
Definition RooGrid.h:74
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:262
std::vector< double > _d
! Internal workspace
Definition RooGrid.h:73
double coord(Int_t i, Int_t j) const
Definition RooGrid.h:56
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:222
std::vector< double > _delx
! Internal workspace
Definition RooGrid.h:72
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:108
void setNBoxes(UInt_t boxes)
Definition RooGrid.h:40
void refine(double alpha=1.5)
Refine the grid using the values that have been accumulated so far.
Definition RooGrid.cxx:274
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:210
std::vector< double > _xin
! Internal workspace
Definition RooGrid.h:75
double & newCoord(Int_t i)
Definition RooGrid.h:62
void print(std::ostream &os, bool verbose=false, std::string const &indent="") const
Print info about this object to the specified stream.
Definition RooGrid.cxx:241
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