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.
EvtPythia.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/EvtId.hh"
25 #include "EvtGenBase/EvtPDL.hh"
27 #include "EvtGenBase/EvtPatches.hh"
29 
31 
33 
34 #include <cmath>
35 #include <iostream>
36 
38 {
39  // Set the Pythia engine to a null pointer at first.
40  // When we do the decay, we retrieve the pointer to the Pythia engine
41  // and use that for all decays. All clones will use the same Pythia engine.
42  _pythiaEngine = 0;
43 }
44 
46 {
47  _commandList.clear();
48 }
49 
50 std::string EvtPythia::getName()
51 {
52  return "PYTHIA";
53 }
54 
56 {
57  return new EvtPythia();
58 }
59 
61 {
62  // Do not check for any arguments. The PythiaEngine will check
63  // to see if there is an integer specifying the decay physics,
64  // otherwise it just uses phase-space.
65 }
66 
68 {
69  noProbMax();
70 }
71 
73 {
74  // We have to initialise the Pythia engine after the decay.dec files have been read in,
75  // since we will be modifying Pythia data tables, and that is only possible once we have
76  // defined all Pythia-type decays we want to use.
77  // We check to see if the engine has been created before doing the decay.
78  // This should only create the full Pythia engine once, and all clones will point to the same engine.
79 
80  if ( !_pythiaEngine ) {
83  }
84 
85  if ( _pythiaEngine ) {
86  _pythiaEngine->doDecay( p );
87  }
88 
89  this->fixPolarisations( p );
90 }
91 
93 {
94  // Special case to handle the J/psi polarisation
95 
96  if ( !p ) {
97  return;
98  }
99 
100  int nDaug = p->getNDaug();
101  int i( 0 );
102 
103  static EvtId Jpsi = EvtPDL::getId( "J/psi" );
104 
105  for ( i = 0; i < nDaug; i++ ) {
106  EvtParticle* theDaug = p->getDaug( i );
107 
108  if ( theDaug ) {
109  if ( theDaug->getId() == Jpsi ) {
110  EvtSpinDensity rho;
111 
112  rho.setDim( 3 );
113  rho.set( 0, 0, 0.5 );
114  rho.set( 0, 1, 0.0 );
115  rho.set( 0, 2, 0.0 );
116 
117  rho.set( 1, 0, 0.0 );
118  rho.set( 1, 1, 1.0 );
119  rho.set( 1, 2, 0.0 );
120 
121  rho.set( 2, 0, 0.0 );
122  rho.set( 2, 1, 0.0 );
123  rho.set( 2, 2, 0.5 );
124 
125  EvtVector4R p4Psi = theDaug->getP4();
126 
127  double alpha = atan2( p4Psi.get( 2 ), p4Psi.get( 1 ) );
128  double beta = acos( p4Psi.get( 3 ) / p4Psi.d3mag() );
129 
130  theDaug->setSpinDensityForwardHelicityBasis( rho, alpha, beta,
131  0.0 );
133  }
134  }
135  }
136 }
137 
139 {
140  // Allow backward compatibility for decay.dec files
141  // having JetSetPar parameters. They are obsolete for Pythia 8,
142  // since the JetSet-type array variables do not exist.
143  // Need to think about including user defined parameters in
144  // EvtPythiaEngine::updatePhysicsParameters().
145  return std::string( "JetSetPar" );
146 }
147 
148 void EvtPythia::command( std::string cmd )
149 {
150  // Locally store commands in a vector
151  _commandList.push_back( cmd );
152 }
std::string commandName() override
Definition: EvtPythia.cpp:138
static EvtExternalGenFactory * getInstance()
EvtAbsExternalGen * _pythiaEngine
Definition: EvtPythia.hh:56
EvtId getId() const
EvtDecayBase * clone() override
Definition: EvtPythia.cpp:55
void command(std::string) override
Definition: EvtPythia.cpp:148
EvtAbsExternalGen * getGenerator(int genId=0)
Definition: EvtId.hh:27
size_t getNDaug() const
double get(int i) const
Definition: EvtVector4R.hh:162
static EvtId getId(const std::string &name)
Definition: EvtPDL.cpp:287
std::vector< std::string > _commandList
Definition: EvtPythia.hh:60
const EvtVector4R & getP4() const
virtual bool doDecay(EvtParticle *theMother)=0
void setSpinDensityForwardHelicityBasis(const EvtSpinDensity &rho)
void fixPolarisations(EvtParticle *p)
Definition: EvtPythia.cpp:92
double d3mag() const
void setDaughterSpinDensity(int daughter)
void init() override
Definition: EvtPythia.cpp:60
void initProbMax() override
Definition: EvtPythia.cpp:67
EvtParticle * getDaug(int i)
Definition: EvtParticle.cpp:91
std::string getName() override
Definition: EvtPythia.cpp:50
void set(int i, int j, const EvtComplex &rhoij)
void decay(EvtParticle *p) override
Definition: EvtPythia.cpp:72
void setDim(int n)