Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooRealIntegral.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooRealIntegral.h,v 1.44 2007/05/11 09:11:30 verkerke Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_REAL_INTEGRAL
0017 #define ROO_REAL_INTEGRAL
0018 
0019 #include <RooAbsPdf.h>
0020 #include <RooAbsReal.h>
0021 #include <RooArgSet.h>
0022 #include <RooListProxy.h>
0023 #include <RooRealProxy.h>
0024 #include <RooSetProxy.h>
0025 
0026 class RooAbsIntegrator;
0027 class RooNumIntConfig;
0028 
0029 class RooRealIntegral : public RooAbsReal {
0030 public:
0031 
0032   // Constructors, assignment etc
0033   RooRealIntegral() ;
0034   RooRealIntegral(const char *name, const char *title, const RooAbsReal& function, const RooArgSet& depList,
0035         const RooArgSet* funcNormSet=nullptr, const RooNumIntConfig* config=nullptr, const char* rangeName=nullptr) ;
0036   RooRealIntegral(const RooRealIntegral& other, const char* name=nullptr);
0037   TObject* clone(const char* newname) const override { return new RooRealIntegral(*this,newname); }
0038   ~RooRealIntegral() override;
0039 
0040   double getValV(const RooArgSet* set=nullptr) const override ;
0041 
0042   bool isValid() const override { return _valid; }
0043 
0044   void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override ;
0045   void printMetaArgs(std::ostream& os) const override ;
0046 
0047   const RooArgSet& numIntCatVars() const { return _sumList ; }
0048   const RooArgSet& numIntRealVars() const { return _intList ; }
0049   const RooArgSet& anaIntVars() const { return _anaList ; }
0050 
0051   RooArgSet intVars() const { RooArgSet tmp(_sumList) ; tmp.add(_intList) ; tmp.add(_anaList) ; tmp.add(_facList) ; return tmp ; }
0052   const char* intRange() const { return _rangeName ? _rangeName->GetName() : nullptr ; }
0053   const RooAbsReal& integrand() const { return *_function; }
0054 
0055   void setCacheNumeric(bool flag) {
0056     // If true, value of this integral is cached if it is (partially numeric)
0057     _cacheNum = flag ;
0058   }
0059 
0060   bool getCacheNumeric() {
0061     // If true, value of this integral is cached if it is (partially numeric)
0062     return _cacheNum ;
0063   }
0064 
0065   static void setCacheAllNumeric(Int_t ndim) ;
0066 
0067   static Int_t getCacheAllNumeric() ;
0068 
0069   std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override {
0070     // Forward plot sampling hint of integrand
0071     return _function->plotSamplingHint(obs,xlo,xhi) ;
0072   }
0073 
0074   RooFit::OwningPtr<RooAbsReal> createIntegral(const RooArgSet& iset, const RooArgSet* nset=nullptr, const RooNumIntConfig* cfg=nullptr, const char* rangeName=nullptr) const override ;
0075 
0076   void setAllowComponentSelection(bool allow);
0077   bool getAllowComponentSelection() const;
0078 
0079   std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const override;
0080 
0081   void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
0082 
0083   inline RooArgSet const* funcNormSet() const { return _funcNormSet.get(); }
0084 
0085 protected:
0086 
0087   mutable bool _valid = false;
0088   bool _respectCompSelect = true;
0089 
0090   const RooArgSet& parameters() const ;
0091 
0092   enum IntOperMode { Hybrid, Analytic, PassThrough } ;
0093   //friend class RooAbsPdf ;
0094 
0095   bool initNumIntegrator() const;
0096   void autoSelectDirtyMode() ;
0097 
0098   virtual double sum() const ;
0099   virtual double integrate() const ;
0100   virtual double jacobianProduct() const ;
0101 
0102   // Evaluation and validation implementation
0103   double evaluate() const override ;
0104   bool isValidReal(double value, bool printError=false) const override ;
0105 
0106   bool redirectServersHook(const RooAbsCollection& newServerList,
0107                  bool mustReplaceAll, bool nameChange, bool isRecursive) override ;
0108 
0109   // Internal function to get the normalization set for the integrated
0110   // function. By default, we will take the normalization set from the function
0111   // proxy, but _funcNormSet will be used if it is set.
0112   inline RooArgSet const* actualFuncNormSet() const {
0113     return _funcNormSet ? _funcNormSet.get() : _function.nset();
0114   }
0115 
0116   // Function pointer and integrands list
0117   RooSetProxy _sumList; ///< Set of discrete observable over which is summed numerically
0118   RooSetProxy _intList; ///< Set of continuous observables over which is integrated numerically
0119   RooSetProxy _anaList; ///< Set of observables over which is integrated/summed analytically
0120   RooSetProxy _jacList; ///< Set of lvalue observables over which is analytically integration that have a non-unit Jacobian
0121   RooSetProxy _facList; ///< Set of observables on which function does not depends, which are integrated nevertheless
0122 
0123   RooRealProxy       _function ;     ///< Function being integrated
0124   std::unique_ptr<RooArgSet> _funcNormSet; ///< Optional normalization set passed to function
0125 
0126   RooArgSet _saveInt; ///<!
0127   RooArgSet _saveSum; ///<!
0128 
0129   RooNumIntConfig* _iconfig = nullptr;
0130 
0131   RooListProxy _sumCat ; ///<!
0132 
0133   Int_t _mode = 0;
0134   IntOperMode _intOperMode = Hybrid;   ///< integration operation mode
0135 
0136   mutable bool _restartNumIntEngine = false; ///<!
0137   mutable std::unique_ptr<RooAbsIntegrator> _numIntEngine;  ///<!
0138   mutable std::unique_ptr<RooAbsFunc> _numIntegrand;        ///<!
0139 
0140   TNamed* _rangeName = nullptr;
0141 
0142   mutable std::unique_ptr<RooArgSet> _params; ///<! cache for set of parameters
0143 
0144   bool _cacheNum = false;           ///< Cache integral if numeric
0145   static Int_t _cacheAllNDim ; ///<! Cache all integrals with given numeric dimension
0146 
0147 private:
0148   void addNumIntDep(RooAbsArg const &arg);
0149 
0150   ClassDefOverride(RooRealIntegral,5) // Real-valued function representing an integral over a RooAbsReal object
0151 };
0152 
0153 #endif