#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();
virtual void printName(std::ostream& os) const ;
virtual void printTitle(std::ostream& os) const ;
virtual void printClassName(std::ostream& os) const ;
virtual void printMultiline(std::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 };
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;
UInt_t _dim,_bins,_boxes;
Double_t _vol;
Double_t *_xl;
Double_t *_xu;
Double_t *_delx;
Double_t *_d;
Double_t *_xi;
Double_t *_xin;
Double_t *_weight;
ClassDef(RooGrid,1)
};
#endif