diff --git a/NPSimulation/CMakeLists.txt b/NPSimulation/CMakeLists.txt index 5d36cb66811d51901d7533ace19c290c07110d47..78556f65630c92b3a0875568ebdbb8fdc8be7637 100644 --- a/NPSimulation/CMakeLists.txt +++ b/NPSimulation/CMakeLists.txt @@ -16,8 +16,22 @@ set(CMAKE_INSTALL_MESSAGE LAZY) # Finding Geant 4 find_package(Geant4 REQUIRED ui_all vis_all) -message(${Geant4_USE_FILE}) + +# Rely on name of the file to set the version +string(REGEX MATCH "Geant4-*.*.*/" G4Version "${Geant4_USE_FILE}") +string(REPLACE "Geant4-" "" G4Version "${G4Version}") +string(REPLACE "/" "" G4Version "${G4Version}") +string(FIND "${G4Version}" "." pos) +string(SUBSTRING "${G4Version}" "0" "${pos}" NPS_GEANT4_VERSION_MAJOR) +string(REPLACE "${NPS_GEANT4_VERSION_MAJOR}." "" G4Version "${G4Version}") +string(FIND "${G4Version}" "." pos) +string(SUBSTRING "${G4Version}" "0" "${pos}" NPS_GEANT4_VERSION_MINOR) +string(REPLACE "${NPS_GEANT4_VERSION_MINOR}." "" G4Version "${G4Version}") +set(NPS_GEANT4_VERSION_PATCH "${G4Version}") +message ("Geant4 found, Version : ${NPS_GEANT4_VERSION_MAJOR}.${NPS_GEANT4_VERSION_MINOR}.${NPS_GEANT4_VERSION_PATCH}") + include(${Geant4_USE_FILE}) +add_definitions(${Geant4_DEFINITIONS}) # Finding NPLib find_package(NPLib) @@ -75,6 +89,9 @@ if(Geant4_gdml_FOUND) endif() +# set the Geant4 version info +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNPS_GEANT4_VERSION_MAJOR=${NPS_GEANT4_VERSION_MAJOR}") + # If the compiler is Clang, silence the unrecognised flags if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics -Wno-deprecated-register -Wno-shadow") diff --git a/NPSimulation/Core/PhysicsList.cc b/NPSimulation/Core/PhysicsList.cc index c5048cbb0cfe1b25762319ff47ea0080060548ce..d5103c60299c8495977cfff96f763ce6ba68e8f0 100644 --- a/NPSimulation/Core/PhysicsList.cc +++ b/NPSimulation/Core/PhysicsList.cc @@ -85,9 +85,15 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList(){ if(m_StoppingPhysics) m_PhysList["StoppingPhysics"]=new G4StoppingPhysics(); - if(m_HadronPhysicsQGSP_BIC_HP) - m_PhysList["HadronPhysicsQGSP_BIC_HP"] = new G4HadronPhysicsQGSP_BIC_HP(); + if(m_HadronPhysicsQGSP_BIC_HP){ + #if NPS_GEANT4_VERSION_MAJOR > 9 + m_PhysList["HadronPhysicsQGSP_BIC_HP"] = new G4HadronPhysicsQGSP_BIC_HP(); + #else + std::cout << "\r\032[1;31m Warning: physics list HadronPhysicsQGSP_BIC_HP require Geant4 10, process not activated \033[0m" <<std::endl; + #endif + m_PhysList["HadronPhysicsQGSP_BIC_HP"] = new G4HadronPhysicsQGSP_BIC_HP(); + } // Optical Photon for scintillator simulation if(m_OpticalPhysics){ opticalPhysicsList = new G4OpticalPhysics(0); diff --git a/NPSimulation/Core/PhysicsList.hh b/NPSimulation/Core/PhysicsList.hh index be3f6571660c79b4f77f6a585bd6df7d00f8a4aa..f263cf6388e805e6de195f65269d970f86a6cc84 100644 --- a/NPSimulation/Core/PhysicsList.hh +++ b/NPSimulation/Core/PhysicsList.hh @@ -56,7 +56,9 @@ #include "G4HadronElasticPhysics.hh" #include "G4HadronElasticPhysicsHP.hh" #include "G4IonBinaryCascadePhysics.hh" +#if NPS_GEANT4_VERSION_MAJOR > 9 #include "G4HadronPhysicsQGSP_BIC_HP.hh" +#endif #include "G4HadronPhysicsQGSP_BIC.hh" class G4VPhysicsConstructor;