ATLAS Offline Software
Pythia8_i.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3  Author: James Monk
4 */
5 
6 #ifndef GENERATOR_PYTHIA8_H
7 #define GENERATOR_PYTHIA8_H
8 
10 
11 // calls to fortran routines
12 #include "CLHEP/Random/RandFlat.h"
13 #include "GaudiKernel/ToolHandle.h"
16 
17 //#include "Pythia8/../Pythia8Plugins/HepMC2.h"
18 #ifdef HEPMC3
19 #include "Pythia8Plugins/HepMC3.h"
20 namespace HepMC {
21  typedef HepMC3::Pythia8ToHepMC3 Pythia8ToHepMC;
22 }
23 #else
24 #include "Pythia8Plugins/HepMC2.h"
25 #endif
26 
27 #include <stdexcept>
28 
29 
34 namespace Pythia8{
35  class Sigma2Process;
36 }
37 
38 
39 class customRndm : public Pythia8::RndmEngine {
40 public:
41 
42  // Constructor.
44 
45  // Routine for generating a random number.
46  inline double flat(){
47  m_RNC++;
48  return CLHEP::RandFlat::shoot(m_engine);
49  };
50 
51  // Initialisation Routine
52  inline void init(CLHEP::HepRandomEngine* engine) {m_engine=engine; m_RNC=0;}
53  inline CLHEP::HepRandomEngine* getEngine() { return m_engine; }
54  inline unsigned long long int getRNCalls() {return m_RNC;}
55 private:
56  unsigned long long int m_RNC{};
57  CLHEP::HepRandomEngine* m_engine{};
58 };
59 
60 
61 //namespace Generator{
62 class Pythia8_i: public GenModule{
63 
64 public:
65  Pythia8_i(const std::string &name, ISvcLocator *pSvcLocator);
66 
67  ~Pythia8_i();
68 
69  class CommandException : public std::runtime_error{
70  public:
71 
72  CommandException(const std::string &cmd): std::runtime_error("Cannot interpret command: " + cmd){
73  }
74  };
75 
76  virtual StatusCode genInitialize();
77  virtual StatusCode callGenerator();
78  virtual StatusCode fillEvt(HepMC::GenEvent *evt);
79  virtual StatusCode fillWeights(HepMC::GenEvent *evt);
80  virtual StatusCode genFinalize();
81 
82  double pythiaVersion() const;
83 
84  static const std::string& pythia_stream();
85  static std::string xmlpath();
86 
87 protected:
88 
89  bool useRndmGenSvc() const { return m_useRndmGenSvc; }
90  bool useReseed() const {return m_useReseed; }
91 
92  std::unique_ptr<Pythia8::Pythia> m_pythia{};
93  HepMC::Pythia8ToHepMC m_pythiaToHepMC;
94  UnsignedIntegerProperty m_maxFailures{this, "MaxFailures", 10};
95 
96  BooleanProperty m_useRndmGenSvc{this, "useRndmGenSvc", true, "the max number of consecutive failures"};
97  std::shared_ptr<customRndm> m_atlasRndmEngine{};
98 
99  BooleanProperty m_useReseed{this,"useReseed", false};
100 
101  IntegerProperty m_dsid{this, "Dsid", 999999, "Dataset ID number"};
102  StringArrayProperty m_userHooks{this, "UserHooks", {} };
103 //for Py8B
104  DoubleProperty m_pt0timesMPI{this,"pT0timesMPI", 1.0};
105  DoubleProperty m_numberAlphaS{this,"numberAlphaS", 3.0};
106  BooleanProperty m_sameAlphaSAsMPI{this,"useSameAlphaSasMPI", false};
107 
108 private:
109 
110  static std::string findValue(const std::string &command, const std::string &key);
111 
113 
114  double m_version{-1.};
115 
116  StringArrayProperty m_commands{this, "Commands", {} };
117  std::vector<std::string> m_userParams;
118  std::vector<std::string> m_userModes;
119 
120  enum PDGID {PROTON=2212, ANTIPROTON=-2212, LEAD=1000822080, NEUTRON=2112, ANTINEUTRON=-2112, MUON=13, ANTIMUON=-13, ELECTRON=11, POSITRON=-11, INVALID=0};
121 
122  DoubleProperty m_collisionEnergy{this, "CollisionEnergy", 14000.0};
123 
124 
125  StringProperty m_beam1{this, "Beam1", "PROTON"};
126  StringProperty m_beam2{this, "Beam2", "PROTON"};
128 
129  StringProperty m_lheFile{this, "LHEFile", ""};
130 
131  BooleanProperty m_doCKKWLAcceptance{this, "CKKWLAcceptance", false};
132  BooleanProperty m_doFxFxXS{this, "FxFxXS", false};
133  BooleanProperty m_computeEfficiency{this, "computeEfficiency", false};
134  double m_nAccepted{0.};
135  double m_nMerged{0.};
136  double m_sigmaTotal{0.};
137  double m_conversion{1.};
138 
139  unsigned int m_failureCount{0};
140 
141  std::map<std::string, PDGID> m_particleIDs;
142 
143  std::vector<long int> m_seeds{};
144 
145  StringProperty m_userProcess{this, "UserProcess", ""};
146 
147  // ptr to possible user process
148  std::shared_ptr<Pythia8::Sigma2Process> m_procPtr{};
149 
150  std::vector<UserHooksPtrType> m_userHooksPtrs{};
151 
152  StringProperty m_userResonances{this, "UserResonances", ""};
153 
154  std::vector<std::shared_ptr<Pythia8::ResonanceWidths> > m_userResonancePtrs;
155 
156  BooleanProperty m_useLHAPDF{this, "UseLHAPDF", true};
157 
158  StringProperty m_particleDataFile{this, "ParticleData", ""};
159  StringProperty m_outputParticleDataFile{this, "OutputParticleData", "ParticleData.local.xml"};
160 
161  double m_mergingWeight{1.0};
162  double m_enhanceWeight{1.0};
163  std::vector<std::string> m_weightIDs{};
164  std::vector<std::string> m_weightNames{};
165  bool m_doLHE3Weights{false};
166  std::vector<std::string> m_weightCommands{};
167  std::vector<std::string> m_showerWeightNames{"nominal"};
168  StringArrayProperty m_showerWeightNamesProp{this, "ShowerWeightNames", {} };
169 
170  PublicToolHandle<IPythia8Custom> m_athenaTool{this, "CustomInterface", ""};
171 
172  BooleanProperty m_saveLHE{this, "SaveLHERecord", false};
173 
174  static int s_allowedTunes(double version);
175 
177 
178 };
179 
180 #endif
Pythia8_i::NEUTRON
@ NEUTRON
Definition: Pythia8_i.h:120
Pythia8_i::m_maxFailures
UnsignedIntegerProperty m_maxFailures
Definition: Pythia8_i.h:94
Pythia8_i::m_enhanceWeight
double m_enhanceWeight
Definition: Pythia8_i.h:162
customRndm
Definition: Pythia8_i.h:39
Pythia8_i::m_nMerged
double m_nMerged
Definition: Pythia8_i.h:135
Pythia8_i::m_saveLHE
BooleanProperty m_saveLHE
Definition: Pythia8_i.h:172
Pythia8_i::fillWeights
virtual StatusCode fillWeights(HepMC::GenEvent *evt)
Definition: Pythia8_i.cxx:486
Pythia8_i::m_version
double m_version
Definition: Pythia8_i.h:114
Pythia8_i::m_procPtr
std::shared_ptr< Pythia8::Sigma2Process > m_procPtr
Definition: Pythia8_i.h:148
Pythia8_i::xmlpath
static std::string xmlpath()
Definition: Pythia8_i.cxx:708
Pythia8_i::m_particleDataFile
StringProperty m_particleDataFile
Definition: Pythia8_i.h:158
Pythia8_i::m_weightNames
std::vector< std::string > m_weightNames
Definition: Pythia8_i.h:164
Pythia8_i::m_useReseed
BooleanProperty m_useReseed
Definition: Pythia8_i.h:99
rerun_display.cmd
string cmd
Definition: rerun_display.py:67
Pythia8_i::m_failureCount
unsigned int m_failureCount
Definition: Pythia8_i.h:139
Pythia8_i::ELECTRON
@ ELECTRON
Definition: Pythia8_i.h:120
Pythia8_i::m_athenaTool
PublicToolHandle< IPythia8Custom > m_athenaTool
Definition: Pythia8_i.h:170
customRndm::init
void init(CLHEP::HepRandomEngine *engine)
Definition: Pythia8_i.h:52
Pythia8_i::pythiaVersion
double pythiaVersion() const
Definition: Pythia8_i.cxx:698
Pythia8_i::m_userHooks
StringArrayProperty m_userHooks
Definition: Pythia8_i.h:102
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
Pythia8_i::m_pt0timesMPI
DoubleProperty m_pt0timesMPI
Definition: Pythia8_i.h:104
IPythia8Custom.h
Pythia8_i::m_showerWeightNamesProp
StringArrayProperty m_showerWeightNamesProp
Definition: Pythia8_i.h:168
Pythia8_i::useReseed
bool useReseed() const
Definition: Pythia8_i.h:90
Pythia8_i::ANTIPROTON
@ ANTIPROTON
Definition: Pythia8_i.h:120
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
Pythia8_i::ANTINEUTRON
@ ANTINEUTRON
Definition: Pythia8_i.h:120
UserHooksFactory.h
Pythia8_i::m_userHooksPtrs
std::vector< UserHooksPtrType > m_userHooksPtrs
Definition: Pythia8_i.h:150
Pythia8_i::m_doFxFxXS
BooleanProperty m_doFxFxXS
Definition: Pythia8_i.h:132
Pythia8
Author: James Monk (jmonk@cern.ch)
Definition: IPythia8Custom.h:13
Pythia8_i::m_doLHE3Weights
bool m_doLHE3Weights
Definition: Pythia8_i.h:165
GenModule
Base class for common behaviour of generator interfaces.
Definition: GenModule.h:39
Pythia8_i::m_userResonancePtrs
std::vector< std::shared_ptr< Pythia8::ResonanceWidths > > m_userResonancePtrs
Definition: Pythia8_i.h:154
Pythia8_i::fillEvt
virtual StatusCode fillEvt(HepMC::GenEvent *evt)
For filling the HepMC event object.
Definition: Pythia8_i.cxx:420
Pythia8_i::m_numberAlphaS
DoubleProperty m_numberAlphaS
Definition: Pythia8_i.h:105
Pythia8_i
Definition: Pythia8_i.h:62
Pythia8_i::m_showerWeightNames
std::vector< std::string > m_showerWeightNames
Definition: Pythia8_i.h:167
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Pythia8_i::m_atlasRndmEngine
std::shared_ptr< customRndm > m_atlasRndmEngine
Definition: Pythia8_i.h:97
Pythia8_i::callGenerator
virtual StatusCode callGenerator()
For calling the generator on each iteration of the event loop.
Definition: Pythia8_i.cxx:355
Pythia8_i::genFinalize
virtual StatusCode genFinalize()
For finalising the generator, if required.
Definition: Pythia8_i.cxx:645
Pythia8_i::m_nAccepted
double m_nAccepted
Definition: Pythia8_i.h:134
customRndm::customRndm
customRndm()
Definition: Pythia8_i.h:43
customRndm::m_engine
CLHEP::HepRandomEngine * m_engine
Definition: Pythia8_i.h:57
ppToJpsimu0mu0.SuppressSmallPT
SuppressSmallPT
Definition: ppToJpsimu0mu0.py:26
Pythia8_i::findValue
static std::string findValue(const std::string &command, const std::string &key)
Pythia8_i::m_useLHAPDF
BooleanProperty m_useLHAPDF
Definition: Pythia8_i.h:156
Pythia8_i::m_userModes
std::vector< std::string > m_userModes
Definition: Pythia8_i.h:118
Pythia8_i::m_beam2
StringProperty m_beam2
Definition: Pythia8_i.h:126
Pythia8_i::m_lheFile
StringProperty m_lheFile
Definition: Pythia8_i.h:129
Pythia8_i::m_sigmaTotal
double m_sigmaTotal
Definition: Pythia8_i.h:136
Pythia8_i::m_SuppressSmallPT
Pythia8::SuppressSmallPT * m_SuppressSmallPT
Definition: Pythia8_i.h:176
customRndm::flat
double flat()
Definition: Pythia8_i.h:46
Pythia8_i::m_weightIDs
std::vector< std::string > m_weightIDs
Definition: Pythia8_i.h:163
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Pythia8_i::~Pythia8_i
~Pythia8_i()
Definition: Pythia8_i.cxx:84
Pythia8_i::LEAD
@ LEAD
Definition: Pythia8_i.h:120
Pythia8_i::m_weightCommands
std::vector< std::string > m_weightCommands
Definition: Pythia8_i.h:166
Pythia8_i::PDGID
PDGID
Definition: Pythia8_i.h:120
customRndm::getEngine
CLHEP::HepRandomEngine * getEngine()
Definition: Pythia8_i.h:53
Pythia8_i::INVALID
@ INVALID
Definition: Pythia8_i.h:120
Pythia8_i::Pythia8_i
Pythia8_i(const std::string &name, ISvcLocator *pSvcLocator)
Definition: Pythia8_i.cxx:68
Pythia8_i::m_userProcess
StringProperty m_userProcess
Definition: Pythia8_i.h:145
Pythia8_i::m_seeds
std::vector< long int > m_seeds
Definition: Pythia8_i.h:143
customRndm::getRNCalls
unsigned long long int getRNCalls()
Definition: Pythia8_i.h:54
Pythia8_i::m_particleIDs
std::map< std::string, PDGID > m_particleIDs
Definition: Pythia8_i.h:141
get_generator_info.version
version
Definition: get_generator_info.py:33
Pythia8_i::POSITRON
@ POSITRON
Definition: Pythia8_i.h:120
Pythia8_i::m_mergingWeight
double m_mergingWeight
Definition: Pythia8_i.h:161
Pythia8_i::ANTIMUON
@ ANTIMUON
Definition: Pythia8_i.h:120
Pythia8_i::useRndmGenSvc
bool useRndmGenSvc() const
Definition: Pythia8_i.h:89
HepMC
Definition: Barcode.h:14
GenModule.h
Pythia8_i::m_outputParticleDataFile
StringProperty m_outputParticleDataFile
Definition: Pythia8_i.h:159
Pythia8_i::CommandException::CommandException
CommandException(const std::string &cmd)
Definition: Pythia8_i.h:72
Pythia8_i::m_conversion
double m_conversion
Definition: Pythia8_i.h:137
Pythia8_i::m_dsid
IntegerProperty m_dsid
Definition: Pythia8_i.h:101
Pythia8_i::m_override_transform_beamenergy
bool m_override_transform_beamenergy
Definition: Pythia8_i.h:127
Pythia8_i::m_userParams
std::vector< std::string > m_userParams
Definition: Pythia8_i.h:117
Pythia8_i::m_sameAlphaSAsMPI
BooleanProperty m_sameAlphaSAsMPI
Definition: Pythia8_i.h:106
Pythia8_i::m_userResonances
StringProperty m_userResonances
Definition: Pythia8_i.h:152
Pythia8_i::m_doCKKWLAcceptance
BooleanProperty m_doCKKWLAcceptance
Definition: Pythia8_i.h:131
Pythia8_i::s_allowedTunes
static int s_allowedTunes(double version)
Pythia8_i::m_commands
StringArrayProperty m_commands
Definition: Pythia8_i.h:116
Pythia8_i::m_collisionEnergy
DoubleProperty m_collisionEnergy
Definition: Pythia8_i.h:122
customRndm::m_RNC
unsigned long long int m_RNC
Definition: Pythia8_i.h:56
Pythia8_i::m_useRndmGenSvc
BooleanProperty m_useRndmGenSvc
Definition: Pythia8_i.h:96
Pythia8_i::PROTON
@ PROTON
Definition: Pythia8_i.h:120
Pythia8_i::m_beam1
StringProperty m_beam1
Definition: Pythia8_i.h:125
Pythia8_i::genInitialize
virtual StatusCode genInitialize()
For initializing the generator, if required.
Definition: Pythia8_i.cxx:96
get_generator_info.command
string command
Definition: get_generator_info.py:38
Pythia8_i::m_internal_event_number
int m_internal_event_number
Definition: Pythia8_i.h:112
Pythia8_i::pythia_stream
static const std::string & pythia_stream()
Definition: Pythia8_i.cxx:703
Pythia8_i::m_pythia
std::unique_ptr< Pythia8::Pythia > m_pythia
Definition: Pythia8_i.h:92
Pythia8_i::m_computeEfficiency
BooleanProperty m_computeEfficiency
Definition: Pythia8_i.h:133
Pythia8_i::CommandException
Definition: Pythia8_i.h:69
Pythia8_i::m_pythiaToHepMC
HepMC::Pythia8ToHepMC m_pythiaToHepMC
Definition: Pythia8_i.h:93
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37