RooGrid.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooGrid.h,v 1.10 2007/05/11 09:11:30 verkerke Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_GRID
00017 #define ROO_GRID
00018 
00019 #include "TObject.h"
00020 #include "RooPrintable.h"
00021 
00022 class RooAbsFunc;
00023 
00024 class RooGrid : public TObject, public RooPrintable {
00025 public:
00026   RooGrid() ;
00027   RooGrid(const RooAbsFunc &function);
00028   virtual ~RooGrid();
00029 
00030   // Printing interface
00031   virtual void printName(ostream& os) const ;
00032   virtual void printTitle(ostream& os) const ;
00033   virtual void printClassName(ostream& os) const ;
00034   virtual void printMultiline(ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const;
00035 
00036   inline virtual void Print(Option_t *options= 0) const {
00037     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
00038   }
00039 
00040   inline Bool_t isValid() const { return _valid; }
00041   inline UInt_t getDimension() const { return _dim; }
00042   inline Double_t getVolume() const { return _vol; }
00043   inline UInt_t getNBins() const { return _bins; }
00044   inline UInt_t getNBoxes() const { return _boxes; }
00045   inline void setNBoxes(UInt_t boxes) { _boxes= boxes; }
00046 
00047   inline Double_t *createPoint() const { return _valid ? new Double_t[_dim] : 0; }
00048   inline UInt_t *createIndexVector() const { return _valid ? new UInt_t[_dim] : 0; }
00049 
00050   Bool_t initialize(const RooAbsFunc &function);
00051   void resize(UInt_t bins);
00052   void resetValues();
00053   void generatePoint(const UInt_t box[], Double_t x[], UInt_t bin[],
00054                      Double_t &vol, Bool_t useQuasiRandom= kTRUE) const;
00055   void accumulate(const UInt_t bin[], Double_t amount);
00056   void refine(Double_t alpha= 1.5);
00057 
00058   void firstBox(UInt_t box[]) const;
00059   Bool_t nextBox(UInt_t box[]) const;
00060 
00061   enum { maxBins = 50 }; // must be even
00062 
00063   // Accessor for the j-th normalized grid point along the i-th dimension
00064 public:
00065   inline Double_t coord(Int_t i, Int_t j) const { return _xi[i*_dim + j]; }
00066   inline Double_t value(Int_t i,Int_t j) const { return _d[i*_dim + j]; }
00067 protected:
00068   inline Double_t& coord(Int_t i, Int_t j) { return _xi[i*_dim + j]; }
00069   inline Double_t& value(Int_t i,Int_t j) { return _d[i*_dim + j]; }
00070   inline Double_t& newCoord(Int_t i) { return _xin[i]; }
00071 
00072 protected:
00073 
00074   Bool_t _valid;              // Is configuration valid
00075   UInt_t _dim,_bins,_boxes;   // Number of dimensions, bins and boxes
00076   Double_t _vol;              // Volume
00077 
00078   Double_t *_xl;     //! Internal workspace
00079   Double_t *_xu;     //! Internal workspace
00080   Double_t *_delx;   //! Internal workspace
00081   Double_t *_d;      //! Internal workspace
00082   Double_t *_xi;     //! Internal workspace
00083   Double_t *_xin;    //! Internal workspace
00084   Double_t *_weight; //! Internal workspace
00085 
00086   ClassDef(RooGrid,1) // Utility class for RooMCIntegrator holding a multi-dimensional grid
00087 };
00088 
00089 #endif
00090 
00091 

Generated on Tue Jul 5 14:26:11 2011 for ROOT_528-00b_version by  doxygen 1.5.1