evtgen is hosted by Hepforge, IPPP Durham
EvtGen  2.0.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
EvtBreitWignerPdf.cpp
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4 * *
5 * This file is part of EvtGen. *
6 * *
7 * EvtGen is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * EvtGen is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19 ***********************************************************************/
20 
22 
23 #include "EvtGenBase/EvtConst.hh"
24 #include "EvtGenBase/EvtPatches.hh"
25 
26 #include <assert.h>
27 #include <math.h>
28 #include <stdio.h>
29 
30 EvtBreitWignerPdf::EvtBreitWignerPdf( double min, double max, double m0,
31  double g0 ) :
32  EvtIntegPdf1D( min, max ), _m0( m0 ), _g0( g0 )
33 {
34 }
35 
37  EvtIntegPdf1D( other ), _m0( other._m0 ), _g0( other._g0 )
38 {
39 }
40 
41 double EvtBreitWignerPdf::pdf( const EvtPoint1D& x ) const
42 {
43  double m = x.value();
44  if ( ( 0 == ( m - _m0 ) ) && ( 0. == _g0 ) ) {
45  printf( "Delta function Breit-Wigner\n" );
46  assert( 0 );
47  }
48 
49  double ret = _g0 / EvtConst::twoPi /
50  ( ( m - _m0 ) * ( m - _m0 ) + _g0 * _g0 / 4 );
51 
52  return ret;
53 }
54 
55 double EvtBreitWignerPdf::pdfIntegral( double m ) const
56 {
57  double itg = 0;
58  if ( _g0 == 0 ) {
59  if ( m > _m0 )
60  itg = 1.;
61  else if ( m < _m0 )
62  itg = 0.;
63  else
64  itg = 0.5;
65  } else
66  itg = atan( ( m - _m0 ) / ( _g0 / 2. ) ) / EvtConst::pi + 0.5;
67 
68  return itg;
69 }
70 
71 double EvtBreitWignerPdf::pdfIntegralInverse( double x ) const
72 {
73  if ( x < 0 || x > 1 ) {
74  printf( "Invalid integral value %f\n", x );
75  assert( 0 );
76  }
77 
78  double m = _m0;
79  if ( _g0 != 0 )
80  m = _m0 + ( _g0 / 2. ) * tan( EvtConst::pi * ( x - 0.5 ) );
81 
82  return m;
83 }
double value() const
Definition: EvtPoint1D.hh:35
static const double twoPi
Definition: EvtConst.hh:27
static const double pi
Definition: EvtConst.hh:26
double pdfIntegralInverse(double x) const override
double pdfIntegral(double m) const override
EvtBreitWignerPdf(double min, double max, double m0, double g0)
double pdf(const EvtPoint1D &x) const override
Index other(Index i, Index j)
Definition: EvtCyclic3.cpp:156