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.
EvtCGCoefSingle.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 
24 #include "EvtGenBase/EvtPatches.hh"
25 
26 #include <assert.h>
27 #include <iostream>
28 #include <math.h>
29 #include <stdlib.h>
30 
31 void EvtCGCoefSingle::init( int j1, int j2 )
32 {
33  _j1 = j1;
34  _j2 = j2;
35 
36  _Jmax = abs( j1 + j2 );
37  _Jmin = abs( j1 - j2 );
38 
39  _table.resize( ( _Jmax - _Jmin ) / 2 + 1 );
40 
41  int J, M;
42 
43  int lenmax = j1 + 1;
44  if ( j2 < j1 )
45  lenmax = j2 + 1;
46 
47  //set vector sizes
48  for ( J = _Jmax; J >= _Jmin; J -= 2 ) {
49  _table[( J - _Jmin ) / 2].resize( J + 1 );
50  for ( M = J; J >= -M; M -= 2 ) {
51  int len = ( ( _j1 + _j2 ) - abs( M ) ) / 2 + 1;
52  if ( len > lenmax )
53  len = lenmax;
54  _table[( J - _Jmin ) / 2][( M + J ) / 2].resize( len );
55  }
56  }
57 
58  //now fill the vectors
59  for ( J = _Jmax; J >= _Jmin; J -= 2 ) {
60  //bootstrap with highest M(=J) as a special case
61  if ( J == _Jmax ) {
62  cg( J, J, _j1, _j2 ) = 1.0;
63  } else {
64  int n = ( _Jmax - J ) / 2 + 1;
65  std::vector<double>* vectors = new std::vector<double>[n - 1];
66  int i, k;
67  for ( i = 0; i < n - 1; i++ ) {
68  // i corresponds to J=Jmax-2*i
69  vectors[i].resize( n );
70  for ( k = 0; k < n; k++ ) {
71  double tmp = _table[( _Jmax - _Jmin ) / 2 - i]
72  [( J + _Jmax - 2 * i ) / 2][k];
73  vectors[i][k] = tmp;
74  }
75  }
76  EvtOrthogVector getOrth( n, vectors );
77  std::vector<double> orth = getOrth.getOrthogVector();
78  int sign = 1;
79  if ( orth[n - 1] < 0.0 )
80  sign = -1;
81  for ( k = 0; k < n; k++ ) {
82  _table[( J - _Jmin ) / 2][J][k] = sign * orth[k];
83  }
84  delete[] vectors;
85  }
86  for ( M = J - 2; M >= -J; M -= 2 ) {
87  int len = ( ( _j1 + _j2 ) - abs( M ) ) / 2 + 1;
88  if ( len > lenmax )
89  len = lenmax;
90  int mmin = M - j2;
91  if ( mmin < -j1 )
92  mmin = -j1;
93  int m1;
94  for ( m1 = mmin; m1 < mmin + len * 2; m1 += 2 ) {
95  int m2 = M - m1;
96  double sum = 0.0;
97  float fkwTmp = _j1 * ( _j1 + 2 ) - ( m1 + 2 ) * m1;
98  //fkw 2/2/2001: changes needed to satisfy KCC
99  //fkw if (m1+2<=_j1) sum+=0.5*sqrt(_j1*(_j1+2)-(m1+2)*m1)*cg(J,M+2,m1+2,m2);
100  //fkw if (m2+2<=_j2) sum+=0.5*sqrt(_j2*(_j2+2)-(m2+2)*m2)*cg(J,M+2,m1,m2+2);
101  //fkw sum/=(0.5*sqrt(J*(J+2)-(M+2)*M));
102  if ( m1 + 2 <= _j1 )
103  sum += 0.5 * sqrt( fkwTmp ) * cg( J, M + 2, m1 + 2, m2 );
104  fkwTmp = _j2 * ( _j2 + 2 ) - ( m2 + 2 ) * m2;
105  if ( m2 + 2 <= _j2 )
106  sum += 0.5 * sqrt( fkwTmp ) * cg( J, M + 2, m1, m2 + 2 );
107  fkwTmp = J * ( J + 2 ) - ( M + 2 ) * M;
108  sum /= ( 0.5 * sqrt( fkwTmp ) );
109  cg( J, M, m1, m2 ) = sum;
110  }
111  }
112  }
113 }
114 
115 double EvtCGCoefSingle::coef( int J, int M, int j1, int j2, int m1, int m2 )
116 {
117  assert( j1 == _j1 );
118  _unused( j1 );
119  assert( j2 == _j2 );
120  _unused( j2 );
121 
122  return cg( J, M, m1, m2 );
123 }
124 
125 double& EvtCGCoefSingle::cg( int J, int M, int m1, int m2 )
126 {
127  assert( M == m1 + m2 );
128  _unused( m2 );
129  assert( abs( M ) <= J );
130  assert( J <= _Jmax );
131  assert( J >= _Jmin );
132  assert( abs( m1 ) <= _j1 );
133  assert( abs( m2 ) <= _j2 );
134 
135  //find lowest m1 allowed for the given M
136 
137  int mmin = M - _j2;
138 
139  if ( mmin < -_j1 )
140  mmin = -_j1;
141 
142  int n = m1 - mmin;
143 
144  return _table[( J - _Jmin ) / 2][( M + J ) / 2][n / 2];
145 }
#define _unused(x)
Definition: EvtPatches.hh:28
void init(int j1, int j2)
std::vector< std::vector< std::vector< double > > > _table
double & cg(int J, int M, int m1, int m2)
double coef(int J, int M, int j1, int j2, int m1, int m2)
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:201
std::vector< double > getOrthogVector()