ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooGrid.h,v 1.10 2007/05/11 09:11:30 verkerke Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_GRID
#define ROO_GRID

#include "TObject.h"
#include "RooPrintable.h"

class RooAbsFunc;

class RooGrid : public TObject, public RooPrintable {
public:
  RooGrid() ;
  RooGrid(const RooAbsFunc &function);
  virtual ~RooGrid();

  // Printing interface
  virtual void printName(ostream& os) const ;
  virtual void printTitle(ostream& os) const ;
  virtual void printClassName(ostream& os) const ;
  virtual void printMultiline(ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const;

  inline virtual void Print(Option_t *options= 0) const {
    printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
  }

  inline Bool_t isValid() const { return _valid; }
  inline UInt_t getDimension() const { return _dim; }
  inline Double_t getVolume() const { return _vol; }
  inline UInt_t getNBins() const { return _bins; }
  inline UInt_t getNBoxes() const { return _boxes; }
  inline void setNBoxes(UInt_t boxes) { _boxes= boxes; }

  inline Double_t *createPoint() const { return _valid ? new Double_t[_dim] : 0; }
  inline UInt_t *createIndexVector() const { return _valid ? new UInt_t[_dim] : 0; }

  Bool_t initialize(const RooAbsFunc &function);
  void resize(UInt_t bins);
  void resetValues();
  void generatePoint(const UInt_t box[], Double_t x[], UInt_t bin[],
		     Double_t &vol, Bool_t useQuasiRandom= kTRUE) const;
  void accumulate(const UInt_t bin[], Double_t amount);
  void refine(Double_t alpha= 1.5);

  void firstBox(UInt_t box[]) const;
  Bool_t nextBox(UInt_t box[]) const;

  enum { maxBins = 50 }; // must be even

  // Accessor for the j-th normalized grid point along the i-th dimension
public:
  inline Double_t coord(Int_t i, Int_t j) const { return _xi[i*_dim + j]; }
  inline Double_t value(Int_t i,Int_t j) const { return _d[i*_dim + j]; }
protected:
  inline Double_t& coord(Int_t i, Int_t j) { return _xi[i*_dim + j]; }
  inline Double_t& value(Int_t i,Int_t j) { return _d[i*_dim + j]; }
  inline Double_t& newCoord(Int_t i) { return _xin[i]; }

protected:

  Bool_t _valid;              // Is configuration valid
  UInt_t _dim,_bins,_boxes;   // Number of dimensions, bins and boxes
  Double_t _vol;              // Volume

  Double_t *_xl;     //! Internal workspace
  Double_t *_xu;     //! Internal workspace
  Double_t *_delx;   //! Internal workspace
  Double_t *_d;      //! Internal workspace
  Double_t *_xi;     //! Internal workspace
  Double_t *_xin;    //! Internal workspace
  Double_t *_weight; //! Internal workspace

  ClassDef(RooGrid,1) // Utility class for RooMCIntegrator holding a multi-dimensional grid
};

#endif


 RooGrid.h:1
 RooGrid.h:2
 RooGrid.h:3
 RooGrid.h:4
 RooGrid.h:5
 RooGrid.h:6
 RooGrid.h:7
 RooGrid.h:8
 RooGrid.h:9
 RooGrid.h:10
 RooGrid.h:11
 RooGrid.h:12
 RooGrid.h:13
 RooGrid.h:14
 RooGrid.h:15
 RooGrid.h:16
 RooGrid.h:17
 RooGrid.h:18
 RooGrid.h:19
 RooGrid.h:20
 RooGrid.h:21
 RooGrid.h:22
 RooGrid.h:23
 RooGrid.h:24
 RooGrid.h:25
 RooGrid.h:26
 RooGrid.h:27
 RooGrid.h:28
 RooGrid.h:29
 RooGrid.h:30
 RooGrid.h:31
 RooGrid.h:32
 RooGrid.h:33
 RooGrid.h:34
 RooGrid.h:35
 RooGrid.h:36
 RooGrid.h:37
 RooGrid.h:38
 RooGrid.h:39
 RooGrid.h:40
 RooGrid.h:41
 RooGrid.h:42
 RooGrid.h:43
 RooGrid.h:44
 RooGrid.h:45
 RooGrid.h:46
 RooGrid.h:47
 RooGrid.h:48
 RooGrid.h:49
 RooGrid.h:50
 RooGrid.h:51
 RooGrid.h:52
 RooGrid.h:53
 RooGrid.h:54
 RooGrid.h:55
 RooGrid.h:56
 RooGrid.h:57
 RooGrid.h:58
 RooGrid.h:59
 RooGrid.h:60
 RooGrid.h:61
 RooGrid.h:62
 RooGrid.h:63
 RooGrid.h:64
 RooGrid.h:65
 RooGrid.h:66
 RooGrid.h:67
 RooGrid.h:68
 RooGrid.h:69
 RooGrid.h:70
 RooGrid.h:71
 RooGrid.h:72
 RooGrid.h:73
 RooGrid.h:74
 RooGrid.h:75
 RooGrid.h:76
 RooGrid.h:77
 RooGrid.h:78
 RooGrid.h:79
 RooGrid.h:80
 RooGrid.h:81
 RooGrid.h:82
 RooGrid.h:83
 RooGrid.h:84
 RooGrid.h:85
 RooGrid.h:86
 RooGrid.h:87
 RooGrid.h:88
 RooGrid.h:89
 RooGrid.h:90
 RooGrid.h:91