Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:09

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 eventgenerator/HepMC/HepMCEx01/src/HepMCG4PythiaInterface.cc
0027 /// \brief Implementation of the HepMCG4PythiaInterface class
0028 //
0029 //
0030 
0031 #ifdef G4LIB_USE_PYTHIA
0032 
0033 #  include "HepMCG4PythiaInterface.hh"
0034 
0035 #  include "HepMC/GenEvent.h"
0036 #  include "HepMC/PythiaWrapper6_4.h"
0037 #  include "HepMCG4PythiaMessenger.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 // additional pythia calls
0041 #  define pygive pygive_
0042 #  define pyrget pyrget_
0043 #  define pyrset pyrset_
0044 
0045 extern "C"
0046 {
0047   void pygive(const char*, int);
0048   void pyrget(int*, int*);
0049   void pyrset(int*, int*);
0050 }
0051 
0052 void call_pygive(G4String s)
0053 {
0054   pygive(s.c_str(), s.length());
0055 }
0056 void call_pyrget(int a, int b)
0057 {
0058   pyrget(&a, &b);
0059 }
0060 void call_pyrset(int a, int b)
0061 {
0062   pyrset(&a, &b);
0063 }
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 HepMCG4PythiaInterface::HepMCG4PythiaInterface() : verbose(0), mpylist(0)
0067 {
0068 #  ifdef NEED_INITPYDATA
0069   initpydata();
0070   // Some platforms may require the initialization of pythia PYDATA block
0071   // data as external - if you get pythia initialization errors try
0072   // commenting in/out the below call to initpydata().
0073 #  endif
0074 
0075   messenger = new HepMCG4PythiaMessenger(this);
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 HepMCG4PythiaInterface::~HepMCG4PythiaInterface()
0080 {
0081   delete messenger;
0082 }
0083 
0084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0085 void HepMCG4PythiaInterface::CallPygive(G4String par)
0086 {
0087   call_pygive(par);
0088 }
0089 
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0091 void HepMCG4PythiaInterface::CallPyinit(G4String frame, G4String beam, G4String target,
0092                                         G4double win)
0093 {
0094   call_pyinit(frame.c_str(), beam.c_str(), target.c_str(), win);
0095 }
0096 
0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0098 void HepMCG4PythiaInterface::CallPystat(G4int istat)
0099 {
0100   call_pystat(istat);
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0104 void HepMCG4PythiaInterface::SetRandomSeed(G4int iseed)
0105 {
0106   pydatr.mrpy[1 - 1] = iseed;
0107 }
0108 
0109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0110 void HepMCG4PythiaInterface::CallPyrget(G4int lun, G4int move)
0111 {
0112   call_pyrget(lun, move);
0113 }
0114 
0115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0116 void HepMCG4PythiaInterface::CallPyrset(G4int lun, G4int move)
0117 {
0118   call_pyrset(lun, move);
0119 }
0120 
0121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0122 void HepMCG4PythiaInterface::PrintRandomStatus(std::ostream& ostr) const
0123 {
0124   ostr << "# Pythia random numbers status" << G4endl;
0125   for (G4int j = 0; j < 6; j++) {
0126     ostr << "pydatr.mrpy[" << j << "]= " << pydatr.mrpy[j] << G4endl;
0127   }
0128   for (G4int k = 0; k < 100; k++) {
0129     ostr << "pydatr.rrpy[" << k << "]= " << pydatr.rrpy[k] << G4endl;
0130   }
0131 }
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0134 void HepMCG4PythiaInterface::SetUserParameters()
0135 {
0136   G4cout << "set user parameters of PYTHIA common." << G4endl << "nothing to be done in default."
0137          << G4endl;
0138 }
0139 
0140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0141 HepMC::GenEvent* HepMCG4PythiaInterface::GenerateHepMCEvent()
0142 {
0143   static G4int nevent = 0;  // event counter
0144 
0145   call_pyevnt();  // generate one event with Pythia
0146   if (mpylist >= 1 && mpylist <= 3) call_pylist(mpylist);
0147 
0148   call_pyhepc(1);
0149 
0150   HepMC::GenEvent* evt = hepevtio.read_next_event();
0151   evt->set_event_number(nevent++);
0152   if (verbose > 0) evt->print();
0153 
0154   return evt;
0155 }
0156 
0157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0158 void HepMCG4PythiaInterface::Print() const
0159 {
0160   G4cout << "PythiaInterface::Print()..." << G4endl;
0161 }
0162 
0163 #endif