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.
EvtdFunctionSingle.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/EvtPatches.hh"
24 
25 #include <assert.h>
26 #include <iostream>
27 #include <math.h>
28 #include <stdlib.h>
29 
31 {
32  _j = 0;
33  _m1 = 0;
34  _m2 = 0;
35  _coef = 0;
36  _kmin = 0;
37  _kmax = 0;
38 }
39 
41 {
42  if ( _coef != 0 )
43  delete[] _coef;
44 }
45 
46 void EvtdFunctionSingle::init( int j, int m1, int m2 )
47 {
48  assert( abs( m2 ) >= abs( m1 ) );
49  assert( m2 >= 0 );
50 
51  _j = j;
52  _m1 = m1;
53  _m2 = m2;
54 
55  _kmin = _m2 - _m1;
56  _kmax = _j - _m1;
57 
58  assert( _kmin <= _kmax );
59 
60  _coef = new double[( _kmax - _kmin ) / 2 + 1];
61 
62  int k;
63 
64  for ( k = _kmin; k <= _kmax; k += 2 ) {
65  int sign = 1;
66  if ( ( k - _m2 + _m1 ) % 4 != 0 )
67  sign = -sign;
68  double tmp = fact( ( _j + _m2 ) / 2 ) * fact( ( _j - _m2 ) / 2 ) *
69  fact( ( _j + _m1 ) / 2 ) * fact( ( _j - _m1 ) / 2 );
70  _coef[( k - _kmin ) / 2] =
71  sign * sqrt( tmp ) /
72  ( fact( ( _j + _m2 - k ) / 2 ) * fact( k / 2 ) *
73  fact( ( _j - _m1 - k ) / 2 ) * fact( ( k - _m2 + _m1 ) / 2 ) );
74  }
75 }
76 
77 double EvtdFunctionSingle::d( int j, int m1, int m2, double theta )
78 {
79  assert( j == _j );
80  _unused( j );
81  assert( m1 == _m1 );
82  assert( m2 == _m2 );
83 
84  double c2 = cos( 0.5 * theta );
85  double s2 = sin( 0.5 * theta );
86 
87  double d = 0.0;
88 
89  int k;
90  for ( k = _kmin; k <= _kmax; k += 2 ) {
91  d += _coef[( k - _kmin ) / 2] *
92  pow( c2, ( 2 * _j - 2 * k + m2 - m1 ) / 2 ) *
93  pow( s2, ( 2 * k - m2 + m1 ) / 2 );
94  }
95 
96  return d;
97 }
98 
100 {
101  assert( n >= 0 );
102 
103  int f = 1;
104 
105  int k;
106  for ( k = 2; k <= n; k++ )
107  f *= k;
108 
109  return f;
110 }
void init(int j, int m1, int m2)
#define _unused(x)
Definition: EvtPatches.hh:28
double d(int j, int m1, int m2, double theta)
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:201