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.
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"
26 #include "EvtGenBase/EvtPatches.hh"
27 #include "EvtGenBase/EvtRadCorr.hh"
28 #include "EvtGenBase/EvtRandom.hh"
29 #include "EvtGenBase/EvtReport.hh"
30 using std::endl;
31 
32 void EvtDecayProb::makeDecay( EvtParticle* p, bool recursive )
33 {
34  int ntimes = 10000;
35 
36  double dummy;
37 
38  do {
39  _weight = 1.0;
41 
42  decay( p );
43 
44  ntimes--;
45 
46  _prob = _prob / _weight;
47 
48  dummy = getProbMax( _prob ) * EvtRandom::Flat();
50 
51  } while ( ntimes && ( _prob < dummy ) );
52 
53  if ( ntimes == 0 ) {
54  EvtGenReport( EVTGEN_DEBUG, "EvtGen" )
55  << "Tried accept/reject:10000"
56  << " times, and rejected all the times!" << endl;
57  EvtGenReport( EVTGEN_DEBUG, "EvtGen" )
58  << "Is therefore accepting the last event!" << endl;
59  EvtGenReport( EVTGEN_DEBUG, "EvtGen" )
60  << "Decay of particle:" << EvtPDL::name( p->getId() ).c_str()
61  << "(channel:" << p->getChannel() << ") with mass " << p->mass()
62  << endl;
63 
64  for ( size_t ii = 0; ii < p->getNDaug(); ii++ ) {
65  EvtGenReport( EVTGEN_DEBUG, "EvtGen" )
66  << "Daughter " << ii << ":"
67  << EvtPDL::name( p->getDaug( ii )->getId() ).c_str()
68  << " with mass " << p->getDaug( ii )->mass() << endl;
69  }
70  }
71 
72  EvtSpinDensity rho;
73  rho.setDiag( p->getSpinStates() );
74  p->setSpinDensityBackward( rho );
75  if ( getPHOTOS() || EvtRadCorr::alwaysRadCorr() ) {
77  }
78 
79  if ( !recursive )
80  return;
81 
82  //Now decay the daughters.
83  if ( !daugsDecayedByParentModel() ) {
84  for ( size_t i = 0; i < p->getNDaug(); i++ ) {
85  //Need to set the spin density of the daughters to be
86  //diagonal.
87  rho.setDiag( p->getDaug( i )->getSpinStates() );
88  p->getDaug( i )->setSpinDensityForward( rho );
89 
90  //Now decay the daughter. Really!
91  p->getDaug( i )->decay();
92  }
93  }
94 }
double _weight
Definition: EvtDecayProb.hh:40
const char * c_str(Index i)
Definition: EvtCyclic3.cpp:323
static std::string name(EvtId i)
Definition: EvtPDL.cpp:382
double getProbMax(double prob)
void setSpinDensityForward(const EvtSpinDensity &rho)
Definition: EvtParticle.hh:337
void setDecayProb(double p)
void setDiag(int n)
void setSpinDensityBackward(const EvtSpinDensity &rho)
Definition: EvtParticle.hh:369
static void doRadCorr(EvtParticle *p)
Definition: EvtRadCorr.cpp:54
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
Definition: EvtReport.cpp:33
int getSpinStates() const
EvtId getId() const
size_t getNDaug() const
bool _daugsDecayedByParentModel
int getPHOTOS() const
Definition: EvtDecayBase.hh:69
static double Flat()
Definition: EvtRandom.cpp:72
int getChannel() const
double mass() const
virtual void decay(EvtParticle *p)=0
EvtParticle * getDaug(int i)
Definition: EvtParticle.cpp:91
void makeDecay(EvtParticle *p, bool recursive=true) override
bool daugsDecayedByParentModel()
static bool alwaysRadCorr()
Definition: EvtRadCorr.cpp:68