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
EvtSingleParticle.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"
28
29#include <stdlib.h>
30#include <string>
31using std::endl;
32
33std::string EvtSingleParticle::getName() const
34{
35 return "SINGLE";
36}
37
42
47
49{
50 //turn off checks for charge conservation
52
53 if ( ( getNArg() == 6 ) || ( getNArg() == 4 ) || ( getNArg() == 2 ) ) {
54 if ( getNArg() == 6 ) {
55 //copy the arguments into eaiser to remember names!
56
57 m_pmin = getArg( 0 );
58 m_pmax = getArg( 1 );
59
60 m_cthetamin = getArg( 2 );
61 m_cthetamax = getArg( 3 );
62
63 m_phimin = getArg( 4 );
64 m_phimax = getArg( 5 );
65 }
66
67 if ( getNArg() == 4 ) {
68 //copy the arguments into eaiser to remember names!
69
70 m_pmin = getArg( 0 );
71 m_pmax = getArg( 1 );
72
73 m_cthetamin = getArg( 2 );
74 m_cthetamax = getArg( 3 );
75
76 m_phimin = 0.0;
78 }
79
80 if ( getNArg() == 2 ) {
81 //copy the arguments into eaiser to remember names!
82
83 m_pmin = getArg( 0 );
84 m_pmax = getArg( 1 );
85
86 m_cthetamin = -1.0;
87 m_cthetamax = 1.0;
88
89 m_phimin = 0.0;
91 }
92
93 } else {
94 EvtGenReport( EVTGEN_ERROR, "EvtGen" )
95 << "EvtSingleParticle generator expected "
96 << " 6, 4, or 2 arguments but found:" << getNArg() << endl;
97 EvtGenReport( EVTGEN_ERROR, "EvtGen" )
98 << "Will terminate execution!" << endl;
99 ::abort();
100 }
101
102 EvtGenReport( EVTGEN_INFO, "EvtGen" )
103 << "The single particle generator has been configured:" << endl;
104 EvtGenReport( EVTGEN_INFO, "EvtGen" )
105 << m_pmax << " > p > " << m_pmin << endl;
106 EvtGenReport( EVTGEN_INFO, "EvtGen" )
107 << m_cthetamax << " > costheta > " << m_cthetamin << endl;
108 EvtGenReport( EVTGEN_INFO, "EvtGen" )
109 << m_phimax << " > phi > " << m_phimin << endl;
110}
111
113{
114 EvtParticle* d;
115 EvtVector4R p4;
116
117 double mass = EvtPDL::getMass( getDaug( 0 ) );
118
120 d = p->getDaug( 0 );
121
122 //generate flat distribution in p
123 //we are now in the parents restframe! This means the
124 //restframe of the e+e- collison.
125 double pcm = EvtRandom::Flat( m_pmin, m_pmax );
126 //generate flat distribution in phi.
127 double phi = EvtRandom::Flat( m_phimin, m_phimax );
128
129 double cthetalab;
130
131 do {
132 //generate flat distribution in costheta
133 double ctheta = EvtRandom::Flat( m_cthetamin, m_cthetamax );
134 double stheta = sqrt( 1.0 - ctheta * ctheta );
135 p4.set( sqrt( mass * mass + pcm * pcm ), pcm * cos( phi ) * stheta,
136 pcm * sin( phi ) * stheta, pcm * ctheta );
137
138 d->init( getDaug( 0 ), p4 );
139
140 //get 4 vector in the lab frame!
141 EvtVector4R p4lab = d->getP4Lab();
142 cthetalab = p4lab.get( 3 ) / p4lab.d3mag();
143 } while ( cthetalab > m_cthetamax || cthetalab < m_cthetamin );
144
145 return;
146}
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition EvtReport.cpp:32
@ EVTGEN_INFO
Definition EvtReport.hh:52
@ EVTGEN_ERROR
Definition EvtReport.hh:49
static const double twoPi
Definition EvtConst.hh:27
EvtDecayBase()=default
int getNDaug() const
int getNArg() const
double getArg(unsigned int j)
void disableCheckQ()
EvtId getDaug(int i) const
const EvtId * getDaugs() const
static double getMass(EvtId i)
Definition EvtPDL.cpp:311
virtual void init(EvtId part_n, const EvtVector4R &p4)=0
EvtParticle * getDaug(const int i)
EvtVector4R getP4Lab() const
void makeDaughters(size_t ndaug, const EvtId *id)
static double Flat()
Definition EvtRandom.cpp:95
EvtDecayBase * clone() const override
void initProbMax() override
void decay(EvtParticle *p) override
std::string getName() const override
double get(int i) const
double d3mag() const
void set(int i, double d)