File indexing completed on 2025-01-18 10:11:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROO_MOMENT_MORPH_FUNC
0012 #define ROO_MOMENT_MORPH_FUNC
0013
0014 #include "RooAbsPdf.h"
0015 #include "RooRealProxy.h"
0016 #include "RooCategoryProxy.h"
0017 #include "RooAbsReal.h"
0018 #include "RooAbsCategory.h"
0019 #include "RooSetProxy.h"
0020 #include "RooListProxy.h"
0021 #include "RooArgList.h"
0022
0023 #include "TMatrixD.h"
0024 #include "TVectorD.h"
0025
0026 #include <list>
0027
0028 class RooChangeTracker;
0029
0030 class RooMomentMorphFunc : public RooAbsReal {
0031 public:
0032 enum Setting { Linear, NonLinear, NonLinearPosFractions, NonLinearLinFractions, SineLinear };
0033
0034 RooMomentMorphFunc();
0035
0036 RooMomentMorphFunc(const char *name, const char *title, RooAbsReal &_m, const RooArgList &varList,
0037 const RooArgList &pdfList, const RooArgList &mrefList, Setting setting = NonLinearPosFractions);
0038 RooMomentMorphFunc(const char *name, const char *title, RooAbsReal &_m, const RooArgList &varList,
0039 const RooArgList &pdfList, const TVectorD &mrefpoints, Setting setting = NonLinearPosFractions);
0040 RooMomentMorphFunc(const RooMomentMorphFunc &other, const char *name = nullptr);
0041 TObject *clone(const char *newname) const override { return new RooMomentMorphFunc(*this, newname); }
0042 ~RooMomentMorphFunc() override;
0043
0044 void setMode(const Setting &setting) { _setting = setting; }
0045
0046 void useHorizontalMorphing(bool val) { _useHorizMorph = val; }
0047
0048 virtual bool selfNormalized() const
0049 {
0050
0051 return true;
0052 }
0053
0054 double getValV(const RooArgSet *set = nullptr) const override;
0055 RooAbsReal *sumFunc(const RooArgSet *nset);
0056 const RooAbsReal *sumFunc(const RooArgSet *nset) const;
0057
0058 std::list<double> *plotSamplingHint(RooAbsRealLValue &obs, double xlo, double xhi) const override;
0059 std::list<double> *binBoundaries(RooAbsRealLValue & , double , double ) const override;
0060 bool isBinnedDistribution(const RooArgSet &obs) const override;
0061
0062 protected:
0063 class CacheElem : public RooAbsCacheElement {
0064 public:
0065 CacheElem(RooAbsReal &sumFunc, RooChangeTracker &tracker, const RooArgList &flist)
0066 : _sumFunc(&sumFunc), _tracker(&tracker)
0067 {
0068 _frac.add(flist);
0069 };
0070 ~CacheElem() override;
0071 RooArgList containedArgs(Action) override;
0072 RooAbsReal *_sumFunc;
0073 RooChangeTracker *_tracker;
0074 RooArgList _frac;
0075
0076 RooRealVar *frac(Int_t i);
0077 const RooRealVar *frac(Int_t i) const;
0078 void calculateFractions(const RooMomentMorphFunc &self, bool verbose = true) const;
0079 };
0080 mutable RooObjCacheManager _cacheMgr;
0081 mutable RooArgSet *_curNormSet = nullptr;
0082
0083 friend class CacheElem;
0084
0085 double evaluate() const override;
0086
0087 void initialize();
0088 CacheElem *getCache(const RooArgSet *nset) const;
0089
0090 inline Int_t ij(const Int_t &i, const Int_t &j) const { return (i * _varList.size() + j); }
0091 int idxmin(const double &m) const;
0092 int idxmax(const double &m) const;
0093
0094 RooRealProxy m;
0095 RooSetProxy _varList;
0096 RooListProxy _pdfList;
0097 mutable TVectorD *_mref = nullptr;
0098
0099 mutable TMatrixD *_M = nullptr;
0100
0101 Setting _setting;
0102
0103 bool _useHorizMorph = true;
0104
0105 ClassDefOverride(RooMomentMorphFunc, 3);
0106 };
0107
0108 #endif