Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooProdPdf.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: RooProdPdf.h,v 1.44 2007/07/16 21:04:28 wouter 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_PROD_PDF
0017 #define ROO_PROD_PDF
0018 
0019 #include "RooAbsPdf.h"
0020 #include "RooListProxy.h"
0021 #include "RooLinkedList.h"
0022 #include "RooAICRegistry.h"
0023 #include "RooObjCacheManager.h"
0024 #include "RooCmdArg.h"
0025 
0026 #include <vector>
0027 #include <list>
0028 #include <string>
0029 
0030 typedef RooArgList* pRooArgList ;
0031 typedef RooLinkedList* pRooLinkedList ;
0032 
0033 class RooProdPdf : public RooAbsPdf {
0034 public:
0035 
0036   RooProdPdf() ;
0037   RooProdPdf(const char *name, const char *title,
0038        RooAbsPdf& pdf1, RooAbsPdf& pdf2, double cutOff=0.0) ;
0039   RooProdPdf(const char* name, const char* title, const RooArgList& pdfList, double cutOff=0.0) ;
0040   RooProdPdf(const char* name, const char* title, const RooArgSet& fullPdfSet, const RooLinkedList& cmdArgList) ;
0041 
0042   RooProdPdf(const char* name, const char* title, const RooArgSet& fullPdfSet,
0043            const RooCmdArg& arg1            , const RooCmdArg& arg2={},
0044              const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
0045              const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
0046              const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) ;
0047 
0048   RooProdPdf(const char* name, const char* title,
0049              const RooCmdArg& arg1,             const RooCmdArg& arg2={},
0050              const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
0051              const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
0052              const RooCmdArg& arg7={}, const RooCmdArg& arg8={}) ;
0053 
0054   RooProdPdf(const RooProdPdf& other, const char* name=nullptr) ;
0055   TObject* clone(const char* newname) const override { return new RooProdPdf(*this,newname) ; }
0056   ~RooProdPdf() override ;
0057 
0058   bool forceAnalyticalInt(const RooAbsArg& dep) const override ;
0059   Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
0060   double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
0061   bool selfNormalized() const override { return _selfNorm ; }
0062 
0063   ExtendMode extendMode() const override ;
0064   double expectedEvents(const RooArgSet* nset) const override ;
0065   std::unique_ptr<RooAbsReal> createExpectedEventsFunc(const RooArgSet* nset) const override;
0066 
0067   const RooArgList& pdfList() const { return _pdfList ; }
0068 
0069   void addPdfs(RooAbsCollection const& pdfs);
0070   void removePdfs(RooAbsCollection const& pdfs);
0071 
0072   Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool staticInitOK=true) const override;
0073   void initGenerator(Int_t code) override ;
0074   void generateEvent(Int_t code) override;
0075   bool isDirectGenSafe(const RooAbsArg& arg) const override ;
0076 
0077   // Constraint management
0078   RooArgSet* getConstraints(const RooArgSet& observables, RooArgSet& constrainedParams,
0079                             bool stripDisconnected, bool removeConstraintsFromPdf=false) const override ;
0080 
0081   std::list<double>* plotSamplingHint(RooAbsRealLValue& obs, double xlo, double xhi) const override ;
0082   std::list<double>* binBoundaries(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override ;
0083   bool isBinnedDistribution(const RooArgSet& obs) const override  ;
0084 
0085   void printMetaArgs(std::ostream& os) const override ;
0086 
0087   void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override ;
0088   void fixRefRange(const char* rangeName) ;
0089 
0090   void setSelfNormalized(bool flag) { _selfNorm = flag ; }
0091   void setDefNormSet(const RooArgSet& nset) { _defNormSet.removeAll() ; _defNormSet.addClone(nset) ; }
0092 
0093 
0094   bool redirectServersHook(const RooAbsCollection& /*newServerList*/, bool /*mustReplaceAll*/, bool /*nameChange*/, bool /*isRecursive*/) override ;
0095 
0096   RooArgSet* getConnectedParameters(const RooArgSet& observables) const ;
0097 
0098   RooArgSet* findPdfNSet(RooAbsPdf const& pdf) const ;
0099 
0100   std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const override;
0101 
0102 private:
0103 
0104   std::unique_ptr<RooArgSet> fillNormSetForServer(RooArgSet const& normSet, RooAbsArg const& server) const;
0105 
0106   double evaluate() const override ;
0107 
0108   std::unique_ptr<RooAbsReal> makeCondPdfRatioCorr(RooAbsReal& term, const RooArgSet& termNset, const RooArgSet& termImpSet, const char* normRange, const char* refRange) const ;
0109 
0110   void getParametersHook(const RooArgSet* /*nset*/, RooArgSet* /*list*/, bool stripDisconnected) const override ;
0111 
0112   void initializeFromCmdArgList(const RooArgSet& fullPdfSet, const RooLinkedList& l) ;
0113 
0114   void factorizeProduct(const RooArgSet& normSet, const RooArgSet& intSet,
0115                         RooLinkedList& termList,   RooLinkedList& normList,
0116                         RooLinkedList& impDepList, RooLinkedList& crossDepList,
0117                         RooLinkedList& intList) const;
0118   std::string makeRGPPName(const char* pfx, const RooArgSet& term, const RooArgSet& iset, const RooArgSet& nset, const char* isetRangeName) const ;
0119   void groupProductTerms(std::list<std::vector<RooArgSet*>>& groupedTerms, RooArgSet& outerIntDeps,
0120                          const RooLinkedList& terms, const RooLinkedList& norms,
0121                          const RooLinkedList& imps, const RooLinkedList& ints, const RooLinkedList& cross) const ;
0122 
0123 
0124 
0125   Int_t getPartIntList(const RooArgSet* nset, const RooArgSet* iset, const char* isetRangeName=nullptr) const ;
0126 
0127   std::vector<RooAbsReal*> processProductTerm(const RooArgSet* nset, const RooArgSet* iset, const char* isetRangeName,
0128                      const RooArgSet* term,const RooArgSet& termNSet, const RooArgSet& termISet,
0129                      bool& isOwned, bool forceWrap=false) const ;
0130 
0131 
0132   CacheMode canNodeBeCached() const override { return RooAbsArg::NotAdvised ; } ;
0133   void setCacheAndTrackHints(RooArgSet&) override ;
0134 
0135   // The cache object
0136   class CacheElem final : public RooAbsCacheElement {
0137   public:
0138     CacheElem() : _isRearranged(false) { }
0139     // Payload
0140     RooArgList _partList ;
0141     RooArgList _numList ;
0142     RooArgList _denList ;
0143     RooArgList _ownedList ;
0144     std::vector<std::unique_ptr<RooArgSet>> _normList;
0145     bool _isRearranged ;
0146     std::unique_ptr<RooAbsReal> _rearrangedNum{};
0147     std::unique_ptr<RooAbsReal> _rearrangedDen{};
0148     // Cache management functions
0149     RooArgList containedArgs(Action) override ;
0150     void printCompactTreeHook(std::ostream&, const char *, Int_t, Int_t) override ;
0151     void writeToStream(std::ostream& os) const ;
0152   } ;
0153 
0154   std::unique_ptr<CacheElem> createCacheElem(const RooArgSet* nset, const RooArgSet* iset, const char* isetRangeName=nullptr) const;
0155 
0156   mutable RooObjCacheManager _cacheMgr ; //! The cache manager
0157 
0158   CacheElem* getCacheElem(RooArgSet const* nset) const ;
0159   void rearrangeProduct(CacheElem&) const;
0160   std::unique_ptr<RooAbsReal> specializeIntegral(RooAbsReal& orig, const char* targetRangeName) const ;
0161   std::unique_ptr<RooAbsReal> specializeRatio(RooFormulaVar& input, const char* targetRangeName) const ;
0162   double calculate(const RooProdPdf::CacheElem& cache, bool verbose=false) const ;
0163   void doEvalImpl(RooAbsArg const* caller, const RooProdPdf::CacheElem &cache, RooFit::EvalContext &) const;
0164 
0165 
0166   friend class RooProdGenContext ;
0167   friend class RooFixedProdPdf ;
0168   RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
0169                                   const RooArgSet *auxProto=nullptr, bool verbose= false) const override ;
0170 
0171 
0172   mutable RooAICRegistry _genCode ; ///<! Registry of composite direct generator codes
0173 
0174   double _cutOff = 0.0;       ///<  Cutoff parameter for running product
0175   RooListProxy _pdfList ;  ///<  List of PDF components
0176   std::vector<std::unique_ptr<RooArgSet>> _pdfNSetList ; ///< List of PDF component normalization sets
0177   Int_t _extendedIndex = -1; ///<  Index of extended PDF (if any)
0178 
0179   void useDefaultGen(bool flag=true) { _useDefaultGen = flag ; }
0180   bool _useDefaultGen = false; ///< Use default or distributed event generator
0181 
0182   mutable TNamed* _refRangeName = nullptr; ///< Reference range name for interpretation of conditional products
0183 
0184   bool _selfNorm = true; ///< Is self-normalized
0185   RooArgSet _defNormSet ; ///< Default normalization set
0186 
0187 private:
0188 
0189 
0190 
0191   ClassDefOverride(RooProdPdf,6) // PDF representing a product of PDFs
0192 };
0193 
0194 
0195 #endif