ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooNumConvolution.h,v 1.4 2007/05/11 09:11:30 verkerke Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_NUM_CONVOLUTION
#define ROO_NUM_CONVOLUTION

#include "RooAbsPdf.h"
#include "RooRealProxy.h"
#include "RooSetProxy.h"
#include "RooListProxy.h"
#include "RooNumIntConfig.h"

class RooConvIntegrandBinding ;
class RooAbsIntegrator ;
class TH2 ;

class RooNumConvolution : public RooAbsReal {
public:

  RooNumConvolution() ;

  RooNumConvolution(const char *name, const char *title, 
	         RooRealVar& convVar, RooAbsReal& pdf, RooAbsReal& resmodel, const RooNumConvolution* proto=0) ;

  RooNumConvolution(const RooNumConvolution& other, const char* name=0) ;

  virtual TObject* clone(const char* newname) const { return new RooNumConvolution(*this,newname) ; }
  virtual ~RooNumConvolution() ;

  Double_t evaluate() const ;

  RooNumIntConfig& convIntConfig() { _init = kFALSE ; return _convIntConfig ; }
  const RooNumIntConfig& convIntConfig() const { _init = kFALSE ; return _convIntConfig ; }

  void clearConvolutionWindow() ;
  void setConvolutionWindow(RooAbsReal& centerParam, RooAbsReal& widthParam, Double_t widthScaleFactor=1) ;

  void setCallWarning(Int_t threshold=2000) ;
  void setCallProfiling(Bool_t flag, Int_t nbinX = 40, Int_t nbinCall = 40, Int_t nCallHigh=1000) ;
  const TH2* profileData() const { return _doProf ? _callHist : 0 ; }

  // Access components
  RooRealVar&  var() const { return (RooRealVar&) _origVar.arg() ; }
  RooAbsReal&  pdf() const { return (RooAbsReal&) _origPdf.arg() ; }
  RooAbsReal&  model() const { return (RooAbsReal&) _origModel.arg() ; }

protected:

  friend class RooNumConvPdf ;

  mutable Bool_t _init ;
  void initialize() const ;
  Bool_t redirectServersHook(const RooAbsCollection& newServerList, Bool_t mustReplaceAll, Bool_t nameChange, Bool_t isRecursive) ;

  virtual void printCompactTreeHook(ostream& os, const char* indent="") ;

  RooNumIntConfig _convIntConfig ; // Configuration of numeric convolution integral ;
  mutable RooConvIntegrandBinding* _integrand ; //! Binding of Convolution Integrand function
  mutable RooAbsIntegrator* _integrator ;  //! Numeric integrator of convolution integrand

  RooRealProxy _origVar ;         // Original convolution variable
  RooRealProxy _origPdf ;         // Original input PDF
  RooRealProxy _origModel ;       // Original resolution model

  mutable RooArgSet    _ownedClonedPdfSet ;   // Owning set of cloned PDF components
  mutable RooArgSet    _ownedClonedModelSet ; // Owning set of cloned model components

  mutable RooAbsReal*  _cloneVar ;        // Pointer to cloned convolution variable
  mutable RooAbsReal*  _clonePdf ;        // Pointer to cloned PDF 
  mutable RooAbsReal*  _cloneModel ;      // Pointer to cloned model

  friend class RooConvGenContext ;
  RooRealVar&  cloneVar()   const { if (!_init) initialize() ; return (RooRealVar&) *_cloneVar ; }
  RooAbsReal&   clonePdf()   const { if (!_init) initialize() ; return (RooAbsReal&)  *_clonePdf ; }
  RooAbsReal&   cloneModel() const { if (!_init) initialize() ; return (RooAbsReal&)  *_cloneModel ; }

  Bool_t       _useWindow   ;     // Switch to activate window convolution
  Double_t     _windowScale ;     // Scale factor for window parameter
  RooListProxy _windowParam ;     // Holder for optional convolution integration window scaling parameter

