#include "EvtGenBase/EvtPatches.hh" /******************************************************************************* * Project: BaBar detector at the SLAC PEP-II B-factory * Package: EvtGenBase * File: $Id: EvtIntegPdf1D.cc,v 1.10 2004/12/21 19:58:44 ryd Exp $ * Author: Alexei Dvoretskii, dvoretsk@slac.stanford.edu, 2001-2002 * * Copyright (C) 2002 Caltech *******************************************************************************/ #include #include "EvtGenBase/EvtPatches.hh" #include "EvtGenBase/EvtMacros.hh" #include "EvtGenBase/EvtIntegPdf1D.hh" EvtIntegPdf1D::EvtIntegPdf1D(double min, double max) : EvtPdf(), _min(min), _max(max) { assert(min <= max); } EvtIntegPdf1D::EvtIntegPdf1D(const EvtIntegPdf1D& other) : EvtPdf(other), _min(other._min), _max(other._max) {} EvtIntegPdf1D::~EvtIntegPdf1D() {} EvtValError EvtIntegPdf1D::compute_integral() const { double x1 = pdfIntegral(_min); double x2 = pdfIntegral(_max); return EvtValError(x2-x1,0.); } EvtPoint1D EvtIntegPdf1D::randomPoint() { double itgmin = pdfIntegral(_min); double itgmax = pdfIntegral(_max); double itgrnd = EvtRandom::Flat(itgmin,itgmax); return EvtPoint1D(_min,_max,pdfIntegralInverse(itgrnd)); }