RooAddPdf.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Project: RooFit                                                           *
00003  * Package: RooFitCore                                                       *
00004  *    File: $Id: RooAddPdf.h,v 1.46 2007/07/12 20:30:28 wouter Exp $
00005  * Authors:                                                                  *
00006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
00007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
00008  *                                                                           *
00009  * Copyright (c) 2000-2005, Regents of the University of California          *
00010  *                          and Stanford University. All rights reserved.    *
00011  *                                                                           *
00012  * Redistribution and use in source and binary forms,                        *
00013  * with or without modification, are permitted according to the terms        *
00014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
00015  *****************************************************************************/
00016 #ifndef ROO_ADD_PDF
00017 #define ROO_ADD_PDF
00018 
00019 #include "RooAbsPdf.h"
00020 #include "RooListProxy.h"
00021 #include "RooSetProxy.h"
00022 #include "RooAICRegistry.h"
00023 #include "RooNormSetCache.h"
00024 #include "RooNameSet.h"
00025 #include "RooCacheManager.h"
00026 #include "RooObjCacheManager.h"
00027 #include "RooNameReg.h"
00028 
00029 class RooAddPdf : public RooAbsPdf {
00030 public:
00031 
00032   RooAddPdf() ;
00033   RooAddPdf(const char *name, const char *title=0);
00034   RooAddPdf(const char *name, const char *title,
00035             RooAbsPdf& pdf1, RooAbsPdf& pdf2, RooAbsReal& coef1) ;
00036   RooAddPdf(const char *name, const char *title, const RooArgList& pdfList) ;
00037   RooAddPdf(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, Bool_t recursiveFraction=kFALSE) ;
00038   
00039   RooAddPdf(const RooAddPdf& other, const char* name=0) ;
00040   virtual TObject* clone(const char* newname) const { return new RooAddPdf(*this,newname) ; }
00041   virtual ~RooAddPdf() ;
00042 
00043   Double_t evaluate() const ;
00044   virtual Bool_t checkObservables(const RooArgSet* nset) const ;        
00045 
00046   virtual Bool_t forceAnalyticalInt(const RooAbsArg& /*dep*/) const { 
00047     // Force RooRealIntegral to offer all observables for internal integration
00048     return kTRUE ; 
00049   }
00050   Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=0) const ;
00051   Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
00052   virtual Bool_t selfNormalized() const { 
00053     // P.d.f is self normalized
00054     return kTRUE ; 
00055   }
00056 
00057   virtual ExtendMode extendMode() const { 
00058     // Return extended mode capabilities
00059     return (_haveLastCoef || _allExtendable) ? MustBeExtended : CanNotBeExtended; 
00060   }
00061   virtual Double_t expectedEvents(const RooArgSet* nset) const ;
00062   virtual Double_t expectedEvents(const RooArgSet& nset) const { 
00063     // Return expected number of events for extended likelihood calculation
00064     // which is the sum of all coefficients
00065     return expectedEvents(&nset) ; 
00066   }
00067 
00068   const RooArgList& pdfList() const { 
00069     // Return list of component p.d.fs
00070     return _pdfList ; 
00071   }
00072   const RooArgList& coefList() const { 
00073     // Return list of coefficients of component p.d.f.s
00074     return _coefList ; 
00075   }
00076 
00077   void fixCoefNormalization(const RooArgSet& refCoefNorm) ;  
00078   void fixCoefRange(const char* rangeName) ;
00079   
00080   const RooArgSet& getCoefNormalization() const { return _refCoefNorm ; }
00081   const char* getCoefRange() const { return _refCoefRangeName?RooNameReg::str(_refCoefRangeName):"" ; }
00082 
00083   virtual void resetErrorCounters(Int_t resetValue=10) ;
00084 
00085   virtual std::list<Double_t>* plotSamplingHint(RooAbsRealLValue& obs, Double_t xlo, Double_t xhi) const ; 
00086 
00087   void printMetaArgs(ostream& os) const ;
00088 
00089 protected:
00090 
00091   virtual void selectNormalization(const RooArgSet* depSet=0, Bool_t force=kFALSE) ;
00092   virtual void selectNormalizationRange(const char* rangeName=0, Bool_t force=kFALSE) ;
00093 
00094   mutable RooSetProxy _refCoefNorm ;   // Reference observable set for coefficient interpretation
00095   mutable TNamed* _refCoefRangeName ;  // Reference range name for coefficient interpreation
00096 
00097   Bool_t _projectCoefs ;         // If true coefficients need to be projected for use in evaluate()
00098   mutable Double_t* _coefCache ; //! Transiet cache with transformed values of coefficients
00099 
00100 
00101   class CacheElem : public RooAbsCacheElement {
00102   public:
00103     virtual ~CacheElem() {} ;
00104 
00105     RooArgList _suppNormList ; // Supplemental normalization list
00106 
00107     RooArgList _projList ; // Projection integrals to be multiplied with coefficients
00108     RooArgList _suppProjList ; // Projection integrals to be multiplied with coefficients for supplemental normalization terms
00109     RooArgList _refRangeProjList ; // Range integrals to be multiplied with coefficients (reference range)
00110     RooArgList _rangeProjList ; // Range integrals to be multiplied with coefficients (target range)
00111 
00112     virtual RooArgList containedArgs(Action) ;
00113 
00114   } ;
00115   mutable RooObjCacheManager _projCacheMgr ;  // Manager of cache with coefficient projections and transformations
00116   CacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=0, const char* rangeName=0) const ;
00117   void updateCoefficients(CacheElem& cache, const RooArgSet* nset) const ;
00118 
00119   
00120   friend class RooAddGenContext ;
00121   virtual RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0, 
00122                                        const RooArgSet* auxProto=0, Bool_t verbose= kFALSE) const ;
00123 
00124 
00125   mutable RooAICRegistry _codeReg ;  //! Registry of component analytical integration codes
00126 
00127   RooListProxy _pdfList ;   //  List of component PDFs
00128   RooListProxy _coefList ;  //  List of coefficients
00129   mutable RooArgList* _snormList ;  //!  List of supplemental normalization factors
00130   TIterator* _pdfIter ;     //! Iterator over PDF list
00131   TIterator* _coefIter ;    //! Iterator over coefficient list
00132   
00133   Bool_t _haveLastCoef ;    //  Flag indicating if last PDFs coefficient was supplied in the ctor
00134   Bool_t _allExtendable ;   //  Flag indicating if all PDF components are extendable
00135 
00136   mutable Int_t _coefErrCount ; //! Coefficient error counter
00137 
00138 private:
00139 
00140   ClassDef(RooAddPdf,2) // PDF representing a sum of PDFs
00141 };
00142 
00143 #endif

Generated on Tue Jul 5 14:26:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1