File indexing completed on 2025-01-18 10:11:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_SIMULTANEOUS
0017 #define ROO_SIMULTANEOUS
0018
0019 #include <RooAICRegistry.h>
0020 #include <RooAbsCacheElement.h>
0021 #include <RooAbsPdf.h>
0022 #include <RooArgList.h>
0023 #include <RooCategoryProxy.h>
0024 #include <RooGlobalFunc.h>
0025 #include <RooObjCacheManager.h>
0026 #include <RooRealProxy.h>
0027 #include <RooSetProxy.h>
0028
0029 #include <TList.h>
0030
0031 #include <map>
0032 #include <string>
0033
0034 class RooAbsCategoryLValue ;
0035 class RooFitResult ;
0036 class RooPlot ;
0037 class RooAbsData ;
0038 class RooLinkedList ;
0039 class RooSuperCategory ;
0040
0041 class RooSimultaneous : public RooAbsPdf {
0042 public:
0043
0044
0045 struct InitializationOutput {
0046
0047 ~InitializationOutput();
0048
0049 void addPdf(const RooAbsPdf &pdf, std::string const &catLabel);
0050
0051 std::vector<RooAbsPdf const *> finalPdfs;
0052 std::vector<std::string> finalCatLabels;
0053 RooAbsCategoryLValue *indexCat = nullptr;
0054 std::unique_ptr<RooSuperCategory> superIndex;
0055 };
0056
0057
0058 inline RooSimultaneous() : _partIntMgr(this,10) {}
0059 RooSimultaneous(const char *name, const char *title, RooAbsCategoryLValue& indexCat) ;
0060 RooSimultaneous(const char *name, const char *title, std::map<std::string,RooAbsPdf*> pdfMap, RooAbsCategoryLValue& inIndexCat) ;
0061 RooSimultaneous(const char *name, const char *title, RooFit::Detail::FlatMap<std::string,RooAbsPdf*> const &pdfMap, RooAbsCategoryLValue& inIndexCat);
0062 RooSimultaneous(const char *name, const char *title, const RooArgList& pdfList, RooAbsCategoryLValue& indexCat) ;
0063 RooSimultaneous(const RooSimultaneous& other, const char* name=nullptr);
0064 TObject* clone(const char* newname) const override { return new RooSimultaneous(*this,newname) ; }
0065 ~RooSimultaneous() override ;
0066
0067 double evaluate() const override ;
0068 bool selfNormalized() const override { return true ; }
0069 bool addPdf(const RooAbsPdf& pdf, const char* catLabel) ;
0070
0071 ExtendMode extendMode() const override ;
0072
0073 double expectedEvents(const RooArgSet* nset) const override ;
0074
0075 bool forceAnalyticalInt(const RooAbsArg&) const override { return true ; }
0076 Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
0077 double analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=nullptr) const override ;
0078
0079 using RooAbsPdf::plotOn ;
0080 RooPlot* plotOn(RooPlot* frame,
0081 const RooCmdArg& arg1 , const RooCmdArg& arg2={},
0082 const RooCmdArg& arg3={}, const RooCmdArg& arg4={},
0083 const RooCmdArg& arg5={}, const RooCmdArg& arg6={},
0084 const RooCmdArg& arg7={}, const RooCmdArg& arg8={},
0085 const RooCmdArg& arg9={}, const RooCmdArg& arg10={}) const override {
0086 return RooAbsReal::plotOn(frame,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10) ;
0087 }
0088 RooPlot* plotOn(RooPlot* frame, RooLinkedList& cmdList) const override ;
0089
0090 RooAbsPdf* getPdf(RooStringView catName) const ;
0091 const RooAbsCategoryLValue& indexCat() const { return (RooAbsCategoryLValue&) _indexCat.arg() ; }
0092
0093
0094 RooFit::OwningPtr<RooDataSet> generateSimGlobal(const RooArgSet& whatVars, Int_t nEvents) override ;
0095
0096 virtual RooDataHist* fillDataHist(RooDataHist *hist, const RooArgSet* nset, double scaleFactor,
0097 bool correctForBinVolume=false, bool showProgress=false) const ;
0098
0099 void wrapPdfsInBinSamplingPdfs(RooAbsData const &data, double precision);
0100 void wrapPdfsInBinSamplingPdfs(RooAbsData const &data,
0101 std::map<std::string, double> const& precisions,
0102 bool useCategoryNames=false);
0103
0104 RooAbsGenContext* autoGenContext(const RooArgSet &vars, const RooDataSet* prototype=nullptr, const RooArgSet* auxProto=nullptr,
0105 bool verbose=false, bool autoBinned=true, const char* binnedTag="") const override ;
0106 RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=nullptr,
0107 const RooArgSet* auxProto=nullptr, bool verbose= false) const override ;
0108
0109 std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const override;
0110
0111 protected:
0112
0113 void selectNormalization(const RooArgSet* depSet=nullptr, bool force=false) override ;
0114 void selectNormalizationRange(const char* rangeName=nullptr, bool force=false) override ;
0115
0116 RooArgSet const& flattenedCatList() const;
0117
0118 mutable RooSetProxy _plotCoefNormSet ;
0119 const TNamed* _plotCoefNormRange = nullptr;
0120
0121 class CacheElem : public RooAbsCacheElement {
0122 public:
0123 RooArgList containedArgs(Action) override { return RooArgList(_partIntList) ; }
0124 RooArgList _partIntList ;
0125 } ;
0126 mutable RooObjCacheManager _partIntMgr ;
0127
0128
0129 friend class RooSimGenContext ;
0130 friend class RooSimSplitGenContext ;
0131
0132 RooCategoryProxy _indexCat ;
0133 TList _pdfProxyList ;
0134 Int_t _numPdf = 0;
0135
0136 private:
0137
0138
0139 RooSimultaneous(const char *name, const char *title, InitializationOutput && initInfo);
0140
0141 static std::unique_ptr<RooSimultaneous::InitializationOutput>
0142 initialize(std::string const& name, RooAbsCategoryLValue &inIndexCat,
0143 std::map<std::string, RooAbsPdf *> const &pdfMap);
0144
0145 mutable std::unique_ptr<RooArgSet> _indexCatSet ;
0146
0147 ClassDefOverride(RooSimultaneous,3)
0148 };
0149
0150 #endif