  Int_t        _verboseThresh ;   // Call count threshold for verbose printing
  Bool_t       _doProf   ;        // Switch to activate profiling option
  TH2*         _callHist ;        //! Histogram recording number of calls per convolution integral calculation

  ClassDef(RooNumConvolution,1)   // Operator PDF implementing numeric convolution of 2 input functions
};

#endif
 RooNumConvolution.h:1
 RooNumConvolution.h:2
 RooNumConvolution.h:3
 RooNumConvolution.h:4
 RooNumConvolution.h:5
 RooNumConvolution.h:6
 RooNumConvolution.h:7
 RooNumConvolution.h:8
 RooNumConvolution.h:9
 RooNumConvolution.h:10
 RooNumConvolution.h:11
 RooNumConvolution.h:12
 RooNumConvolution.h:13
 RooNumConvolution.h:14
 RooNumConvolution.h:15
 RooNumConvolution.h:16
 RooNumConvolution.h:17
 RooNumConvolution.h:18
 RooNumConvolution.h:19
 RooNumConvolution.h:20
 RooNumConvolution.h:21
 RooNumConvolution.h:22
 RooNumConvolution.h:23
 RooNumConvolution.h:24
 RooNumConvolution.h:25
 RooNumConvolution.h:26
 RooNumConvolution.h:27
 RooNumConvolution.h:28
 RooNumConvolution.h:29
 RooNumConvolution.h:30
 RooNumConvolution.h:31
 RooNumConvolution.h:32
 RooNumConvolution.h:33
 RooNumConvolution.h:34
 RooNumConvolution.h:35
 RooNumConvolution.h:36
 RooNumConvolution.h:37
 RooNumConvolution.h:38
 RooNumConvolution.h:39
 RooNumConvolution.h:40
 RooNumConvolution.h:41
 RooNumConvolution.h:42
 RooNumConvolution.h:43
 RooNumConvolution.h:44
 RooNumConvolution.h:45
 RooNumConvolution.h:46
 RooNumConvolution.h:47
 RooNumConvolution.h:48
 RooNumConvolution.h:49
 RooNumConvolution.h:50
 RooNumConvolution.h:51
 RooNumConvolution.h:52
 RooNumConvolution.h:53
 RooNumConvolution.h:54
 RooNumConvolution.h:55
 RooNumConvolution.h:56
 RooNumConvolution.h:57
 RooNumConvolution.h:58
 RooNumConvolution.h:59
 RooNumConvolution.h:60
 RooNumConvolution.h:61
 RooNumConvolution.h:62
 RooNumConvolution.h:63
 RooNumConvolution.h:64
 RooNumConvolution.h:65
 RooNumConvolution.h:66
 RooNumConvolution.h:67
 RooNumConvolution.h:68
 RooNumConvolution.h:69
 RooNumConvolution.h:70
 RooNumConvolution.h:71
 RooNumConvolution.h:72
 RooNumConvolution.h:73
 RooNumConvolution.h:74
 RooNumConvolution.h:75
 RooNumConvolution.h:76
 RooNumConvolution.h:77
 RooNumConvolution.h:78
 RooNumConvolution.h:79
 RooNumConvolution.h:80
 RooNumConvolution.h:81
 RooNumConvolution.h:82
 RooNumConvolution.h:83
 RooNumConvolution.h:84
 RooNumConvolution.h:85
 RooNumConvolution.h:86
 RooNumConvolution.h:87
 RooNumConvolution.h:88
 RooNumConvolution.h:89
 RooNumConvolution.h:90
 RooNumConvolution.h:91
 RooNumConvolution.h:92
 RooNumConvolution.h:93
 RooNumConvolution.h:94
 RooNumConvolution.h:95
 RooNumConvolution.h:96
 RooNumConvolution.h:97
 RooNumConvolution.h:98
 RooNumConvolution.h:99
 RooNumConvolution.h:100