Line data Source code
1 : #include "EvtGenBase/EvtPatches.hh"
2 : /*******************************************************************************
3 : * Project: BaBar detector at the SLAC PEP-II B-factory
4 : * Package: EvtGenBase
5 : * File: $Id: EvtIntegPdf1D.cpp,v 1.3 2009-03-16 15:48:09 robbep Exp $
6 : * Author: Alexei Dvoretskii, dvoretsk@slac.stanford.edu, 2001-2002
7 : *
8 : * Copyright (C) 2002 Caltech
9 : *******************************************************************************/
10 :
11 : #include <assert.h>
12 : #include "EvtGenBase/EvtPatches.hh"
13 : #include "EvtGenBase/EvtMacros.hh"
14 : #include "EvtGenBase/EvtIntegPdf1D.hh"
15 :
16 : EvtIntegPdf1D::EvtIntegPdf1D(double min, double max)
17 0 : : EvtPdf<EvtPoint1D>(), _min(min), _max(max)
18 0 : {
19 0 : assert(min <= max);
20 0 : }
21 :
22 : EvtIntegPdf1D::EvtIntegPdf1D(const EvtIntegPdf1D& other)
23 0 : : EvtPdf<EvtPoint1D>(other), _min(other._min), _max(other._max)
24 0 : {}
25 :
26 : EvtIntegPdf1D::~EvtIntegPdf1D()
27 0 : {}
28 :
29 : EvtValError EvtIntegPdf1D::compute_integral() const
30 : {
31 0 : double x1 = pdfIntegral(_min);
32 0 : double x2 = pdfIntegral(_max);
33 0 : return EvtValError(x2-x1,0.);
34 0 : }
35 :
36 :
37 : EvtPoint1D EvtIntegPdf1D::randomPoint()
38 : {
39 0 : double itgmin = pdfIntegral(_min);
40 0 : double itgmax = pdfIntegral(_max);
41 0 : double itgrnd = EvtRandom::Flat(itgmin,itgmax);
42 :
43 0 : return EvtPoint1D(_min,_max,pdfIntegralInverse(itgrnd));
44 0 : }
45 :
46 :
|