From 7e42b983e387e78b95a225ad17d2a77be1a5a557 Mon Sep 17 00:00:00 2001 From: "Joseph F. Boudreau" <boudreau@pitt.edu> Date: Tue, 22 Feb 2022 23:11:18 +0100 Subject: [PATCH] Here is an additional tweak to a few programs. These are designed to obviate the need for users to specify environment variables pointing to certain directories which hold the plugins and configuration files --- FullSimLight/CMakeLists.txt | 2 ++ FullSimLight/fullSimLight.cc | 15 +++++++++++ FullSimLight/geantinoMaps.cc | 26 ++++++++++++------- .../GeoModelExplorer/CMakeLists.txt | 3 +++ .../GeoModelExplorer/src/main.cxx | 19 +++----------- 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt index 1d5a0a8c8..ce36c8e37 100644 --- a/FullSimLight/CMakeLists.txt +++ b/FullSimLight/CMakeLists.txt @@ -99,6 +99,8 @@ file(GLOB headers ${PROJECT_SOURCE_DIR}/inc/*.hh) set(OUTPUT bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${OUTPUT}) +add_definitions (-DG4SHAREDIR="${CMAKE_INSTALL_PREFIX}/share" ) + add_executable(fullSimLight fullSimLight.cc ${sources} ${headers}) add_executable(gmclash geoModelClash.cc ${sources} ${headers}) add_executable(gmmasscalc geoModelMassCalculator.cc ${sources} ${headers}) diff --git a/FullSimLight/fullSimLight.cc b/FullSimLight/fullSimLight.cc index 7ebd744ce..16c64362b 100644 --- a/FullSimLight/fullSimLight.cc +++ b/FullSimLight/fullSimLight.cc @@ -44,6 +44,21 @@ void Help(); int main(int argc, char** argv) { + // JFB if the G4 environment does not already set path to these variables, look for + // them in standard places. + const std::string g4ShareDir=G4SHAREDIR; + setenv("G4NEUTRONHPDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4NDL4.6").c_str(), 0); + setenv("G4LEDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4EMLOW7.9.1").c_str(), 0); + setenv("G4LEVELGAMMADATA",(g4ShareDir+"/Geant4-10.6.1/data/PhotonEvaporation5.5").c_str(), 0); + setenv("G4RADIOACTIVEDATA",(g4ShareDir+"/Geant4-10.6.1/data/RadioactiveDecay5.4").c_str(), 0); + setenv("G4PARTICLEXSDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4PARTICLEXS2.1").c_str(), 0); + setenv("G4PIIDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4PII1.3").c_str(), 0); + setenv("G4REALSURFACEDATA",(g4ShareDir+"/Geant4-10.6.1/data/RealSurface2.1.1").c_str() , 0); + setenv("G4SAIDXSDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4SAIDDATA2.0").c_str(), 0); + setenv("G4ABLADATA",(g4ShareDir+"/Geant4-10.6.1/data/G4ABLA3.1").c_str(), 0); + setenv("G4INCLDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4INCL1.0").c_str(), 0); + setenv("G4ENSDFSTATEDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4ENSDFSTATE2.2").c_str(), 0); + // Get input arguments GetInputArguments(argc, argv); diff --git a/FullSimLight/geantinoMaps.cc b/FullSimLight/geantinoMaps.cc index bb7af271c..1d358784c 100644 --- a/FullSimLight/geantinoMaps.cc +++ b/FullSimLight/geantinoMaps.cc @@ -82,15 +82,23 @@ int main(int argc, char** argv) { return 1; } - // JFB: Check that the macro file exists and is readable: - if (!getenv("G4ENSDFSTATEDATA")) { - G4cout << G4endl; - G4cout << "INFO: It appears that your Geant4 environment is not set up" << G4endl; - G4cout << "INFO: Please source the script geant4.sh" << G4endl; - G4cout << "INFO: Possible locations: /usr/bin or /usr/local/bin" << G4endl; - G4cout << "INFO: Exiting" <<G4endl; - return 1; - } + // JFB. In case the user has not set up the pointers to G4 data files, look for them + // in standard directories. + + const std::string g4ShareDir=G4SHAREDIR; + setenv("G4NEUTRONHPDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4NDL4.6").c_str(), 0); + setenv("G4LEDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4EMLOW7.9.1").c_str(), 0); + setenv("G4LEVELGAMMADATA",(g4ShareDir+"/Geant4-10.6.1/data/PhotonEvaporation5.5").c_str(), 0); + setenv("G4RADIOACTIVEDATA",(g4ShareDir+"/Geant4-10.6.1/data/RadioactiveDecay5.4").c_str(), 0); + setenv("G4PARTICLEXSDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4PARTICLEXS2.1").c_str(), 0); + setenv("G4PIIDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4PII1.3").c_str(), 0); + setenv("G4REALSURFACEDATA",(g4ShareDir+"/Geant4-10.6.1/data/RealSurface2.1.1").c_str() , 0); + setenv("G4SAIDXSDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4SAIDDATA2.0").c_str(), 0); + setenv("G4ABLADATA",(g4ShareDir+"/Geant4-10.6.1/data/G4ABLA3.1").c_str(), 0); + setenv("G4INCLDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4INCL1.0").c_str(), 0); + setenv("G4ENSDFSTATEDATA",(g4ShareDir+"/Geant4-10.6.1/data/G4ENSDFSTATE2.2").c_str(), 0); + + //#if G4VERSION_NUMBER>=1040 // std::cout<<"G4VERSION_NUMBER:::: "<<G4VERSION_NUMBER<<std::endl; // exit(1); diff --git a/GeoModelVisualization/GeoModelExplorer/CMakeLists.txt b/GeoModelVisualization/GeoModelExplorer/CMakeLists.txt index 8b28c7e3b..b41741b94 100644 --- a/GeoModelVisualization/GeoModelExplorer/CMakeLists.txt +++ b/GeoModelVisualization/GeoModelExplorer/CMakeLists.txt @@ -2,6 +2,9 @@ # Add the executable. add_executable( gmex src/main.cxx ) + +add_definitions (-DGXPLUGINDIR="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/gxplugins" ) + target_link_libraries( gmex PRIVATE GXGui Qt5::Core ) target_compile_definitions( gmex PRIVATE GEOMODEL_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" ) diff --git a/GeoModelVisualization/GeoModelExplorer/src/main.cxx b/GeoModelVisualization/GeoModelExplorer/src/main.cxx index b5c7d412b..538026364 100644 --- a/GeoModelVisualization/GeoModelExplorer/src/main.cxx +++ b/GeoModelVisualization/GeoModelExplorer/src/main.cxx @@ -38,23 +38,10 @@ int main(int argc, char** argv) setenv(variable, plus, true); } }; - // Preprocessor: we are passing the install directory to this - // class, from the CMake configuration. - // Drivers will be loaded from this install directory. - // However in some cases "linux" is part of the install directory - // name and that may be defined in a macro to be 1. So if that is - // the case we temporarily undef it. -#ifdef linux -#define waslinux linux -#undef linux - const char * standardPlaces = GEOMODEL_INSTALL_PREFIX; -#define linux waslinux -#else - const char * standardPlaces = GEOMODEL_INSTALL_PREFIX; -#endif - std::cout << "standardPlaces: " << standardPlaces << std::endl; - std::string gxpluginpath= std::string(standardPlaces)+"/lib/gxplugins"; + + std::string gxpluginpath= GXPLUGINDIR; pManip("GXPLUGINPATH",gxpluginpath.c_str()); + std::cout << "Plugins resolved in path: " << getenv("GXPLUGINPATH") << std::endl; QStringList arguments; for (int i = 0; i<=argc; i++){ arguments << argv[i]; -- GitLab