Warning, file /include/root/RooAddGenContext.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_ADD_GEN_CONTEXT
0017 #define ROO_ADD_GEN_CONTEXT
0018
0019 #include "RooAbsGenContext.h"
0020 #include "RooArgSet.h"
0021 #include "RooAddPdf.h"
0022 #include "RooAddModel.h"
0023 #include "RooGenContext.h"
0024 #include "RooMsgService.h"
0025
0026 #include <memory>
0027 #include <vector>
0028
0029 class AddCacheElem;
0030 class RooDataSet;
0031
0032 class RooAddGenContext : public RooAbsGenContext {
0033 public:
0034 RooAddGenContext(const RooAddPdf &model, const RooArgSet &vars, const RooDataSet *prototype=nullptr,
0035 const RooArgSet* auxProto=nullptr, bool _verbose= false);
0036 RooAddGenContext(const RooAddModel &model, const RooArgSet &vars, const RooDataSet *prototype=nullptr,
0037 const RooArgSet* auxProto=nullptr, bool _verbose= false);
0038
0039 void setProtoDataOrder(Int_t* lut) override ;
0040
0041 void attach(const RooArgSet& params) override ;
0042
0043 void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override ;
0044
0045 template<class Pdf_t>
0046 static std::unique_ptr<RooAbsGenContext> create(const Pdf_t &pdf, const RooArgSet &vars,
0047 const RooDataSet *prototype,
0048 const RooArgSet* auxProto, bool verbose);
0049
0050 protected:
0051
0052 void initGenerator(const RooArgSet &theEvent) override;
0053 void generateEvent(RooArgSet &theEvent, Int_t remaining) override;
0054 void updateThresholds() ;
0055
0056 RooAddGenContext(const RooAddGenContext& other) ;
0057
0058 std::unique_ptr<RooArgSet> _vars ;
0059 std::unique_ptr<RooArgSet> _pdfSet ;
0060 RooAbsPdf *_pdf ;
0061 std::vector<std::unique_ptr<RooAbsGenContext>> _gcList ;
0062 Int_t _nComp ;
0063 std::vector<double> _coefThresh ;
0064 bool _isModel ;
0065 AddCacheElem* _pcache = nullptr;
0066
0067 ClassDefOverride(RooAddGenContext,0)
0068 };
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078 template<class Pdf_t>
0079 std::unique_ptr<RooAbsGenContext> RooAddGenContext::create(const Pdf_t &pdf, const RooArgSet &vars,
0080 const RooDataSet *prototype,
0081 const RooArgSet* auxProto, bool verbose)
0082 {
0083
0084
0085 auto hasNegativeCoefs = [&]() {
0086 for(auto * coef : static_range_cast<RooAbsReal*>(pdf._coefList)) {
0087 if(coef->getVal() < 0) return true;
0088 }
0089 return false;
0090 };
0091
0092
0093
0094 if(hasNegativeCoefs()) {
0095 oocxcoutI(&pdf, Generation) << pdf.ClassName() << "::genContext():"
0096 << " using a generic generator context instead of the RooAddGenContext for the "
0097 << pdf.ClassName() << " \"" << pdf.GetName() << "\", because the pdf has negative coefficients." << std::endl;
0098 return std::make_unique<RooGenContext>(pdf, vars, prototype, auxProto, verbose);
0099 }
0100
0101 return std::make_unique<RooAddGenContext>(pdf, vars, prototype, auxProto,verbose) ;
0102 }
0103
0104 #endif