Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 {
37  printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
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