00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 #ifndef ROO_MC_INTEGRATOR
00017 #define ROO_MC_INTEGRATOR
00018 
00019 #include "RooAbsIntegrator.h"
00020 #include "RooGrid.h"
00021 #include "RooNumIntConfig.h"
00022 #include "TStopwatch.h"
00023 
00024 class RooMCIntegrator : public RooAbsIntegrator {
00025 public:
00026 
00027   
00028   enum SamplingMode { Importance, ImportanceOnly, Stratified };
00029   enum GeneratorType { QuasiRandom, PseudoRandom };
00030   RooMCIntegrator() ;
00031   RooMCIntegrator(const RooAbsFunc& function, SamplingMode mode= Importance,
00032                   GeneratorType genType= QuasiRandom, Bool_t verbose= kFALSE);
00033   RooMCIntegrator(const RooAbsFunc& function, const RooNumIntConfig& config);
00034   virtual RooAbsIntegrator* clone(const RooAbsFunc& function, const RooNumIntConfig& config) const ;
00035   virtual ~RooMCIntegrator();
00036 
00037   virtual Bool_t checkLimits() const;
00038   virtual Double_t integral(const Double_t* yvec=0);
00039 
00040   enum Stage { AllStages, ReuseGrid, RefineGrid };
00041   Double_t vegas(Stage stage, UInt_t calls, UInt_t iterations, Double_t *absError= 0);
00042 
00043   Double_t getAlpha() const { return _alpha;   }
00044   void setAlpha(Double_t alpha) { _alpha= alpha; }
00045 
00046   GeneratorType getGenType() const { return _genType; }
00047   void setGenType(GeneratorType type) { _genType= type; }
00048 
00049   const RooGrid &grid() const { return _grid; }
00050 
00051   virtual Bool_t canIntegrate1D() const { return kTRUE ; }
00052   virtual Bool_t canIntegrate2D() const { return kTRUE ; }
00053   virtual Bool_t canIntegrateND() const { return kTRUE ; }
00054   virtual Bool_t canIntegrateOpenEnded() const { return kFALSE ; }
00055 
00056 protected:
00057 
00058   friend class RooNumIntFactory ;
00059   static void registerIntegrator(RooNumIntFactory& fact) ;      
00060 
00061   mutable RooGrid _grid;  
00062 
00063   
00064   Bool_t _verbose;          
00065   Double_t _alpha;          
00066   Int_t _mode;              
00067   GeneratorType _genType;   
00068   Int_t _nRefineIter ;      
00069   Int_t _nRefinePerDim ;    
00070   Int_t _nIntegratePerDim ; 
00071 
00072   TStopwatch _timer;        
00073 
00074   Double_t _jac,_wtd_int_sum,_sum_wgts,_chi_sum,_chisq,_result,_sigma; 
00075   UInt_t _it_start,_it_num,_samples,_calls_per_box;                    
00076 
00077   ClassDef(RooMCIntegrator,0) 
00078 };
00079 
00080 #endif