Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-08 08:06:54

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file HepMCG4PythiaInterface.cc
0027 /// \brief Implementation of the HepMCG4PythiaInterface class
0028 
0029 #ifdef G4LIB_USE_PYTHIA
0030 
0031 #  include "HepMCG4PythiaInterface.hh"
0032 
0033 #  include "HepMC/GenEvent.h"
0034 #  include "HepMC/PythiaWrapper6_4.h"
0035 #  include "HepMCG4PythiaMessenger.hh"
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 // additional pythia calls
0039 #  define pygive pygive_
0040 #  define pyrget pyrget_
0041 #  define pyrset pyrset_
0042 
0043 extern "C"
0044 {
0045   void pygive(const char*, int);
0046   void pyrget(int*, int*);
0047   void pyrset(int*, int*);
0048 }
0049 
0050 void call_pygive(G4String s)
0051 {
0052   pygive(s.c_str(), s.length());
0053 }
0054 void call_pyrget(int a, int b)
0055 {
0056   pyrget(&a, &b);
0057 }
0058 void call_pyrset(int a, int b)
0059 {
0060   pyrset(&a, &b);
0061 }
0062 
0063 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0064 HepMCG4PythiaInterface::HepMCG4PythiaInterface() : verbose(0), mpylist(0)
0065 {
0066 #  ifdef NEED_INITPYDATA
0067   initpydata();
0068   // Some platforms may require the initialization of pythia PYDATA block
0069   // data as external - if you get pythia initialization errors try
0070   // commenting in/out the below call to initpydata().
0071 #  endif
0072 
0073   messenger = new HepMCG4PythiaMessenger(this);
0074 }
0075 
0076 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0077 HepMCG4PythiaInterface::~HepMCG4PythiaInterface()
0078 {
0079   delete messenger;
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 void HepMCG4PythiaInterface::CallPygive(G4String par)
0084 {
0085   call_pygive(par);
0086 }
0087 
0088 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0089 void HepMCG4PythiaInterface::CallPyinit(G4String frame, G4String beam, G4String target,
0090                                         G4double win)
0091 {
0092   call_pyinit(frame.c_str(), beam.c_str(), target.c_str(), win);
0093 }
0094 
0095 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0096 void HepMCG4PythiaInterface::CallPystat(G4int istat)
0097 {
0098   call_pystat(istat);
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 void HepMCG4PythiaInterface::SetRandomSeed(G4int iseed)
0103 {
0104   pydatr.mrpy[1 - 1] = iseed;
0105 }
0106 
0107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0108 void HepMCG4PythiaInterface::CallPyrget(G4int lun, G4int move)
0109 {
0110   call_pyrget(lun, move);
0111 }
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0114 void HepMCG4PythiaInterface::CallPyrset(G4int lun, G4int move)
0115 {
0116   call_pyrset(lun, move);
0117 }
0118 
0119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0120 void HepMCG4PythiaInterface::PrintRandomStatus(std::ostream& ostr) const
0121 {
0122   ostr << "# Pythia random numbers status" << G4endl;
0123   for (G4int j = 0; j < 6; j++) {
0124     ostr << "pydatr.mrpy[" << j << "]= " << pydatr.mrpy[j] << G4endl;
0125   }
0126   for (G4int k = 0; k < 100; k++) {
0127     ostr << "pydatr.rrpy[" << k << "]= " << pydatr.rrpy[k] << G4endl;
0128   }
0129 }
0130 
0131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0132 void HepMCG4PythiaInterface::SetUserParameters()
0133 {
0134   G4cout << "set user parameters of PYTHIA common." << G4endl << "nothing to be done in default."
0135          << G4endl;
0136 }
0137 
0138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0139 HepMC::GenEvent* HepMCG4PythiaInterface::GenerateHepMCEvent()
0140 {
0141   static G4int nevent = 0;  // event counter
0142 
0143   call_pyevnt();  // generate one event with Pythia
0144   if (mpylist >= 1 && mpylist <= 3) call_pylist(mpylist);
0145 
0146   call_pyhepc(1);
0147 
0148   HepMC::GenEvent* evt = hepevtio.read_next_event();
0149   evt->set_event_number(nevent++);
0150   if (verbose > 0) evt->print();
0151 
0152   return evt;
0153 }
0154 
0155 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0156 void HepMCG4PythiaInterface::Print() const
0157 {
0158   G4cout << "PythiaInterface::Print()..." << G4endl;
0159 }
0160 
0161 #endif