]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TEvtGen/EvtGen/EvtGenBase/EvtIntegPdf1D.cpp
Converting TEvtGen to native cmake
[u/mrichter/AliRoot.git] / TEvtGen / EvtGen / EvtGenBase / EvtIntegPdf1D.cpp
diff --git a/TEvtGen/EvtGen/EvtGenBase/EvtIntegPdf1D.cpp b/TEvtGen/EvtGen/EvtGenBase/EvtIntegPdf1D.cpp
new file mode 100644 (file)
index 0000000..d2fa8b4
--- /dev/null
@@ -0,0 +1,46 @@
+#include "EvtGenBase/EvtPatches.hh"
+/*******************************************************************************
+ * Project: BaBar detector at the SLAC PEP-II B-factory
+ * Package: EvtGenBase
+ *    File: $Id: EvtIntegPdf1D.cpp,v 1.3 2009-03-16 15:48:09 robbep Exp $
+ *  Author: Alexei Dvoretskii, dvoretsk@slac.stanford.edu, 2001-2002
+ *
+ * Copyright (C) 2002 Caltech
+ *******************************************************************************/
+
+#include <assert.h>
+#include "EvtGenBase/EvtPatches.hh"
+#include "EvtGenBase/EvtMacros.hh"
+#include "EvtGenBase/EvtIntegPdf1D.hh"
+
+EvtIntegPdf1D::EvtIntegPdf1D(double min, double max)
+  : EvtPdf<EvtPoint1D>(), _min(min), _max(max)
+{
+  assert(min <= max);
+}
+
+EvtIntegPdf1D::EvtIntegPdf1D(const EvtIntegPdf1D& other)
+  : EvtPdf<EvtPoint1D>(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));
+}
+
+