Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooRealSumPdf.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: RooRealSumPdf.h,v 1.10 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_SUM_PDF
0017 #define ROO_REAL_SUM_PDF
0018 
0019 #include "RooAbsPdf.h"
0020 #include "RooListProxy.h"
0021 #include "RooAICRegistry.h"
0022 #include "RooObjCacheManager.h"
0023 
0024 class RooRealSumPdf : public RooAbsPdf {
0025 public:
0026 
0027   RooRealSumPdf() ;
0028   RooRealSumPdf(const char *name, const char *title);
0029   RooRealSumPdf(const char *name, const char *title, const RooArgList& funcList, const RooArgList& coefList, bool extended=false) ;
0030   RooRealSumPdf(const char *name, const char *title,
0031          RooAbsReal& func1, RooAbsReal& func2, RooAbsReal& coef1) ;
0032   RooRealSumPdf(const RooRealSumPdf& other, const char* name=nullptr) ;
0033   TObject* clone(const char* newname) const override { return new RooRealSumPdf(*this,newname) ; }
0034 
0035   double evaluate() const override ;
0036   bool checkObservables(const RooArgSet* nset) const override ;
0037 
0038   void doEval(RooFit::EvalContext &) const override;
0039 
0040   bool forceAnalyticalInt(const RooAbsArg& arg) const override { return arg.isFundamental() ; }
0041   Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
0042   double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
0043 
0044   const RooArgList& funcList() const { return _funcList ; }
0045   const RooArgList& coefList() const { return _coefList ; }
0046 
0047   ExtendMode extendMode() const override ;
0048 
0049   /// Return expected number of events for extended likelihood calculation, which
0050   /// is the sum of all coefficients.
0051   double expectedEvents(const RooArgSet* nset) const override ;
0052 
0053   bool selfNormalized() const override { return getAttribute("BinnedLikelihoodActive") ; }
0054 
0055   void printMetaArgs(std::ostream& os) const override ;
0056 
0057 
0058   std::list<double>* binBoundaries(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override ;
0059   std::list<double>* plotSamplingHint(RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/) const override ;
0060   bool isBinnedDistribution(const RooArgSet& obs) const override  ;
0061 
0062   void setFloor(bool flag) { _doFloor = flag ; }
0063   bool getFloor() const { return _doFloor ; }
0064   static void setFloorGlobal(bool flag) { _doFloorGlobal = flag ; }
0065   static bool getFloorGlobal() { return _doFloorGlobal ; }
0066 
0067   CacheMode canNodeBeCached() const override { return RooAbsArg::NotAdvised ; } ;
0068   void setCacheAndTrackHints(RooArgSet&) override ;
0069 
0070   std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const override;
0071 
0072   std::unique_ptr<RooAbsReal> createExpectedEventsFunc(const RooArgSet* nset) const override;
0073 
0074   void translate(RooFit::Detail::CodeSquashContext &ctx) const override;
0075 
0076 protected:
0077 
0078   class CacheElem : public RooAbsCacheElement {
0079   public:
0080     CacheElem()  {} ;
0081     RooArgList containedArgs(Action) override { RooArgList ret(_funcIntList) ; ret.add(_funcNormList) ; return ret ; }
0082     RooArgList _funcIntList ;
0083     RooArgList _funcNormList ;
0084   } ;
0085   mutable RooObjCacheManager _normIntMgr ; ///<! The integration cache manager
0086 
0087 
0088   RooListProxy _funcList ;  ///<  List of component FUNCs
0089   RooListProxy _coefList ;  ///<  List of coefficients
0090   bool _extended ;        ///< Allow use as extended p.d.f.
0091 
0092   bool _doFloor = false; ///< Introduce floor at zero in pdf
0093   mutable bool _haveWarned{false}; ///<!
0094   static bool _doFloorGlobal ; ///< Global flag for introducing floor at zero in pdf
0095 
0096 private:
0097 
0098   friend class RooAddPdf;
0099   friend class RooAddition;
0100   friend class RooRealSumFunc;
0101 
0102   static void initializeFuncsAndCoefs(RooAbsReal const& caller,
0103                                       const RooArgList& inFuncList, const RooArgList& inCoefList,
0104                                       RooArgList& funcList, RooArgList& coefList);
0105 
0106   static double evaluate(RooAbsReal const& caller,
0107                          RooArgList const& funcList,
0108                          RooArgList const& coefList,
0109                          bool doFloor,
0110                          bool & hasWarnedBefore);
0111 
0112   static std::string translateImpl(RooFit::Detail::CodeSquashContext &ctx, RooAbsArg const *klass,
0113                                    RooArgList const &funcList, RooArgList const &coefList, bool normalize=false);
0114 
0115   static bool checkObservables(RooAbsReal const &caller, RooArgSet const *nset, RooArgList const &funcList,
0116                                RooArgList const &coefList);
0117 
0118   static Int_t getAnalyticalIntegralWN(RooAbsReal const& caller, RooObjCacheManager & normIntMgr,
0119                                        RooArgList const& funcList, RooArgList const& coefList,
0120                                        RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName);
0121   static double analyticalIntegralWN(RooAbsReal const& caller, RooObjCacheManager & normIntMgr,
0122                                      RooArgList const& funcList, RooArgList const& coefList,
0123                                      Int_t code, const RooArgSet* normSet, const char* rangeName,
0124                                      bool hasWarnedBefore);
0125 
0126   static std::list<double>* binBoundaries(
0127           RooArgList const& funcList, RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/);
0128   static std::list<double>* plotSamplingHint(
0129           RooArgList const& funcList, RooAbsRealLValue& /*obs*/, double /*xlo*/, double /*xhi*/);
0130   static bool isBinnedDistribution(RooArgList const& funcList, const RooArgSet& obs);
0131 
0132   static void printMetaArgs(RooArgList const& funcList, RooArgList const& coefList, std::ostream& os);
0133 
0134   static void setCacheAndTrackHints(RooArgList const& funcList, RooArgSet& trackNodes);
0135 
0136   inline void setExtended(bool extended) { _extended = extended; }
0137 
0138   ClassDefOverride(RooRealSumPdf, 5) // PDF constructed from a sum of (non-pdf) functions
0139 };
0140 
0141 #endif