diff --git a/cmake/Modules/FindLHAPDF.cmake b/cmake/Modules/FindLHAPDF.cmake new file mode 100644 index 00000000000..cf0dbe2fdbd --- /dev/null +++ b/cmake/Modules/FindLHAPDF.cmake @@ -0,0 +1,56 @@ +# - Try to find LHAPDF +# Defines: +# +# LHAPDF_FOUND +# LHAPDF_INCLUDE_DIR +# LHAPDF_INCLUDE_DIRS (not cached) +# LHAPDF_LIBRARY +# LHAPDF_LIBRARIES (not cached) +# LHAPDF_LIBRARY_DIRS (not cached) + +if (LHAPDF_ROOT_DIR OR LHAPDF_DIR OR (DEFINED ENV{LHAPDF_ROOT_DIR}) OR (DEFINED ENV{LHAPDF_DIR}) ) + set(LHAPDF_SEARCH_DIRS "" CACHE STRING "" FORCE) + if (LHAPDF_ROOT_DIR) + list (APPEND LHAPDF_SEARCH_DIRS "${LHAPDF_ROOT_DIR}" ) + endif() + if (LHAPDF_DIR) + list (APPEND LHAPDF_SEARCH_DIRS "${LHAPDF_DIR}" ) + endif() + if (DEFINED EVN{LHAPDF_ROOT_DIR}) + list (APPEND LHAPDF_SEARCH_DIRS "$ENV{LHAPDF_ROOT_DIR}" ) + endif() + if (DEFINED ENV{LHAPDF_DIR}) + list (APPEND LHAPDF_SEARCH_DIRS "ENV{LHAPDF_DIR}" ) + endif() +endif() +if (LHAPDF_SEARCH_DIRS) + find_path(LHAPDF_INCLUDE_DIR LHAPDF/LHAPDF.h PATHS ${LHAPDF_SEARCH_DIRS} PATH_SUFFIXES include NO_DEFAULT_PATH) + find_library(LHAPDF_LIBRARY NAMES LHAPDF PATHS ${LHAPDF_SEARCH_DIRS} PATH_SUFFIXES lib lib64 NO_DEFAULT_PATH) +else() + find_path(LHAPDF_INCLUDE_DIR LHAPDF/LHAPDF.h PATH_SUFFIXES include) + find_library(LHAPDF_LIBRARY NAMES LHAPDF PATHS_SUFFIXES lib lib64) +endif() +set(LHAPDF_VERSION 0.0.0) +if (LHAPDF_INCLUDE_DIR) + if (EXISTS ${LHAPDF_INCLUDE_DIR}/LHAPDF/Version.h) + file(STRINGS ${LHAPDF_INCLUDE_DIR}/LHAPDF/Version.h LHAPDF_VERSION_STRING_CONTENT REGEX "^#define[ ]+LHAPDF_VERSION[ ]+\"" ) + if (LHAPDF_VERSION_STRING_CONTENT) + string(REGEX MATCH "[1234567890\.]+[a-zA-Z]*" LHAPDF_VERSION ${LHAPDF_VERSION_STRING_CONTENT}) + endif() + endif() +endif() + + +mark_as_advanced(LHAPDF_INCLUDE_DIR LHAPDF_LIBRARY) + +# handle the QUIETLY and REQUIRED arguments and set LHAPDF_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LHAPDF DEFAULT_MSG LHAPDF_INCLUDE_DIR LHAPDF_LIBRARY) + +set(LHAPDF_LIBRARIES ${LHAPDF_LIBRARY}) +get_filename_component(LHAPDF_LIBRARY_DIRS ${LHAPDF_LIBRARY} PATH) + +set(LHAPDF_INCLUDE_DIRS ${LHAPDF_INCLUDE_DIR}) + +mark_as_advanced(LHAPDF_FOUND) diff --git a/cmake/Modules/FindPythia6.cmake b/cmake/Modules/FindPythia6.cmake index 110e934aa14..b4f115bfaf0 100644 --- a/cmake/Modules/FindPythia6.cmake +++ b/cmake/Modules/FindPythia6.cmake @@ -4,9 +4,17 @@ # Defines: # PYTHIA6_FOUND # PYTHIA6_LIBRARIES +set(TEST_PYTHIA6_ROOT_DIR "" ${PYTHIA6_ROOT_DIR}) +IF(TEST_PYTHIA6_ROOT_DIR STREQUAL "") + IF(DEFINED ENV{PYTHIA6_ROOT_DIR}) + set(PYTHIA6_ROOT_DIR $ENV{PYTHIA6_ROOT_DIR}) + else() + set(PYTHIA6_ROOT_DIR "/usr") + endif() +endif() -find_library(PYTHIA6_LIBRARY NAMES Pythia6 pythia6-$ENV{PYTHIA6_VERSION} - HINTS $ENV{PYTHIA6} $ENV{PYTHIA6}/lib) +find_library(PYTHIA6_LIBRARY NAMES Pythia6 pythia6 pythia6-$ENV{PYTHIA6_VERSION} + HINTS $ENV{PYTHIA6} $ENV{PYTHIA6}/lib $ENV{PYTHIA6}/lib64 ${PYTHIA6_ROOT_DIR}/lib ${PYTHIA6_ROOT_DIR}/lib64) set(PYTHIA6_LIBRARIES ${PYTHIA6_LIBRARY}) #message(STATUS PYTHIA6_LIBRARIES ${PYTHIA6_LIBRARIES} ) diff --git a/cmake/Modules/FindPythia8.cmake b/cmake/Modules/FindPythia8.cmake index 6a5e9d2f7e1..3b709392f6c 100644 --- a/cmake/Modules/FindPythia8.cmake +++ b/cmake/Modules/FindPythia8.cmake @@ -1,24 +1,51 @@ -# Locate Pythia8 library -# in a directory defined via PYTHIA8 environment variable -# +# - Locate pythia8 library # Defines: -# PYTHIA8_FOUND -# PYTHIA8_LIBRARIES -# PYTHIA8_INCLUDES +# +# Pythia_FOUND +# PYTHIA8_VERSION +# PYTHIA8_INCLUDE_DIR +# PYTHIA8_XMLDOC_DIR +# PYTHIA8_INCLUDE_DIRS (not cached) +# PYTHIA8_LIBRARY +# PYTHIA8_hepmcinterface_LIBRARY +# PYTHIA8_lhapdfdummy_LIBRARY +# PYTHIA8_LIBRARIES (not cached) : includes 3 libraries above; not to be used if lhapdf is used +set(TEST_PYTHIA8_ROOT_DIR "" ${PYTHIA8_ROOT_DIR}) +IF(TEST_PYTHIA8_ROOT_DIR STREQUAL "") + IF(DEFINED ENV{PYTHIA8_ROOT_DIR}) + set(PYTHIA8_ROOT_DIR $ENV{PYTHIA8_ROOT_DIR}) + else() + set(PYTHIA8_ROOT_DIR "/usr") + endif() +endif() -find_library(PYTHIA8_LIBRARY NAMES pythia8 - HINTS $ENV{PYTHIA8} $ENV{PYTHIA8}/lib) +find_path(PYTHIA8_INCLUDE_DIR Pythia.h Pythia8/Pythia.h HINTS ${PYTHIA8_ROOT_DIR}/include) -set(PYTHIA8_LIBRARIES ${PYTHIA8_LIBRARY}) -#message(STATUS PYTHIA8_LIBRARIES ${PYTHIA8_LIBRARIES} ) +find_path(PYTHIA8_XMLDOC_DIR Version.xml HINTS ${PYTHIA8_ROOT_DIR}/xmldoc ${PYTHIA8_ROOT_DIR}/share/Pythia8/xmldoc ${PYTHIA8_ROOT_DIR}/share/pythia8-data/xmldoc ${PYTHIA8_ROOT_DIR}/share/doc/packages/pythia/xmldoc ) -find_path( PYTHIA8_INCLUDES Pythia8/Pythia.h - HINTS $ENV{PYTHIA8} $ENV{PYTHIA8}/include $ENV{PYTHIA8}/include/Pythia8 ) -set(PYTHIA8_INCLUDES ${PYTHIA8_INCLUDES}) +if(PYTHIA8_INCLUDE_DIR AND PYTHIA8_XMLDOC_DIR) + file(READ ${PYTHIA8_XMLDOC_DIR}/Version.xml versionstr) + string(REGEX REPLACE ".*Pythia:versionNumber.*default.*[0-9][.]([0-9]+).*" "\\1" PYTHIA8_VERSION "${versionstr}") + set(PYTHIA8_VERSION "8.${PYTHIA8_VERSION}") + find_library(PYTHIA8_LIBRARY NAMES pythia8 Pythia8 HINTS ${PYTHIA8_ROOT_DIR}/lib ${PYTHIA8_ROOT_DIR}/lib64) + find_library(PYTHIA8_lhapdfdummy_LIBRARY NAMES lhapdfdummy HINTS ${PYTHIA8_ROOT_DIR}/lib ${PYTHIA8_ROOT_DIR}/lib64) + set(PYTHIA8_INCLUDE_DIRS ${PYTHIA8_INCLUDE_DIR} ${PYTHIA8_INCLUDE_DIR}/Pythia8 ${PYTHIA8_INCLUDE_DIR}/Pythia8Plugins ) + set(PYTHIA8_LIBRARIES ${PYTHIA8_LIBRARY}) + if(PYTHIA8_VERSION VERSION_LESS 8.200) + #Is this library needed? + set(PYTHIA8_LIBRARIES ${PYTHIA8_LIBRARY} ${PYTHIA8_lhapdfdummy_LIBRARY}) + endif() + find_file(resHEPMC3 HepMC3.h PATHS ${PYTHIA8_INCLUDE_DIRS} NO_DEFAULT_PATH) + if (resHEPMC3) + set(Pythia8_HEPMC3_FOUND TRUE) + endif() +endif() -# handle the QUIETLY and REQUIRED arguments and set PYTHIA8_FOUND to TRUE if +# handle the QUIETLY and REQUIRED arguments and set Pythia8_FOUND to TRUE if # all listed variables are TRUE + INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pythia8 DEFAULT_MSG PYTHIA8_LIBRARIES) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pythia8 REQUIRED_VARS PYTHIA8_INCLUDE_DIR PYTHIA8_LIBRARIES PYTHIA8_XMLDOC_DIR VERSION_VAR PYTHIA8_VERSION HANDLE_COMPONENTS) + +mark_as_advanced(Pythia8_FOUND PYTHIA8_INCLUDE_DIR PYTHIA8_LIBRARY PYTHIA8_LIBRARIES PYTHIA8_XMLDOC_DIR) -mark_as_advanced(PYTHIA8_FOUND PYTHIA8_LIBRARIES PYTHIA8_INCLUDES) diff --git a/examples/extended/eventgenerator/CMakeLists.txt b/examples/extended/eventgenerator/CMakeLists.txt index 6c700593fc9..6a685f5b2e3 100644 --- a/examples/extended/eventgenerator/CMakeLists.txt +++ b/examples/extended/eventgenerator/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16...3.27) +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/Modules ${CMAKE_MODULE_PATH}) find_package(Geant4) include(${Geant4_USE_FILE}) @@ -11,26 +12,47 @@ add_subdirectory(particleGun) add_subdirectory(exgps) add_subdirectory(userPrimaryGenerator) -#---------------------------------------------------------------------------- -# HepMC examples require HepMC -# -find_package(HepMC QUIET) -if(HEPMC_FOUND) - add_subdirectory(HepMC) -else() - message(STATUS "G4 Examples: HepMC package not found. --> HepMC examples disabled.") -endif() #---------------------------------------------------------------------------- # decayer6 example requires Pythia6 # -find_package(Pythia6 QUIET) -if(PYTHIA6_FOUND) +option(PYTHIA6_INTERNAL "Download and compile Pythia6" OFF) +if (NOT PYTHIA6_INTERNAL) + find_package(Pythia6) +endif() +if(PYTHIA6_FOUND OR PYTHIA6_INTERNAL) + if (PYTHIA6_INTERNAL) + message(STATUS "Pythia6 will be downloaded and compiled") + include(FetchContent) + FetchContent_Declare( + p6 + URL https://pythia.org/download/pythia6/pythia6428-split.tgz + URL_HASH MD5=5391da11b95aa1d90600bc69da4f84cd + ) + FetchContent_GetProperties(p6) + if (NOT p6_POPULATED) + FetchContent_Populate(p6) + endif() + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.pythia6 DESTINATION ${p6_SOURCE_DIR}) + file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/pyinit.f DESTINATION ${p6_SOURCE_DIR}) + file(RENAME ${p6_SOURCE_DIR}/CMakeLists.txt.pythia6 ${p6_SOURCE_DIR}/CMakeLists.txt) + add_subdirectory(${p6_SOURCE_DIR} ${p6_BINARY_DIR}) + set(PYTHIA6_LIBRARIES G4Pythia6) + endif() add_subdirectory(pythia/decayer6) else() message(STATUS "G4 Examples: Pythia6 package not found. --> decayer6 example disabled.") endif() +#---------------------------------------------------------------------------- +# HepMC examples require HepMC +# +find_package(HepMC QUIET) +if(HEPMC_FOUND) + add_subdirectory(HepMC) +else() + message(STATUS "G4 Examples: HepMC package not found. --> HepMC examples disabled.") +endif() #---------------------------------------------------------------------------- # py8decayer example requires Pythia8 # diff --git a/examples/extended/eventgenerator/CMakeLists.txt.pythia6 b/examples/extended/eventgenerator/CMakeLists.txt.pythia6 index 05448b9e06d..3a74c7eb7f3 100644 --- a/examples/extended/eventgenerator/CMakeLists.txt.pythia6 +++ b/examples/extended/eventgenerator/CMakeLists.txt.pythia6 @@ -1,35 +1,28 @@ -# CMake configuration file for building Pythia6 from the source -# downloaded from the PYTHIA6 download site: -# http://www.hepforge.org/downloads/pythia6 -# -# To build Pythia6 library: -# % cd mydir -# % mkdir pythia6_source -# % mkdir pythia6_build -# % mkdir pythia6 -# % cp CMakeLists.txt.pythia6 pythia6_source/CMakeLists.txt -# % cp pythia6-version.f pythia6_source -# % cd pythia6_build -# % cmake -DCMAKE_INSTALL_PREFIX=../pythia6 ../pythia6_source -# % make -# % make install - -#---------------------------------------------------------------------------- -# Setup the project -cmake_minimum_required(VERSION 3.16...3.27) -project(pythia6 Fortran) - #---------------------------------------------------------------------------- # Locate sources and headers for this project # -file(GLOB sources ${PROJECT_SOURCE_DIR}/*.f) +# file(GLOB sources ${CMAKE_CURRENT_SOURCE_DIR}/*.f) +#AV The original line from pythia6. We do not use pdfset.f as we link with LHAPDF +#SRCS := $(wildcard py*.f) $(wildcard struct*.f) $(wildcard up*.f) ssmssm.f sugra.f visaje.f $(wildcard fh*.f) pdfset.f +enable_language(Fortran) +file(GLOB py_sources ${CMAKE_CURRENT_SOURCE_DIR}/py*.f) +file(GLOB struct_sources ${CMAKE_CURRENT_SOURCE_DIR}/struct*.f) +file(GLOB up_sources ${CMAKE_CURRENT_SOURCE_DIR}/up*.f) +file(GLOB fh_sources ${CMAKE_CURRENT_SOURCE_DIR}/fh*.f) #---------------------------------------------------------------------------- # Add library # -add_library(Pythia6 SHARED ${sources}) - +add_library(G4Pythia6 SHARED ${py_sources} + ${struct_sources} + ${up_sources} + ${fh_sources} + ${CMAKE_CURRENT_SOURCE_DIR}/ssmssm.f + ${CMAKE_CURRENT_SOURCE_DIR}/sugra.f + ${CMAKE_CURRENT_SOURCE_DIR}/visaje.f + ${CMAKE_CURRENT_SOURCE_DIR}/pdfset.f + ) #---------------------------------------------------------------------------- # Install library # -install(TARGETS Pythia6 DESTINATION lib) +install(TARGETS G4Pythia6 DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/examples/extended/eventgenerator/HepMC/HepMCEx01/CMakeLists.txt b/examples/extended/eventgenerator/HepMC/HepMCEx01/CMakeLists.txt index 9f0833388b7..e6b14947f28 100644 --- a/examples/extended/eventgenerator/HepMC/HepMCEx01/CMakeLists.txt +++ b/examples/extended/eventgenerator/HepMC/HepMCEx01/CMakeLists.txt @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # Setup the project cmake_minimum_required(VERSION 3.16...3.27) -project(HepMCEx01) +project(HepMCEx01 LANGUAGES C CXX Fortran ) #---------------------------------------------------------------------------- # Find Geant4 package, activating all available UI and Vis drivers by default @@ -24,43 +24,50 @@ include(${Geant4_USE_FILE}) # Find HepMC (required package) # find_package(HepMC REQUIRED) - +#---------------------------------------------------------------------------- +# Find LHAPDF (required package) +# +find_package(LHAPDF REQUIRED) #---------------------------------------------------------------------------- # Find Pythia6 (optional package) # -find_package(Pythia6 QUIET) -if(PYTHIA6_FOUND) +if (NOT PYTHIA6_INTERNAL) + find_package(Pythia6) +endif() +if(PYTHIA6_FOUND OR PYTHIA6_INTERNAL) message(STATUS "G4 Examples: Pythia6 found. --> HepMCEx01 example with Pythia6 enabled.") - add_definitions(-DG4LIB_USE_PYTHIA) + add_definitions(-DG4LIB_USE_PYTHIA) + enable_language(Fortran) + set (generator_sources + ${PROJECT_SOURCE_DIR}/external/initpydata.f + ${PROJECT_SOURCE_DIR}/external/upevnt.F + ${PROJECT_SOURCE_DIR}/external/upinit.F + ${PROJECT_SOURCE_DIR}/external/upveto.F + ) else() set(PYTHIA6_LIBRARIES "") + set (generator_sources "") endif() #---------------------------------------------------------------------------- # Locate sources and headers for this project # -include_directories(${PROJECT_SOURCE_DIR}/include - ${Geant4_INCLUDE_DIR} - ${HEPMC_INCLUDE_DIR}) file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc) file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) #---------------------------------------------------------------------------- # Add the executable, and link it to the Geant4 libraries # -add_executable(HepMCEx01 HepMCEx01.cc ${sources} ${headers}) -#target_link_libraries(HepMCEx01 ${Geant4_LIBRARIES} -# ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES} -# ${PYTHIA6_LIBRARIES} gfortran) +add_executable(HepMCEx01 HepMCEx01.cc ${sources} ${headers} ${generator_sources}) target_link_libraries(HepMCEx01 ${Geant4_LIBRARIES} ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES} - ${PYTHIA6_LIBRARIES}) - -# if pythia is compiled with g77, link with -lg2c instead. -#target_link_libraries(HepMCEx01 ${Geant4_LIBRARIES} -# ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES} -# ${PYTHIA6_LIBRARIES} g2c) - + ${PYTHIA6_LIBRARIES} ${LHAPDF_LIBRARIES}) +target_include_directories(HepMCEx01 PRIVATE ${PROJECT_SOURCE_DIR}/include + ${Geant4_INCLUDE_DIR} + ${HEPMC_INCLUDE_DIR}) +if(PYTHIA6_FOUND) +set_target_properties(HepMCEx01 PROPERTIES LINKER_LANGUAGE Fortran) +endif() #---------------------------------------------------------------------------- # Copy all scripts to the build directory, i.e. the directory in which we # build HepMCEx01. This is so that we can run the executable directly because it diff --git a/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upevnt.F b/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upevnt.F new file mode 100644 index 00000000000..15e72907f7b --- /dev/null +++ b/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upevnt.F @@ -0,0 +1,28 @@ + +C********************************************************************* + +C...UPEVNT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Depending on cross section model chosen, it either has +C...to generate a process of the type IDPRUP requested, or pick a type +C...itself and generate this event. The event is to be stored in the +C...HEPEUP commonblock, including (often) an event weight. + + SUBROUTINE UPEVNT + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process event common block. + INTEGER MAXNUP + PARAMETER (MAXNUP=500) + INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP + DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP + COMMON/HEPEUP/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP), + &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP), + &VTIMUP(MAXNUP),SPINUP(MAXNUP) + SAVE /HEPEUP/ + + RETURN + END diff --git a/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upinit.F b/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upinit.F new file mode 100644 index 00000000000..6492b62b09c --- /dev/null +++ b/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upinit.F @@ -0,0 +1,26 @@ + +C********************************************************************* + +C...UPINIT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Is supposed to fill the HEPRUP commonblock with info +C...on incoming beams and allowed processes. + + SUBROUTINE UPINIT + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process initialization commonblock. + INTEGER MAXPUP + PARAMETER (MAXPUP=100) + INTEGER IDBMUP,PDFGUP,PDFSUP,IDWTUP,NPRUP,LPRUP + DOUBLE PRECISION EBMUP,XSECUP,XERRUP,XMAXUP + COMMON/HEPRUP/IDBMUP(2),EBMUP(2),PDFGUP(2),PDFSUP(2), + &IDWTUP,NPRUP,XSECUP(MAXPUP),XERRUP(MAXPUP),XMAXUP(MAXPUP), + &LPRUP(MAXPUP) + SAVE /HEPRUP/ + + RETURN + END diff --git a/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upveto.F b/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upveto.F new file mode 100644 index 00000000000..48af84ee02e --- /dev/null +++ b/examples/extended/eventgenerator/HepMC/HepMCEx01/external/upveto.F @@ -0,0 +1,28 @@ + +C********************************************************************* + +C...UPEVNT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Depending on cross section model chosen, it either has +C...to generate a process of the type IDPRUP requested, or pick a type +C...itself and generate this event. The event is to be stored in the +C...HEPEUP commonblock, including (often) an event weight. + + SUBROUTINE UPVETO + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process event common block. + INTEGER MAXNUP + PARAMETER (MAXNUP=500) + INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP + DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP + COMMON/HEPEUP/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP), + &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP), + &VTIMUP(MAXNUP),SPINUP(MAXNUP) + SAVE /HEPEUP/ + + RETURN + END diff --git a/examples/extended/eventgenerator/HepMC/HepMCEx02/CMakeLists.txt b/examples/extended/eventgenerator/HepMC/HepMCEx02/CMakeLists.txt index 47acb01460b..b9df081ff7d 100644 --- a/examples/extended/eventgenerator/HepMC/HepMCEx02/CMakeLists.txt +++ b/examples/extended/eventgenerator/HepMC/HepMCEx02/CMakeLists.txt @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # Setup the project cmake_minimum_required(VERSION 3.16...3.27) -project(HepMCEx02) +project(HepMCEx02 LANGUAGES C CXX Fortran ) #---------------------------------------------------------------------------- # Find Geant4 package, activating all available UI and Vis drivers by default @@ -24,42 +24,50 @@ include(${Geant4_USE_FILE}) # Find HepMC (required package) # find_package(HepMC REQUIRED) +#---------------------------------------------------------------------------- +# Find LHAPDF (required package) +# +find_package(LHAPDF REQUIRED) #---------------------------------------------------------------------------- # Find Pythia6 (optional package) # -find_package(Pythia6 QUIET) -if(PYTHIA6_FOUND) +if (NOT PYTHIA6_INTERNAL) + find_package(Pythia6) +endif() +if(PYTHIA6_FOUND OR PYTHIA6_INTERNAL) message(STATUS "G4 Examples: Pythia6 found. --> HepMCEx02 example with Pythia6 enabled.") - add_definitions(-DG4LIB_USE_PYTHIA) + add_definitions(-DG4LIB_USE_PYTHIA) + enable_language(Fortran) + set (generator_sources + ${PROJECT_SOURCE_DIR}/external/upevnt.F + ${PROJECT_SOURCE_DIR}/external/upinit.F + ${PROJECT_SOURCE_DIR}/external/upveto.F + ) else() set(PYTHIA6_LIBRARIES "") + set (generator_sources "") endif() #---------------------------------------------------------------------------- # Locate sources and headers for this project # -include_directories(${PROJECT_SOURCE_DIR}/include - ${Geant4_INCLUDE_DIR} - ${HEPMC_INCLUDE_DIR}) file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc) file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) #---------------------------------------------------------------------------- # Add the executable, and link it to the Geant4 libraries # -add_executable(HepMCEx02 HepMCEx02.cc ${sources} ${headers}) -#target_link_libraries(HepMCEx02 ${Geant4_LIBRARIES} -# ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES} -# ${PYTHIA6_LIBRARIES} gfortran) +add_executable(HepMCEx02 HepMCEx02.cc ${sources} ${headers} ${generator_sources}) target_link_libraries(HepMCEx02 ${Geant4_LIBRARIES} ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES} - ${PYTHIA6_LIBRARIES}) - -# if pythia is compiled with g77, link with -lg2c instead. -#target_link_libraries(HepMCEx02 ${Geant4_LIBRARIES} -# ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES} -# ${PYTHIA6_LIBRARIES} g2c) + ${PYTHIA6_LIBRARIES} ${LHAPDF_LIBRARIES}) +target_include_directories(HepMCEx02 PRIVATE ${PROJECT_SOURCE_DIR}/include + ${Geant4_INCLUDE_DIR} + ${HEPMC_INCLUDE_DIR}) +if(PYTHIA6_FOUND) + set_target_properties(HepMCEx02 PROPERTIES LINKER_LANGUAGE Fortran) +endif() #---------------------------------------------------------------------------- # Copy all scripts to the build directory, i.e. the directory in which we diff --git a/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upevnt.F b/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upevnt.F new file mode 100644 index 00000000000..15e72907f7b --- /dev/null +++ b/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upevnt.F @@ -0,0 +1,28 @@ + +C********************************************************************* + +C...UPEVNT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Depending on cross section model chosen, it either has +C...to generate a process of the type IDPRUP requested, or pick a type +C...itself and generate this event. The event is to be stored in the +C...HEPEUP commonblock, including (often) an event weight. + + SUBROUTINE UPEVNT + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process event common block. + INTEGER MAXNUP + PARAMETER (MAXNUP=500) + INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP + DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP + COMMON/HEPEUP/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP), + &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP), + &VTIMUP(MAXNUP),SPINUP(MAXNUP) + SAVE /HEPEUP/ + + RETURN + END diff --git a/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upinit.F b/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upinit.F new file mode 100644 index 00000000000..6492b62b09c --- /dev/null +++ b/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upinit.F @@ -0,0 +1,26 @@ + +C********************************************************************* + +C...UPINIT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Is supposed to fill the HEPRUP commonblock with info +C...on incoming beams and allowed processes. + + SUBROUTINE UPINIT + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process initialization commonblock. + INTEGER MAXPUP + PARAMETER (MAXPUP=100) + INTEGER IDBMUP,PDFGUP,PDFSUP,IDWTUP,NPRUP,LPRUP + DOUBLE PRECISION EBMUP,XSECUP,XERRUP,XMAXUP + COMMON/HEPRUP/IDBMUP(2),EBMUP(2),PDFGUP(2),PDFSUP(2), + &IDWTUP,NPRUP,XSECUP(MAXPUP),XERRUP(MAXPUP),XMAXUP(MAXPUP), + &LPRUP(MAXPUP) + SAVE /HEPRUP/ + + RETURN + END diff --git a/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upveto.F b/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upveto.F new file mode 100644 index 00000000000..48af84ee02e --- /dev/null +++ b/examples/extended/eventgenerator/HepMC/HepMCEx02/external/upveto.F @@ -0,0 +1,28 @@ + +C********************************************************************* + +C...UPEVNT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Depending on cross section model chosen, it either has +C...to generate a process of the type IDPRUP requested, or pick a type +C...itself and generate this event. The event is to be stored in the +C...HEPEUP commonblock, including (often) an event weight. + + SUBROUTINE UPVETO + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process event common block. + INTEGER MAXNUP + PARAMETER (MAXNUP=500) + INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP + DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP + COMMON/HEPEUP/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP), + &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP), + &VTIMUP(MAXNUP),SPINUP(MAXNUP) + SAVE /HEPEUP/ + + RETURN + END diff --git a/examples/extended/eventgenerator/pyinit.f b/examples/extended/eventgenerator/pyinit.f new file mode 100644 index 00000000000..7b8c2b57a4c --- /dev/null +++ b/examples/extended/eventgenerator/pyinit.f @@ -0,0 +1,315 @@ + +C********************************************************************* + +C...PYINIT +C...Initializes the generation procedure; finds maxima of the +C...differential cross-sections to be used for weighting. + SUBROUTINE PYINIT(FRAME,BEAM,TARGET,WIN) +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + INTEGER PYK,PYCHGE,PYCOMP +C...Commonblocks. + COMMON/PYDAT1/MSTU(200),PARU(200),MSTJ(200),PARJ(200) + COMMON/PYDAT2/KCHG(500,4),PMAS(500,4),PARF(2000),VCKM(4,4) + COMMON/PYDAT3/MDCY(500,3),MDME(8000,2),BRAT(8000),KFDP(8000,5) + COMMON/PYDAT4/CHAF(500,2) + CHARACTER CHAF*16 + COMMON/PYSUBS/MSEL,MSELPD,MSUB(500),KFIN(2,-40:40),CKIN(200) + COMMON/PYPARS/MSTP(200),PARP(200),MSTI(200),PARI(200) + COMMON/PYINT1/MINT(400),VINT(400) + COMMON/PYINT2/ISET(500),KFPR(500,2),COEF(500,20),ICOL(40,4,2) + COMMON/PYINT5/NGENPD,NGEN(0:500,3),XSEC(0:500,3) + COMMON/PYPUED/IUED(0:99),RUED(0:99) + SAVE /PYDAT1/,/PYDAT2/,/PYDAT3/,/PYDAT4/,/PYSUBS/,/PYPARS/, + &/PYINT1/,/PYINT2/,/PYINT5/,/PYPUED/ +C...Local arrays and character variables. + DIMENSION ALAMIN(20),NFIN(20) + CHARACTER*(*) FRAME,BEAM,TARGET + CHARACTER CHFRAM*12,CHBEAM*12,CHTARG*12,CHLH(2)*6 + +C...Interface to PDFLIB. + COMMON/W50511/NPTYPE,NGROUP,NSET,MODE,NFL,LO,TMAS + COMMON/W50512/QCDL4,QCDL5 + SAVE /W50511/,/W50512/ + DOUBLE PRECISION VALUE(20),TMAS,QCDL4,QCDL5 + CHARACTER*20 PARM(20) + DATA VALUE/20*0D0/,PARM/20*' '/ + +C...Data:Lambda and n_f values for parton distributions.. + DATA ALAMIN/0.177D0,0.239D0,0.247D0,0.2322D0,0.248D0,0.248D0, + &0.192D0,0.326D0,2*0.2D0,0.2D0,0.2D0,0.29D0,0.2D0,0.4D0,5*0.2D0/, + &NFIN/20*4/ + DATA CHLH/'lepton','hadron'/ +C...Check that BLOCK DATA PYDATA has been loaded. + CALL PYCKBD + +C...Reset MINT and VINT arrays. Write headers. + MSTI(53)=0 + DO 100 J=1,400 + MINT(J)=0 + VINT(J)=0D0 + 100 CONTINUE + IF(MSTU(12).NE.12345) CALL PYLIST(0) + IF(MSTP(122).GE.1) WRITE(MSTU(11),5100) + + +C...Reset error counters. + MSTU(23)=0 + MSTU(27)=0 + MSTU(30)=0 + + +C...Reset processes that should not be on. + MSUB(96)=0 + MSUB(97)=0 +C...Select global FSR/ISR/UE parameter set = 'tune' +C...See routine PYTUNE for details + IF (MSTP(5).NE.0) THEN + MSTP5=MSTP(5) + CALL PYTUNE(MSTP5) + ENDIF + +C...Call user process initialization routine. + IF(FRAME(1:1).EQ.'u'.OR.FRAME(1:1).EQ.'U') THEN + MSEL=0 + CALL UPINIT + MSEL=0 + ENDIF + +C...Maximum 4 generations; set maximum number of allowed flavours. + MSTP(1)=MIN(4,MSTP(1)) + MSTU(114)=MIN(MSTU(114),2*MSTP(1)) + MSTP(58)=MIN(MSTP(58),2*MSTP(1)) + +C...Sum up Cabibbo-Kobayashi-Maskawa factors for each quark/lepton. + DO 120 I=-20,20 + VINT(180+I)=0D0 + IA=IABS(I) + IF(IA.GE.1.AND.IA.LE.2*MSTP(1)) THEN + DO 110 J=1,MSTP(1) + IB=2*J-1+MOD(IA,2) + IF(IB.GE.6.AND.MSTP(9).EQ.0) GOTO 110 + IPM=(5-ISIGN(1,I))/2 + IDC=J+MDCY(IA,2)+2 + IF(MDME(IDC,1).EQ.1.OR.MDME(IDC,1).EQ.IPM) VINT(180+I)= + & VINT(180+I)+VCKM((IA+1)/2,(IB+1)/2) + 110 CONTINUE + ELSEIF(IA.GE.11.AND.IA.LE.10+2*MSTP(1)) THEN + VINT(180+I)=1D0 + ENDIF + 120 CONTINUE +C...Initialize parton distributions: PDFLIB. + IF(MSTP(52).EQ.2) THEN + PARM(1)='NPTYPE' + VALUE(1)=1 + PARM(2)='NGROUP' + VALUE(2)=MSTP(51)/1000 + PARM(3)='NSET' + VALUE(3)=MOD(MSTP(51),1000) + PARM(4)='TMAS' + VALUE(4)=PMAS(6,1) + CALL PDFSET(PARM,VALUE) + MINT(93)=1000000+MSTP(51) + ENDIF +C...Choose Lambda value to use in alpha-strong. + MSTU(111)=MSTP(2) + IF(MSTP(3).GE.2) THEN + ALAM=0.2D0 + NF=4 + IF(MSTP(52).EQ.1.AND.MSTP(51).GE.1.AND.MSTP(51).LE.20) THEN + ALAM=ALAMIN(MSTP(51)) + NF=NFIN(MSTP(51)) + ELSEIF(MSTP(52).EQ.2.AND.NFL.EQ.5) THEN + ALAM=QCDL5 + NF=5 + ELSEIF(MSTP(52).EQ.2) THEN + ALAM=QCDL4 + NF=4 + ENDIF + PARP(1)=ALAM + PARP(61)=ALAM + PARP(72)=ALAM + PARU(112)=ALAM + MSTU(112)=NF + IF(MSTP(3).EQ.3) PARJ(81)=ALAM + ENDIF + +C...Initialize the UED masses and widths + IF (IUED(1).EQ.1) CALL PYXDIN +C...Initialize the SUSY generation: couplings, masses, +C...decay modes, branching ratios, and so on. + CALL PYMSIN +C...Initialize widths and partial widths for resonances. + CALL PYINRE +C...Set Z0 mass and width for e+e- routines. + PARJ(123)=PMAS(23,1) + PARJ(124)=PMAS(23,2) +C...Identify beam and target particles and frame of process. + CHFRAM=FRAME(1:len(FRAME))//' ' + CHBEAM=BEAM(1:len(BEAM))//' ' + CHTARG=TARGET(1:len(TARGET))//' ' + CALL PYINBM(CHFRAM,CHBEAM,CHTARG,WIN) + IF(MINT(65).EQ.1) GOTO 170 +C...For gamma-p or gamma-gamma allow many (3 or 6) alternatives. +C...For e-gamma allow 2 alternatives. + MINT(121)=1 + IF(MSTP(14).EQ.10.AND.(MSEL.EQ.1.OR.MSEL.EQ.2)) THEN + IF((MINT(11).EQ.22.OR.MINT(12).EQ.22).AND. + & (IABS(MINT(11)).GT.100.OR.IABS(MINT(12)).GT.100)) MINT(121)=3 + IF(MINT(11).EQ.22.AND.MINT(12).EQ.22) MINT(121)=6 + IF((MINT(11).EQ.22.OR.MINT(12).EQ.22).AND. + & (IABS(MINT(11)).EQ.11.OR.IABS(MINT(12)).EQ.11)) MINT(121)=2 + ELSEIF(MSTP(14).EQ.20.AND.(MSEL.EQ.1.OR.MSEL.EQ.2)) THEN + IF((MINT(11).EQ.22.OR.MINT(12).EQ.22).AND. + & (IABS(MINT(11)).GT.100.OR.IABS(MINT(12)).GT.100)) MINT(121)=3 + IF(MINT(11).EQ.22.AND.MINT(12).EQ.22) MINT(121)=9 + ELSEIF(MSTP(14).EQ.25.AND.(MSEL.EQ.1.OR.MSEL.EQ.2)) THEN + IF((MINT(11).EQ.22.OR.MINT(12).EQ.22).AND. + & (IABS(MINT(11)).GT.100.OR.IABS(MINT(12)).GT.100)) MINT(121)=2 + IF(MINT(11).EQ.22.AND.MINT(12).EQ.22) MINT(121)=4 + ELSEIF(MSTP(14).EQ.30.AND.(MSEL.EQ.1.OR.MSEL.EQ.2)) THEN + IF((MINT(11).EQ.22.OR.MINT(12).EQ.22).AND. + & (IABS(MINT(11)).GT.100.OR.IABS(MINT(12)).GT.100)) MINT(121)=4 + IF(MINT(11).EQ.22.AND.MINT(12).EQ.22) MINT(121)=13 + ENDIF + MINT(123)=MSTP(14) + IF((MSTP(14).EQ.10.OR.MSTP(14).EQ.20.OR.MSTP(14).EQ.25.OR. + &MSTP(14).EQ.30).AND.MSEL.NE.1.AND.MSEL.NE.2) MINT(123)=0 + IF(MSTP(14).GE.11.AND.MSTP(14).LE.19) THEN + IF(MSTP(14).EQ.11) MINT(123)=0 + IF(MSTP(14).EQ.12.OR.MSTP(14).EQ.14) MINT(123)=5 + IF(MSTP(14).EQ.13.OR.MSTP(14).EQ.17) MINT(123)=6 + IF(MSTP(14).EQ.15) MINT(123)=2 + IF(MSTP(14).EQ.16.OR.MSTP(14).EQ.18) MINT(123)=7 + IF(MSTP(14).EQ.19) MINT(123)=3 + ELSEIF(MSTP(14).GE.21.AND.MSTP(14).LE.24) THEN + IF(MSTP(14).EQ.21) MINT(123)=0 + IF(MSTP(14).EQ.22.OR.MSTP(14).EQ.23) MINT(123)=4 + IF(MSTP(14).EQ.24) MINT(123)=1 + ELSEIF(MSTP(14).GE.26.AND.MSTP(14).LE.29) THEN + IF(MSTP(14).EQ.26.OR.MSTP(14).EQ.28) MINT(123)=8 + IF(MSTP(14).EQ.27.OR.MSTP(14).EQ.29) MINT(123)=9 + ENDIF +C...Set up kinematics of process. + CALL PYINKI(0) + +C...Set up kinematics for photons inside leptons. + IF(MINT(141).NE.0.OR.MINT(142).NE.0) CALL PYGAGA(1,WTGAGA) + +C...Precalculate flavour selection weights. + CALL PYKFIN +C...Loop over gamma-p or gamma-gamma alternatives. + CKIN3=CKIN(3) + MSAV48=0 + DO 160 IGA=1,MINT(121) + CKIN(3)=CKIN3 + MINT(122)=IGA + +C...Select partonic subprocesses to be included in the simulation. + CALL PYINPR + MINT(101)=1 + MINT(102)=1 + MINT(103)=MINT(11) + MINT(104)=MINT(12) + +C...Count number of subprocesses on. + MINT(48)=0 + DO 130 ISUB=1,500 + IF(MINT(50).EQ.0.AND.ISUB.GE.91.AND.ISUB.LE.96.AND. + & MSUB(ISUB).EQ.1.AND.MINT(121).GT.1) THEN + MSUB(ISUB)=0 + ELSEIF(MINT(50).EQ.0.AND.ISUB.GE.91.AND.ISUB.LE.96.AND. + & MSUB(ISUB).EQ.1) THEN + WRITE(MSTU(11),5200) ISUB,CHLH(MINT(41)),CHLH(MINT(42)) + CALL PYSTOP(1) + ELSEIF(MSUB(ISUB).EQ.1.AND.ISET(ISUB).EQ.-1) THEN + WRITE(MSTU(11),5300) ISUB + CALL PYSTOP(1) + ELSEIF(MSUB(ISUB).EQ.1.AND.ISET(ISUB).LE.-2) THEN + WRITE(MSTU(11),5400) ISUB + CALL PYSTOP(1) + ELSEIF(MSUB(ISUB).EQ.1) THEN + MINT(48)=MINT(48)+1 + ENDIF + 130 CONTINUE + +C...Stop or raise warning flag if no subprocesses on. + IF(MINT(121).EQ.1.AND.MINT(48).EQ.0) THEN + IF(MSTP(127).NE.1) THEN + WRITE(MSTU(11),5500) + CALL PYSTOP(1) + ELSE + WRITE(MSTU(11),5700) + MSTI(53)=1 + ENDIF + ENDIF + MINT(49)=MINT(48)-MSUB(91)-MSUB(92)-MSUB(93)-MSUB(94) + MSAV48=MSAV48+MINT(48) + +C...Reset variables for cross-section calculation. + DO 150 I=0,500 + DO 140 J=1,3 + NGEN(I,J)=0 + XSEC(I,J)=0D0 + 140 CONTINUE + 150 CONTINUE + +C...Find parametrized total cross-sections. + CALL PYXTOT + VINT(318)=VINT(317) + +C...Maxima of differential cross-sections. + IF(MSTP(121).LE.1) CALL PYMAXI + +C...Initialize possibility of pileup events. + IF(MINT(121).GT.1) MSTP(131)=0 + IF(MSTP(131).NE.0) CALL PYPILE(1) + +C...Initialize multiple interactions with variable impact parameter. + IF(MINT(50).EQ.1) THEN + PTMN=PARP(82)*(VINT(1)/PARP(89))**PARP(90) + IF(MOD(MSTP(81),10).EQ.0.AND.(CKIN(3).GT.PTMN.OR. + & ((MSEL.NE.1.AND.MSEL.NE.2)))) MSTP(82)=MIN(1,MSTP(82)) + IF((MINT(49).NE.0.OR.MSTP(131).NE.0).AND.MSTP(82).GE.2) THEN + MINT(35)=1 + CALL PYMULT(1) + MINT(35)=3 + CALL PYMIGN(1) + ENDIF + ENDIF + +C...Save results for gamma-p and gamma-gamma alternatives. + IF(MINT(121).GT.1) CALL PYSAVE(1,IGA) + 160 CONTINUE + +C...Initialization finished. + IF(MSAV48.EQ.0) THEN + IF(MSTP(127).NE.1) THEN + WRITE(MSTU(11),5500) + CALL PYSTOP(1) + ELSE + WRITE(MSTU(11),5700) + MSTI(53)=1 + ENDIF + ENDIF + 170 IF(MSTP(122).GE.1) WRITE(MSTU(11),5600) + +C...Formats for initialization information. + 5100 FORMAT('1',18('*'),1X,'PYINIT: initialization of PYTHIA ', + &'routines',1X,17('*')) + 5200 FORMAT(1X,'Error: process number ',I3,' not meaningful for ',A6, + &'-',A6,' interactions.'/1X,'Execution stopped!') + 5300 FORMAT(1X,'Error: requested subprocess',I4,' not implemented.'/ + &1X,'Execution stopped!') + 5400 FORMAT(1X,'Error: requested subprocess',I4,' not existing.'/ + &1X,'Execution stopped!') + 5500 FORMAT(1X,'Error: no subprocess switched on.'/ + &1X,'Execution stopped.') + 5600 FORMAT(/1X,22('*'),1X,'PYINIT: initialization completed',1X, + &22('*')) + 5700 FORMAT(1X,'Error: no subprocess switched on.'/ + &1X,'Execution will stop if you try to generate events.') + + RETURN + END diff --git a/examples/extended/eventgenerator/pythia/decayer6/CMakeLists.txt b/examples/extended/eventgenerator/pythia/decayer6/CMakeLists.txt index 00fb0f84ecd..37d7bf39484 100644 --- a/examples/extended/eventgenerator/pythia/decayer6/CMakeLists.txt +++ b/examples/extended/eventgenerator/pythia/decayer6/CMakeLists.txt @@ -1,7 +1,7 @@ #---------------------------------------------------------------------------- # Setup the project cmake_minimum_required(VERSION 3.16...3.27) -project(decayer6) +project(decayer6 LANGUAGES C CXX Fortran ) #---------------------------------------------------------------------------- # Find Geant4 package, activating all available UI and Vis drivers by default @@ -23,18 +23,23 @@ include(${Geant4_USE_FILE}) #---------------------------------------------------------------------------- # Find Pythia6 (required package) # -find_package(Pythia6 REQUIRED) - +if (NOT PYTHIA6_INTERNAL) + find_package(Pythia6 REQUIRED) +endif() +#---------------------------------------------------------------------------- +# Find LHAPDF (required package) +# +find_package(LHAPDF REQUIRED) #---------------------------------------------------------------------------- # Locate sources and headers for this project # -include_directories(${PROJECT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/common/include - ${Geant4_INCLUDE_DIR} - ${PYTHIA6_INCLUDE_DIR}) file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc ${PROJECT_SOURCE_DIR}/src/*.c) file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) - +set (generator_sources + ${PROJECT_SOURCE_DIR}/src/upevnt.F + ${PROJECT_SOURCE_DIR}/src/upinit.F + ${PROJECT_SOURCE_DIR}/src/upveto.F + ) #---------------------------------------------------------------------------- # Add common subdirectory and # - disable building examples in common @@ -47,9 +52,17 @@ add_subdirectory(common) #---------------------------------------------------------------------------- # Add the executable, and link it to the Geant4 libraries # -add_executable(pythia6_decayer pythia6_decayer.cc ${sources} ${headers}) -target_link_libraries(pythia6_decayer ${common_prefix}common ${Geant4_LIBRARIES} ${PYTHIA6_LIBRARIES} ) - +add_executable(pythia6_decayer pythia6_decayer.cc ${sources} ${headers} ${generator_sources}) +target_link_libraries(pythia6_decayer ${common_prefix}common + ${Geant4_LIBRARIES} + ${PYTHIA6_LIBRARIES} + ${LHAPDF_LIBRARIES}) +target_include_directories(pythia6_decayer PRIVATE ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/common/include + ${Geant4_INCLUDE_DIR} + ${LHAPDF_INCLUDE_DIR} + ) +set_target_properties(pythia6_decayer PROPERTIES LINKER_LANGUAGE Fortran) #---------------------------------------------------------------------------- # Copy all scripts to the build directory, i.e. the directory in which we # build decayer6. This is so that we can run the executable directly because it diff --git a/examples/extended/eventgenerator/pythia/decayer6/src/upevnt.F b/examples/extended/eventgenerator/pythia/decayer6/src/upevnt.F new file mode 100644 index 00000000000..15e72907f7b --- /dev/null +++ b/examples/extended/eventgenerator/pythia/decayer6/src/upevnt.F @@ -0,0 +1,28 @@ + +C********************************************************************* + +C...UPEVNT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Depending on cross section model chosen, it either has +C...to generate a process of the type IDPRUP requested, or pick a type +C...itself and generate this event. The event is to be stored in the +C...HEPEUP commonblock, including (often) an event weight. + + SUBROUTINE UPEVNT + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process event common block. + INTEGER MAXNUP + PARAMETER (MAXNUP=500) + INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP + DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP + COMMON/HEPEUP/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP), + &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP), + &VTIMUP(MAXNUP),SPINUP(MAXNUP) + SAVE /HEPEUP/ + + RETURN + END diff --git a/examples/extended/eventgenerator/pythia/decayer6/src/upinit.F b/examples/extended/eventgenerator/pythia/decayer6/src/upinit.F new file mode 100644 index 00000000000..6492b62b09c --- /dev/null +++ b/examples/extended/eventgenerator/pythia/decayer6/src/upinit.F @@ -0,0 +1,26 @@ + +C********************************************************************* + +C...UPINIT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Is supposed to fill the HEPRUP commonblock with info +C...on incoming beams and allowed processes. + + SUBROUTINE UPINIT + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process initialization commonblock. + INTEGER MAXPUP + PARAMETER (MAXPUP=100) + INTEGER IDBMUP,PDFGUP,PDFSUP,IDWTUP,NPRUP,LPRUP + DOUBLE PRECISION EBMUP,XSECUP,XERRUP,XMAXUP + COMMON/HEPRUP/IDBMUP(2),EBMUP(2),PDFGUP(2),PDFSUP(2), + &IDWTUP,NPRUP,XSECUP(MAXPUP),XERRUP(MAXPUP),XMAXUP(MAXPUP), + &LPRUP(MAXPUP) + SAVE /HEPRUP/ + + RETURN + END diff --git a/examples/extended/eventgenerator/pythia/decayer6/src/upveto.F b/examples/extended/eventgenerator/pythia/decayer6/src/upveto.F new file mode 100644 index 00000000000..48af84ee02e --- /dev/null +++ b/examples/extended/eventgenerator/pythia/decayer6/src/upveto.F @@ -0,0 +1,28 @@ + +C********************************************************************* + +C...UPEVNT +C...Dummy routine, to be replaced by a user implementing external +C...processes. Depending on cross section model chosen, it either has +C...to generate a process of the type IDPRUP requested, or pick a type +C...itself and generate this event. The event is to be stored in the +C...HEPEUP commonblock, including (often) an event weight. + + SUBROUTINE UPVETO + +C...Double precision and integer declarations. + IMPLICIT DOUBLE PRECISION(A-H, O-Z) + IMPLICIT INTEGER(I-N) + +C...User process event common block. + INTEGER MAXNUP + PARAMETER (MAXNUP=500) + INTEGER NUP,IDPRUP,IDUP,ISTUP,MOTHUP,ICOLUP + DOUBLE PRECISION XWGTUP,SCALUP,AQEDUP,AQCDUP,PUP,VTIMUP,SPINUP + COMMON/HEPEUP/NUP,IDPRUP,XWGTUP,SCALUP,AQEDUP,AQCDUP,IDUP(MAXNUP), + &ISTUP(MAXNUP),MOTHUP(2,MAXNUP),ICOLUP(2,MAXNUP),PUP(5,MAXNUP), + &VTIMUP(MAXNUP),SPINUP(MAXNUP) + SAVE /HEPEUP/ + + RETURN + END