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: EvtDalitzFlatPdf.cpp,v 1.3 2009-03-16 15:53:27 robbep Exp $
6 : * Author: Alexei Dvoretskii, dvoretsk@slac.stanford.edu, 2001-2002
7 : *
8 : * Copyright (C) 2002 Caltech
9 : *******************************************************************************/
10 :
11 : #include "EvtGenBase/EvtPatches.hh"
12 : #include "EvtGenBase/EvtDalitzFlatPdf.hh"
13 :
14 : EvtDalitzFlatPdf::EvtDalitzFlatPdf(const EvtDalitzPlot& dp)
15 0 : : EvtPdf<EvtDalitzPoint>(), _dp(dp)
16 0 : {}
17 :
18 : EvtDalitzFlatPdf::EvtDalitzFlatPdf(const EvtDalitzFlatPdf& other)
19 0 : : EvtPdf<EvtDalitzPoint>(other), _dp(other._dp)
20 0 : {}
21 :
22 : EvtDalitzFlatPdf::~EvtDalitzFlatPdf()
23 0 : {}
24 :
25 : EvtPdf<EvtDalitzPoint>* EvtDalitzFlatPdf::clone() const
26 : {
27 0 : return new EvtDalitzFlatPdf(*this);
28 0 : }
29 :
30 : double EvtDalitzFlatPdf::pdf(const EvtDalitzPoint&) const
31 : {
32 0 : return 1.;
33 : }
34 :
35 : EvtValError EvtDalitzFlatPdf::compute_integral(int N) const
36 : {
37 0 : return EvtValError(_dp.getArea(N),0.);
38 : }
39 :
40 : EvtDalitzPoint EvtDalitzFlatPdf::randomPoint()
41 : {
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
47 : // case. Abort.
48 :
49 : EvtCyclic3::Pair pair1 = EvtCyclic3::BC;
50 : EvtCyclic3::Pair pair2 = EvtCyclic3::CA;
51 :
52 : int n = 0;
53 : int maxTries = 1000;
54 0 : while(n++ < maxTries) {
55 :
56 0 : double q1 = EvtRandom::Flat(_dp.qAbsMin(pair1),_dp.qAbsMax(pair2));
57 0 : double q2 = EvtRandom::Flat(_dp.qAbsMin(pair2),_dp.qAbsMax(pair2));
58 :
59 0 : EvtDalitzCoord point(pair1,q1,pair2,q2);
60 0 : EvtDalitzPoint x(_dp,point);
61 :
62 0 : if(x.isValid()) return x;
63 0 : }
64 :
65 0 : printf("No point generated for dalitz plot after %d tries\n",maxTries);
66 0 : return EvtDalitzPoint();
67 0 : }
|