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
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
22
24#include "EvtGenBase/EvtPDL.hh"
29using std::endl;
30
31void EvtDecayProb::makeDecay( EvtParticle* p, bool recursive )
32{
33 int ntimes = 10000;
34
35 double dummy;
36
37 do {
38 m_weight = 1.0;
40
41 decay( p );
42
43 ntimes--;
44
46
47 dummy = getProbMax( m_prob ) * EvtRandom::Flat();
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
72 rho.setDiag( p->getSpinStates() );
73 p->setSpinDensityBackward( rho );
74
75 if ( ( getFSR() || EvtRadCorr::alwaysRadCorr() ) &&
78 }
79
80 if ( !recursive )
81 return;
82
83 //Now decay the daughters.
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}
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition EvtReport.cpp:32
@ EVTGEN_DEBUG
Definition EvtReport.hh:53
bool getFSR() const
virtual void decay(EvtParticle *p)=0
bool daugsDecayedByParentModel() const
bool m_daugsDecayedByParentModel
double getProbMax(double prob)
void makeDecay(EvtParticle *p, bool recursive=true) override
static std::string name(EvtId i)
Definition EvtPDL.cpp:376
void setSpinDensityBackward(const EvtSpinDensity &rho)
void setSpinDensityForward(const EvtSpinDensity &rho)
void setDecayProb(double p)
EvtId getId() const
int getSpinStates() const
EvtParticle * getDaug(const int i)
double mass() const
size_t getNDaug() const
int getChannel() const
static bool alwaysRadCorr()
static bool neverRadCorr()
static void doRadCorr(EvtParticle *p)
static double Flat()
Definition EvtRandom.cpp:95
void setDiag(int n)