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.
EvtMHelAmp.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 
21 #include "EvtGenBase/EvtMHelAmp.hh"
22 
23 #include "EvtGenBase/EvtKine.hh"
24 #include "EvtGenBase/EvtPatches.hh"
25 #include "EvtGenBase/EvtReport.hh"
26 
27 #include <stdlib.h>
28 
29 using std::endl;
30 
32  const vector<EvtMNode*>& children,
33  const vector<EvtComplex>& elem )
34 {
35  _id = id;
37  _parent = NULL;
38  _lineshape = lineshape;
39 
40  _elem = elem;
41 
42  vector<EvtSpinType::spintype> type;
43  for ( size_t i = 0; i < children.size(); ++i ) {
44  _children.push_back( children[i] );
45  type.push_back( children[i]->getspintype() );
46  const vector<int>& res = children[i]->getresonance();
47  for ( size_t j = 0; j < res.size(); ++j )
48  _resonance.push_back( res[j] );
49  children[i]->setparent( this );
50  }
51 
52  // XXX New code - bugs could appear here XXX
53  _amp = EvtSpinAmp( type );
54  vector<int> index = _amp.iterinit();
55  size_t i = 0;
56  do {
57  if ( !_amp.allowed( index ) )
58  _amp( index ) = 0.0;
59  else if ( abs( index[0] - index[1] ) > _twospin )
60  _amp( index ) = 0.0;
61  else {
62  _amp( index ) = elem[i];
63  ++i;
64  }
65  } while ( _amp.iterate( index ) );
66  if ( elem.size() != i ) {
67  EvtGenReport( EVTGEN_ERROR, "EvtGen" )
68  << "Wrong number of elements input in helicity amplitude." << endl;
69  ::abort();
70  }
71 
72  if ( children.size() > 2 ) {
73  EvtGenReport( EVTGEN_ERROR, "EvtGen" )
74  << "Helicity amplitude formalism can only handle two body resonances"
75  << endl;
76  ::abort();
77  }
78 }
79 
80 EvtSpinAmp EvtMHelAmp::amplitude( const vector<EvtVector4R>& product ) const
81 {
82  EvtVector4R d = _children[0]->get4vector( product );
83  double phi, theta;
84 
85  if ( _parent == NULL ) {
86  // This means that we're calculating the first level and we need to just
87  // calculate the polar and azymuthal angles daughters in rest frame of
88  // this (root) particle (this is automatic).
89  phi = atan2( d.get( 1 ), d.get( 2 ) );
90  theta = acos( d.get( 3 ) / d.d3mag() );
91 
92  } else {
93  // We have parents therefore calculate things in correct coordinate
94  // system
95  EvtVector4R p = _parent->get4vector( product );
96  EvtVector4R q = get4vector( product );
97 
98  // See if we have a grandparent - if no then the z-axis is defined by
99  // the z-axis of the root particle
100  EvtVector4R g = _parent->getparent() == NULL
101  ? EvtVector4R( 0.0, 0.0, 0.0, 1.0 )
102  : _parent->getparent()->get4vector( product );
103 
104  theta = acos( EvtDecayAngle( p, q, d ) );
105  phi = EvtDecayAnglePhi( g, p, q, d );
106  }
107 
108  vector<EvtSpinType::spintype> types( 3 );
109  types[0] = getspintype();
110  types[1] = _children[0]->getspintype();
111  types[2] = _children[1]->getspintype();
112  EvtSpinAmp amp( types, EvtComplex( 0.0, 0.0 ) );
113  vector<int> index = amp.iterallowedinit();
114 
115  do {
116  if ( abs( index[1] - index[2] ) > _twospin )
117  continue;
118  amp( index ) += conj( wignerD( _twospin, index[0], index[1] - index[2],
119  phi, theta, 0.0 ) ) *
120  _amp( index[1], index[2] );
121  } while ( amp.iterateallowed( index ) );
122 
123  EvtSpinAmp amp0 = _children[0]->amplitude( product );
124  EvtSpinAmp amp1 = _children[1]->amplitude( product );
125 
126  amp.extcont( amp0, 1, 0 );
127  amp.extcont( amp1, 1, 0 );
128 
129  amp *= sqrt( ( _twospin + 1 ) / ( 2 * EvtConst::twoPi ) ) *
130  _children[0]->line( product ) * _children[1]->line( product );
131 
132  return amp;
133 }
134 
136 {
137  vector<EvtMNode*> children;
138 
139  for ( size_t i = 0; i < _children.size(); ++i ) {
140  children.push_back( _children[i]->duplicate() );
141  }
142 
143  EvtMLineShape* lineshape = _lineshape->duplicate();
144  EvtMHelAmp* ret = new EvtMHelAmp( _id, lineshape, children, _elem );
145  lineshape->setres( ret );
146 
147  return ret;
148 }
vector< EvtComplex > _elem
Definition: EvtMHelAmp.hh:37
EvtSpinAmp amplitude(const vector< EvtVector4R > &product) const override
Definition: EvtMHelAmp.cpp:80
EvtVector4R get4vector(const vector< EvtVector4R > &product) const
Definition: EvtMNode.cpp:25
EvtMHelAmp(const EvtId &id, EvtMLineShape *, const vector< EvtMNode * > &, const vector< EvtComplex > &)
Definition: EvtMHelAmp.cpp:31
bool iterateallowed(vector< int > &index) const
Definition: EvtSpinAmp.cpp:442
EvtSpinAmp _amp
Definition: EvtMRes.hh:57
EvtMNode * _parent
Definition: EvtMNode.hh:87
void extcont(const EvtSpinAmp &, int, int)
Definition: EvtSpinAmp.cpp:522
static EvtSpinType::spintype getSpinType(EvtId i)
Definition: EvtPDL.cpp:377
vector< EvtMNode * > _children
Definition: EvtMRes.hh:54
int _twospin
Definition: EvtMNode.hh:80
vector< int > iterallowedinit() const
Definition: EvtSpinAmp.cpp:452
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
Evt3Rank3C conj(const Evt3Rank3C &t2)
Definition: Evt3Rank3C.cpp:172
static const double twoPi
Definition: EvtConst.hh:27
virtual EvtMLineShape * duplicate() const =0
EvtId _id
Definition: EvtMNode.hh:77
EvtSpinType::spintype getspintype() const
Definition: EvtMNode.hh:51
bool allowed(const vector< int > &index) const
Definition: EvtSpinAmp.cpp:416
void setres(EvtMRes *n)
Definition: EvtMRes.hh:32
Definition: EvtId.hh:27
EvtMNode * duplicate() const override
Definition: EvtMHelAmp.cpp:135
double EvtDecayAnglePhi(const EvtVector4R &g, const EvtVector4R &p, const EvtVector4R &q, const EvtVector4R &d)
Definition: EvtKine.cpp:106
vector< int > iterinit() const
Definition: EvtSpinAmp.cpp:389
double get(int i) const
Definition: EvtVector4R.hh:162
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:201
bool iterate(vector< int > &index) const
Definition: EvtSpinAmp.cpp:399
static int getSpin2(spintype stype)
Definition: EvtSpinType.cpp:26
double EvtDecayAngle(const EvtVector4R &, const EvtVector4R &, const EvtVector4R &)
Definition: EvtKine.cpp:33
double d3mag() const
EvtComplex wignerD(int j, int m1, int m2, double phi, double theta, double gamma)
Definition: EvtKine.cpp:127
EvtMLineShape * _lineshape
Definition: EvtMRes.hh:60
vector< int > _resonance
Definition: EvtMNode.hh:84
EvtMNode * getparent() const
Definition: EvtMNode.hh:63