00001 #include "EvtGenBase/EvtPatches.hh" 00002 /******************************************************************************* 00003 * Project: BaBar detector at the SLAC PEP-II B-factory 00004 * Package: EvtGenBase 00005 * File: $Id: EvtIntegPdf1D.cc,v 1.1.1.2 2007/10/26 05:03:14 pingrg Exp $ 00006 * Author: Alexei Dvoretskii, dvoretsk@slac.stanford.edu, 2001-2002 00007 * 00008 * Copyright (C) 2002 Caltech 00009 *******************************************************************************/ 00010 00011 #include <assert.h> 00012 #include "EvtGenBase/EvtPatches.hh" 00013 #include "EvtGenBase/EvtMacros.hh" 00014 #include "EvtGenBase/EvtIntegPdf1D.hh" 00015 00016 EvtIntegPdf1D::EvtIntegPdf1D(double min, double max) 00017 : EvtPdf<EvtPoint1D>(), _min(min), _max(max) 00018 { 00019 assert(min <= max); 00020 } 00021 00022 EvtIntegPdf1D::EvtIntegPdf1D(const EvtIntegPdf1D& other) 00023 : EvtPdf<EvtPoint1D>(other), _min(other._min), _max(other._max) 00024 {} 00025 00026 EvtIntegPdf1D::~EvtIntegPdf1D() 00027 {} 00028 00029 EvtValError EvtIntegPdf1D::compute_integral() const 00030 { 00031 double x1 = pdfIntegral(_min); 00032 double x2 = pdfIntegral(_max); 00033 return EvtValError(x2-x1,0.); 00034 } 00035 00036 00037 EvtPoint1D EvtIntegPdf1D::randomPoint() 00038 { 00039 double itgmin = pdfIntegral(_min); 00040 double itgmax = pdfIntegral(_max); 00041 double itgrnd = EvtRandom::Flat(itgmin,itgmax); 00042 00043 return EvtPoint1D(_min,_max,pdfIntegralInverse(itgrnd)); 00044 } 00045 00046