1 #include "EvtGenBase/EvtPatches.hh"
2 /*******************************************************************************
3 * Project: BaBar detector at the SLAC PEP-II B-factory
5 * File: $Id: EvtDalitzFlatPdf.cc,v 1.4 2004/12/21 19:58:42 ryd Exp $
6 * Author: Alexei Dvoretskii, dvoretsk@slac.stanford.edu, 2001-2002
8 * Copyright (C) 2002 Caltech
9 *******************************************************************************/
11 #include "EvtGenBase/EvtPatches.hh"
12 #include "EvtGenBase/EvtDalitzFlatPdf.hh"
14 EvtDalitzFlatPdf::EvtDalitzFlatPdf(const EvtDalitzPlot& dp)
15 : EvtPdf<EvtDalitzPoint>(), _dp(dp)
18 EvtDalitzFlatPdf::EvtDalitzFlatPdf(const EvtDalitzFlatPdf& other)
19 : EvtPdf<EvtDalitzPoint>(other), _dp(other._dp)
22 EvtDalitzFlatPdf::~EvtDalitzFlatPdf()
25 EvtPdf<EvtDalitzPoint>* EvtDalitzFlatPdf::clone() const
27 return new EvtDalitzFlatPdf(*this);
30 double EvtDalitzFlatPdf::pdf(const EvtDalitzPoint&) const
35 EvtValError EvtDalitzFlatPdf::compute_integral(int N) const
37 return EvtValError(_dp.getArea(N),0.);
40 EvtDalitzPoint EvtDalitzFlatPdf::randomPoint()
42 // To obtain a uniform distribution generate
43 // in terms of q's. Generate in a box that circumscribes the
44 // Dalitz plot. Accept points inside. If there are two
45 // many unsuccessful attempts it's a hint that the Dalitz plot
46 // area is tiny compared to the box. It's a pathological
49 EvtCyclic3::Pair pair1 = EvtCyclic3::BC;
50 EvtCyclic3::Pair pair2 = EvtCyclic3::CA;
54 while(n++ < maxTries) {
56 double q1 = EvtRandom::Flat(_dp.qAbsMin(pair1),_dp.qAbsMax(pair2));
57 double q2 = EvtRandom::Flat(_dp.qAbsMin(pair2),_dp.qAbsMax(pair2));
59 EvtDalitzCoord point(pair1,q1,pair2,q2);
60 EvtDalitzPoint x(_dp,point);
62 if(x.isValid()) return x;
65 printf("No point generated for dalitz plot after %d tries\n",maxTries);