Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooMomentMorph.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  *
0004  * Copyright (c) 2023, CERN
0005  *
0006  * Redistribution and use in source and binary forms,
0007  * with or without modification, are permitted according to the terms
0008  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
0009  */
0010 
0011 #ifndef ROOMOMENTMORPH
0012 #define ROOMOMENTMORPH
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 class RooChangeTracker;
0027 
0028 class RooMomentMorph : public RooAbsPdf {
0029 public:
0030 
0031   enum Setting { Linear, NonLinear, NonLinearPosFractions, NonLinearLinFractions, SineLinear } ;
0032 
0033   RooMomentMorph() ;
0034 
0035   RooMomentMorph(const char *name, const char *title, RooAbsReal& _m, const RooArgList& varList,
0036           const RooArgList& pdfList, const RooArgList& mrefList, Setting setting = NonLinearPosFractions);
0037   RooMomentMorph(const char *name, const char *title, RooAbsReal& _m, const RooArgList& varList,
0038           const RooArgList& pdfList, const TVectorD& mrefpoints, Setting setting = NonLinearPosFractions );
0039   RooMomentMorph(const RooMomentMorph& other, const char* name=nullptr) ;
0040   TObject* clone(const char* newname) const override { return new RooMomentMorph(*this,newname); }
0041   ~RooMomentMorph() override;
0042 
0043   void     setMode(const Setting& setting) { _setting = setting; }
0044 
0045   void useHorizontalMorphing(bool val) { _useHorizMorph = val; }
0046 
0047   bool selfNormalized() const override {
0048     // P.d.f is self normalized
0049     return true ;
0050   }
0051 
0052   double getValV(const RooArgSet* set=nullptr) const override;
0053   RooAbsPdf* sumPdf(const RooArgSet* nset) ;
0054 
0055 
0056 protected:
0057 
0058   class CacheElem : public RooAbsCacheElement {
0059   public:
0060     CacheElem(std::unique_ptr<RooAbsPdf> && sumPdf,
0061               std::unique_ptr<RooChangeTracker> && tracker,
0062               const RooArgList& flist);
0063     ~CacheElem() override ;
0064     RooArgList containedArgs(Action) override ;
0065     std::unique_ptr<RooAbsPdf> _sumPdf ;
0066     std::unique_ptr<RooChangeTracker> _tracker ;
0067     RooArgList _frac ;
0068 
0069     RooRealVar* frac(Int_t i ) ;
0070     const RooRealVar* frac(Int_t i ) const ;
0071     void calculateFractions(const RooMomentMorph& self, bool verbose=true) const;
0072   } ;
0073   mutable RooObjCacheManager _cacheMgr ; //! The cache manager
0074   mutable RooArgSet* _curNormSet = nullptr; //! Current normalization set
0075 
0076   friend class CacheElem ; // Cache needs to be able to clear _norm pointer
0077 
0078   double evaluate() const override ;
0079 
0080   void     initialize();
0081   CacheElem* getCache(const RooArgSet* nset) const ;
0082 
0083   inline   Int_t ij(const Int_t& i, const Int_t& j) const { return (i*_varList.size()+j); }
0084   int      idxmin(const double& m) const;
0085   int      idxmax(const double& m) const;
0086 
0087   RooRealProxy m ;
0088   RooSetProxy  _varList ;
0089   RooListProxy _pdfList ;
0090   mutable TVectorD* _mref = nullptr;
0091 
0092   mutable TMatrixD* _M = nullptr;
0093 
0094   Setting _setting;
0095 
0096   bool _useHorizMorph = true;
0097 
0098   ClassDefOverride(RooMomentMorph,3);
0099 };
0100 
0101 #endif
0102 
0103