/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooNumConvPdf.h,v 1.2 2007/05/11 10:42:36 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_CONV_PDF
#define ROO_NUM_CONV_PDF

#include "RooAbsPdf.h"
#include "RooNumConvolution.h"

class TH2 ;
class RooArgSet ;
class RooDataSet ;

class RooNumConvPdf : public RooAbsPdf {
public:

  RooNumConvPdf() ;

  RooNumConvPdf(const char *name, const char *title, 
                RooRealVar& convVar, RooAbsPdf& pdf, RooAbsPdf& resmodel) ;

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

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

  virtual Double_t evaluate() const ;

  // Calls forwarded to RooNumConvolution
  inline RooNumIntConfig& convIntConfig() { return conv().convIntConfig() ; }
  inline void clearConvolutionWindow() { conv().clearConvolutionWindow() ; }
  inline void setConvolutionWindow(RooAbsReal& centerParam, RooAbsReal& widthParam, Double_t widthScaleFactor=1) 
	{ conv().setConvolutionWindow(centerParam,widthParam,widthScaleFactor) ; }
  inline void setCallWarning(Int_t threshold=2000) { conv().setCallWarning(threshold) ; }
  inline void setCallProfiling(Bool_t flag, Int_t nbinX = 40, Int_t nbinCall = 40, Int_t nCallHigh=1000) 
	{ conv().setCallProfiling(flag,nbinX,nbinCall,nCallHigh) ; }
  inline const TH2* profileData() const { return conv().profileData() ; }

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

  void printMetaArgs(std::ostream& os) const ;

protected:

  // WVE Store all properties of RooNumConvolution here so that can be take
  // along in the copy ctor.

  RooNumConvolution& conv() const { if (!_init) initialize() ; return *_conv ; }

  mutable Bool_t _init ; //! do not persist
  void initialize() const ;
  mutable RooNumConvolution* _conv ; //! Actual convolution calculation

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

  virtual RooAbsGenContext* genContext(const RooArgSet &vars, const RooDataSet *prototype=0, 
                                       const RooArgSet* auxProto=0, Bool_t verbose= kFALSE) const ;

  friend class RooConvGenContext ;

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

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