EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Loading...
Searching...
No Matches
src
EvtGenBase
EvtDecayProb.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/EvtDecayProb.hh
"
22
23
#include "
EvtGenBase/EvtDecayBase.hh
"
24
#include "
EvtGenBase/EvtPDL.hh
"
25
#include "
EvtGenBase/EvtParticle.hh
"
26
#include "
EvtGenBase/EvtRadCorr.hh
"
27
#include "
EvtGenBase/EvtRandom.hh
"
28
#include "
EvtGenBase/EvtReport.hh
"
29
using
std::endl;
30
31
void
EvtDecayProb::makeDecay
(
EvtParticle
* p,
bool
recursive )
32
{
33
int
ntimes = 10000;
34
35
double
dummy;
36
37
do
{
38
m_weight
= 1.0;
39
m_daugsDecayedByParentModel
=
false
;
40
41
decay
( p );
42
43
ntimes--;
44
45
m_prob
=
m_prob
/
m_weight
;
46
47
dummy =
getProbMax
(
m_prob
) *
EvtRandom::Flat
();
48
p->
setDecayProb
(
m_prob
/
getProbMax
(
m_prob
) );
49
50
}
while
( ntimes && (
m_prob
< dummy ) );
51
52
if
( ntimes == 0 ) {
53
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
54
<<
"Tried accept/reject:10000"
55
<<
" times, and rejected all the times!"
<< endl;
56
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
57
<<
"Is therefore accepting the last event!"
<< endl;
58
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
59
<<
"Decay of particle:"
<<
EvtPDL::name
( p->
getId
() ).c_str()
60
<<
"(channel:"
<< p->
getChannel
() <<
") with mass "
<< p->
mass
()
61
<< endl;
62
63
for
(
size_t
ii = 0; ii < p->
getNDaug
(); ii++ ) {
64
EvtGenReport
(
EVTGEN_DEBUG
,
"EvtGen"
)
65
<<
"Daughter "
<< ii <<
":"
66
<<
EvtPDL::name
( p->
getDaug
( ii )->
getId
() ).c_str()
67
<<
" with mass "
<< p->
getDaug
( ii )->
mass
() << endl;
68
}
69
}
70
71
EvtSpinDensity
rho;
72
rho.
setDiag
( p->
getSpinStates
() );
73
p->
setSpinDensityBackward
( rho );
74
75
if
( (
getFSR
() ||
EvtRadCorr::alwaysRadCorr
() ) &&
76
!
EvtRadCorr::neverRadCorr
() ) {
77
EvtRadCorr::doRadCorr
( p );
78
}
79
80
if
( !recursive )
81
return
;
82
83
//Now decay the daughters.
84
if
( !
daugsDecayedByParentModel
() ) {
85
for
(
size_t
i = 0; i < p->
getNDaug
(); i++ ) {
86
//Need to set the spin density of the daughters to be
87
//diagonal.
88
rho.
setDiag
( p->
getDaug
( i )->
getSpinStates
() );
89
p->
getDaug
( i )->
setSpinDensityForward
( rho );
90
91
//Now decay the daughter. Really!
92
p->
getDaug
( i )->
decay
();
93
}
94
}
95
}
EvtDecayBase.hh
EvtDecayProb.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
EvtDecayBase::getFSR
bool getFSR() const
Definition
EvtDecayBase.hh:68
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
EvtDecayProb::m_weight
double m_weight
Definition
EvtDecayProb.hh:38
EvtDecayProb::makeDecay
void makeDecay(EvtParticle *p, bool recursive=true) override
Definition
EvtDecayProb.cpp:31
EvtDecayProb::m_prob
double m_prob
Definition
EvtDecayProb.hh:37
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::getSpinStates
int getSpinStates() const
Definition
EvtParticle.cpp:139
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::getChannel
int getChannel() const
Definition
EvtParticle.cpp:149
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::setDiag
void setDiag(int n)
Definition
EvtSpinDensity.cpp:118
Generated by
1.16.1