ATLAS Offline Software
EvtPythia.cxx
Go to the documentation of this file.
1 
2 /***********************************************************************
3 * Copyright 1998-2022 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 
21 #include "EvtGen_i/EvtGenExternal/EvtPythia.hh"
22 
23 #include "EvtGenBase/EvtDecayBase.hh"
24 #include "EvtGenBase/EvtId.hh"
25 #include "EvtGenBase/EvtPDL.hh"
26 #include "EvtGenBase/EvtParticle.hh"
27 #include "EvtGenBase/EvtPatches.hh"
28 #include "EvtGenBase/EvtSpinDensity.hh"
29 
30 #include "EvtGenModels/EvtAbsExternalGen.hh"
31 
32 #include "EvtGen_i/EvtGenExternal/EvtExternalGenFactory.hh"
33 
34 #include <cmath>
35 #include <iostream>
36 
37 EvtPythia::EvtPythia()
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  m_pythiaEngine = 0;
43 }
44 
45 EvtPythia::~EvtPythia()
46 {
47  m_commandList.clear();
48 }
49 
50 std::string EvtPythia::getName()
51 {
52  return "PYTHIA";
53 }
54 
55 EvtDecayBase* EvtPythia::clone()
56 {
57  return new EvtPythia();
58 }
59 
60 void EvtPythia::init()
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 
67 void EvtPythia::initProbMax()
68 {
69  noProbMax();
70 }
71 
72 void EvtPythia::decay( EvtParticle* p )
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 ( !m_pythiaEngine ) {
81  m_pythiaEngine = EvtExternalGenFactory::getInstance()->getGenerator(
82  EvtExternalGenFactory::PythiaGenId );
83  }
84 
85  if ( m_pythiaEngine ) {
86  m_pythiaEngine->doDecay( p );
87  }
88 
89  this->fixPolarisations( p );
90 }
91 
92 void EvtPythia::fixPolarisations( EvtParticle* p )
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 const 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 );
132  setDaughterSpinDensity( i );
133  }
134  }
135  }
136 }
137 
138 std::string EvtPythia::commandName()
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  m_commandList.push_back( cmd );
152 }
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
rerun_display.cmd
string cmd
Definition: rerun_display.py:67
python.Utilities.clone
clone
Definition: Utilities.py:134
lumiFormat.i
int i
Definition: lumiFormat.py:92
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition: PyKernel.py:45
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
get_generator_info.command
string command
Definition: get_generator_info.py:38
fitman.rho
rho
Definition: fitman.py:532