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.
EvtHelAmp.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"
25 #include "EvtGenBase/EvtGenKine.hh"
26 #include "EvtGenBase/EvtId.hh"
27 #include "EvtGenBase/EvtPDL.hh"
29 #include "EvtGenBase/EvtPatches.hh"
30 #include "EvtGenBase/EvtReport.hh"
31 
32 #include <string>
33 #include <vector>
34 using std::endl;
35 
36 std::string EvtHelAmp::getName()
37 {
38  return "HELAMP";
39 }
40 
42 {
43  return new EvtHelAmp;
44 }
45 
47 {
48  checkNDaug( 2 );
49 
50  //find out how many states each particle have
54 
55  if ( verbose() ) {
56  EvtGenReport( EVTGEN_INFO, "EvtGen" )
57  << "_nA,_nB,_nC:" << _nA << "," << _nB << "," << _nC << endl;
58  }
59 
60  //find out what 2 times the spin is
64 
65  if ( verbose() ) {
66  EvtGenReport( EVTGEN_INFO, "EvtGen" )
67  << "_JA2,_JB2,_JC2:" << _JA2 << "," << _JB2 << "," << _JC2 << endl;
68  }
69 
70  //allocate memory
71  std::vector<int> _lambdaA2( _nA );
72  std::vector<int> _lambdaB2( _nB );
73  std::vector<int> _lambdaC2( _nC );
74 
75  EvtComplexPtr* _HBC = new EvtComplexPtr[_nB];
76  for ( int ib = 0; ib < _nB; ib++ ) {
77  _HBC[ib] = new EvtComplex[_nC];
78  }
79 
80  int i;
81  //find the allowed helicities (actually 2*times the helicity!)
82 
83  fillHelicity( _lambdaA2.data(), _nA, _JA2, getParentId() );
84  fillHelicity( _lambdaB2.data(), _nB, _JB2, getDaug( 0 ) );
85  fillHelicity( _lambdaC2.data(), _nC, _JC2, getDaug( 1 ) );
86 
87  if ( verbose() ) {
88  EvtGenReport( EVTGEN_INFO, "EvtGen" )
89  << "Helicity states of particle A:" << endl;
90  for ( i = 0; i < _nA; i++ ) {
91  EvtGenReport( EVTGEN_INFO, "EvtGen" ) << _lambdaA2[i] << endl;
92  }
93 
94  EvtGenReport( EVTGEN_INFO, "EvtGen" )
95  << "Helicity states of particle B:" << endl;
96  for ( i = 0; i < _nB; i++ ) {
97  EvtGenReport( EVTGEN_INFO, "EvtGen" ) << _lambdaB2[i] << endl;
98  }
99 
100  EvtGenReport( EVTGEN_INFO, "EvtGen" )
101  << "Helicity states of particle C:" << endl;
102  for ( i = 0; i < _nC; i++ ) {
103  EvtGenReport( EVTGEN_INFO, "EvtGen" ) << _lambdaC2[i] << endl;
104  }
105  }
106 
107  //now read in the helicity amplitudes
108 
109  int argcounter = 0;
110 
111  for ( int ib = 0; ib < _nB; ib++ ) {
112  for ( int ic = 0; ic < _nC; ic++ ) {
113  _HBC[ib][ic] = 0.0;
114  if ( abs( _lambdaB2[ib] - _lambdaC2[ic] ) <= _JA2 )
115  argcounter += 2;
116  }
117  }
118 
119  checkNArg( argcounter );
120 
121  argcounter = 0;
122 
123  for ( int ib = 0; ib < _nB; ib++ ) {
124  for ( int ic = 0; ic < _nC; ic++ ) {
125  if ( abs( _lambdaB2[ib] - _lambdaC2[ic] ) <= _JA2 ) {
126  _HBC[ib][ic] = getArg( argcounter ) *
127  exp( EvtComplex( 0.0, getArg( argcounter + 1 ) ) );
128  ;
129  argcounter += 2;
130  if ( verbose() ) {
131  EvtGenReport( EVTGEN_INFO, "EvtGen" )
132  << "_HBC[" << ib << "][" << ic << "]=" << _HBC[ib][ic]
133  << endl;
134  }
135  }
136  }
137  }
138 
139  _evalHelAmp = std::make_unique<EvtEvalHelAmp>( getParentId(), getDaug( 0 ),
140  getDaug( 1 ), _HBC );
141 
142  // Note: these are not class data members but local variables.
143  for ( int ib = 0; ib < _nB; ib++ ) {
144  delete[] _HBC[ib];
145  }
146  delete[] _HBC; // _HBC is copied in ctor of EvtEvalHelAmp above.
147 }
148 
150 {
151  double maxprob = _evalHelAmp->probMax();
152 
153  if ( verbose() ) {
154  EvtGenReport( EVTGEN_INFO, "EvtGen" )
155  << "Calculated probmax" << maxprob << endl;
156  }
157 
158  setProbMax( maxprob );
159 }
160 
162 {
163  //first generate simple phase space
165 
166  _evalHelAmp->evalAmp( p, _amp2 );
167 }
168 
169 void EvtHelAmp::fillHelicity( int* lambda2, int n, int J2, EvtId id )
170 {
171  int i;
172 
173  //photon is special case!
174  if ( n == 2 && J2 == 2 ) {
175  lambda2[0] = 2;
176  lambda2[1] = -2;
177  return;
178  }
179 
180  //and so is the neutrino!
181  if ( n == 1 && J2 == 1 ) {
182  if ( EvtPDL::getStdHep( id ) > 0 ) {
183  //particle i.e. lefthanded
184  lambda2[0] = -1;
185  } else {
186  //anti particle i.e. righthanded
187  lambda2[0] = 1;
188  }
189  return;
190  }
191 
192  assert( n == J2 + 1 );
193 
194  for ( i = 0; i < n; i++ ) {
195  lambda2[i] = n - i * 2 - 1;
196  }
197 
198  return;
199 }
void initProbMax() override
Definition: EvtHelAmp.cpp:149
void decay(EvtParticle *p) override
Definition: EvtHelAmp.cpp:161
void init() override
Definition: EvtHelAmp.cpp:46
double getArg(unsigned int j)
static EvtSpinType::spintype getSpinType(EvtId i)
Definition: EvtPDL.cpp:377
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
std::string getName() override
Definition: EvtHelAmp.cpp:36
static int getSpinStates(spintype stype)
Definition: EvtSpinType.cpp:57
std::unique_ptr< EvtEvalHelAmp > _evalHelAmp
Definition: EvtHelAmp.hh:48
EvtId * getDaugs()
Definition: EvtDecayBase.hh:66
void setProbMax(double prbmx)
Definition: EvtId.hh:27
EvtId getParentId() const
Definition: EvtDecayBase.hh:61
double initializePhaseSpace(unsigned int numdaughter, EvtId *daughters, bool forceResetMasses=false, double poleSize=-1., int whichTwo1=0, int whichTwo2=1)
void checkNDaug(int d1, int d2=-1)
void checkNArg(int a1, int a2=-1, int a3=-1, int a4=-1)
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:201
static int getSpin2(spintype stype)
Definition: EvtSpinType.cpp:26
EvtDecayBase * clone() override
Definition: EvtHelAmp.cpp:41
int getNDaug() const
Definition: EvtDecayBase.hh:65
EvtComplex exp(const EvtComplex &c)
Definition: EvtComplex.hh:240
int verbose() const
Definition: EvtDecayBase.hh:82
EvtAmp _amp2
Definition: EvtDecayAmp.hh:73
void fillHelicity(int *lambda2, int n, int J2, EvtId id)
Definition: EvtHelAmp.cpp:169
static int getStdHep(EvtId id)
Definition: EvtPDL.cpp:362
EvtId getDaug(int i) const
Definition: EvtDecayBase.hh:67