#include "RooFit.h"
#include "Riostream.h"
#include "Riostream.h"
#include <math.h>
#include "TMath.h"
#include "RooDstD0BG.h"
#include "RooAbsReal.h"
#include "RooRealVar.h"
#include "RooIntegrator1D.h"
#include "RooAbsFunc.h"
ClassImp(RooDstD0BG) 
static const char rcsid[] =
"$Id: RooDstD0BG.cxx,v 1.20 2007/05/14 14:38:04 wouter Exp $";
RooDstD0BG::RooDstD0BG(const char *name, const char *title,
		       RooAbsReal& _dm, RooAbsReal& _dm0,
		       RooAbsReal& _c, RooAbsReal& _a, RooAbsReal& _b) :
  RooAbsPdf(name,title),
  dm("dm","Dstar-D0 Mass Diff",this, _dm),
  dm0("dm0","Threshold",this, _dm0),
  C("C","Shape Parameter",this, _c),
  A("A","Shape Parameter 2",this, _a),
  B("B","Shape Parameter 3",this, _b)
{
}
RooDstD0BG::RooDstD0BG(const RooDstD0BG& other, const char *name) :
  RooAbsPdf(other,name), dm("dm",this,other.dm), dm0("dm0",this,other.dm0),
  C("C",this,other.C), A("A",this,other.A), B("B",this,other.B)
{
}
Double_t RooDstD0BG::evaluate() const
{
  Double_t arg= dm- dm0;
  if (arg <= 0 ) return 0;
  Double_t ratio= dm/dm0;
  Double_t val= (1- exp(-arg/C))* TMath::Power(ratio, A) + B*(ratio-1);
  return (val > 0 ? val : 0) ;
}
Int_t RooDstD0BG::getAnalyticalIntegral(RooArgSet& , RooArgSet& , const char* ) const 
{
  
  return 0 ;
}
Double_t RooDstD0BG::analyticalIntegral(Int_t code, const char* rangeName) const 
{
  switch(code) {
  case 1: 
    {
      Double_t min= dm.min(rangeName);
      Double_t max= dm.max(rangeName);
      if (max <= dm0 ) return 0;
      else if (min < dm0) min = dm0;
      Bool_t doNumerical= kFALSE;
      if ( A != 0 ) doNumerical= kTRUE;
      else if (B < 0) {
	
	
	
	
	
	if ( 1- exp(-(max-dm0)/C) + B*(max/dm0 -1) < 0) doNumerical= kTRUE;
      }
      if ( ! doNumerical ) {
	return (max-min)+ C* exp(dm0/C)* (exp(-max/C)- exp(-min/C)) +
	  B * (0.5* (max*max - min*min)/dm0 - (max- min));
      } else {
	
	
	
	
	
	RooArgSet vset(dm.arg(),"vset");
	RooAbsFunc *func= bindVars(vset);
	RooIntegrator1D integrator(*func,min,max);
	return integrator.integral();
      }
    }
  }
  
  assert(0) ;
  return 0 ;
}
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.