EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Toggle main menu visibility
Loading...
Searching...
No Matches
src
EvtGenBase
EvtDecayAmp.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/EvtDecayAmp.hh
"
22
23
#include "
EvtGenBase/EvtAmp.hh
"
24
#include "
EvtGenBase/EvtDecayBase.hh
"
25
#include "
EvtGenBase/EvtPDL.hh
"
26
#include "
EvtGenBase/EvtParticle.hh
"
27
#include "
EvtGenBase/EvtRadCorr.hh
"
28
#include "
EvtGenBase/EvtRandom.hh
"
29
#include "
EvtGenBase/EvtReport.hh
"
30
using
std::endl;
31
32
void
EvtDecayAmp::makeDecay
(
EvtParticle
* p,
bool
recursive )
33
{
34
//original default value
35
int
ntimes = 10000;
36
37
int
more;
38
39
EvtSpinDensity
rho;
40
double
prob, prob_max;
41
42
m_amp2
.init( p->
getId
(),
getNDaug
(),
getDaugs
() );
43
44
do
{
45
m_daugsDecayedByParentModel
=
false
;
46
m_weight
= 1.0;
47
decay
( p );
48
49
rho =
m_amp2
.getSpinDensity();
50
51
prob = p->
getSpinDensityForward
().
normalizedProb
( rho );
52
53
if
( prob < 0.0 ) {
54
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
55
<<
"Negative prob:"
<< p->
getId
().
getId
() <<
" "
56
<< p->
getChannel
() << endl;
57
58
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
) <<
"rho_forward:"
<< endl;
59
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
) << p->
getSpinDensityForward
();
60
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
) <<
"rho decay:"
<< endl;
61
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
) << rho << endl;
62
}
63
64
if
( prob != prob ) {
65
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
66
<<
"Forward density matrix:"
<< endl;
67
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
) << p->
getSpinDensityForward
();
68
69
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
70
<<
"Decay density matrix:"
<< endl;
71
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
) << rho;
72
73
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
) <<
"prob:"
<< prob << endl;
74
75
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
76
<<
"Particle:"
<<
EvtPDL::name
( p->
getId
() ).c_str() << endl;
77
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
78
<<
"channel :"
<< p->
getChannel
() << endl;
79
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
80
<<
"Momentum:"
<< p->
getP4
() <<
" "
<< p->
mass
() << endl;
81
if
( p->
getParent
() !=
nullptr
) {
82
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
83
<<
"parent:"
84
<<
EvtPDL::name
( p->
getParent
()->
getId
() ).c_str() << endl;
85
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
86
<<
"parent channel :"
<< p->
getParent
()->
getChannel
()
87
<< endl;
88
89
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
) <<
"parent daughters :"
;
90
for
(
size_t
i = 0; i < p->
getParent
()->
getNDaug
(); i++ ) {
91
EvtGenReport
(
EVTGEN_DEBUG
,
""
)
92
<<
EvtPDL::name
( p->
getParent
()->
getDaug
( i )->
getId
() )
93
.c_str()
94
<<
" "
;
95
}
96
EvtGenReport
(
EVTGEN_DEBUG
,
""
) << endl;
97
98
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
) <<
"daughters :"
;
99
for
(
size_t
i = 0; i < p->
getNDaug
(); i++ ) {
100
EvtGenReport
(
EVTGEN_DEBUG
,
""
)
101
<<
EvtPDL::name
( p->
getDaug
( i )->
getId
() ).c_str()
102
<<
" "
;
103
}
104
EvtGenReport
(
EVTGEN_DEBUG
,
""
) << endl;
105
106
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
107
<<
"daughter momenta :"
<< endl;
108
;
109
for
(
size_t
i = 0; i < p->
getNDaug
(); i++ ) {
110
EvtGenReport
(
EVTGEN_DEBUG
,
""
)
111
<< p->
getDaug
( i )->
getP4
() <<
" "
112
<< p->
getDaug
( i )->
mass
();
113
EvtGenReport
(
EVTGEN_DEBUG
,
""
) << endl;
114
}
115
}
116
}
117
118
prob /=
m_weight
;
119
120
prob_max =
getProbMax
( prob );
121
p->
setDecayProb
( prob / prob_max );
122
123
more = prob <
EvtRandom::Flat
( prob_max );
124
125
ntimes--;
126
127
}
while
( ntimes && more );
128
129
if
( ntimes == 0 ) {
130
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
131
<<
"Tried accept/reject: 10000"
132
<<
" times, and rejected all the times!"
<< endl;
133
134
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
135
<< p->
getSpinDensityForward
() << endl;
136
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
137
<<
"Is therefore accepting the last event!"
<< endl;
138
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
139
<<
"Decay of particle:"
<<
EvtPDL::name
( p->
getId
() ).c_str()
140
<<
"(channel:"
<< p->
getChannel
() <<
") with mass "
<< p->
mass
()
141
<< endl;
142
143
for
(
size_t
ii = 0; ii < p->
getNDaug
(); ii++ ) {
144
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
145
<<
"Daughter "
<< ii <<
":"
146
<<
EvtPDL::name
( p->
getDaug
( ii )->
getId
() ).c_str()
147
<<
" with mass "
<< p->
getDaug
( ii )->
mass
() << endl;
148
}
149
}
150
151
EvtSpinDensity
rho_list[10];
152
153
rho_list[0] = p->
getSpinDensityForward
();
154
155
EvtAmp
ampcont;
156
157
if
(
m_amp2
.m_pstates != 1 ) {
158
ampcont =
m_amp2
.contract( 0, p->
getSpinDensityForward
() );
159
}
else
{
160
ampcont =
m_amp2
;
161
}
162
163
// it may be that the parent decay model has already
164
// done the decay - this should be rare and the
165
// model better know what it is doing..
166
167
if
( !
daugsDecayedByParentModel
() ) {
168
if
( recursive ) {
169
for
(
size_t
i = 0; i < p->
getNDaug
(); i++ ) {
170
rho.
setDim
(
m_amp2
.m_dstates[i] );
171
172
if
(
m_amp2
.m_dstates[i] == 1 ) {
173
rho.
set
( 0, 0,
EvtComplex
( 1.0, 0.0 ) );
174
}
else
{
175
rho = ampcont.
contract
(
m_amp2
.m_dnontrivial[i],
m_amp2
);
176
}
177
178
if
( !rho.
check
() ) {
179
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
180
<<
"-------start error-------"
<< endl;
181
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
182
<<
"forward rho failed Check:"
183
<<
EvtPDL::name
( p->
getId
() ).c_str() <<
" "
184
<< p->
getChannel
() <<
" "
<< i << endl;
185
186
p->
printTree
();
187
188
for
(
size_t
idaug = 0; idaug < p->
getNDaug
(); idaug++ ) {
189
EvtParticle
* daughter = p->
getDaug
( idaug );
190
if
( daughter !=
nullptr
) {
191
daughter->
printTree
();
192
}
193
}
194
195
EvtParticle
* pParent = p->
getParent
();
196
if
( pParent !=
nullptr
) {
197
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
198
<<
"Parent:"
199
<<
EvtPDL::name
( pParent->
getId
() ).c_str() << endl;
200
201
EvtParticle
* grandParent = pParent->
getParent
();
202
203
if
( grandParent !=
nullptr
) {
204
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
205
<<
"GrandParent:"
206
<<
EvtPDL::name
( grandParent->
getId
() ).c_str()
207
<< endl;
208
}
209
}
210
211
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
212
<<
" EvtSpinDensity rho: "
<< rho;
213
214
m_amp2
.dump();
215
216
for
(
size_t
ii = 0; ii < i + 1; ii++ ) {
217
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
218
<<
"rho_list["
<< ii <<
"] = "
<< rho_list[ii];
219
}
220
221
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
222
<<
"-------Done with error-------"
<< endl;
223
}
224
225
p->
getDaug
( i )->
setSpinDensityForward
( rho );
226
p->
getDaug
( i )->
decay
();
227
228
rho_list[i + 1] = p->
getDaug
( i )->
getSpinDensityBackward
();
229
230
if
(
m_amp2
.m_dstates[i] != 1 ) {
231
ampcont = ampcont.
contract
(
m_amp2
.m_dnontrivial[i],
232
rho_list[i + 1] );
233
}
234
}
235
236
p->
setSpinDensityBackward
(
m_amp2
.getBackwardSpinDensity( rho_list ) );
237
238
if
( !p->
getSpinDensityBackward
().
check
() ) {
239
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
240
<<
"rho_backward failed Check"
<< p->
getId
().
getId
() <<
" "
241
<< p->
getChannel
() << endl;
242
243
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
244
<< p->
getSpinDensityBackward
();
245
}
246
}
247
}
248
249
if
( (
getFSR
() ||
EvtRadCorr::alwaysRadCorr
() ) &&
250
!
EvtRadCorr::neverRadCorr
() ) {
251
int
n_daug_orig = p->
getNDaug
();
252
EvtRadCorr::doRadCorr
( p );
253
int
n_daug_new = p->
getNDaug
();
254
for
(
int
i = n_daug_orig; i < n_daug_new; i++ ) {
255
p->
getDaug
( i )->
decay
();
256
}
257
}
258
}
EvtAmp.hh
EvtDecayAmp.hh
EvtDecayBase.hh
EvtPDL.hh
EvtParticle.hh
EvtRadCorr.hh
EvtRandom.hh
EvtReport.hh
EvtGenReport
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition
EvtReport.cpp:32
EVTGEN_DEBUG
@ EVTGEN_DEBUG
Definition
EvtReport.hh:53
EVTGEN_ERROR
@ EVTGEN_ERROR
Definition
EvtReport.hh:49
EvtAmp
Definition
EvtAmp.hh:29
EvtAmp::contract
EvtSpinDensity contract(int i, const EvtAmp &a) const
Definition
EvtAmp.cpp:322
EvtComplex
Definition
EvtComplex.hh:29
EvtDecayAmp::m_amp2
EvtAmp m_amp2
Definition
EvtDecayAmp.hh:73
EvtDecayAmp::makeDecay
void makeDecay(EvtParticle *p, bool recursive=true) override
Definition
EvtDecayAmp.cpp:32
EvtDecayAmp::m_weight
double m_weight
Definition
EvtDecayAmp.hh:76
EvtDecayBase::getFSR
bool getFSR() const
Definition
EvtDecayBase.hh:68
EvtDecayBase::getNDaug
int getNDaug() const
Definition
EvtDecayBase.hh:64
EvtDecayBase::decay
virtual void decay(EvtParticle *p)=0
EvtDecayBase::daugsDecayedByParentModel
bool daugsDecayedByParentModel() const
Definition
EvtDecayBase.hh:111
EvtDecayBase::m_daugsDecayedByParentModel
bool m_daugsDecayedByParentModel
Definition
EvtDecayBase.hh:110
EvtDecayBase::getProbMax
double getProbMax(double prob)
Definition
EvtDecayBase.cpp:74
EvtDecayBase::getDaugs
const EvtId * getDaugs() const
Definition
EvtDecayBase.hh:65
EvtId::getId
int getId() const
Definition
EvtId.hh:41
EvtPDL::name
static std::string name(EvtId i)
Definition
EvtPDL.cpp:376
EvtParticle
Definition
EvtParticle.hh:45
EvtParticle::setSpinDensityBackward
void setSpinDensityBackward(const EvtSpinDensity &rho)
Definition
EvtParticle.hh:373
EvtParticle::setSpinDensityForward
void setSpinDensityForward(const EvtSpinDensity &rho)
Definition
EvtParticle.hh:341
EvtParticle::setDecayProb
void setDecayProb(double p)
Definition
EvtParticle.cpp:1271
EvtParticle::decay
void decay()
Definition
EvtParticle.cpp:438
EvtParticle::getId
EvtId getId() const
Definition
EvtParticle.cpp:124
EvtParticle::getP4
const EvtVector4R & getP4() const
Definition
EvtParticle.cpp:144
EvtParticle::printTree
void printTree() const
Definition
EvtParticle.cpp:976
EvtParticle::getDaug
EvtParticle * getDaug(const int i)
Definition
EvtParticle.hh:173
EvtParticle::mass
double mass() const
Definition
EvtParticle.cpp:159
EvtParticle::getNDaug
size_t getNDaug() const
Definition
EvtParticle.cpp:154
EvtParticle::getSpinDensityBackward
EvtSpinDensity getSpinDensityBackward()
Definition
EvtParticle.hh:381
EvtParticle::getChannel
int getChannel() const
Definition
EvtParticle.cpp:149
EvtParticle::getParent
EvtParticle * getParent() const
Definition
EvtParticle.cpp:90
EvtParticle::getSpinDensityForward
EvtSpinDensity getSpinDensityForward()
Definition
EvtParticle.hh:368
EvtRadCorr::alwaysRadCorr
static bool alwaysRadCorr()
Definition
EvtRadCorr.cpp:57
EvtRadCorr::neverRadCorr
static bool neverRadCorr()
Definition
EvtRadCorr.cpp:61
EvtRadCorr::doRadCorr
static void doRadCorr(EvtParticle *p)
Definition
EvtRadCorr.cpp:43
EvtRandom::Flat
static double Flat()
Definition
EvtRandom.cpp:95
EvtSpinDensity
Definition
EvtSpinDensity.hh:28
EvtSpinDensity::setDim
void setDim(int n)
Definition
EvtSpinDensity.cpp:79
EvtSpinDensity::normalizedProb
double normalizedProb(const EvtSpinDensity &d)
Definition
EvtSpinDensity.cpp:131
EvtSpinDensity::set
void set(int i, int j, const EvtComplex &rhoij)
Definition
EvtSpinDensity.cpp:106
EvtSpinDensity::check
int check()
Definition
EvtSpinDensity.cpp:162
Generated by
1.17.0