Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooAddModel.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: RooAddPdf.h,v 1.46 2007/07/12 20:30: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_ADD_MODEL
0017 #define ROO_ADD_MODEL
0018 
0019 #include "RooResolutionModel.h"
0020 #include "RooListProxy.h"
0021 #include "RooSetProxy.h"
0022 #include "RooAICRegistry.h"
0023 #include "RooObjCacheManager.h"
0024 
0025 class AddCacheElem;
0026 
0027 class RooAddModel : public RooResolutionModel {
0028 public:
0029 
0030   RooAddModel() ;
0031   RooAddModel(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, bool ownPdfList=false) ;
0032   RooAddModel(const RooAddModel& other, const char* name=nullptr) ;
0033   TObject* clone(const char* newname) const override { return new RooAddModel(*this,newname) ; }
0034   RooResolutionModel* convolution(RooFormulaVar* basis, RooAbsArg* owner) const override ;
0035 
0036   double evaluate() const override ;
0037   bool checkObservables(const RooArgSet* nset) const override ;
0038 
0039   void doEval(RooFit::EvalContext &) const override;
0040   inline bool canComputeBatchWithCuda() const override { return true; }
0041 
0042   Int_t basisCode(const char* name) const override ;
0043 
0044   bool forceAnalyticalInt(const RooAbsArg& /*dep*/) const override {
0045     // Force RooRealIntegral to offer all observables for internal integration
0046     return true ;
0047   }
0048   Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
0049   double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
0050 
0051   /// Model is self normalized when used as p.d.f
0052   bool selfNormalized() const override {
0053     return _basisCode==0 ? true : false ;
0054   }
0055 
0056   /// Return extended mode capabilities
0057   ExtendMode extendMode() const override {
0058     return (_haveLastCoef || _allExtendable) ? MustBeExtended : CanNotBeExtended;
0059   }
0060 
0061   /// Return expected number of events for extended likelihood calculation, which
0062   /// is the sum of all coefficients.
0063   double expectedEvents(const RooArgSet* nset) const override ;
0064 
0065   /// Return list of component p.d.fs
0066   const RooArgList& pdfList() const {
0067     return _pdfList ;
0068   }
0069 
0070   /// Return list of coefficients of component p.d.f.s
0071   const RooArgList& coefList() const {
0072     return _coefList ;
0073   }
0074 
0075   bool isDirectGenSafe(const RooAbsArg& arg) const override ;
0076 
0077   Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, bool staticInitOK=true) const override;
0078   void generateEvent(Int_t code) override;
0079 
0080 
0081   void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
0082   void fixCoefRange(const char* rangeName) ;
0083   void resetErrorCounters(Int_t resetValue=10) override ;
0084 
0085   void printMetaArgs(std::ostream& os) const override ;
0086 
0087 protected:
0088 
0089   friend class RooAddGenContext ;
0090   RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
0091                                        const RooArgSet* auxProto=nullptr, bool verbose= false) const override ;
0092 
0093   void selectNormalization(const RooArgSet* depSet=nullptr, bool force=false) override ;
0094   void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override ;
0095 
0096   mutable RooSetProxy _refCoefNorm ;   ///<! Reference observable set for coefficient interpretation
0097   mutable TNamed* _refCoefRangeName = nullptr;  ///<! Reference range name for coefficient interpretation
0098 
0099   mutable std::vector<double> _coefCache; ///<! Transient cache with transformed values of coefficients
0100 
0101 
0102   mutable RooObjCacheManager _projCacheMgr ;  ///<! Manager of cache with coefficient projections and transformations
0103   AddCacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=nullptr) const ;
0104   void updateCoefficients(AddCacheElem& cache, const RooArgSet* nset) const ;
0105 
0106   typedef RooArgList* pRooArgList ;
0107   void getCompIntList(const RooArgSet* nset, const RooArgSet* iset, pRooArgList& compIntList, Int_t& code, const char* isetRangeName) const ;
0108   class IntCacheElem : public RooAbsCacheElement {
0109   public:
0110     RooArgList _intList ; ///< List of component integrals
0111     RooArgList containedArgs(Action) override ;
0112   } ;
0113 
0114   mutable RooObjCacheManager _intCacheMgr ; ///<! Manager of cache with integrals
0115 
0116   mutable RooAICRegistry _codeReg = 10; ///<! Registry of component analytical integration codes
0117 
0118   RooListProxy _pdfList ;   ///<  List of component PDFs
0119   RooListProxy _coefList ;  ///<  List of coefficients
0120   mutable RooArgList* _snormList{nullptr};  ///<!  List of supplemental normalization factors
0121 
0122   bool _haveLastCoef = false;    ///<  Flag indicating if last PDFs coefficient was supplied in the constructor
0123   bool _allExtendable = false;   ///<  Flag indicating if all PDF components are extendable
0124 
0125   mutable Int_t _coefErrCount ; ///<! Coefficient error counter
0126 
0127   mutable RooArgSet _ownedComps ; ///<! Owned components
0128 
0129 private:
0130 
0131   ClassDefOverride(RooAddModel,3) // Resolution model representing a sum of resolution models
0132 };
0133 
0134 #endif