RooAddModel.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_MODEL
00017 #define ROO_ADD_MODEL
00018 
00019 #include "RooResolutionModel.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 
00028 class RooAddModel : public RooResolutionModel {
00029 public:
00030 
00031   RooAddModel() ;
00032   RooAddModel(const char *name, const char *title, const RooArgList& pdfList, const RooArgList& coefList, Bool_t ownPdfList=kFALSE) ;
00033   RooAddModel(const RooAddModel& other, const char* name=0) ;
00034   virtual TObject* clone(const char* newname) const { return new RooAddModel(*this,newname) ; }
00035   virtual RooResolutionModel* convolution(RooFormulaVar* basis, RooAbsArg* owner) const ;
00036   virtual ~RooAddModel() ;
00037 
00038   Double_t evaluate() const ;
00039   virtual Bool_t checkObservables(const RooArgSet* nset) const ;        
00040 
00041   virtual Int_t basisCode(const char* name) const ;
00042 
00043   virtual Bool_t forceAnalyticalInt(const RooAbsArg& /*dep*/) const { 
00044     // Force RooRealIntegral to offer all observables for internal integration
00045     return kTRUE ; 
00046   }
00047   Int_t getAnalyticalIntegralWN(RooArgSet& allVars, RooArgSet& numVars, const RooArgSet* normSet, const char* rangeName=0) const ;
00048   Double_t analyticalIntegralWN(Int_t code, const RooArgSet* normSet, const char* rangeName=0) const ;
00049   virtual Bool_t selfNormalized() const { 
00050     // Model is self normalized when used as p.d.f 
00051     return _basisCode==0 ? kTRUE : kFALSE ; 
00052   }
00053 
00054   virtual ExtendMode extendMode() const { 
00055     // Return extended mode capabilities    
00056     return (_haveLastCoef || _allExtendable) ? MustBeExtended : CanNotBeExtended; 
00057   }
00058   virtual Double_t expectedEvents(const RooArgSet* nset) const ;
00059   virtual Double_t expectedEvents(const RooArgSet& nset) const { 
00060     // Return expected number of events for extended likelihood calculation
00061     // which is the sum of all coefficients
00062     return expectedEvents(&nset) ; 
00063   }
00064 
00065   const RooArgList& pdfList() const { 
00066     // Return list of component p.d.fs
00067     return _pdfList ; 
00068   }
00069   const RooArgList& coefList() const { 
00070     // Return list of coefficients of component p.d.f.s
00071     return _coefList ; 
00072   }
00073 
00074   Bool_t isDirectGenSafe(const RooAbsArg& arg) const ;
00075 
00076   Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const;
00077   void generateEvent(Int_t code);
00078 
00079 
00080   void fixCoefNormalization(const RooArgSet& refCoefNorm) ;
00081   void fixCoefRange(const char* rangeName) ;
00082   virtual void resetErrorCounters(Int_t resetValue=10) ;
00083 
00084   void printMetaArgs(ostream& os) const ;
00085 
00086 protected:
00087 
00088   friend class RooAddGenContext ;
00089   virtual RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0, 
00090                                        const RooArgSet* auxProto=0, Bool_t verbose= kFALSE) const ;
00091 
00092   virtual void selectNormalization(const RooArgSet* depSet=0, Bool_t force=kFALSE) ;
00093   virtual void selectNormalizationRange(const char* rangeName=0, Bool_t force=kFALSE) ;
00094 
00095   mutable RooSetProxy _refCoefNorm ;   //! Reference observable set for coefficient interpretation
00096   mutable TNamed* _refCoefRangeName ;  //! Reference range name for coefficient interpreation
00097 
00098   Bool_t _projectCoefs ;         // If true coefficients need to be projected for use in evaluate()
00099   mutable Double_t* _coefCache ; //! Transiet cache with transformed values of coefficients
00100 
00101 
00102   class CacheElem : public RooAbsCacheElement {
00103   public:
00104     virtual ~CacheElem() {} ;
00105 
00106     RooArgList _suppNormList ; // Supplemental normalization list
00107 
00108     RooArgList _projList ; // Projection integrals to be multiplied with coefficients
00109     RooArgList _suppProjList ; // Projection integrals to be multiplied with coefficients for supplemental normalization terms
00110     RooArgList _refRangeProjList ; // Range integrals to be multiplied with coefficients (reference range)
00111     RooArgList _rangeProjList ; // Range integrals to be multiplied with coefficients (target range)
00112 
00113     virtual RooArgList containedArgs(Action) ;
00114 
00115   } ;
00116   mutable RooObjCacheManager _projCacheMgr ;  // Manager of cache with coefficient projections and transformations
00117   CacheElem* getProjCache(const RooArgSet* nset, const RooArgSet* iset=0, const char* rangeName=0) const ;
00118   void updateCoefficients(CacheElem& cache, const RooArgSet* nset) const ;
00119 
00120   typedef RooArgList* pRooArgList ;
00121   void getCompIntList(const RooArgSet* nset, const RooArgSet* iset, pRooArgList& compIntList, Int_t& code, const char* isetRangeName) const ;
00122   class IntCacheElem : public RooAbsCacheElement {
00123   public:
00124     virtual ~IntCacheElem() {} ;
00125     RooArgList _intList ; // List of component integrals 
00126     virtual RooArgList containedArgs(Action) ;
00127   } ;
00128   
00129   mutable RooObjCacheManager _intCacheMgr ; // Manager of cache with integrals
00130  
00131   mutable RooAICRegistry _codeReg ;  //! Registry of component analytical integration codes
00132 
00133   RooListProxy _pdfList ;   //  List of component PDFs
00134   RooListProxy _coefList ;  //  List of coefficients
00135   mutable RooArgList* _snormList ;  //!  List of supplemental normalization factors
00136   TIterator* _pdfIter ;     //! Iterator over PDF list
00137   TIterator* _coefIter ;    //! Iterator over coefficient list
00138   
00139   Bool_t _haveLastCoef ;    //  Flag indicating if last PDFs coefficient was supplied in the ctor
00140   Bool_t _allExtendable ;   //  Flag indicating if all PDF components are extendable
00141 
00142   mutable Int_t _coefErrCount ; //! Coefficient error counter
00143 
00144   mutable RooArgSet _ownedComps ; //! Owned components
00145 
00146 private:
00147 
00148   ClassDef(RooAddModel,1) // Resolution model representing a sum of resolution models
00149 };
00150 
00151 #endif

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