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