Warning, file /include/root/RooAbsSelfCachedReal.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 #ifndef RooFit_RooAbsSelfCachedReal_h
0012 #define RooFit_RooAbsSelfCachedReal_h
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #include <RooAbsCachedPdf.h>
0033 #include <RooAbsCachedReal.h>
0034 #include <RooDataHist.h>
0035 #include <RooHistPdf.h>
0036 #include <RooMsgService.h>
0037 #include <RooRealProxy.h>
0038
0039 #include <Riostream.h>
0040
0041 template <class Base_t>
0042 class RooAbsSelfCached : public Base_t {
0043 public:
0044 RooAbsSelfCached() {}
0045
0046 RooAbsSelfCached(const char *name, const char *title, int ipOrder = 0) : Base_t(name, title, ipOrder) {}
0047
0048
0049 RooAbsSelfCached(const RooAbsSelfCached &other, const char *name = nullptr) : Base_t(other, name) {}
0050
0051 protected:
0052 const char *inputBaseName() const override
0053 {
0054
0055 return Base_t::GetName();
0056 }
0057 RooFit::OwningPtr<RooArgSet> actualObservables(const RooArgSet &nset) const override;
0058 RooFit::OwningPtr<RooArgSet> actualParameters(const RooArgSet &nset) const override;
0059 void fillCacheObject(typename Base_t::CacheElem &cache) const override;
0060
0061 private:
0062 ClassDefOverride(RooAbsSelfCached, 0);
0063 };
0064
0065 using RooAbsSelfCachedReal = RooAbsSelfCached<RooAbsCachedReal>;
0066 using RooAbsSelfCachedPdf = RooAbsSelfCached<RooAbsCachedPdf>;
0067
0068
0069
0070
0071 template <class Base_t>
0072 void RooAbsSelfCached<Base_t>::fillCacheObject(typename Base_t::CacheElem &cache) const
0073 {
0074 RooDataHist &cacheHist = *cache.hist();
0075
0076
0077 RooArgSet cloneSet;
0078 RooArgSet(*this).snapshot(cloneSet, true);
0079 RooAbsSelfCached *clone2 = (RooAbsSelfCached *)cloneSet.find(Base_t::GetName());
0080 clone2->disableCache(true);
0081 clone2->attachDataSet(cacheHist);
0082
0083
0084 for (int i = 0; i < cacheHist.numEntries(); i++) {
0085 const RooArgSet *obs = cacheHist.get(i);
0086 double wgt = clone2->getVal(obs);
0087 cacheHist.set(i, wgt, 0.);
0088 }
0089
0090 cache.setUnitNorm();
0091 }
0092
0093
0094
0095
0096
0097 template <class Base_t>
0098 RooFit::OwningPtr<RooArgSet> RooAbsSelfCached<Base_t>::actualObservables(const RooArgSet &nset) const
0099 {
0100
0101 RooArgSet serverSet;
0102
0103 for (auto server : Base_t::servers()) {
0104 serverSet.add(*server);
0105 }
0106
0107
0108 return RooFit::OwningPtr<RooArgSet>{serverSet.selectCommon(nset)};
0109 }
0110
0111 template <>
0112 inline RooFit::OwningPtr<RooArgSet> RooAbsSelfCached<RooAbsCachedPdf>::actualObservables(const RooArgSet & ) const
0113 {
0114
0115 auto serverSet = new RooArgSet;
0116
0117 for (auto server : servers()) {
0118 serverSet->add(*server);
0119 }
0120
0121
0122
0123
0124
0125 return RooFit::OwningPtr<RooArgSet>{serverSet};
0126 }
0127
0128
0129
0130
0131
0132
0133 template <class Base_t>
0134 RooFit::OwningPtr<RooArgSet> RooAbsSelfCached<Base_t>::actualParameters(const RooArgSet &nset) const
0135 {
0136
0137 RooArgSet *serverSet = new RooArgSet;
0138
0139 for (auto server : Base_t::servers()) {
0140 serverSet->add(*server);
0141 }
0142
0143
0144 serverSet->remove(nset, true, true);
0145
0146 return RooFit::OwningPtr<RooArgSet>{serverSet};
0147 }
0148
0149 #endif