diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 564f8cc..2f3d62c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,156 +1,156 @@ .tags_template: tags: &tags_def - docker stages: - minimal_compile - different_compile - clean_code - publish variables: HEJ_Install_DIR: tmp_HEJ/HEJ_installed HEJ_build_DIR: tmp_HEJ/build_HEJ FOG_build_DIR: tmp_HEJ/build_FOG after_script: - date .HEJ_compile: tags: *tags_def before_script: - date - source /cvmfs/pheno.egi.eu/HEJ/HEJ_env.sh || exit 1 - export t_HEJ_Install_DIR=${PWD}/$HEJ_Install_DIR - export t_HEJ_build_DIR=${PWD}/$HEJ_build_DIR - export t_HEJ_DIR=${PWD} - mkdir -p ${t_HEJ_build_DIR} - cd ${t_HEJ_build_DIR} - cmake ${t_HEJ_DIR} -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=${t_HEJ_Install_DIR} - make -j 8 Minimal_setup: stage: minimal_compile extends: .HEJ_compile image: hejdock/hepenv script: - make test FOG: stage: minimal_compile extends: .HEJ_compile image: hejdock/hepenv script: - date # install HEJ - make install # setup env - export LD_LIBRARY_PATH=${t_HEJ_Install_DIR}/lib:${LD_LIBRARY_PATH} - export PATH=${t_HEJ_Install_DIR}/bin:${PATH} - export t_FOG_build_DIR=${PWD}/$FOG_build_DIR - export t_FOG_DIR=${t_HEJ_DIR}/FixedOrderGen # compile - mkdir -p ${t_FOG_build_DIR} - cd ${t_FOG_build_DIR} - cmake ${t_FOG_DIR} -DCMAKE_BUILD_TYPE=DEBUG - make -j 8 - make test rivet: stage: different_compile extends: .HEJ_compile image: hejdock/rivetenv variables: HEJ_build_DIR: tmp_HEJ/build_HEJ_rivet script: - make test - bash -c '[ -f tst.yoda ]' && echo "found rivet output" - rivet-cmphistos tst.yoda - bash -c '[ -f MC_XS_XS.dat ]' && echo "yoda not empty" QCDloop: stage: different_compile extends: .HEJ_compile image: hejdock/qcdloopenv variables: HEJ_build_DIR: tmp_HEJ/build_HEJ_qcd script: - make test HepMC3: stage: different_compile extends: .HEJ_compile image: hejdock/hepmc3env variables: HEJ_build_DIR: tmp_HEJ/build_HEJ_HepMC3 script: - make test No_tabs: stage: clean_code tags: *tags_def image: hejdock/git script: - date - check_tabs No_warnings: stage: clean_code tags: *tags_def image: hejdock/hepenv before_script: - date - source /cvmfs/pheno.egi.eu/HEJ/HEJ_env.sh || exit 1 - export t_HEJ_Install_DIR=${PWD}/$HEJ_Install_DIR - export t_HEJ_build_DIR=${PWD}/$HEJ_build_DIR - export t_HEJ_DIR=${PWD} - export LD_LIBRARY_PATH=${t_HEJ_Install_DIR}/lib:${LD_LIBRARY_PATH} - export PATH=${t_HEJ_Install_DIR}/bin:${PATH} - export t_FOG_build_DIR=${PWD}/$FOG_build_DIR - export t_FOG_DIR=${t_HEJ_DIR}/FixedOrderGen - mkdir -p ${t_HEJ_build_DIR} - mkdir -p ${t_FOG_build_DIR} script: - - sed -i 's/include_directories(${lhapdf/include_directories(SYSTEM ${lhapdf/g' CMakeLists.txt + - sed -i 's/include_directories(${LHAPDF/include_directories(SYSTEM ${LHAPDF/g' CMakeLists.txt - sed -i 's/include_directories(${fastjet/include_directories(SYSTEM ${fastjet/g' CMakeLists.txt - sed -i 's/include_directories(${Boost/include_directories(SYSTEM ${Boost/g' CMakeLists.txt - cd ${t_HEJ_build_DIR} - cmake ${t_HEJ_DIR} -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_INSTALL_PREFIX=${t_HEJ_Install_DIR} - make -j 8 - make install - cd ${t_FOG_DIR} - - sed -i 's/include_directories(${lhapdf/include_directories(SYSTEM ${lhapdf/g' CMakeLists.txt + - sed -i 's/include_directories(${LHAPDF/include_directories(SYSTEM ${LHAPDF/g' CMakeLists.txt - sed -i 's/include_directories(${fastjet/include_directories(SYSTEM ${fastjet/g' CMakeLists.txt - sed -i 's/include_directories(${Boost/include_directories(SYSTEM ${Boost/g' CMakeLists.txt - cd ${t_FOG_build_DIR} - cmake ${t_FOG_DIR} -DCMAKE_CXX_FLAGS="-Werror" - make -j 8 .Publish: stage: publish tags: *tags_def image: hejdock/git before_script: - mkdir -p .ssh/ && echo "${SSH_KEY}" > .ssh/id_rsa && chmod 0600 .ssh/id_rsa - rm -rf ~/.ssh/id_rsa; mkdir -p ~/.ssh/ - ln -s $PWD/.ssh/id_rsa ~/.ssh/id_rsa && chmod 0600 ~/.ssh/id_rsa - ssh -T ${PUBLIC_GIT_PREFIX} -o "StrictHostKeyChecking no" || echo "added ssh" script: - git remote add public ${PUBLIC_GIT_PREFIX}${PUBLIC_GIT_POSTFIX} - git checkout $CI_COMMIT_REF_NAME - git branch - git pull - git push public - git push public --tags after_script: - rm -f /root/.ssh/id_rsa && rm -fr .ssh - git remote rm public Publish_version: extends: .Publish only: - /^v\d+\.\d+$/ except: - tags when: on_success diff --git a/CMakeLists.txt b/CMakeLists.txt index 611e96a..c48e69f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,267 +1,280 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) set(CMAKE_LEGACY_CYGWIN_WIN32 0) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -project("HEJ" VERSION 2.0.3 LANGUAGES C CXX) +project("HEJ" VERSION 2.0.4 LANGUAGES C CXX) # Set a default build type if none was specified -set(default_build_type "Release") +set(default_build_type "RelWithDebInfo") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${default_build_type}' as none was specified.") set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() ## Flags for the compiler. No warning allowed. if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") elseif (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc") endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 14) ## Create Version set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") # Get the latest abbreviated commit hash of the working branch execute_process( COMMAND git rev-parse HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE PROJECT_GIT_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE ) # Get the current working branch execute_process( COMMAND git rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE PROJECT_GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE ) ## target directories for install set(INSTALL_INCLUDE_DIR_BASE include) set(INSTALL_INCLUDE_DIR ${INSTALL_INCLUDE_DIR_BASE}/HEJ) set(INSTALL_BIN_DIR bin) set(INSTALL_LIB_DIR lib) set(INSTALL_CONFIG_DIR lib/cmake/HEJ) ## Template files configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/Version.hh.in ${PROJECT_BINARY_DIR}/include/HEJ/Version.hh @ONLY ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/HEJ-config.cc.in ${PROJECT_BINARY_DIR}/src/bin/HEJ-config.cc @ONLY ) # Generate CMake config file include(CMakePackageConfigHelpers) configure_package_config_file( cmake/Templates/hej-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config.cmake INSTALL_DESTINATION ${INSTALL_CONFIG_DIR} PATH_VARS INSTALL_INCLUDE_DIR_BASE INSTALL_LIB_DIR ) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config-version.cmake COMPATIBILITY SameMajorVersion ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CONFIG_DIR}/hej-config-version.cmake DESTINATION ${INSTALL_CONFIG_DIR}) ## Add directories and find dependences include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) find_package(fastjet REQUIRED) -include_directories(${fastjet_INCLUDE_PATH}) -find_package(clhep 2.3 REQUIRED) -include_directories(${CLHEP_INCLUDE_PATH}) -find_package(lhapdf REQUIRED) -include_directories(${lhapdf_INCLUDE_PATH}) +include_directories(${fastjet_INCLUDE_DIRS}) +find_package(CLHEP 2.3 REQUIRED) +include_directories(${CLHEP_INCLUDE_DIRS}) +find_package(LHAPDF REQUIRED) +include_directories(${LHAPDF_INCLUDE_DIRS}) ## Amend unintuitive behaviour of FindBoost.cmake ## Priority of BOOST_ROOT over BOOSTROOT matches FindBoost.cmake ## at least for cmake 3.12 if(DEFINED BOOST_ROOT) message("BOOST_ROOT set - only looking for Boost in ${BOOST_ROOT}") set(Boost_NO_BOOST_CMAKE ON) elseif(DEFINED BOOSTROOT) message("BOOSTROOT set - only looking for Boost in ${BOOSTROOT}") set(Boost_NO_BOOST_CMAKE ON) endif() find_package(Boost REQUIRED COMPONENTS iostreams) include_directories(${Boost_INCLUDE_DIRS}) -find_package(yaml-cpp) +find_package(yaml-cpp) # requiring yaml does not work with fedora include_directories(${YAML_CPP_INCLUDE_DIR}) -find_package(HepMC 2) +if(${EXCLUDE_HepMC}) + message(STATUS "Skipping HepMC") + # avoid "unused variable" warning if EXCLUDE_rivet is set by user + set(EXCLUDE_rivet TRUE) +else() + find_package(HepMC 2) +endif() if(${HepMC_FOUND}) - message (STATUS "HepMC installation found: ${HepMC_INCLUDE_DIRS}") set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_HepMC_VERSION=${HepMC_VERSION_MAJOR}" ) include_directories(${HepMC_INCLUDE_DIRS}) - find_package(rivet) + if(${EXCLUDE_rivet}) + message(STATUS "Skipping rivet") + else() + find_package(rivet) + endif() if(${rivet_FOUND}) - include_directories(${rivet_INCLUDE_PATH}) - set( - CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_RIVET" - ) + include_directories(${rivet_INCLUDE_DIRS}) + set( + CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_RIVET" + ) endif() endif() -find_package(QCDloop 2) +if(${EXCLUDE_QCDloop}) + message(STATUS "Skipping QCDloop") +else() + find_package(QCDloop 2) +endif() if(${QCDloop_FOUND}) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_QCDLOOP") include_directories(SYSTEM ${QCDloop_INCLUDE_DIRS}) endif() add_subdirectory(src) ## define executable add_executable(HEJ src/bin/HEJ.cc) ## link libraries target_link_libraries(HEJ hejlib) add_executable(HEJ-config src/bin/HEJ-config.cc) file(GLOB hej_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/HEJ/*.hh ${PROJECT_BINARY_DIR}/include/HEJ/*.hh) file(GLOB lhef_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/LHEF/*.h) install(FILES ${hej_headers} DESTINATION ${INSTALL_INCLUDE_DIR}) install(FILES ${lhef_headers} DESTINATION include/LHEF/) install(TARGETS HEJ HEJ-config DESTINATION ${INSTALL_BIN_DIR}) ## tests enable_testing() set(tst_dir "${CMAKE_CURRENT_SOURCE_DIR}/t") add_executable(test_classify ${tst_dir}/test_classify.cc) add_executable(test_psp ${tst_dir}/test_psp.cc) add_executable(test_ME_generic ${tst_dir}/test_ME_generic.cc) add_executable(check_res ${tst_dir}/check_res.cc) add_executable(check_lhe ${tst_dir}/check_lhe.cc) add_library(scales SHARED ${tst_dir}/scales.cc) add_executable(test_scale_import ${tst_dir}/test_scale_import) add_executable(test_descriptions ${tst_dir}/test_descriptions) add_executable(test_scale_arithmetics ${tst_dir}/test_scale_arithmetics) target_link_libraries(test_classify hejlib) target_link_libraries(test_psp hejlib) target_link_libraries(test_ME_generic hejlib) target_link_libraries(check_res hejlib) target_link_libraries(check_lhe hejlib) target_link_libraries(test_scale_import hejlib) target_link_libraries(test_descriptions hejlib) target_link_libraries(test_scale_arithmetics hejlib) ## add tests add_test( NAME t_classify COMMAND test_classify ${tst_dir}/classify.lhe.gz ) add_test( NAME t_psp COMMAND test_psp ${tst_dir}/psp_gen.lhe.gz ) set(tst_ME_data_dir "${tst_dir}/ME_data") add_test( NAME t_ME_j COMMAND test_ME_generic ${tst_ME_data_dir}/config_mtinf.yml ${tst_ME_data_dir}/ME_jets_tree.dat ${tst_ME_data_dir}/PSP_jets.lhe.gz ) add_test( NAME t_ME_h COMMAND test_ME_generic ${tst_ME_data_dir}/config_mtinf.yml ${tst_ME_data_dir}/ME_h_mtinf_tree.dat ${tst_ME_data_dir}/PSP_h.lhe.gz ) # add_test( # NAME t_ME_w # COMMAND test_ME_generic ${tst_ME_data_dir}/config_w_ME.yml ${tst_ME_data_dir}/ME_w_tree.dat ${tst_ME_data_dir}/PSP_w.lhe.gz # ) add_test( NAME t_ME_w_FKL COMMAND test_ME_generic ${tst_ME_data_dir}/config_w_ME.yml ${tst_ME_data_dir}/ME_w_FKL_tree.dat ${tst_ME_data_dir}/PSP_w_FKL.lhe.gz ) add_test( NAME t_ME_w_FKL_virt COMMAND test_ME_generic ${tst_ME_data_dir}/config_w_ME.yml ${tst_ME_data_dir}/ME_w_FKL_virt.dat ${tst_ME_data_dir}/PSP_w_FKL.lhe.gz ) if(${QCDloop_FOUND}) add_test( NAME t_ME_h_mt COMMAND test_ME_generic ${tst_ME_data_dir}/config_mt.yml ${tst_ME_data_dir}/ME_h_mt_tree.dat ${tst_ME_data_dir}/PSP_h.lhe.gz ) add_test( NAME t_ME_h_mtmb COMMAND test_ME_generic ${tst_ME_data_dir}/config_mtmb.yml ${tst_ME_data_dir}/ME_h_mtmb_tree.dat ${tst_ME_data_dir}/PSP_h.lhe.gz ) endif() add_test( NAME t_2j COMMAND check_res ${tst_dir}/2j.lhe.gz 3.49391e+07 419684 ) add_test( NAME t_3j COMMAND check_res ${tst_dir}/3j.lhe.gz 2.37902e+06 25746.6 ) add_test( NAME t_4j COMMAND check_res ${tst_dir}/4j.lhe.gz 603713 72822.6 ) add_test( NAME t_h_3j COMMAND check_res ${tst_dir}/h_3j.lhe.gz 0.821622 0.0220334 ) add_test( NAME t_h_3j_uno COMMAND check_res ${tst_dir}/h_3j_uno.lhe.gz 0.0261968 0.000341549 uno ) if(${HepMC_FOUND}) file(READ "${tst_dir}/jet_config.yml" config) file(WRITE "${tst_dir}/jet_config_withHepMC.yml" "${config} - tst.hepmc") if(${rivet_FOUND}) file(READ "${tst_dir}/jet_config_withHepMC.yml" config) file(WRITE "${tst_dir}/jet_config_withRivet.yml" "${config}\n\nanalysis:\n rivet: MC_XS\n output: tst") add_test( NAME t_main COMMAND HEJ ${tst_dir}/jet_config_withRivet.yml ${tst_dir}/2j.lhe.gz ) else() add_test( NAME t_main COMMAND HEJ ${tst_dir}/jet_config_withHepMC.yml ${tst_dir}/2j.lhe.gz ) endif() if(${HepMC_VERSION_MAJOR} GREATER 2) add_executable(check_hepmc ${tst_dir}/check_hepmc.cc) target_link_libraries(check_hepmc hejlib) add_test( NAME t_hepmc COMMAND check_hepmc tst.hepmc ) endif() else() add_test( NAME t_main COMMAND HEJ ${tst_dir}/jet_config.yml ${tst_dir}/2j.lhe.gz ) endif() add_test( NAME t_lhe COMMAND check_lhe tst.lhe ) add_test( NAME t_scale_import COMMAND test_scale_import ${tst_dir}/jet_config_with_import.yml ) add_test( NAME t_descriptions COMMAND test_descriptions ) add_test( NAME t_scale_arithmetics COMMAND test_scale_arithmetics ${tst_dir}/jet_config.yml ${tst_dir}/2j.lhe.gz ) diff --git a/Changes.md b/Changes.md index ebdf244..d1f98d3 100644 --- a/Changes.md +++ b/Changes.md @@ -1,20 +1,31 @@ # Version 2.0 ## 2.X.0 * Made `MatrixElement::tree_kin` and `MatrixElement::tree_param` public -* Allow multiplication and division of multiple scale functions e.g. `H_T/2*m_j1j2` +* Allow multiplication and division of multiple scale functions e.g. + `H_T/2*m_j1j2` +* Follow HepMC convention for particle Status codes: incoming = 11, + decaying = 2, outgoing = 1 (unchanged) + +## 2.0.4 + +* Fixed wrong path of `HEJ_INCLUDE_DIR` in `hej-config.cmake` +* Correctly include rivet headers +* New `EXCLUDE_package` variable in `cmake` to not interface to specific + packages +* Consistent search and include for side packages in `cmake` ## 2.0.3 * Fixed parsing of (numerical factor) * (base scale) in configuration * Don't change scale names, but sanitise Rivet output file names instead ## 2.0.2 * Changed scale names to `"_over_"` and `"_times_"` for proper file names (was - `"/"` and `"*"` before) + `"/"` and `"*"` before) ## 2.0.1 * Fixed name of fixed-order generator in error message. diff --git a/FixedOrderGen/CMakeLists.txt b/FixedOrderGen/CMakeLists.txt index f720610..bc4e530 100644 --- a/FixedOrderGen/CMakeLists.txt +++ b/FixedOrderGen/CMakeLists.txt @@ -1,122 +1,113 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR) set(CMAKE_LEGACY_CYGWIN_WIN32 0) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -project("HEJ Fixed Order Generation" VERSION 2.0.3 LANGUAGES C CXX) +project("HEJ Fixed Order Generation" VERSION 2.0.4 LANGUAGES C CXX) # Set a default build type if none was specified -set(default_build_type "Release") +set(default_build_type "RelWithDebInfo") if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to '${default_build_type}' as none was specified.") set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() ## Flags for the compiler. No warning allowed. if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") elseif (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc") endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 14) ## Create Version set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") # Get the latest abbreviated commit hash of the working branch execute_process( COMMAND git rev-parse HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE PROJECT_GIT_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE ) # Get the current working branch execute_process( COMMAND git rev-parse --abbrev-ref HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE PROJECT_GIT_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE ) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/Version.hh.in ${PROJECT_BINARY_DIR}/include/Version.hh @ONLY ) ## Add directories and find dependences -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/../include) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../cmake/Modules/") -find_package(HEJ REQUIRED) -include_directories(${HEJ_INCLUDE_PATH}) +find_package(HEJ 2 REQUIRED) +include_directories(${HEJ_INCLUDE_DIR}) find_package(fastjet REQUIRED) -include_directories(${fastjet_INCLUDE_PATH}) -find_package(clhep 2.3 REQUIRED) -include_directories(${CLHEP_INCLUDE_PATH}) -find_package(lhapdf REQUIRED) -include_directories(${lhapdf_INCLUDE_PATH}) +include_directories(${fastjet_INCLUDE_DIRS}) +find_package(CLHEP 2.3 REQUIRED) +include_directories(${CLHEP_INCLUDE_DIRS}) +find_package(LHAPDF REQUIRED) +include_directories(${LHAPDF_INCLUDE_DIRS}) ## Amend unintuitive behaviour of FindBoost.cmake ## Priority of BOOST_ROOT over BOOSTROOT matches FindBoost.cmake ## at least for cmake 3.12 if(DEFINED BOOST_ROOT) message("BOOST_ROOT set - only looking for Boost in ${BOOST_ROOT}") set(Boost_NO_BOOST_CMAKE ON) elseif(DEFINED BOOSTROOT) message("BOOSTROOT set - only looking for Boost in ${BOOSTROOT}") set(Boost_NO_BOOST_CMAKE ON) endif() find_package(Boost REQUIRED COMPONENTS iostreams) include_directories(${Boost_INCLUDE_DIRS}) -find_package(yaml-cpp) +find_package(yaml-cpp) # requiring yaml does not work with fedora include_directories(${YAML_CPP_INCLUDE_DIR}) -find_package(QCDloop 2) -if(${QCDloop_FOUND}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHEJ_BUILD_WITH_QCDLOOP") - include_directories(SYSTEM ${QCDloop_INCLUDE_DIRS}) -endif() ## define executable file(GLOB HEJFOG_source ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc) list(REMOVE_ITEM HEJFOG_source ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc) add_library(hejfog STATIC ${HEJFOG_source}) add_executable(HEJFOG ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cc) ## link libraries set(libraries ${CMAKE_DL_LIBS} ${LHAPDF_LIBRARIES} ${CLHEP_LIBRARIES} - ${FASTJET_LIBRARIES} ${Boost_LIBRARIES} ${YAML_CPP_LIBRARIES} ${HEJ_LIBRARIES}) -if(${QCDloop_FOUND}) - list(APPEND libraries ${QCDloop_LIBRARIES} quadmath) -endif() + ${fastjet_LIBRARIES} ${Boost_LIBRARIES} ${YAML_CPP_LIBRARIES} ${HEJ_LIBRARIES}) target_link_libraries(hejfog ${libraries}) target_link_libraries(HEJFOG hejfog) install(TARGETS HEJFOG DESTINATION bin) ## tests enable_testing() set(tst_dir "${CMAKE_CURRENT_SOURCE_DIR}/t") foreach(tst h_2j h_3j h_5j h_3j_uno1 h_3j_uno2 h_2j_decay 2j 4j W_2j_classify W_nj_classify) add_executable(test_${tst} ${tst_dir}/${tst}.cc) target_link_libraries(test_${tst} hejfog) add_test(NAME t_${tst} COMMAND test_${tst} WORKING_DIRECTORY ${tst_dir}) endforeach() add_test( NAME t_main_2j COMMAND HEJFOG ${tst_dir}/config_2j.yml ) add_test( NAME t_main_h2j COMMAND HEJFOG ${tst_dir}/config_h_2j.yml ) add_test( NAME t_main_h2j_decay COMMAND HEJFOG ${tst_dir}/config_h_2j_decay.yml ) diff --git a/cmake/Modules/FindCLHEP.cmake b/cmake/Modules/FindCLHEP.cmake new file mode 100644 index 0000000..3f4e4cc --- /dev/null +++ b/cmake/Modules/FindCLHEP.cmake @@ -0,0 +1,219 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +# This is a slightly modified version of FindGSL.cmake taken from cmake 3.7 + +#.rst: +# FindCLHEP +# -------- +# +# Find the native CLHEP includes and libraries. +# +# CLHEP package is an object oriented, C++ event record for High Energy +# Physics Monte Carlo generators and simulation. It is free software +# under the GNU General Public License. +# +# Imported Targets +# ^^^^^^^^^^^^^^^^ +# +# If CLHEP is found, this module defines the following +# :prop_tgt:`IMPORTED` target:: +# +# CLHEP::CLHEP - The main CLHEP library. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module will set the following variables in your project:: +# +# CLHEP_FOUND - True if CLHEP found on the local system +# CLHEP_INCLUDE_DIRS - Location of CLHEP header files. +# CLHEP_LIBRARIES - The CLHEP libraries. +# CLHEP_VERSION - The version of the discovered CLHEP install. +# +# Hints +# ^^^^^ +# +# Set ``CLHEP_ROOT_DIR`` to a directory that contains a CLHEP installation. +# +# This script expects to find libraries at ``$CLHEP_ROOT_DIR/lib`` and the CLHEP +# headers at ``$CLHEP_ROOT_DIR/include/CLHEP``. The library directory may +# optionally provide Release and Debug folders. For Unix-like systems, this +# script will use ``$CLHEP_ROOT_DIR/bin/CLHEP-config`` (if found) to aid in the +# discovery CLHEP. +# +# Cache Variables +# ^^^^^^^^^^^^^^^ +# +# This module may set the following variables depending on platform and type +# of CLHEP installation discovered. These variables may optionally be set to +# help this module find the correct files:: +# +# CLHEP_CONFIG_EXECUTABLE - Location of the ``CLHEP-config`` script (if any). +# CLHEP_LIBRARY - Location of the CLHEP library. +# CLHEP_LIBRARY_DEBUG - Location of the debug CLHEP library (if any). +# + +# Include these modules to handle the QUIETLY and REQUIRED arguments. +include(FindPackageHandleStandardArgs) + +#============================================================================= +# If the user has provided ``CLHEP_ROOT_DIR``, use it! Choose items found +# at this location over system locations. +if( EXISTS "$ENV{CLHEP_ROOT_DIR}" ) + file( TO_CMAKE_PATH "$ENV{CLHEP_ROOT_DIR}" CLHEP_ROOT_DIR ) + set( CLHEP_ROOT_DIR "${CLHEP_ROOT_DIR}" CACHE PATH "Prefix for CLHEP installation." ) +endif() +if( NOT EXISTS "${CLHEP_ROOT_DIR}" ) + set( CLHEP_USE_PKGCONFIG ON ) +endif() + +#============================================================================= +# As a first try, use the PkgConfig module. This will work on many +# *NIX systems. See :module:`findpkgconfig` +# This will return ``CLHEP_INCLUDEDIR`` and ``CLHEP_LIBDIR`` used below. +if( CLHEP_USE_PKGCONFIG ) + find_package(PkgConfig) + pkg_check_modules( CLHEP QUIET CLHEP ) + + if( EXISTS "${CLHEP_INCLUDEDIR}" ) + get_filename_component( CLHEP_ROOT_DIR "${CLHEP_INCLUDEDIR}" DIRECTORY CACHE) + endif() +endif() + +#============================================================================= +# Set CLHEP_INCLUDE_DIRS and CLHEP_LIBRARIES. If we skipped the PkgConfig step, try +# to find the libraries at $CLHEP_ROOT_DIR (if provided), in the directory +# suggested by CLHEP-config (if available), or in standard system +# locations. These find_library and find_path calls will prefer custom +# locations over standard locations (HINTS). If the requested file is found +# neither at the HINTS location nor via CLHEP-config, standard system locations +# will be still be searched (/usr/lib64 (Redhat), lib/i386-linux-gnu (Debian)). + +# If we didn't use PkgConfig, try to find the version via CLHEP-config +if( NOT CLHEP_VERSION ) + find_program( CLHEP_CONFIG_EXECUTABLE + NAMES clhep-config + HINTS "${CLHEP_ROOT_DIR}/bin" + ) + if( EXISTS "${CLHEP_CONFIG_EXECUTABLE}" ) + execute_process( + COMMAND "${CLHEP_CONFIG_EXECUTABLE}" --version + OUTPUT_VARIABLE CLHEP_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE ) + string(REGEX REPLACE "CLHEP " "" CLHEP_VERSION ${CLHEP_VERSION}) + execute_process( + COMMAND "${CLHEP_CONFIG_EXECUTABLE}" --prefix + OUTPUT_VARIABLE CLHEP_CONFIG_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + string (REGEX REPLACE "\"\(.*\)\"[ \t\r\n]*$" "\\1" + CLHEP_CONFIG_ROOT_DIR ${CLHEP_CONFIG_ROOT_DIR} ) + set(CLHEP_CONFIG_INCLUDEDIR ${CLHEP_CONFIG_ROOT_DIR}/include) + set(CLHEP_CONFIG_LIBDIR ${CLHEP_CONFIG_ROOT_DIR}/lib) + endif() +endif() +find_path( CLHEP_INCLUDE_DIR + NAMES CLHEP/ClhepVersion.h + HINTS ${CLHEP_ROOT_DIR}/include ${CLHEP_INCLUDEDIR} ${CLHEP_CONFIG_INCLUDEDIR} +) +find_library( CLHEP_LIBRARY + NAMES CLHEP + HINTS ${CLHEP_ROOT_DIR}/lib ${CLHEP_LIBDIR} ${CLHEP_CONFIG_LIBDIR} + PATH_SUFFIXES Release Debug +) +# Do we also have debug versions? +find_library( CLHEP_LIBRARY_DEBUG + NAMES CLHEP + HINTS ${CLHEP_ROOT_DIR}/lib ${CLHEP_LIBDIR} ${CLHEP_CONFIG_LIBDIR} + PATH_SUFFIXES Debug +) +set( CLHEP_INCLUDE_DIRS ${CLHEP_INCLUDE_DIR} ) +set( CLHEP_LIBRARIES ${CLHEP_LIBRARY} ) + +if( NOT CLHEP_VERSION ) + if(IS_DIRECTORY ${CLHEP_INCLUDE_DIR}) + file(STRINGS "${CLHEP_INCLUDE_DIR}/CLHEP/ClhepVersion.h" _CLHEP_VERS) + string( + REGEX MATCH + "static std::string String\\(\\) *{ *return *\"[^\"]*\"" + _CLHEP_VERSION_STR "${_CLHEP_VERS}" + ) + message(STATUS "_CLHEP_VERSION_STR ${_CLHEP_VERSION_STR}") + string( + REGEX MATCH + "[0-9]*\\.[0-9]*\\.[0-9]*\\.[0-9]*" + CLHEP_VERSION ${_CLHEP_VERSION_STR} + ) + endif() +endif() +if( CLHEP_VERSION ) + string(REPLACE "." ";" t_list ${CLHEP_VERSION}) + list(APPEND t_list 0 0) # add a buffer in case supversion not set + list(GET t_list 0 CLHEP_VERSION_MAJOR) + list(GET t_list 1 CLHEP_VERSION_MINOR) + list(GET t_list 2 CLHEP_VERSION_PATCH) +endif() +#============================================================================= +# handle the QUIETLY and REQUIRED arguments and set CLHEP_FOUND to TRUE if all +# listed variables are TRUE +find_package_handle_standard_args( CLHEP + FOUND_VAR + CLHEP_FOUND + REQUIRED_VARS + CLHEP_INCLUDE_DIR + CLHEP_LIBRARY + VERSION_VAR + CLHEP_VERSION + ) + +mark_as_advanced( CLHEP_ROOT_DIR CLHEP_VERSION CLHEP_LIBRARY CLHEP_INCLUDE_DIR + CLHEP_LIBRARY_DEBUG CLHEP_USE_PKGCONFIG CLHEP_CONFIG ) + +#============================================================================= +# Register imported libraries: +# 1. If we can find a Windows .dll file (or if we can find both Debug and +# Release libraries), we will set appropriate target properties for these. +# 2. However, for most systems, we will only register the import location and +# include directory. + +# Look for dlls, or Release and Debug libraries. +if(WIN32) + string( REPLACE ".lib" ".dll" CLHEP_LIBRARY_DLL "${CLHEP_LIBRARY}" ) + string( REPLACE ".lib" ".dll" CLHEP_LIBRARY_DEBUG_DLL "${CLHEP_LIBRARY_DEBUG}" ) +endif() + +if( CLHEP_FOUND AND NOT TARGET CLHEP::CLHEP ) + if( EXISTS "${CLHEP_LIBRARY_DLL}") + + # Windows systems with dll libraries. + add_library( CLHEP::CLHEP SHARED IMPORTED ) + add_library( CLHEP::CLHEPcblas SHARED IMPORTED ) + + # Windows with dlls, but only Release libraries. + set_target_properties( CLHEP::CLHEP PROPERTIES + IMPORTED_LOCATION_RELEASE "${CLHEP_LIBRARY_DLL}" + IMPORTED_IMPLIB "${CLHEP_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${CLHEP_INCLUDE_DIRS}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + ) + + # If we have both Debug and Release libraries + if( EXISTS "${CLHEP_LIBRARY_DEBUG_DLL}") + set_property( TARGET CLHEP::CLHEP APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( CLHEP::CLHEP PROPERTIES + IMPORTED_LOCATION_DEBUG "${CLHEP_LIBRARY_DEBUG_DLL}" + IMPORTED_IMPLIB_DEBUG "${CLHEP_LIBRARY_DEBUG}" ) + endif() + + else() + + # For all other environments (ones without dll libraries), create + # the imported library targets. + add_library( CLHEP::CLHEP UNKNOWN IMPORTED ) + set_target_properties( CLHEP::CLHEP PROPERTIES + IMPORTED_LOCATION "${CLHEP_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${CLHEP_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + ) + endif() +endif() diff --git a/cmake/Modules/FindHepMC.cmake b/cmake/Modules/FindHepMC.cmake index a311f15..6c5d8d3 100644 --- a/cmake/Modules/FindHepMC.cmake +++ b/cmake/Modules/FindHepMC.cmake @@ -1,218 +1,218 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. # This is a slightly modified version of FindGSL.cmake taken from cmake 3.7 #.rst: # FindHepMC # -------- # # Find the native HepMC includes and libraries. # # HepMC package is an object oriented, C++ event record for High Energy # Physics Monte Carlo generators and simulation. It is free software # under the GNU General Public License. # # Imported Targets # ^^^^^^^^^^^^^^^^ # # If HepMC is found, this module defines the following # :prop_tgt:`IMPORTED` target:: # # HepMC::HepMC - The main HepMC library. # # Result Variables # ^^^^^^^^^^^^^^^^ # # This module will set the following variables in your project:: # # HepMC_FOUND - True if HepMC found on the local system # HepMC_INCLUDE_DIRS - Location of HepMC header files. # HepMC_LIBRARIES - The HepMC libraries. # HepMC_VERSION - The version of the discovered HepMC install. # # Hints # ^^^^^ # # Set ``HepMC_ROOT_DIR`` to a directory that contains a HepMC installation. # # This script expects to find libraries at ``$HepMC_ROOT_DIR/lib`` and the HepMC # headers at ``$HepMC_ROOT_DIR/include/HepMC``. The library directory may # optionally provide Release and Debug folders. For Unix-like systems, this # script will use ``$HepMC_ROOT_DIR/bin/HepMC-config`` (if found) to aid in the # discovery HepMC. # # Cache Variables # ^^^^^^^^^^^^^^^ # # This module may set the following variables depending on platform and type # of HepMC installation discovered. These variables may optionally be set to # help this module find the correct files:: # # HepMC_CONFIG_EXECUTABLE - Location of the ``HepMC-config`` script (if any). # HepMC_LIBRARY - Location of the HepMC library. # HepMC_LIBRARY_DEBUG - Location of the debug HepMC library (if any). # # Include these modules to handle the QUIETLY and REQUIRED arguments. include(FindPackageHandleStandardArgs) #============================================================================= # If the user has provided ``HepMC_ROOT_DIR``, use it! Choose items found # at this location over system locations. if( EXISTS "$ENV{HepMC_ROOT_DIR}" ) file( TO_CMAKE_PATH "$ENV{HepMC_ROOT_DIR}" HepMC_ROOT_DIR ) set( HepMC_ROOT_DIR "${HepMC_ROOT_DIR}" CACHE PATH "Prefix for HepMC installation." ) endif() if( NOT EXISTS "${HepMC_ROOT_DIR}" ) set( HepMC_USE_PKGCONFIG ON ) endif() #============================================================================= # As a first try, use the PkgConfig module. This will work on many # *NIX systems. See :module:`findpkgconfig` # This will return ``HepMC_INCLUDEDIR`` and ``HepMC_LIBDIR`` used below. if( HepMC_USE_PKGCONFIG ) find_package(PkgConfig) pkg_check_modules( HepMC QUIET HepMC ) if( EXISTS "${HepMC_INCLUDEDIR}" ) get_filename_component( HepMC_ROOT_DIR "${HepMC_INCLUDEDIR}" DIRECTORY CACHE) endif() endif() #============================================================================= # Set HepMC_INCLUDE_DIRS and HepMC_LIBRARIES. If we skipped the PkgConfig step, try # to find the libraries at $HepMC_ROOT_DIR (if provided), in the directory # suggested by HepMC-config (if available), or in standard system # locations. These find_library and find_path calls will prefer custom # locations over standard locations (HINTS). If the requested file is found # neither at the HINTS location nor via HepMC-config, standard system locations # will be still be searched (/usr/lib64 (Redhat), lib/i386-linux-gnu (Debian)). # If we didn't use PkgConfig, try to find the version via HepMC-config if( NOT HepMC_VERSION ) find_program( HepMC_CONFIG_EXECUTABLE NAMES HepMC-config HINTS "${HepMC_ROOT_DIR}/bin" ) if( EXISTS "${HepMC_CONFIG_EXECUTABLE}" ) execute_process( COMMAND "${HepMC_CONFIG_EXECUTABLE}" --version OUTPUT_VARIABLE HepMC_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( COMMAND "${HepMC_CONFIG_EXECUTABLE}" --incdir OUTPUT_VARIABLE HepMC_CONFIG_INCLUDEDIR OUTPUT_STRIP_TRAILING_WHITESPACE ) execute_process( COMMAND "${HepMC_CONFIG_EXECUTABLE}" --libdir OUTPUT_VARIABLE HepMC_CONFIG_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE ) endif() endif() find_path( HepMC_INCLUDE_DIR - NAMES HepMC/HepMC.h HepMC/HepMCDefs.h + NAMES HepMC/HepMCDefs.h HINTS ${HepMC_ROOT_DIR}/include ${HepMC_INCLUDEDIR} ${HepMC_CONFIG_INCLUDEDIR} ) find_library( HepMC_LIBRARY NAMES HepMC HINTS ${HepMC_ROOT_DIR}/lib ${HepMC_LIBDIR} ${HepMC_CONFIG_LIBDIR} PATH_SUFFIXES Release Debug ) # Do we also have debug versions? find_library( HepMC_LIBRARY_DEBUG NAMES HepMC HINTS ${HepMC_ROOT_DIR}/lib ${HepMC_LIBDIR} ${HepMC_CONFIG_LIBDIR} PATH_SUFFIXES Debug ) set( HepMC_INCLUDE_DIRS ${HepMC_INCLUDE_DIR} ) set( HepMC_LIBRARIES ${HepMC_LIBRARY} ) if( NOT HepMC_VERSION ) if(IS_DIRECTORY ${HepMC_INCLUDE_DIR}) file(STRINGS "${HepMC_INCLUDE_DIR}/HepMC/HepMCDefs.h" _HepMC_DEFS) file(STRINGS "${HepMC_INCLUDE_DIR}/HepMC/Version.h" _HepMC_VERS) string( REGEX MATCH "#define *HEPMC_VERSION *\"[^\"]*\"" _HepMC_VERSION_STR "${_HepMC_DEFS} ${_HepMC_VERS}" ) string( REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" HepMC_VERSION ${_HepMC_VERSION_STR} ) endif() endif() if( HepMC_VERSION ) string(REPLACE "." ";" t_list ${HepMC_VERSION}) list(APPEND t_list 0 0) # add a buffer in case supversion not set list(GET t_list 0 HepMC_VERSION_MAJOR) list(GET t_list 1 HepMC_VERSION_MINOR) list(GET t_list 2 HepMC_VERSION_PATCH) endif() #============================================================================= # handle the QUIETLY and REQUIRED arguments and set HepMC_FOUND to TRUE if all # listed variables are TRUE find_package_handle_standard_args( HepMC FOUND_VAR HepMC_FOUND REQUIRED_VARS HepMC_INCLUDE_DIR HepMC_LIBRARY VERSION_VAR HepMC_VERSION ) mark_as_advanced( HepMC_ROOT_DIR HepMC_VERSION HepMC_LIBRARY HepMC_INCLUDE_DIR HepMC_LIBRARY_DEBUG HepMC_USE_PKGCONFIG HepMC_CONFIG ) #============================================================================= # Register imported libraries: # 1. If we can find a Windows .dll file (or if we can find both Debug and # Release libraries), we will set appropriate target properties for these. # 2. However, for most systems, we will only register the import location and # include directory. # Look for dlls, or Release and Debug libraries. if(WIN32) string( REPLACE ".lib" ".dll" HepMC_LIBRARY_DLL "${HepMC_LIBRARY}" ) string( REPLACE ".lib" ".dll" HepMC_LIBRARY_DEBUG_DLL "${HepMC_LIBRARY_DEBUG}" ) endif() if( HepMC_FOUND AND NOT TARGET HepMC::HepMC ) if( EXISTS "${HepMC_LIBRARY_DLL}") # Windows systems with dll libraries. add_library( HepMC::HepMC SHARED IMPORTED ) add_library( HepMC::HepMCcblas SHARED IMPORTED ) # Windows with dlls, but only Release libraries. set_target_properties( HepMC::HepMC PROPERTIES IMPORTED_LOCATION_RELEASE "${HepMC_LIBRARY_DLL}" IMPORTED_IMPLIB "${HepMC_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${HepMC_INCLUDE_DIRS}" IMPORTED_CONFIGURATIONS Release IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" ) # If we have both Debug and Release libraries if( EXISTS "${HepMC_LIBRARY_DEBUG_DLL}") set_property( TARGET HepMC::HepMC APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) set_target_properties( HepMC::HepMC PROPERTIES IMPORTED_LOCATION_DEBUG "${HepMC_LIBRARY_DEBUG_DLL}" IMPORTED_IMPLIB_DEBUG "${HepMC_LIBRARY_DEBUG}" ) endif() else() # For all other environments (ones without dll libraries), create # the imported library targets. add_library( HepMC::HepMC UNKNOWN IMPORTED ) set_target_properties( HepMC::HepMC PROPERTIES IMPORTED_LOCATION "${HepMC_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${HepMC_INCLUDE_DIRS}" IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" ) endif() endif() diff --git a/cmake/Modules/FindLHAPDF.cmake b/cmake/Modules/FindLHAPDF.cmake new file mode 100644 index 0000000..4df57a3 --- /dev/null +++ b/cmake/Modules/FindLHAPDF.cmake @@ -0,0 +1,217 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +# This is a slightly modified version of FindGSL.cmake taken from cmake 3.7 + +#.rst: +# FindLHAPDF +# -------- +# +# Find the native LHAPDF includes and libraries. +# +# LHAPDF package is an object oriented, C++ event record for High Energy +# Physics Monte Carlo generators and simulation. It is free software +# under the GNU General Public License. +# +# Imported Targets +# ^^^^^^^^^^^^^^^^ +# +# If LHAPDF is found, this module defines the following +# :prop_tgt:`IMPORTED` target:: +# +# LHAPDF::LHAPDF - The main LHAPDF library. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module will set the following variables in your project:: +# +# LHAPDF_FOUND - True if LHAPDF found on the local system +# LHAPDF_INCLUDE_DIRS - Location of LHAPDF header files. +# LHAPDF_LIBRARIES - The LHAPDF libraries. +# LHAPDF_VERSION - The version of the discovered LHAPDF install. +# +# Hints +# ^^^^^ +# +# Set ``LHAPDF_ROOT_DIR`` to a directory that contains a LHAPDF installation. +# +# This script expects to find libraries at ``$LHAPDF_ROOT_DIR/lib`` and the LHAPDF +# headers at ``$LHAPDF_ROOT_DIR/include/LHAPDF``. The library directory may +# optionally provide Release and Debug folders. For Unix-like systems, this +# script will use ``$LHAPDF_ROOT_DIR/bin/LHAPDF-config`` (if found) to aid in the +# discovery LHAPDF. +# +# Cache Variables +# ^^^^^^^^^^^^^^^ +# +# This module may set the following variables depending on platform and type +# of LHAPDF installation discovered. These variables may optionally be set to +# help this module find the correct files:: +# +# LHAPDF_CONFIG_EXECUTABLE - Location of the ``LHAPDF-config`` script (if any). +# LHAPDF_LIBRARY - Location of the LHAPDF library. +# LHAPDF_LIBRARY_DEBUG - Location of the debug LHAPDF library (if any). +# + +# Include these modules to handle the QUIETLY and REQUIRED arguments. +include(FindPackageHandleStandardArgs) + +#============================================================================= +# If the user has provided ``LHAPDF_ROOT_DIR``, use it! Choose items found +# at this location over system locations. +if( EXISTS "$ENV{LHAPDF_ROOT_DIR}" ) + file( TO_CMAKE_PATH "$ENV{LHAPDF_ROOT_DIR}" LHAPDF_ROOT_DIR ) + set( LHAPDF_ROOT_DIR "${LHAPDF_ROOT_DIR}" CACHE PATH "Prefix for LHAPDF installation." ) +endif() +if( NOT EXISTS "${LHAPDF_ROOT_DIR}" ) + set( LHAPDF_USE_PKGCONFIG ON ) +endif() + +#============================================================================= +# As a first try, use the PkgConfig module. This will work on many +# *NIX systems. See :module:`findpkgconfig` +# This will return ``LHAPDF_INCLUDEDIR`` and ``LHAPDF_LIBDIR`` used below. +if( LHAPDF_USE_PKGCONFIG ) + find_package(PkgConfig) + pkg_check_modules( LHAPDF QUIET LHAPDF ) + + if( EXISTS "${LHAPDF_INCLUDEDIR}" ) + get_filename_component( LHAPDF_ROOT_DIR "${LHAPDF_INCLUDEDIR}" DIRECTORY CACHE) + endif() +endif() + +#============================================================================= +# Set LHAPDF_INCLUDE_DIRS and LHAPDF_LIBRARIES. If we skipped the PkgConfig step, try +# to find the libraries at $LHAPDF_ROOT_DIR (if provided), in the directory +# suggested by LHAPDF-config (if available), or in standard system +# locations. These find_library and find_path calls will prefer custom +# locations over standard locations (HINTS). If the requested file is found +# neither at the HINTS location nor via LHAPDF-config, standard system locations +# will be still be searched (/usr/lib64 (Redhat), lib/i386-linux-gnu (Debian)). + +# If we didn't use PkgConfig, try to find the version via LHAPDF-config +if( NOT LHAPDF_VERSION ) + find_program( LHAPDF_CONFIG_EXECUTABLE + NAMES lhapdf-config + HINTS "${LHAPDF_ROOT_DIR}/bin" + ) + if( EXISTS "${LHAPDF_CONFIG_EXECUTABLE}" ) + execute_process( + COMMAND "${LHAPDF_CONFIG_EXECUTABLE}" --version + OUTPUT_VARIABLE LHAPDF_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE ) + execute_process( + COMMAND "${LHAPDF_CONFIG_EXECUTABLE}" --incdir + OUTPUT_VARIABLE LHAPDF_CONFIG_INCLUDEDIR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + execute_process( + COMMAND "${LHAPDF_CONFIG_EXECUTABLE}" --libdir + OUTPUT_VARIABLE LHAPDF_CONFIG_LIBDIR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + endif() +endif() +find_path( LHAPDF_INCLUDE_DIR + NAMES LHAPDF/LHAPDF.h LHAPDF/Version.h + HINTS ${LHAPDF_ROOT_DIR}/include ${LHAPDF_INCLUDEDIR} ${LHAPDF_CONFIG_INCLUDEDIR} +) +find_library( LHAPDF_LIBRARY + NAMES LHAPDF + HINTS ${LHAPDF_ROOT_DIR}/lib ${LHAPDF_LIBDIR} ${LHAPDF_CONFIG_LIBDIR} + PATH_SUFFIXES Release Debug +) +# Do we also have debug versions? +find_library( LHAPDF_LIBRARY_DEBUG + NAMES LHAPDF + HINTS ${LHAPDF_ROOT_DIR}/lib ${LHAPDF_LIBDIR} ${LHAPDF_CONFIG_LIBDIR} + PATH_SUFFIXES Debug +) +set( LHAPDF_INCLUDE_DIRS ${LHAPDF_INCLUDE_DIR} ) +set( LHAPDF_LIBRARIES ${LHAPDF_LIBRARY} ) + +if( NOT LHAPDF_VERSION ) + if(IS_DIRECTORY ${LHAPDF_INCLUDE_DIR}) + file(STRINGS "${LHAPDF_INCLUDE_DIR}/LHAPDF/Version.h" _LHAPDF_VERS) + string( + REGEX MATCH + "#define *LHAPDF_VERSION *\"[^\"]*\"" + _LHAPDF_VERSION_STR "${_LHAPDF_VERS}" + ) + string( + REGEX MATCH + "[0-9]*\\.[0-9]*\\.[0-9]*" + LHAPDF_VERSION ${_LHAPDF_VERSION_STR} + ) + endif() +endif() +if( LHAPDF_VERSION ) + string(REPLACE "." ";" t_list ${LHAPDF_VERSION}) + list(APPEND t_list 0 0) # add a buffer in case supversion not set + list(GET t_list 0 LHAPDF_VERSION_MAJOR) + list(GET t_list 1 LHAPDF_VERSION_MINOR) + list(GET t_list 2 LHAPDF_VERSION_PATCH) +endif() +#============================================================================= +# handle the QUIETLY and REQUIRED arguments and set LHAPDF_FOUND to TRUE if all +# listed variables are TRUE +find_package_handle_standard_args( LHAPDF + FOUND_VAR + LHAPDF_FOUND + REQUIRED_VARS + LHAPDF_INCLUDE_DIR + LHAPDF_LIBRARY + VERSION_VAR + LHAPDF_VERSION + ) + +mark_as_advanced( LHAPDF_ROOT_DIR LHAPDF_VERSION LHAPDF_LIBRARY LHAPDF_INCLUDE_DIR + LHAPDF_LIBRARY_DEBUG LHAPDF_USE_PKGCONFIG LHAPDF_CONFIG ) + +#============================================================================= +# Register imported libraries: +# 1. If we can find a Windows .dll file (or if we can find both Debug and +# Release libraries), we will set appropriate target properties for these. +# 2. However, for most systems, we will only register the import location and +# include directory. + +# Look for dlls, or Release and Debug libraries. +if(WIN32) + string( REPLACE ".lib" ".dll" LHAPDF_LIBRARY_DLL "${LHAPDF_LIBRARY}" ) + string( REPLACE ".lib" ".dll" LHAPDF_LIBRARY_DEBUG_DLL "${LHAPDF_LIBRARY_DEBUG}" ) +endif() + +if( LHAPDF_FOUND AND NOT TARGET LHAPDF::LHAPDF ) + if( EXISTS "${LHAPDF_LIBRARY_DLL}") + + # Windows systems with dll libraries. + add_library( LHAPDF::LHAPDF SHARED IMPORTED ) + add_library( LHAPDF::LHAPDFcblas SHARED IMPORTED ) + + # Windows with dlls, but only Release libraries. + set_target_properties( LHAPDF::LHAPDF PROPERTIES + IMPORTED_LOCATION_RELEASE "${LHAPDF_LIBRARY_DLL}" + IMPORTED_IMPLIB "${LHAPDF_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LHAPDF_INCLUDE_DIRS}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + ) + + # If we have both Debug and Release libraries + if( EXISTS "${LHAPDF_LIBRARY_DEBUG_DLL}") + set_property( TARGET LHAPDF::LHAPDF APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( LHAPDF::LHAPDF PROPERTIES + IMPORTED_LOCATION_DEBUG "${LHAPDF_LIBRARY_DEBUG_DLL}" + IMPORTED_IMPLIB_DEBUG "${LHAPDF_LIBRARY_DEBUG}" ) + endif() + + else() + + # For all other environments (ones without dll libraries), create + # the imported library targets. + add_library( LHAPDF::LHAPDF UNKNOWN IMPORTED ) + set_target_properties( LHAPDF::LHAPDF PROPERTIES + IMPORTED_LOCATION "${LHAPDF_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LHAPDF_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + ) + endif() +endif() diff --git a/cmake/Modules/Findclhep.cmake b/cmake/Modules/Findclhep.cmake deleted file mode 100644 index 6e4943a..0000000 --- a/cmake/Modules/Findclhep.cmake +++ /dev/null @@ -1,35 +0,0 @@ -include (FindPackageMessage) -include(FindPackageHandleStandardArgs) - -message (STATUS "Detecting clhep installation") -execute_process (COMMAND clhep-config --prefix - OUTPUT_VARIABLE clhep_PREFIX - ) -if (clhep_PREFIX) - string (REGEX REPLACE "\"\(.*\)\"[ \t\r\n]*$" "\\1" clhep_PREFIX ${clhep_PREFIX} ) - message (STATUS "clhep installation found: ${clhep_PREFIX}") - EXECUTE_PROCESS(COMMAND clhep-config --libs OUTPUT_VARIABLE - CLHEP_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND clhep-config --version OUTPUT_VARIABLE - clhep_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "CLHEP " "" clhep_VERSION ${clhep_VERSION}) - set (CLHEP_INCLUDE_PATH ${clhep_PREFIX}/include) - set (clhep_FOUND TRUE) -else (clhep_PREFIX) - set (clhep_FOUND FALSE) -endif (clhep_PREFIX) - -find_package_handle_standard_args(clhep - FOUND_VAR - clhep_FOUND - REQUIRED_VARS - CLHEP_INCLUDE_PATH - CLHEP_LIBRARIES - VERSION_VAR - clhep_VERSION - ) - -mark_as_advanced( - CLHEP_INCLUDE_PATH - CLHEP_LIBRARIES -) diff --git a/cmake/Modules/Findfastjet.cmake b/cmake/Modules/Findfastjet.cmake index a7d9073..ba03935 100644 --- a/cmake/Modules/Findfastjet.cmake +++ b/cmake/Modules/Findfastjet.cmake @@ -1,30 +1,216 @@ -include (FindPackageMessage) - -message (STATUS "Detecting FastJet installation") -execute_process (COMMAND fastjet-config --prefix - OUTPUT_VARIABLE fastjet_PREFIX - ) -if (fastjet_PREFIX) - string (STRIP ${fastjet_PREFIX} fastjet_PREFIX) - message (STATUS "FastJet installation found: ${fastjet_PREFIX}") - EXECUTE_PROCESS(COMMAND fastjet-config --libs OUTPUT_VARIABLE - FASTJET_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE) - # set (fastjet_LIBRARIES ${fastjet_LIBRARIES} ) - set (fastjet_INCLUDE_PATH ${fastjet_PREFIX}/include) - set (fastjet_FOUND TRUE) -else (fastjet_PREFIX) - set (fastjet_FOUND FALSE) -endif (fastjet_PREFIX) - -if (NOT fastjet_FOUND) - message(FATAL_ERROR "FastJet installation not found!") -endif (NOT fastjet_FOUND) - -mark_as_advanced( - fastjet_INCLUDE_PATH - fastjet_LIBRARIES +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +# This is a slightly modified version of FindGSL.cmake taken from cmake 3.7 + +#.rst: +# Findfastjet +# -------- +# +# Find the native fastjet includes and libraries. +# +# fastjet package is an object oriented, C++ event record for High Energy +# Physics Monte Carlo generators and simulation. It is free software +# under the GNU General Public License. +# +# Imported Targets +# ^^^^^^^^^^^^^^^^ +# +# If fastjet is found, this module defines the following +# :prop_tgt:`IMPORTED` target:: +# +# fastjet::fastjet - The main fastjet library. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module will set the following variables in your project:: +# +# fastjet_FOUND - True if fastjet found on the local system +# fastjet_INCLUDE_DIRS - Location of fastjet header files. +# fastjet_LIBRARIES - The fastjet libraries. +# fastjet_VERSION - The version of the discovered fastjet install. +# +# Hints +# ^^^^^ +# +# Set ``fastjet_ROOT_DIR`` to a directory that contains a fastjet installation. +# +# This script expects to find libraries at ``$fastjet_ROOT_DIR/lib`` and the fastjet +# headers at ``$fastjet_ROOT_DIR/include/fastjet``. The library directory may +# optionally provide Release and Debug folders. For Unix-like systems, this +# script will use ``$fastjet_ROOT_DIR/bin/fastjet-config`` (if found) to aid in the +# discovery fastjet. +# +# Cache Variables +# ^^^^^^^^^^^^^^^ +# +# This module may set the following variables depending on platform and type +# of fastjet installation discovered. These variables may optionally be set to +# help this module find the correct files:: +# +# fastjet_CONFIG_EXECUTABLE - Location of the ``fastjet-config`` script (if any). +# fastjet_LIBRARY - Location of the fastjet library. +# fastjet_LIBRARY_DEBUG - Location of the debug fastjet library (if any). +# + +# Include these modules to handle the QUIETLY and REQUIRED arguments. +include(FindPackageHandleStandardArgs) + +#============================================================================= +# If the user has provided ``fastjet_ROOT_DIR``, use it! Choose items found +# at this location over system locations. +if( EXISTS "$ENV{fastjet_ROOT_DIR}" ) + file( TO_CMAKE_PATH "$ENV{fastjet_ROOT_DIR}" fastjet_ROOT_DIR ) + set( fastjet_ROOT_DIR "${fastjet_ROOT_DIR}" CACHE PATH "Prefix for fastjet installation." ) +endif() +if( NOT EXISTS "${fastjet_ROOT_DIR}" ) + set( fastjet_USE_PKGCONFIG ON ) +endif() + +#============================================================================= +# As a first try, use the PkgConfig module. This will work on many +# *NIX systems. See :module:`findpkgconfig` +# This will return ``fastjet_INCLUDEDIR`` and ``fastjet_LIBDIR`` used below. +if( fastjet_USE_PKGCONFIG ) + find_package(PkgConfig) + pkg_check_modules( fastjet QUIET fastjet ) + + if( EXISTS "${fastjet_INCLUDEDIR}" ) + get_filename_component( fastjet_ROOT_DIR "${fastjet_INCLUDEDIR}" DIRECTORY CACHE) + endif() +endif() + +#============================================================================= +# Set fastjet_INCLUDE_DIRS and fastjet_LIBRARIES. If we skipped the PkgConfig step, try +# to find the libraries at $fastjet_ROOT_DIR (if provided), in the directory +# suggested by fastjet-config (if available), or in standard system +# locations. These find_library and find_path calls will prefer custom +# locations over standard locations (HINTS). If the requested file is found +# neither at the HINTS location nor via fastjet-config, standard system locations +# will be still be searched (/usr/lib64 (Redhat), lib/i386-linux-gnu (Debian)). + +# If we didn't use PkgConfig, try to find the version via fastjet-config +if( NOT fastjet_VERSION ) + find_program( fastjet_CONFIG_EXECUTABLE + NAMES fastjet-config + HINTS "${fastjet_ROOT_DIR}/bin" + ) + if( EXISTS "${fastjet_CONFIG_EXECUTABLE}" ) + execute_process( + COMMAND "${fastjet_CONFIG_EXECUTABLE}" --version + OUTPUT_VARIABLE fastjet_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE ) + execute_process( + COMMAND "${fastjet_CONFIG_EXECUTABLE}" --prefix + OUTPUT_VARIABLE fastjet_CONFIG_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + set(fastjet_CONFIG_INCLUDEDIR ${fastjet_CONFIG_ROOT_DIR}/include) + set(fastjet_CONFIG_LIBDIR ${fastjet_CONFIG_ROOT_DIR}/lib) + endif() +endif() +find_path( fastjet_INCLUDE_DIR + NAMES fastjet/config_auto.h fastjet/PseudoJet.hh + HINTS ${fastjet_ROOT_DIR}/include ${fastjet_INCLUDEDIR} ${fastjet_CONFIG_INCLUDEDIR} +) +find_library( fastjet_LIBRARY + NAMES fastjet + HINTS ${fastjet_ROOT_DIR}/lib ${fastjet_LIBDIR} ${fastjet_CONFIG_LIBDIR} + PATH_SUFFIXES Release Debug ) +# Do we also have debug versions? +find_library( fastjet_LIBRARY_DEBUG + NAMES fastjet + HINTS ${fastjet_ROOT_DIR}/lib ${fastjet_LIBDIR} ${fastjet_CONFIG_LIBDIR} + PATH_SUFFIXES Debug +) +set( fastjet_INCLUDE_DIRS ${fastjet_INCLUDE_DIR} ) +set( fastjet_LIBRARIES ${fastjet_LIBRARY} ) + +if( NOT fastjet_VERSION ) + if(IS_DIRECTORY ${fastjet_INCLUDE_DIR}) + file(STRINGS "${fastjet_INCLUDE_DIR}/fastjet/config_auto.h" _fastjet_DEFS) + file(STRINGS "${fastjet_INCLUDE_DIR}/fastjet/version.hh" _fastjet_VERS) + string( + REGEX MATCH + "#define *FASTJET_VERSION *\"[^\"]*\"" + _fastjet_VERSION_STR "${_fastjet_VERS} ${_fastjet_DEFS}" + ) + string( + REGEX MATCH + "[0-9]*\\.[0-9]*\\.[0-9]*" + fastjet_VERSION ${_fastjet_VERSION_STR} + ) + endif() +endif() +if( fastjet_VERSION ) + string(REPLACE "." ";" t_list ${fastjet_VERSION}) + list(APPEND t_list 0 0) # add a buffer in case supversion not set + list(GET t_list 0 fastjet_VERSION_MAJOR) + list(GET t_list 1 fastjet_VERSION_MINOR) + list(GET t_list 2 fastjet_VERSION_PATCH) +endif() +#============================================================================= +# handle the QUIETLY and REQUIRED arguments and set fastjet_FOUND to TRUE if all +# listed variables are TRUE +find_package_handle_standard_args( fastjet + FOUND_VAR + fastjet_FOUND + REQUIRED_VARS + fastjet_INCLUDE_DIR + fastjet_LIBRARY + VERSION_VAR + fastjet_VERSION + ) + +mark_as_advanced( fastjet_ROOT_DIR fastjet_VERSION fastjet_LIBRARY fastjet_INCLUDE_DIR + fastjet_LIBRARY_DEBUG fastjet_USE_PKGCONFIG fastjet_CONFIG ) + +#============================================================================= +# Register imported libraries: +# 1. If we can find a Windows .dll file (or if we can find both Debug and +# Release libraries), we will set appropriate target properties for these. +# 2. However, for most systems, we will only register the import location and +# include directory. + +# Look for dlls, or Release and Debug libraries. +if(WIN32) + string( REPLACE ".lib" ".dll" fastjet_LIBRARY_DLL "${fastjet_LIBRARY}" ) + string( REPLACE ".lib" ".dll" fastjet_LIBRARY_DEBUG_DLL "${fastjet_LIBRARY_DEBUG}" ) +endif() + +if( fastjet_FOUND AND NOT TARGET fastjet::fastjet ) + if( EXISTS "${fastjet_LIBRARY_DLL}") + + # Windows systems with dll libraries. + add_library( fastjet::fastjet SHARED IMPORTED ) + add_library( fastjet::fastjetcblas SHARED IMPORTED ) + # Windows with dlls, but only Release libraries. + set_target_properties( fastjet::fastjet PROPERTIES + IMPORTED_LOCATION_RELEASE "${fastjet_LIBRARY_DLL}" + IMPORTED_IMPLIB "${fastjet_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${fastjet_INCLUDE_DIRS}" + IMPORTED_CONFIGURATIONS Release + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + ) + # If we have both Debug and Release libraries + if( EXISTS "${fastjet_LIBRARY_DEBUG_DLL}") + set_property( TARGET fastjet::fastjet APPEND PROPERTY IMPORTED_CONFIGURATIONS Debug ) + set_target_properties( fastjet::fastjet PROPERTIES + IMPORTED_LOCATION_DEBUG "${fastjet_LIBRARY_DEBUG_DLL}" + IMPORTED_IMPLIB_DEBUG "${fastjet_LIBRARY_DEBUG}" ) + endif() + else() + # For all other environments (ones without dll libraries), create + # the imported library targets. + add_library( fastjet::fastjet UNKNOWN IMPORTED ) + set_target_properties( fastjet::fastjet PROPERTIES + IMPORTED_LOCATION "${fastjet_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${fastjet_INCLUDE_DIRS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + ) + endif() +endif() diff --git a/cmake/Modules/Findlhapdf.cmake b/cmake/Modules/Findlhapdf.cmake deleted file mode 100644 index c8eb556..0000000 --- a/cmake/Modules/Findlhapdf.cmake +++ /dev/null @@ -1,28 +0,0 @@ -include (FindPackageMessage) - -message (STATUS "Detecting lhapdf installation") -execute_process (COMMAND lhapdf-config --prefix - OUTPUT_VARIABLE lhapdf_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE - ) -if (lhapdf_PREFIX) - string (STRIP ${lhapdf_PREFIX} lhapdf_PREFIX) - message (STATUS "lhapdf installation found: ${lhapdf_PREFIX}") - EXECUTE_PROCESS(COMMAND lhapdf-config --ldflags OUTPUT_VARIABLE - LHAPDF_LIBRARIES OUTPUT_STRIP_TRAILING_WHITESPACE) - # set (lhapdf_LIBRARIES ${lhapdf_LIBRARIES} ) - set (lhapdf_INCLUDE_PATH ${lhapdf_PREFIX}/include) - set (lhapdf_FOUND TRUE) -else (lhapdf_PREFIX) - set (lhapdf_FOUND FALSE) -endif (lhapdf_PREFIX) - -if (NOT lhapdf_FOUND) - message(FATAL_ERROR "lhapdf installation not found!") -endif (NOT lhapdf_FOUND) - -mark_as_advanced( - lhapdf_INCLUDE_PATH - lhapdf_LIBRARIES -) - - diff --git a/cmake/Templates/hej-config.cmake.in b/cmake/Templates/hej-config.cmake.in index a1a89e1..9c98a0e 100644 --- a/cmake/Templates/hej-config.cmake.in +++ b/cmake/Templates/hej-config.cmake.in @@ -1,12 +1,12 @@ @PACKAGE_INIT@ # - Config file for the HEJ package # It defines the following variables # HEJ_INCLUDE_DIR - include directory # HEJ_LIBRARIES - libraries to link against -set_and_check(HEJ_INCLUDE_DIR "@INSTALL_INCLUDE_DIR_BASE@") +set_and_check(HEJ_INCLUDE_DIR @PACKAGE_INSTALL_INCLUDE_DIR_BASE@) find_library(HEJ_LIB NAMES HEJ HINTS @PACKAGE_INSTALL_LIB_DIR@) set(HEJ_LIBRARIES ${HEJ_LIB}) diff --git a/doc/sphinx/conf.py b/doc/sphinx/conf.py index 2b87061..a9d958d 100644 --- a/doc/sphinx/conf.py +++ b/doc/sphinx/conf.py @@ -1,175 +1,175 @@ # -*- coding: utf-8 -*- # # HEJ 2 documentation build configuration file, created by # sphinx-quickstart on Fri Sep 15 16:13:57 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = ['sphinx.ext.mathjax', 'sphinx.ext.githubpages'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = '.rst' # The master toctree document. master_doc = 'index' # General information about the project. project = u'HEJ 2' copyright = u'2017, Jeppe Andersen, Tuomas Hapola, Marian Heil, Andreas Maier, Jennifer Smillie' author = u'Jeppe Andersen, Tuomas Hapola, Marian Heil, Andreas Maier, Jennifer Smillie' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = u'2.0' # The full version, including alpha/beta/rc tags. -release = u'2.0.3' +release = u'2.0.4' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] highlight_language = 'C++' # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. html_theme_options = { 'body_text': '#000000', 'narrow_sidebar_fg': '#000000', 'sidebar_header': '#000000', 'sidebar_link': '#000000', 'sidebar_text': '#000000' } # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ['_static'] # Custom sidebar templates, must be a dictionary that maps document names # to template names. # # This is required for the alabaster theme # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars html_sidebars = { '**': [ 'about.html', 'navigation.html', 'relations.html', # needs 'show_related': True theme option to display 'searchbox.html', 'donate.html', ] } # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. htmlhelp_basename = 'HEJ2doc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'HEJ2.tex', u'HEJ 2 Documentation', u'Jeppe Andersen, Tuomas Hapola, Marian Heil, Andreas Maier, Jennifer Smillie', 'manual'), ] # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ (master_doc, 'hej2', u'HEJ 2 Documentation', [author], 1) ] # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ (master_doc, 'HEJ2', u'HEJ 2 Documentation', author, 'HEJ2', 'One line description of project.', 'Miscellaneous'), ] diff --git a/doc/sphinx/installation.rst b/doc/sphinx/installation.rst index 2d2b755..79398c5 100644 --- a/doc/sphinx/installation.rst +++ b/doc/sphinx/installation.rst @@ -1,78 +1,84 @@ .. _Installation: Installation ============ Download -------- A tar archive of the HEJ 2 source code can be downloaded and decompressed with the command:: curl https://hej.web.cern.ch/HEJ/downloads/HEJ_2.0.tar.gz | tar -xz To obtain the latest stable HEJ version, `HEJ_2.0.tar.gz` should be replaced by `HEJ.tar.gz`. Alternatively, the HEJ source code can be obtained by installing the `git version control system `_. and running:: git clone https://phab.hepforge.org/source/hej.git We also provide a `Docker image `_ containing a HEJ 2 installation on. This image can be pulled with:: docker pull hejdock/hej When using the Docker image the remaining installation steps can be skipped. Prerequisites ------------- Before installing HEJ 2, you need the following programs and libraries: - `CMake `_ version 3.1 - A compiler supporting the C++14 standard, for example `gcc `_ 5 or later - `FastJet `_ - `CLHEP `_ - `LHAPDF `_ - The `IOStreams` and `uBLAS` `boost `_ libraries - `yaml-cpp `_ If you want to include finite top mass corrections in Higgs boson + jets production, you additionally need version 2 of the `QCDLoop `_ library. HEJ 2 supports versions 2 and 3 of `HepMC `_ if it is -installed, but does not require it. +installed, but does not require it. Additional HEJ 2 can be interfaced to +`rivet `_, which requires HepMC version 2. Compilation ----------- To compile and install HEJ 2 run:: cmake source/directory -DCMAKE_INSTALL_PREFIX=target/directory make install :file:`source/directory` is the directory containing the file :file:`CMakeLists.txt`. If you omit :code:`-DCMAKE_INSTALL_PREFIX=target/directory` HEJ 2 will be installed to some default location. In case some of the aforementioned prerequisites are not found by :code:`cmake` you can give a hint by adding an additional argument :code:`-Dlibname_ROOT_DIR=/directory/with/library`, where :code:`libname` should be replaced by the name of the library in question. +To not include specific packages one can add +:code:`-DEXCLUDE_packagename=TRUE` to :code:`cmake`, e.g. by +setting :code:`-DEXCLUDE_rivet=TRUE` HEJ 2 will not be interfaced +to `rivet` even if rivet is available on the system. + Testing ------- To test your installation, download the NNPDF 2.3 PDF set with:: lhapdf install NNPDF23_nlo_as_0119 and run:: make test diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e54b15..0b3005c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,19 +1,19 @@ file(GLOB src_files *.cc) add_library(hejlib SHARED ${src_files}) set_target_properties(hejlib PROPERTIES OUTPUT_NAME "HEJ") set(libraries ${CMAKE_DL_LIBS} ${LHAPDF_LIBRARIES} ${CLHEP_LIBRARIES} - ${FASTJET_LIBRARIES} ${Boost_LIBRARIES} ${YAML_CPP_LIBRARIES} yaml-cpp) + ${fastjet_LIBRARIES} ${Boost_LIBRARIES} ${YAML_CPP_LIBRARIES} yaml-cpp) if(${QCDloop_FOUND}) list(APPEND libraries ${QCDloop_LIBRARIES} quadmath) endif() if(${HepMC_FOUND}) list(APPEND libraries ${HepMC_LIBRARIES}) if(${rivet_FOUND}) list(APPEND libraries ${rivet_LIBRARIES}) endif() endif() target_link_libraries(hejlib ${libraries}) install(TARGETS hejlib DESTINATION ${INSTALL_LIB_DIR}) diff --git a/src/HepMCInterface.cc b/src/HepMCInterface.cc index a50c8f8..f83ece6 100644 --- a/src/HepMCInterface.cc +++ b/src/HepMCInterface.cc @@ -1,177 +1,177 @@ /** * \authors Jeppe Andersen, Tuomas Hapola, Marian Heil, Andreas Maier, Jennifer Smillie * \date 2019 * \copyright GPLv2 or later */ #include "HEJ/HepMCInterface.hh" #include "HEJ/exceptions.hh" #ifdef HEJ_BUILD_WITH_HepMC_VERSION #include #include #include "HEJ/Event.hh" #include "HEJ/Particle.hh" #include "HepMC/GenCrossSection.h" #include "HepMC/GenEvent.h" #include "HepMC/GenParticle.h" #include "HepMC/GenVertex.h" namespace HEJ{ namespace { HepMC::FourVector to_FourVector(Particle const & sp){ return {sp.px(), sp.py(), sp.pz(), sp.E()}; } - constexpr int status_in = -1; - constexpr int status_decayed = 3; + constexpr int status_in = 11; + constexpr int status_decayed = 2; constexpr int status_out = 1; template auto make_ptr(Args&&... args){ #if HEJ_BUILD_WITH_HepMC_VERSION >= 3 return HepMC::make_shared(std::forward(args)...); #else return new HepMCClass(std::forward(args)...); #endif } } // namespace anonymous HepMCInterface::HepMCInterface(): event_count_(0.), tot_weight_(0.), tot_weight2_(0.) {} HepMC::GenCrossSection HepMCInterface::cross_section() const { HepMC::GenCrossSection xs; #if HEJ_BUILD_WITH_HepMC_VERSION >= 3 xs.set_cross_section(tot_weight_, sqrt(tot_weight2_), event_count_); /// @TODO add number of attempted events #else // HepMC 2 xs.set_cross_section(tot_weight_, sqrt(tot_weight2_)); #endif return xs; } HepMC::GenEvent HepMCInterface::init_kinematics(Event const & event) { HepMC::GenEvent out_ev{HepMC::Units::GEV, HepMC::Units::MM}; auto vx = make_ptr(); for(auto const & in: event.incoming()){ vx->add_particle_in( make_ptr( to_FourVector(in), static_cast(in.type), status_in ) ); } for(size_t i=0; i < event.outgoing().size(); ++i){ auto const & out = event.outgoing()[i]; auto particle = make_ptr( to_FourVector(out), static_cast(out.type), status_out ); const int status = event.decays().count(i)?status_decayed:status_out; particle->set_status(status); if( status == status_decayed){ auto vx_decay = make_ptr(); vx_decay->add_particle_in(particle); for( auto const & out: event.decays().at(i)){ vx_decay->add_particle_out( make_ptr( to_FourVector(out), static_cast(out.type), status_out ) ); } out_ev.add_vertex(vx_decay); } vx->add_particle_out(particle); } out_ev.add_vertex(vx); return out_ev; } void HepMCInterface::set_central(HepMC::GenEvent & out_ev, Event const & event, ssize_t const weight_index ) { EventParameters event_param; if(weight_index < 0) event_param = event.central(); else if ( (size_t) weight_index < event.variations().size()) event_param = event.variations(weight_index); else throw std::invalid_argument{ "HepMCInterface tried to access a weight outside of the variation range." }; const double wt = event_param.weight; tot_weight_ += wt; tot_weight2_ += wt * wt; if(out_ev.weights().size() == 0){ out_ev.weights().push_back(wt); } else { // central always on first out_ev.weights()[0] = wt; } #if HEJ_BUILD_WITH_HepMC_VERSION >= 3 out_ev.set_cross_section( HepMC::make_shared(cross_section()) ); #else // HepMC 2 out_ev.set_cross_section( cross_section() ); out_ev.set_signal_process_id(event.type()+1); // "+1": conistent with lhe out_ev.set_event_scale(event_param.mur); #endif ++event_count_; out_ev.set_event_number(event_count_); /// @TODO add alphaQCD (need function) and alphaQED /// @TODO output pdf (currently not avaiable from event alone) } void HepMCInterface::add_variation(HepMC::GenEvent & out_ev, std::vector const & varis ) { for(auto const & var: varis){ out_ev.weights().push_back(var.weight); } /// @TODO add name list for weights } HepMC::GenEvent HepMCInterface::operator()(Event const & event, ssize_t const weight_index ) { HepMC::GenEvent out_ev(init_kinematics(event)); set_central(out_ev, event, weight_index); add_variation(out_ev, event.variations()); return out_ev; } } #else // no HepMC => empty class namespace HepMC { class GenEvent {}; class GenCrossSection {}; } namespace HEJ{ HepMCInterface::HepMCInterface(){ throw std::invalid_argument( "Failed to create HepMCInterface: " "HEJ 2 was built without HepMC support" ); } HepMC::GenEvent HepMCInterface::operator()(Event const &, ssize_t) {return HepMC::GenEvent();} HepMC::GenEvent HepMCInterface::init_kinematics(Event const &) {return HepMC::GenEvent();} void HepMCInterface::add_variation(HepMC::GenEvent &, std::vector const &){} void HepMCInterface::set_central(HepMC::GenEvent &, Event const &, ssize_t) {} HepMC::GenCrossSection HepMCInterface::cross_section() const {return HepMC::GenCrossSection();} } #endif