HGCal Test Beam  03a93d6239a951948e06fb3ef8dae4cbdebfad30
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HepMCG4PythiaInterface.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 /// \file eventgenerator/HepMC/HepMCEx01/src/HepMCG4PythiaInterface.cc
27 /// \brief Implementation of the HepMCG4PythiaInterface class
28 //
29 // ====================================================================
30 //
31 // HepMCG4PythiaInterface.cc
32 // $Id$
33 //
34 // ====================================================================
35 
36 #ifdef G4LIB_USE_PYTHIA
37 
38 #include "HepMCG4PythiaInterface.hh"
39 #include "HepMCG4PythiaMessenger.hh"
40 
41 #include "HepMC/GenEvent.h"
42 #include "HepMC/PythiaWrapper6_4.h"
43 
44 // additional pythia calls
45 #define pygive pygive_
46 #define pyrget pyrget_
47 #define pyrset pyrset_
48 
49 extern "C" {
50  void pygive(const char*, int);
51  void pyrget(int*, int*);
52  void pyrset(int*, int*);
53 }
54 
55 void call_pygive(G4String s)
56 {
57  pygive(s.c_str(), s.length());
58 }
59 void call_pyrget(int a, int b)
60 {
61  pyrget(&a, &b);
62 }
63 void call_pyrset(int a, int b)
64 {
65  pyrset(&a, &b);
66 }
67 
68 ////////////////////////////////////////////////
69 HepMCG4PythiaInterface::HepMCG4PythiaInterface()
70  : verbose(0), mpylist(0)
71 ////////////////////////////////////////////////
72 {
73 #ifdef NEED_INITPYDATA
74  initpydata();
75  // Some platforms may require the initialization of pythia PYDATA block
76  // data as external - if you get pythia initialization errors try
77  // commenting in/out the below call to initpydata().
78 #endif
79 
80  messenger = new HepMCG4PythiaMessenger(this);
81 }
82 
83 /////////////////////////////////////////////////
84 HepMCG4PythiaInterface::~HepMCG4PythiaInterface()
85 /////////////////////////////////////////////////
86 {
87  delete messenger;
88 }
89 
90 /////////////////////////////////////////////////////
91 void HepMCG4PythiaInterface::CallPygive(G4String par)
92 /////////////////////////////////////////////////////
93 {
94  call_pygive(par);
95 }
96 
97 //////////////////////////////////////////////////////////////////////
98 void HepMCG4PythiaInterface::CallPyinit(G4String frame, G4String beam,
99  G4String target, G4double win)
100 //////////////////////////////////////////////////////////////////////
101 {
102  call_pyinit(frame.c_str(), beam.c_str(), target.c_str(), win);
103 }
104 
105 ////////////////////////////////////////////////////
106 void HepMCG4PythiaInterface::CallPystat(G4int istat)
107 ////////////////////////////////////////////////////
108 {
109  call_pystat(istat);
110 }
111 
112 ///////////////////////////////////////////////////////
113 void HepMCG4PythiaInterface::SetRandomSeed(G4int iseed)
114 ///////////////////////////////////////////////////////
115 {
116  pydatr.mrpy[1 - 1] = iseed;
117 }
118 
119 //////////////////////////////////////////////////////////////
120 void HepMCG4PythiaInterface::CallPyrget(G4int lun, G4int move)
121 //////////////////////////////////////////////////////////////
122 {
123  call_pyrget(lun, move);
124 }
125 
126 //////////////////////////////////////////////////////////////
127 void HepMCG4PythiaInterface::CallPyrset(G4int lun, G4int move)
128 //////////////////////////////////////////////////////////////
129 {
130  call_pyrset(lun, move);
131 }
132 
133 //////////////////////////////////////////////////////////////////////////
134 void HepMCG4PythiaInterface::PrintRandomStatus(std::ostream& ostr) const
135 //////////////////////////////////////////////////////////////////////////
136 {
137  ostr << "# Pythia random numbers status" << G4endl;
138  for (G4int j = 0; j < 6; j++) {
139  ostr << "pydatr.mrpy[" << j << "]= " << pydatr.mrpy[j] << G4endl;
140  }
141  for (G4int k = 0; k < 100; k++) {
142  ostr << "pydatr.rrpy[" << k << "]= " << pydatr.rrpy[k] << G4endl;
143  }
144 }
145 
146 ////////////////////////////////////////////////
147 void HepMCG4PythiaInterface::SetUserParameters()
148 ////////////////////////////////////////////////
149 {
150  G4cout << "set user parameters of PYTHIA common." << G4endl
151  << "nothing to be done in default."
152  << G4endl;
153 }
154 
155 /////////////////////////////////////////////////////////////
156 HepMC::GenEvent* HepMCG4PythiaInterface::GenerateHepMCEvent()
157 /////////////////////////////////////////////////////////////
158 {
159  static G4int nevent = 0; // event counter
160 
161  call_pyevnt(); // generate one event with Pythia
162  if(mpylist >= 1 && mpylist <= 3) call_pylist(mpylist);
163 
164  call_pyhepc(1);
165 
166  HepMC::GenEvent* evt = hepevtio.read_next_event();
167  evt-> set_event_number(nevent++);
168  if(verbose > 0) evt-> print();
169 
170  return evt;
171 }
172 
173 //////////////////////////////////////////
174 void HepMCG4PythiaInterface::Print() const
175 //////////////////////////////////////////
176 {
177  G4cout << "PythiaInterface::Print()..." << G4endl;
178 }
179 
180 #endif