diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b916b9d --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Lines beginning with a '#' are comments +# Text Editor Temp Files +*~ +*.swp + +# Mac Filesystem +.DS_Store? + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Results of the pre-CMake build system +config.mk +lib +tmp +tmp_ext diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c1a36b9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,93 @@ +# Top level CMakeLists.txt for EvtGen + +# Enforce an out-of-source build. +# Should be the first action in the top level CMakeLists.txt +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(STATUS "EvtGen requires an out-of-source build.") + message(STATUS "Please remove the following files from ${CMAKE_BINARY_DIR}:") + message(STATUS " CMakeCache.txt") + message(STATUS " CMakeFiles") + message(STATUS "Once these files are removed, create a separate directory") + message(STATUS "and run CMake from there, pointing it to:") + message(STATUS " ${CMAKE_SOURCE_DIR}") + message(FATAL_ERROR "in-source build detected") +endif() + +# Also require a minimum version of CMake +cmake_minimum_required(VERSION 3.8.0) + +# Project setup +if(${CMAKE_VERSION} VERSION_LESS 3.9.0) + project(EvtGen + VERSION 2.0.0 + ) +elseif(${CMAKE_VERSION} VERSION_LESS 3.12.0) + project(EvtGen + VERSION 2.0.0 + DESCRIPTION "Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons." + ) +else() + project(EvtGen + VERSION 2.0.0 + DESCRIPTION "Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons." + HOMEPAGE_URL "https://evtgen.hepforge.org" + ) +endif() + +# Prepend this project's custom module path(s) to CMAKE_MODULE_PATH +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH}) +# Include needed modules to perform any custom setup +# Install paths +include(InstallPaths) +# Compilation/linking flags and related settings +include(CompilerFlags) +# EvtGen external dependencies +option(EVTGEN_PYTHIA "Enable/disable linking with Pythia8" OFF) +option(EVTGEN_PHOTOS "Enable/disable linking with Photos++" OFF) +option(EVTGEN_TAUOLA "Enable/disable linking with Tauola++" OFF) +message(STATUS "EvtGen: Linking with Pythia8 ${EVTGEN_PYTHIA}") +message(STATUS "EvtGen: Linking with Photos++ ${EVTGEN_PHOTOS}") +message(STATUS "EvtGen: Linking with Tauola++ ${EVTGEN_TAUOLA}") +include(ExternalDependencies) + +# Now build the library +add_subdirectory(src) + +# Copy the particle property and decay tables +configure_file(DECAY.DEC ${CMAKE_CURRENT_BINARY_DIR}/DECAY.DEC COPYONLY) +configure_file(DECAY.XML ${CMAKE_CURRENT_BINARY_DIR}/DECAY.XML COPYONLY) +configure_file(evt.pdl ${CMAKE_CURRENT_BINARY_DIR}/evt.pdl COPYONLY) + +# Build the executables in the test and validation directories +add_subdirectory(test) +add_subdirectory(validation) + +# Install the include directories +install(DIRECTORY EvtGen DESTINATION ${CMAKE_INSTALL_PREFIX}) +install(DIRECTORY EvtGenBase DESTINATION ${CMAKE_INSTALL_PREFIX}) +install(DIRECTORY EvtGenExternal DESTINATION ${CMAKE_INSTALL_PREFIX}) +install(DIRECTORY EvtGenModels DESTINATION ${CMAKE_INSTALL_PREFIX}) + +# Install the particle properties and decay tables +install(FILES DECAY.DEC DECAY.XML evt.pdl DESTINATION ${CMAKE_INSTALL_PREFIX}) + +# Generate CMake config files, which can be used by other projects +include(CMakePackageConfigHelpers) + +set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) +set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + +configure_package_config_file(cmake/Templates/EvtGenConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfig.cmake + INSTALL_DESTINATION cmake + PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR + ) + +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfigVersion.cmake + COMPATIBILITY AnyNewerVersion + ) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/EvtGenConfigVersion.cmake + DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake + ) diff --git a/cmake/Modules/CompilerFlags.cmake b/cmake/Modules/CompilerFlags.cmake new file mode 100644 index 0000000..e3fa0ad --- /dev/null +++ b/cmake/Modules/CompilerFlags.cmake @@ -0,0 +1,52 @@ + +# Set the build type (if not already specified) +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "EvtGen: Setting build type to 'Release' as none was specified") + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Release, MinSizeRel, Debug, RelWithDebInfo" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +elseif(CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "EvtGen: Build type '${CMAKE_BUILD_TYPE}'") +endif() + +# Set the warning/optimise/debug flags for each build type +if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" ) + message(STATUS "EvtGen: Customising warning/optimise/debug flags for each build type") + + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Woverloaded-virtual") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") + + if( ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" ) + set(CMAKE_CXX_FLAGS_DEBUG "-Og -g3") + set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g3") + elseif( ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" ) + set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") + set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") + set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") + endif() +else() + message(STATUS "EvtGen: No customisation of warning/optimise/debug flags implemented for compiler: ${CMAKE_CXX_COMPILER_ID}") +endif() + +# Control verbosity of the build +set(CMAKE_VERBOSE_MAKEFILE OFF) + +# C++ standard settings +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Special linker flags for MacOSX +if (APPLE) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -single_module -undefined dynamic_lookup") +endif() + +# RPATH handling +set(CMAKE_MACOSX_RPATH TRUE) +set(CMAKE_SKIP_BUILD_RPATH FALSE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + diff --git a/cmake/Modules/ExternalDependencies.cmake b/cmake/Modules/ExternalDependencies.cmake new file mode 100644 index 0000000..9f28593 --- /dev/null +++ b/cmake/Modules/ExternalDependencies.cmake @@ -0,0 +1,16 @@ + +set(HEPMC2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/HepMC" CACHE STRING "Location of HepMC 2 installation") +set(PYTHIA8_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/pythia$ENV{PYTHIAVER}" CACHE STRING "Location of Pythia8 installation") +set(PHOTOSPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/PHOTOS" CACHE STRING "Location of Photos++ installation") +set(TAUOLAPP_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../external/TAUOLA" CACHE STRING "Location of Tauola++ installation") + +find_package(HepMC2 REQUIRED) +if(${EVTGEN_PYTHIA}) + find_package(Pythia8 REQUIRED) +endif() +if(${EVTGEN_PHOTOS}) + find_package(Photos++ REQUIRED) +endif() +if(${EVTGEN_TAUOLA}) + find_package(Tauola++ REQUIRED) +endif() diff --git a/cmake/Modules/FindHepMC2.cmake b/cmake/Modules/FindHepMC2.cmake new file mode 100644 index 0000000..50cbfcc --- /dev/null +++ b/cmake/Modules/FindHepMC2.cmake @@ -0,0 +1,42 @@ +# - Locate HepMC library +# in a directory defined via HEPMC2_ROOT_DIR or HEPMC2_DIR environment variable +# Defines: +# +# HEPMC2_FOUND +# HEPMC2_INCLUDE_DIR +# HEPMC2_INCLUDE_DIRS (not cached) +# HEPMC2_LIBRARIES +# HEPMC2_FIO_LIBRARIES +set(TEST_HEPMC2_ROOT_DIR "" ${HEPMC2_ROOT_DIR}) +IF(TEST_HEPMC2_ROOT_DIR STREQUAL "") +IF(DEFINED ENV{HEPMC2_ROOT_DIR}) +set(HEPMC2_ROOT_DIR $ENV{HEPMC2_ROOT_DIR}) +else() +set(HEPMC2_ROOT_DIR "/usr") +endif() +endif() + +find_path(HEPMC2_INCLUDE_DIR HepMC/GenEvent.h + HINTS $ENV{HEPMC2_ROOT_DIR}/include ${HEPMC2_ROOT_DIR}/include + $ENV{HEPMC2_DIR}/include ${HEPMC2_DIR}/include) + +find_library(HEPMC2_LIBRARIES NAMES HepMC + HINTS $ENV{HEPMC2_ROOT_DIR}/lib ${HEPMC2_ROOT_DIR}/lib + HINTS $ENV{HEPMC2_DIR}/lib ${HEPMC2_DIR}/lib + HINTS $ENV{HEPMC2_ROOT_DIR}/lib64 ${HEPMC2_ROOT_DIR}/lib64 + HINTS $ENV{HEPMC2_DIR}/lib64 ${HEPMC2_DIR}/lib64 + ) + +get_filename_component(HEPMC2_LIBRARY_DIR ${HEPMC2_LIBRARIES} PATH) +set(HEPMC2_FIO_LIBRARIES "-L${HEPMC2_LIBRARY_DIR} -lHepMCfio") + +set(HEPMC2_INCLUDE_DIRS ${HEPMC2_INCLUDE_DIR}) + +# handle the QUIETLY and REQUIRED arguments and set HEPMC2_FOUND to TRUE if +# all listed variables are TRUE + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(HepMC2 FOUND_VAR HEPMC2_FOUND REQUIRED_VARS HEPMC2_INCLUDE_DIR HEPMC2_LIBRARIES) + +mark_as_advanced(HEPMC2_FOUND HEPMC2_INCLUDE_DIRS HEPMC2_LIBRARIES) diff --git a/cmake/Modules/FindPhotos++.cmake b/cmake/Modules/FindPhotos++.cmake new file mode 100644 index 0000000..3cb454a --- /dev/null +++ b/cmake/Modules/FindPhotos++.cmake @@ -0,0 +1,50 @@ +# - Try to find Photos++ +# Defines: +# +# PHOTOS++_FOUND +# PHOTOS++_INCLUDE_DIR +# PHOTOS++_INCLUDE_DIRS (not cached) +# PHOTOS++__LIBRARY +# PHOTOS++__FOUND +# PHOTOS++_LIBRARIES (not cached) +# PHOTOS++_LIBRARY_DIRS (not cached) + +# Enforce a minimal list if none is explicitly requested +if(NOT PHOTOS++_FIND_COMPONENTS) + set(PHOTOS++_FIND_COMPONENTS pp ppHepMC) +endif() + +foreach(component ${PHOTOS++_FIND_COMPONENTS}) + find_library(PHOTOS++_${component}_LIBRARY NAMES Photos${component} + HINTS ${PHOTOS++_ROOT_DIR}/lib + $ENV{PHOTOSPP_ROOT_DIR}/lib + ${PHOTOSPP_ROOT_DIR}/lib) + if (PHOTOS++_${component}_LIBRARY) + set(PHOTOS++_${component}_FOUND 1) + list(APPEND PHOTOS++_LIBRARIES ${PHOTOS++_${component}_LIBRARY}) + + get_filename_component(libdir ${PHOTOS++_${component}_LIBRARY} PATH) + list(APPEND PHOTOS++_LIBRARY_DIRS ${libdir}) + else() + set(PHOTOS++_${component}_FOUND 0) + endif() + mark_as_advanced(PHOTOS++_${component}_LIBRARY) +endforeach() + +if(PHOTOS++_LIBRARY_DIRS) + list(REMOVE_DUPLICATES PHOTOS++_LIBRARY_DIRS) +endif() + +find_path(PHOTOS++_INCLUDE_DIR Photos/Photos.h + HINTS ${PHOTOS++_ROOT_DIR}/include + $ENV{PHOTOSPP_ROOT_DIR}/include + ${PHOTOSPP_ROOT_DIR}/include) +set(PHOTOS++_INCLUDE_DIRS ${PHOTOS++_INCLUDE_DIR}) +mark_as_advanced(PHOTOS++_INCLUDE_DIR) + +# handle the QUIETLY and REQUIRED arguments and set PHOTOS++_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Photos++ DEFAULT_MSG PHOTOS++_INCLUDE_DIR PHOTOS++_LIBRARIES) + +mark_as_advanced(PHOTOS++_FOUND) diff --git a/cmake/Modules/FindPythia8.cmake b/cmake/Modules/FindPythia8.cmake new file mode 100644 index 0000000..83123bc --- /dev/null +++ b/cmake/Modules/FindPythia8.cmake @@ -0,0 +1,63 @@ +# - Try to find Pythia8 +# Defines: +# +# PYTHIA8_FOUND +# PYTHIA8_VERSION +# PYTHIA8_INCLUDE_DIR +# PYTHIA8_INCLUDE_DIRS (not cached) +# PYTHIA8_LIBRARY +# PYTHIA8_LIBRARIES (not cached) +# PYTHIA8_LIBRARY_DIRS (not cached) + +find_path(PYTHIA8_INCLUDE_DIR Pythia.h Pythia8/Pythia.h + HINTS $ENV{PYTHIA8_ROOT_DIR}/include ${PYTHIA8_ROOT_DIR}/include + PATH_SUFFIXES include) + +find_file(PYTHIA8_XML xmldoc PATH_SUFFIXES share/Pythia8 + HINTS ${PYTHIA8_INCLUDE_DIR}/.. $ENV{PYTHIA8_ROOT_DIR} ${PYTHIA8_ROOT_DIR}) + +mark_as_advanced(PYTHIA8_INCLUDE_DIR PYTHIA8_XML) + +if(PYTHIA8_XML AND NOT PYTHIA8_VERSION) + file(READ ${PYTHIA8_XML}/Version.xml versionstr) + string(REGEX REPLACE ".*Pythia:versionNumber.*default.*[0-9][.]([0-9]+).*" "\\1" PYTHIA8_VERSION "${versionstr}") + set(PYTHIA8_VERSION ${PYTHIA8_VERSION} CACHE STRING "Detected version of Pythia8.") + mark_as_advanced(PYTHIA8_VERSION) +endif() + +# Enforce a minimal list if none is explicitly requested +if(NOT Pythia8_FIND_COMPONENTS) + set(Pythia8_FIND_COMPONENTS pythia8) +endif() + +# component alternative names +set(_pythia8tohepmc_names hepmcinterface) +set(_hepmcinterface_names pythia8tohepmc) + +foreach(component ${Pythia8_FIND_COMPONENTS}) + find_library(PYTHIA8_${component}_LIBRARY NAMES ${component} ${_${component}_names} + HINTS $ENV{PYTHIA8_ROOT_DIR}/lib ${PYTHIA8_ROOT_DIR}/lib) + if (PYTHIA8_${component}_LIBRARY) + set(PYTHIA8_${component}_FOUND 1) + list(APPEND PYTHIA8_LIBRARIES ${PYTHIA8_${component}_LIBRARY}) + + get_filename_component(libdir ${PYTHIA8_${component}_LIBRARY} PATH) + list(APPEND PYTHIA8_LIBRARY_DIRS ${libdir}) + else() + set(PYTHIA8_${component}_FOUND 0) + endif() + mark_as_advanced(PYTHIA8_${component}_LIBRARY) +endforeach() + +if(PYTHIA8_LIBRARY_DIRS) + list(REMOVE_DUPLICATES PYTHIA8_LIBRARY_DIRS) +endif() + +# 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_INCLUDE_DIR PYTHIA8_LIBRARIES PYTHIA8_XML) + +set(PYTHIA8_INCLUDE_DIRS ${PYTHIA8_INCLUDE_DIR}) + +mark_as_advanced(PYTHIA8_FOUND) diff --git a/cmake/Modules/FindTauola++.cmake b/cmake/Modules/FindTauola++.cmake new file mode 100644 index 0000000..c2a7644 --- /dev/null +++ b/cmake/Modules/FindTauola++.cmake @@ -0,0 +1,53 @@ +# - Try to find Tauola++ +# Defines: +# +# TAUOLA++_FOUND +# TAUOLA++_INCLUDE_DIR +# TAUOLA++_INCLUDE_DIRS (not cached) +# TAUOLA++__LIBRARY +# TAUOLA++__FOUND +# TAUOLA++_LIBRARIES (not cached) +# TAUOLA++_LIBRARY_DIRS (not cached) + +# Enforce a minimal list if none is explicitly requested +if(NOT Tauola++_FIND_COMPONENTS) + set(Tauola++_FIND_COMPONENTS Fortran CxxInterface) +endif() + +#message(STATUS "Tauola++ CMAKE_PREFIX_PATH") +#foreach(_x ${CMAKE_PREFIX_PATH}) +# message(STATUS "Tauola++ -- ${_x}") +#endforeach() + +foreach(component ${Tauola++_FIND_COMPONENTS}) + find_library(TAUOLA++_${component}_LIBRARY NAMES Tauola${component} + HINTS ${TAUOLA++_ROOT_DIR}/lib + $ENV{TAUOLAPP_ROOT_DIR}/lib ${TAUOLAPP_ROOT_DIR}/lib) + if (TAUOLA++_${component}_LIBRARY) + set(TAUOLA++_${component}_FOUND 1) + list(APPEND TAUOLA++_LIBRARIES ${TAUOLA++_${component}_LIBRARY}) + + get_filename_component(libdir ${TAUOLA++_${component}_LIBRARY} PATH) + list(APPEND TAUOLA++_LIBRARY_DIRS ${libdir}) + else() + set(TAUOLA++_${component}_FOUND 0) + endif() + mark_as_advanced(TAUOLA++_${component}_LIBRARY) +endforeach() + +if(TAUOLA++_LIBRARY_DIRS) + list(REMOVE_DUPLICATES TAUOLA++_LIBRARY_DIRS) +endif() + +find_path(TAUOLA++_INCLUDE_DIR Tauola/Tauola.h + HINTS ${TAUOLA++_ROOT_DIR}/include + $ENV{TAUOLAPP_ROOT_DIR}/include ${TAUOLAPP_ROOT_DIR}/include) +set(TAUOLA++_INCLUDE_DIRS ${TAUOLA++_INCLUDE_DIR}) +mark_as_advanced(TAUOLA++_INCLUDE_DIR) + +# handle the QUIETLY and REQUIRED arguments and set TAUOLA++_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tauola++ DEFAULT_MSG TAUOLA++_INCLUDE_DIR TAUOLA++_LIBRARIES) + +mark_as_advanced(TAUOLA++_FOUND) diff --git a/cmake/Modules/InstallPaths.cmake b/cmake/Modules/InstallPaths.cmake new file mode 100644 index 0000000..73a328a --- /dev/null +++ b/cmake/Modules/InstallPaths.cmake @@ -0,0 +1,8 @@ + +# Always a CMAKE_INSTALL_PREFIX based installation, +# except on frameworks where we use the system default +set(CMAKE_INSTALL_BINDIR bin) +set(CMAKE_INSTALL_LIBDIR lib) +#set(CMAKE_INSTALL_INCLUDEDIR include) +#set(CMAKE_INSTALL_FRAMEWORKDIR /Library/Frameworks) + diff --git a/cmake/Templates/EvtGenConfig.cmake.in b/cmake/Templates/EvtGenConfig.cmake.in new file mode 100644 index 0000000..ac7875b --- /dev/null +++ b/cmake/Templates/EvtGenConfig.cmake.in @@ -0,0 +1,6 @@ +@PACKAGE_INIT@ + +set_and_check(EVTGEN_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set_and_check(EVTGEN_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") + +check_required_components(EvtGen) diff --git a/setupEvtGen.sh b/setupEvtGen.sh index ce4c974..fa7f2e1 100644 --- a/setupEvtGen.sh +++ b/setupEvtGen.sh @@ -1,102 +1,110 @@ #!/bin/bash # This script installs EvtGen with all external dependencies. The variable VERSION specifies the # tag of EvtGen you want to use. The list of available tags can be found by either going to the url # https://phab.hepforge.org/source/evtgen/tags/master # or issuing the command (without the need to clone the git repository) # git ls-remote --tags http://phab.hepforge.org/source/evtgen.git | cut -d '/' -f3 # Note that some earlier EvtGen versions will not be compatible with all external dependency # versions given below, owing to C++ interface differences; see the specific tagged version of # the EvtGen/README file for guidance. # To obtain this script use the "Download File" option on the right of the webpage: # https://phab.hepforge.org/source/evtgen/browse/master/setupEvtGen.sh?view=raw # Version or tag number. No extra spaces on this line! -VERSION=R01-07-00 +VERSION=cmake # Pythia version number with no decimal points, e.g. 8230 corresponds to version 8.230. This # follows the naming convention of Pythia install tar files. Again, no extra spaces allowed PYTHIAVER=8230 PYTHIAPKG="pythia"$PYTHIAVER PYTHIATAR=$PYTHIAPKG".tgz" echo Pythia version set to $PYTHIAVER, package tar name $PYTHIATAR mkdir -p EvtGen cd EvtGen INSTALL_BASE=`pwd` echo Will setup EvtGen $VERSION in $INSTALL_BASE echo Downloading EvtGen from GIT -git clone -b $VERSION http://phab.hepforge.org/source/evtgen.git -# Replace the above line with the following one for the "head" version -#git clone http://phab.hepforge.org/source/evtgen.git +git clone http://phab.hepforge.org/source/evtgen.git evtgen.git +cd evtgen.git +#git checkout -b $VERSION $VERSION +git checkout $VERSION +cd $INSTALL_BASE +# Replace the above lines with the following one for the "head" version +#git clone http://phab.hepforge.org/source/evtgen.git evtgen.git osArch=`uname` echo Downloading external dependencies mkdir -p external cd external # Recommended versions of the external packages. HepMC is mandatory. # Later versions should be OK as well, assuming their C++ interfaces do not change curl -O http://lcgapp.cern.ch/project/simu/HepMC/download/HepMC-2.06.09.tar.gz curl -O http://home.thep.lu.se/~torbjorn/pythia8/$PYTHIATAR curl -O http://photospp.web.cern.ch/photospp/resources/PHOTOS.3.61/PHOTOS.3.61.tar.gz curl -O http://tauolapp.web.cern.ch/tauolapp/resources/TAUOLA.1.1.6c/TAUOLA.1.1.6c.tar.gz echo Extracting external dependencies tar -xzf HepMC-2.06.09.tar.gz tar -xzf $PYTHIATAR tar -xzf PHOTOS.3.61.tar.gz tar -xzf TAUOLA.1.1.6c.tar.gz # Patch TAUOLA and PHOTOS on Darwin (Mac) if [ "$osArch" == "Darwin" ] then - patch -p0 < $INSTALL_BASE/evtgen/platform/tauola_Darwin.patch - patch -p0 < $INSTALL_BASE/evtgen/platform/photos_Darwin.patch + patch -p0 < $INSTALL_BASE/evtgen.git/platform/tauola_Darwin.patch + patch -p0 < $INSTALL_BASE/evtgen.git/platform/photos_Darwin.patch fi echo Installing HepMC in $INSTALL_BASE/external/HepMC mkdir -p HepMC -cd HepMC +mkdir -p HepMC.build +cd HepMC.build cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_BASE/external/HepMC $INSTALL_BASE/external/HepMC-2.06.09 -Dmomentum:STRING=GEV -Dlength:STRING=MM make make install echo Installing pythia8 in $INSTALL_BASE/external/$PYTHIAPKG cd ../$PYTHIAPKG if [ "$PYTHIAVER" -lt "8200" ] then ./configure --with-hepmc=$INSTALL_BASE/external/HepMC --with-hepmcversion=2.06.09 --enable-shared else ./configure --with-hepmc2=$INSTALL_BASE/external/HepMC --enable-shared fi make echo Installing PHOTOS in $INSTALL_BASE/external/PHOTOS cd ../PHOTOS ./configure --with-hepmc=$INSTALL_BASE/external/HepMC make echo Installing TAUOLA in $INSTALL_BASE/external/TAUOLA cd ../TAUOLA ./configure --with-hepmc=$INSTALL_BASE/external/HepMC make echo Building EvtGen -cd $INSTALL_BASE/evtgen -./configure --hepmcdir=$INSTALL_BASE/external/HepMC --photosdir=$INSTALL_BASE/external/PHOTOS --pythiadir=$INSTALL_BASE/external/$PYTHIAPKG --tauoladir=$INSTALL_BASE/external/TAUOLA +cd $INSTALL_BASE +mkdir -p evtgen.build +mkdir -p evtgen +cd evtgen.build +cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_BASE/evtgen $INSTALL_BASE/evtgen.git -DEVTGEN_PYTHIA=ON -DEVTGEN_PHOTOS=ON -DEVTGEN_TAUOLA=ON make +make install +cd $INSTALL_BASE/evtgen echo Setup done. -echo To complete, add the following command to your .bashrc file or run it in your terminal before running any programs that use the EvtGen library: -echo LD_LIBRARY_PATH=$INSTALL_BASE/external/HepMC/lib:$INSTALL_BASE/external/$PYTHIAPKG/lib:$INSTALL_BASE/external/PHOTOS/lib:$INSTALL_BASE/external/TAUOLA/lib:$INSTALL_BASE/evtgen/lib:\$LD_LIBRARY_PATH -echo Also set the Pythia8 data path: +echo To complete, set the Pythia8 data path: if [ "$PYTHIAVER" -lt "8200" ] then echo PYTHIA8DATA=$INSTALL_BASE/external/$PYTHIAPKG/xmldoc else echo PYTHIA8DATA=$INSTALL_BASE/external/$PYTHIAPKG/share/Pythia8/xmldoc fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..3bf6387 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,100 @@ + +# Use glob to find the sources for the main and external libraries +file(GLOB EVTGEN_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenBase/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenModels/*.cpp + ) + +file(GLOB EVTGEN_EXTERNAL_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/EvtGenExternal/*.cpp + ) + + +# Add the main EvtGen library... +add_library(objlib OBJECT ${EVTGEN_SOURCES}) +set_target_properties(objlib PROPERTIES POSITION_INDEPENDENT_CODE 1) +target_include_directories(objlib PRIVATE ${CMAKE_SOURCE_DIR}) +target_include_directories(objlib PRIVATE ${HEPMC2_INCLUDE_DIR}) +target_compile_definitions(objlib PRIVATE EVTGEN_CPP11) + +add_library(EvtGen SHARED $) +set_target_properties(EvtGen PROPERTIES OUTPUT_NAME EvtGen) +set_target_properties(EvtGen PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) +set_target_properties(EvtGen PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) +target_include_directories(EvtGen PUBLIC ${CMAKE_SOURCE_DIR}) +target_include_directories(EvtGen PUBLIC ${HEPMC2_INCLUDE_DIR}) +target_compile_definitions(EvtGen PUBLIC EVTGEN_CPP11) +target_link_libraries(EvtGen ${HEPMC2_LIBRARIES}) + +add_library(EvtGenStatic STATIC $) +set_target_properties(EvtGenStatic PROPERTIES OUTPUT_NAME EvtGen) +set_target_properties(EvtGenStatic PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/archive) +target_include_directories(EvtGenStatic PUBLIC ${CMAKE_SOURCE_DIR}) +target_include_directories(EvtGenStatic PUBLIC ${HEPMC2_INCLUDE_DIR}) +target_compile_definitions(EvtGenStatic PUBLIC EVTGEN_CPP11) +target_link_libraries(EvtGenStatic ${HEPMC2_LIBRARIES}) + + +# Add the EvtGenExternal library... +if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) + add_library(objlib_ext OBJECT ${EVTGEN_EXTERNAL_SOURCES}) + set_target_properties(objlib_ext PROPERTIES POSITION_INDEPENDENT_CODE 1) + target_include_directories(objlib_ext PRIVATE ${CMAKE_SOURCE_DIR}) + target_include_directories(objlib_ext PRIVATE ${HEPMC2_INCLUDE_DIR}) + target_compile_definitions(objlib_ext PRIVATE EVTGEN_CPP11) + if(${EVTGEN_PYTHIA}) + target_include_directories(objlib_ext PRIVATE ${PYTHIA8_INCLUDE_DIR}) + target_compile_definitions(objlib_ext PRIVATE EVTGEN_PYTHIA) + endif() + if(${EVTGEN_PHOTOS}) + target_include_directories(objlib_ext PRIVATE ${PHOTOS++_INCLUDE_DIR}) + target_compile_definitions(objlib_ext PRIVATE EVTGEN_PHOTOS) + endif() + if(${EVTGEN_TAUOLA}) + target_include_directories(objlib_ext PRIVATE ${TAUOLA++_INCLUDE_DIR}) + target_compile_definitions(objlib_ext PRIVATE EVTGEN_TAUOLA) + endif() + + add_library(EvtGenExternal SHARED $) + set_target_properties(EvtGenExternal PROPERTIES OUTPUT_NAME EvtGenExternal) + set_target_properties(EvtGenExternal PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) + set_target_properties(EvtGenExternal PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) + target_link_libraries(EvtGenExternal ${HEPMC2_LIBRARIES}) + if(${EVTGEN_PYTHIA}) + target_link_libraries(EvtGenExternal ${PYTHIA8_LIBRARIES}) + endif() + if(${EVTGEN_PHOTOS}) + target_link_libraries(EvtGenExternal ${PHOTOS++_LIBRARIES}) + endif() + if(${EVTGEN_TAUOLA}) + target_link_libraries(EvtGenExternal ${TAUOLA++_LIBRARIES}) + endif() + + add_library(EvtGenExternalStatic STATIC $) + set_target_properties(EvtGenExternalStatic PROPERTIES OUTPUT_NAME EvtGenExternal) + set_target_properties(EvtGenExternalStatic PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}/archive) + target_link_libraries(EvtGenExternalStatic ${HEPMC2_LIBRARIES}) + if(${EVTGEN_PYTHIA}) + target_link_libraries(EvtGenExternalStatic ${PYTHIA8_LIBRARIES}) + endif() + if(${EVTGEN_PHOTOS}) + target_link_libraries(EvtGenExternalStatic ${PHOTOS++_LIBRARIES}) + endif() + if(${EVTGEN_TAUOLA}) + target_link_libraries(EvtGenExternalStatic ${TAUOLA++_LIBRARIES}) + endif() +endif() + +# Install the libraries +install(TARGETS EvtGen EvtGenStatic + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/archive + ) + +if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) + install(TARGETS EvtGenExternal EvtGenExternalStatic + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/archive + ) +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..e149173 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,25 @@ + +# the test executables require ROOT for histogramming etc. +find_package(ROOT REQUIRED) +include(${ROOT_USE_FILE}) + +# build each of the executables +foreach( test_exe evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC ) + add_executable(${test_exe} ${test_exe}.cc) + target_link_libraries(${test_exe} PRIVATE EvtGen ${ROOT_LIBRARIES}) + if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) + target_compile_definitions(${test_exe} PRIVATE EVTGEN_EXTERNAL) + target_link_libraries(${test_exe} PRIVATE EvtGenExternal) + endif() +endforeach() + +# install the executables +install(TARGETS evt_dalitz evtgenlhc_test1 example1 exampleWriteHepMC + RUNTIME DESTINATION test + ) + +# install the decay files, macros, scripts, etc. +install(DIRECTORY exampleFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/test) +install(FILES do_tests + DESTINATION ${CMAKE_INSTALL_PREFIX}/test + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/validation/CMakeLists.txt b/validation/CMakeLists.txt new file mode 100644 index 0000000..750267d --- /dev/null +++ b/validation/CMakeLists.txt @@ -0,0 +1,55 @@ + +# the validation executables require ROOT for histogramming etc. +find_package(ROOT REQUIRED) +include(${ROOT_USE_FILE}) + +# build each of the executables +foreach( validation_exe compareRootFiles genExampleRootFiles genRootDecayChain testCPVDecays ) + add_executable(${validation_exe} ${validation_exe}.cc) + target_link_libraries(${validation_exe} PRIVATE EvtGen ${ROOT_LIBRARIES}) + if( ${EVTGEN_PYTHIA} OR ${EVTGEN_PHOTOS} OR ${EVTGEN_TAUOLA} ) + target_compile_definitions(${validation_exe} PRIVATE EVTGEN_EXTERNAL) + target_link_libraries(${validation_exe} PRIVATE EvtGenExternal) + endif() +endforeach() + +# install the executables +install(TARGETS compareRootFiles genExampleRootFiles genRootDecayChain testCPVDecays + RUNTIME DESTINATION validation + ) + +# install the decay files, macros, scripts, etc. +install(DIRECTORY B0Files DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY CPVDecayFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY UpsilonFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY TauolaFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY Bs0Files DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY tauFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY rootFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY PHSPFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY BpFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY gifFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(DIRECTORY DalitzFiles DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(FILES BKstarGamma.dec BuDst0rhop.dec Kspimumu.dec photosTest.dec DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(FILES compareDalitz.C PhaseSpacePlots.C photosPlots.C plotBKstarGamma.C PlotKspimumu.C DESTINATION ${CMAKE_INSTALL_PREFIX}/validation) +install(FILES compareAllDecays.sh + compareB0PythiaDecays.sh + compareBpPythiaDecays.sh + compareBs0PythiaDecays.sh + compareTauolaDecays.sh + compareTauPythiaDecays.sh + compareUpsilonPythiaDecays.sh + genAllDecayExamples.sh + genB0PythiaDecays.sh + genBpPythiaDecays.sh + genBs0PythiaDecays.sh + genDalitzDecays.sh + genDDalitzModes.sh + genPHSP.sh + genTauolaDecays.sh + genTauPythiaDecays.sh + genUpsilonPythiaDecays.sh + runKspimumu.sh + runPhotosTest.sh + DESTINATION ${CMAKE_INSTALL_PREFIX}/validation + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)