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