Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooIntegralMorph.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) 2000-2007, Regents of the University of California          *
0005  *                          and Stanford University. All rights reserved.    *
0006  *                                                                           *
0007  * Redistribution and use in source and binary forms,                        *
0008  * with or without modification, are permitted according to the terms        *
0009  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0010  *****************************************************************************/
0011 
0012 #ifndef ROOLINEARMORPH
0013 #define ROOLINEARMORPH
0014 
0015 #include "RooAbsCachedPdf.h"
0016 #include "RooRealProxy.h"
0017 #include "RooCategoryProxy.h"
0018 #include "RooAbsReal.h"
0019 #include "RooAbsCategory.h"
0020 #include <vector>
0021 
0022 class RooBrentRootFinder;
0023 
0024 class TH1D;
0025 
0026 class RooIntegralMorph : public RooAbsCachedPdf {
0027 public:
0028   RooIntegralMorph() = default;
0029   RooIntegralMorph(const char *name, const char *title,
0030          RooAbsReal& _pdf1,
0031          RooAbsReal& _pdf2,
0032            RooAbsReal& _x,
0033          RooAbsReal& _alpha, bool cacheAlpha=false);
0034   RooIntegralMorph(const RooIntegralMorph& other, const char* name=nullptr) ;
0035   TObject* clone(const char* newname) const override { return new RooIntegralMorph(*this,newname); }
0036 
0037   bool selfNormalized() const override {
0038     // P.d.f is self normalized
0039     return true ;
0040   }
0041   void setCacheAlpha(bool flag) {
0042     // Activate caching of p.d.f. shape for all values of alpha as well
0043     _cacheMgr.sterilize() ; _cacheAlpha = flag ;
0044   }
0045   bool cacheAlpha() const {
0046     // If true caching of p.d.f for all alpha values is active
0047     return _cacheAlpha ;
0048   }
0049 
0050   void preferredObservableScanOrder(const RooArgSet& obs, RooArgSet& orderedObs) const override ;
0051 
0052   class MorphCacheElem : public RooAbsCachedPdf::PdfCacheElem {
0053   public:
0054     MorphCacheElem(RooIntegralMorph& self, const RooArgSet* nset) ;
0055     ~MorphCacheElem() override ;
0056     void calculate(TIterator* iter) ;
0057     RooArgList containedArgs(Action) override ;
0058 
0059   protected:
0060 
0061     void findRange() ;
0062     double calcX(double y, bool& ok) ;
0063     Int_t binX(double x) ;
0064     void fillGap(Int_t ixlo, Int_t ixhi,double splitPoint=0.5) ;
0065     void interpolateGap(Int_t ixlo, Int_t ixhi) ;
0066 
0067     RooIntegralMorph* _self ; //
0068     std::unique_ptr<RooArgSet> _nset ;
0069     RooAbsPdf* _pdf1 ; // PDF1
0070     RooAbsPdf* _pdf2 ; // PDF2
0071     RooRealVar* _x   ; // X
0072     RooAbsReal* _alpha ; // ALPHA
0073     std::unique_ptr<RooAbsReal> _c1 ; // CDF of PDF 1
0074     std::unique_ptr<RooAbsReal> _c2 ; // CDF of PDF 2
0075     std::unique_ptr<RooAbsFunc> _cb1 ; // Binding of CDF1
0076     std::unique_ptr<RooAbsFunc> _cb2 ; // Binding of CDF2
0077     std::unique_ptr<RooBrentRootFinder> _rf1; // ROOT finder on CDF1
0078     std::unique_ptr<RooBrentRootFinder> _rf2; // ROOT finder of CDF2 ;
0079 
0080     std::vector<double> _yatX ; //
0081     std::vector<double> _calcX; //
0082     Int_t _yatXmin, _yatXmax ;
0083     Int_t _ccounter ;
0084 
0085     double _ycutoff ;
0086 
0087   } ;
0088 
0089 protected:
0090 
0091   friend class MorphCacheElem ;
0092   PdfCacheElem* createCache(const RooArgSet* nset) const override ;
0093   const char* inputBaseName() const override ;
0094   RooFit::OwningPtr<RooArgSet> actualObservables(const RooArgSet& nset) const override ;
0095   RooFit::OwningPtr<RooArgSet> actualParameters(const RooArgSet& nset) const override ;
0096   void fillCacheObject(PdfCacheElem& cache) const override ;
0097 
0098   RooRealProxy pdf1 ; // First input shape
0099   RooRealProxy pdf2 ; // Second input shape
0100   RooRealProxy x ;    // Observable
0101   RooRealProxy alpha ; // Interpolation parameter
0102   bool _cacheAlpha ; // If true, both (x,alpha) are cached
0103   mutable MorphCacheElem* _cache = nullptr; // Current morph cache element in use
0104 
0105 
0106   double evaluate() const override ;
0107 
0108 private:
0109 
0110   ClassDefOverride(RooIntegralMorph,1) // Linear shape interpolation operator p.d.f
0111 };
0112 
0113 #endif