From e1d5a8addf21a12bd8b4aab57d48d37108a5ebb8 Mon Sep 17 00:00:00 2001 From: lobis Date: Sat, 5 Mar 2022 21:46:42 +0100 Subject: [PATCH 01/13] Updated CMake --- CMakeLists.txt | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe82a6f8..9ede92d3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,34 @@ -set( LibraryVersion "1.5" ) +set(LibraryVersion "1.5") add_definitions(-DLIBRARY_VERSION="${LibraryVersion}") #find garfield libs and includes -IF( NOT DEFINED REST_GARFIELD ) - set(REST_GARFIELD OFF) -ENDIF() +IF (NOT DEFINED REST_GARFIELD) + set(REST_GARFIELD OFF) +ENDIF () if (${REST_GARFIELD} MATCHES "ON") add_definitions(-DUSE_Garfield) - include(FindGarfield) - message(STATUS "GARFIELD " ${Garfield_INCLUDE_DIRS}) - set(external_include_dirs ${external_include_dirs} ${Garfield_INCLUDE_DIRS}) - set(external_libs "${external_libs} ${Garfield_LIBRARIES}") - set(external_include_dirs ${external_include_dirs} ${Garfield_DIR}/Heed) - message(STATUS "HEED Include " ${Garfield_DIR}/Heed) - message(STATUS "ALL INCLUDES: " ${external_include_dirs}) - set(feature_added "Garfield") + + if (DEFINED ENV{GARFIELD_INSTALL}) + message(STATUS "Using new Garfield CMake") + set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) + # find_package(Garfield REQUIRED) + # recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script4 + elseif (DEFINED ENV{GARFIELD_HOME}) + # Old way, for backwards compatibility + message(STATUS "Using old Garfield CMake") + set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) + # include(FindGarfield) + else () + message(FATAL_ERROR "Garfield not found") + endif () + + set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) + message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}") + set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) + set(external_libs ${external_libs} "-L${GARFIELD_INSTALL}/lib -lGarfield") + + set(feature_added "Garfield") set(feature_added ${feature_added} PARENT_SCOPE) else () set(REST_GARFIELD OFF) From 5224dfac5fb0c5a30d26781b1c312fac4dd13c6f Mon Sep 17 00:00:00 2001 From: lobis Date: Sat, 5 Mar 2022 23:33:32 +0100 Subject: [PATCH 02/13] change for backwards compatibility --- CMakeLists.txt | 1 + inc/TRestDetectorGarfieldDriftProcess.h | 15 ++++++++----- inc/TRestDetectorGeometry.h | 30 +++++++++++++++++-------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ede92d3e..6dbce73c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ if (${REST_GARFIELD} MATCHES "ON") # Old way, for backwards compatibility message(STATUS "Using old Garfield CMake") set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) + add_definitions(-DUSE_Garfield_OLD) # include(FindGarfield) else () message(FATAL_ERROR "Garfield not found") diff --git a/inc/TRestDetectorGarfieldDriftProcess.h b/inc/TRestDetectorGarfieldDriftProcess.h index f8e73dc78..0de966906 100644 --- a/inc/TRestDetectorGarfieldDriftProcess.h +++ b/inc/TRestDetectorGarfieldDriftProcess.h @@ -17,21 +17,24 @@ #include -#if defined USE_Garfield +#if defined USE_Garfield_OLD #include "AvalancheMC.hh" #include "ComponentBase.hh" #include "Sensor.hh" +#elif USE_Garfield +#include "AvalancheMC.hh" +#include "Component.hh" +#include "Sensor.hh" // TODO Could we have this as an option given through metadata? #define DRIFT_METHOD AvalancheMC #endif #include -#include -#include -#include -#include - +#include "TRestDetectorGeometry.h" +#include "TRestDetectorHitsEvent.h" +#include "TRestDetectorReadout.h" +#include "TRestDetectorSignalEvent.h" #include "TRestEventProcess.h" class TRestDetectorGarfieldDriftProcess : public TRestEventProcess { diff --git a/inc/TRestDetectorGeometry.h b/inc/TRestDetectorGeometry.h index 5df6af110..48893f046 100644 --- a/inc/TRestDetectorGeometry.h +++ b/inc/TRestDetectorGeometry.h @@ -16,20 +16,24 @@ #ifndef RestCore_TRestDetectorGeometry #define RestCore_TRestDetectorGeometry +#include +#include +#include +#include + #include #include -#include "TGeoManager.h" -#include "TGeoMaterial.h" -#include "TGeoVolume.h" -#include "TObject.h" - -#include +#include "TRestDetectorGas.h" -#if defined USE_Garfield +#if defined USE_Garfield_OLD #include "ComponentBase.hh" #include "GeometryRoot.hh" #include "Sensor.hh" +#elif USE_Garfield +#include "Component.hh" +#include "GeometryRoot.hh" +#include "Sensor.hh" #endif using namespace std; @@ -55,6 +59,14 @@ class TRestDetectorGeometry : public TGeoManager { void InitGfGeometry(); #if defined USE_Garfield + typedef Garfield::Component Component; +#endif + +#if defined USE_Garfield_OLD + typedef Garfield::ComponentBase Component; +#endif + +#if defined USE_Garfield || defined USE_Garfield_OLD /// Return pointer to Garfield::GeometryRoot geometry object Garfield::GeometryRoot* GetGfGeometry() { return fGfGeometry; } @@ -64,7 +76,7 @@ class TRestDetectorGeometry : public TGeoManager { } /// Set Garfield field component - void AddGfComponent(Garfield::ComponentBase* c) { + void AddGfComponent(Component* c) { c->SetGeometry(fGfGeometry); vGfComponent.push_back(c); } @@ -93,7 +105,7 @@ class TRestDetectorGeometry : public TGeoManager { } /// Get i^th Gf component - Garfield::ComponentBase* GetGfComponent(unsigned int i) { + Component* GetGfComponent(unsigned int i) { if (i < vGfComponent.size()) return vGfComponent[i]; else From e6ea478cb8f73b45e0e40ceebc2847ae29f97d3d Mon Sep 17 00:00:00 2001 From: lobis Date: Sun, 6 Mar 2022 00:04:28 +0100 Subject: [PATCH 03/13] change for backwards compatibility --- inc/TRestDetectorGas.h | 3 +-- inc/TRestDetectorGeometry.h | 41 ++++++++++++++++++++----------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/inc/TRestDetectorGas.h b/inc/TRestDetectorGas.h index 00e9ade31..44ad0a057 100644 --- a/inc/TRestDetectorGas.h +++ b/inc/TRestDetectorGas.h @@ -23,8 +23,8 @@ #ifndef RestCore_TRestDetectorGas #define RestCore_TRestDetectorGas #include -#include +#include #include #include @@ -40,7 +40,6 @@ #include "TSystem.h" #include "TVector3.h" -//#define USE_Garfield #if defined USE_Garfield #include "ComponentConstant.hh" #include "GeometrySimple.hh" diff --git a/inc/TRestDetectorGeometry.h b/inc/TRestDetectorGeometry.h index 48893f046..d8ecefbd0 100644 --- a/inc/TRestDetectorGeometry.h +++ b/inc/TRestDetectorGeometry.h @@ -26,14 +26,23 @@ #include "TRestDetectorGas.h" +#if defined USE_Garfield + #if defined USE_Garfield_OLD #include "ComponentBase.hh" -#include "GeometryRoot.hh" -#include "Sensor.hh" -#elif USE_Garfield +#else #include "Component.hh" +#endif + #include "GeometryRoot.hh" #include "Sensor.hh" + +#if defined USE_Garfield_OLD +typedef Garfield::ComponentBase Component; +#else +typedef Garfield::Component Component; +#endif + #endif using namespace std; @@ -41,12 +50,13 @@ using namespace std; class TRestDetectorGeometry : public TGeoManager { protected: #if defined USE_Garfield - Garfield::GeometryRoot* fGfGeometry; //!///< Pointer to Garfield::GeometryRoot object of the - //! geometry - vector vGfComponent; //!///< Vector of pointers to Garfield Component object - vector vGfSensor; //!///< Vector of pointers to Garfield Sensor object - TGeoNode* fDriftElec; //!///< pointer to drift electrode - vector vReadoutElec; //!///< vector of pointers to readout planes + Garfield::GeometryRoot* fGfGeometry; //!///< Pointer to Garfield::GeometryRoot object of the + //! geometry + vector vGfComponent; //!///< Vector of pointers to Garfield Component object + vector vGfSensor; //!///< Vector of pointers to Garfield Sensor object + TGeoNode* fDriftElec; //!///< pointer to drift electrode + vector vReadoutElec; //!///< vector of pointers to readout planes + #endif public: @@ -59,14 +69,7 @@ class TRestDetectorGeometry : public TGeoManager { void InitGfGeometry(); #if defined USE_Garfield - typedef Garfield::Component Component; -#endif - -#if defined USE_Garfield_OLD - typedef Garfield::ComponentBase Component; -#endif -#if defined USE_Garfield || defined USE_Garfield_OLD /// Return pointer to Garfield::GeometryRoot geometry object Garfield::GeometryRoot* GetGfGeometry() { return fGfGeometry; } @@ -101,7 +104,7 @@ class TRestDetectorGeometry : public TGeoManager { if (i < vReadoutElec.size()) return vReadoutElec[i]; else - return 0; + return nullptr; } /// Get i^th Gf component @@ -109,7 +112,7 @@ class TRestDetectorGeometry : public TGeoManager { if (i < vGfComponent.size()) return vGfComponent[i]; else - return 0; + return nullptr; } /// Getnumber of Gf components @@ -120,7 +123,7 @@ class TRestDetectorGeometry : public TGeoManager { if (i < vGfSensor.size()) return vGfSensor[i]; else - return 0; + return nullptr; } /// Getnumber of Gf sensors From 6fde6bd9a3a3b6df28ca8bde3bd5e2e8b8c43b53 Mon Sep 17 00:00:00 2001 From: lobis Date: Sun, 6 Mar 2022 00:17:53 +0100 Subject: [PATCH 04/13] change external_include_dirs for backwards compatibility --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6dbce73c2..6afac50e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,12 +12,14 @@ if (${REST_GARFIELD} MATCHES "ON") if (DEFINED ENV{GARFIELD_INSTALL}) message(STATUS "Using new Garfield CMake") set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) + set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) # find_package(Garfield REQUIRED) # recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script4 elseif (DEFINED ENV{GARFIELD_HOME}) # Old way, for backwards compatibility message(STATUS "Using old Garfield CMake") set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) + set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Include) add_definitions(-DUSE_Garfield_OLD) # include(FindGarfield) else () @@ -26,7 +28,6 @@ if (${REST_GARFIELD} MATCHES "ON") set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}") - set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) set(external_libs ${external_libs} "-L${GARFIELD_INSTALL}/lib -lGarfield") set(feature_added "Garfield") From 95de77293c52af90548353d83796a80aff1b5cf6 Mon Sep 17 00:00:00 2001 From: lobis Date: Sun, 6 Mar 2022 00:31:10 +0100 Subject: [PATCH 05/13] fix bug in preprocessor directives --- inc/TRestDetectorGarfieldDriftProcess.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/TRestDetectorGarfieldDriftProcess.h b/inc/TRestDetectorGarfieldDriftProcess.h index 0de966906..071d247f7 100644 --- a/inc/TRestDetectorGarfieldDriftProcess.h +++ b/inc/TRestDetectorGarfieldDriftProcess.h @@ -21,12 +21,13 @@ #include "AvalancheMC.hh" #include "ComponentBase.hh" #include "Sensor.hh" +typedef AvalancheMC DRIFT_METHOD; #elif USE_Garfield #include "AvalancheMC.hh" #include "Component.hh" #include "Sensor.hh" +typedef AvalancheMC DRIFT_METHOD; // TODO Could we have this as an option given through metadata? -#define DRIFT_METHOD AvalancheMC #endif #include From 7dde6a4c5eb917a91d0223cedede0029ab6d9cd9 Mon Sep 17 00:00:00 2001 From: lobis Date: Sun, 6 Mar 2022 00:37:50 +0100 Subject: [PATCH 06/13] fix bug --- inc/TRestDetectorGarfieldDriftProcess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/TRestDetectorGarfieldDriftProcess.h b/inc/TRestDetectorGarfieldDriftProcess.h index 071d247f7..6c8cce099 100644 --- a/inc/TRestDetectorGarfieldDriftProcess.h +++ b/inc/TRestDetectorGarfieldDriftProcess.h @@ -52,8 +52,8 @@ class TRestDetectorGarfieldDriftProcess : public TRestEventProcess { TRestDetectorGas* fGas; //! TRestDetectorGeometry* fGeometry; //! - Garfield::Sensor* fGfSensor; //! - Garfield::DRIFT_METHOD* fGfDriftMethod; //! + Garfield::Sensor* fGfSensor; //! + DRIFT_METHOD* fGfDriftMethod; //! void InitFromConfigFile(); From e7b0c19a808cf0eb6a56d9ef35779500a4695542 Mon Sep 17 00:00:00 2001 From: lobis Date: Sun, 6 Mar 2022 00:50:15 +0100 Subject: [PATCH 07/13] fix cmake --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6afac50e4..289795c66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,23 +12,25 @@ if (${REST_GARFIELD} MATCHES "ON") if (DEFINED ENV{GARFIELD_INSTALL}) message(STATUS "Using new Garfield CMake") set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) - set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) # find_package(Garfield REQUIRED) + set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) + set(external_libs ${external_libs} "-L${GARFIELD_INSTALL}/lib -lGarfield") # recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script4 elseif (DEFINED ENV{GARFIELD_HOME}) # Old way, for backwards compatibility message(STATUS "Using old Garfield CMake") set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) + # include(FindGarfield) set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Include) + set(external_include_dirs ${external_include_dirs} ${Garfield_DIR}/Heed) + set(external_libs "${external_libs} ${Garfield_LIBRARIES}") add_definitions(-DUSE_Garfield_OLD) - # include(FindGarfield) else () message(FATAL_ERROR "Garfield not found") endif () set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}") - set(external_libs ${external_libs} "-L${GARFIELD_INSTALL}/lib -lGarfield") set(feature_added "Garfield") set(feature_added ${feature_added} PARENT_SCOPE) From d10da5a35ab000d1eedb5eef262a1931cbf1384c Mon Sep 17 00:00:00 2001 From: lobis Date: Sun, 6 Mar 2022 00:56:19 +0100 Subject: [PATCH 08/13] fix whitespaces in cmake variable --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 289795c66..ca5326817 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,9 @@ if (${REST_GARFIELD} MATCHES "ON") message(FATAL_ERROR "Garfield not found") endif () + string(STRIP "${external_include_dirs}" external_include_dirs) + string(STRIP "${external_libs}" external_libs) + set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}") From 5cf2d5ee8cafe3059ab289bcd4440a2318d9d677 Mon Sep 17 00:00:00 2001 From: lobis Date: Sun, 6 Mar 2022 00:59:11 +0100 Subject: [PATCH 09/13] fix include garfield --- CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca5326817..2e0187a27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ if (${REST_GARFIELD} MATCHES "ON") # Old way, for backwards compatibility message(STATUS "Using old Garfield CMake") set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) - # include(FindGarfield) + include(FindGarfield) set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Include) set(external_include_dirs ${external_include_dirs} ${Garfield_DIR}/Heed) set(external_libs "${external_libs} ${Garfield_LIBRARIES}") @@ -29,9 +29,6 @@ if (${REST_GARFIELD} MATCHES "ON") message(FATAL_ERROR "Garfield not found") endif () - string(STRIP "${external_include_dirs}" external_include_dirs) - string(STRIP "${external_libs}" external_libs) - set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}") From 98eac853cbd94d477cbe2491d820d3ac3ba5a216 Mon Sep 17 00:00:00 2001 From: lobis Date: Sun, 6 Mar 2022 01:00:01 +0100 Subject: [PATCH 10/13] cmake variable change --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e0187a27..912b9d3bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if (${REST_GARFIELD} MATCHES "ON") set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) include(FindGarfield) set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Include) - set(external_include_dirs ${external_include_dirs} ${Garfield_DIR}/Heed) + set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Heed) set(external_libs "${external_libs} ${Garfield_LIBRARIES}") add_definitions(-DUSE_Garfield_OLD) else () From 432001f46dbb50a1360698131c1d2f067d33794d Mon Sep 17 00:00:00 2001 From: Luis Obis <35803280+lobis@users.noreply.github.com> Date: Mon, 7 Mar 2022 11:43:28 +0100 Subject: [PATCH 11/13] Update Docker image on GitLab pipeline --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2be66d9a1..747f593c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,5 @@ -image: nkx1231/root6-geant4-garfield:0.8 +image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-26-00_Geant4-v10.4.3_Garfield-af4a1451 +# image: nkx1231/root6-geant4-garfield:0.8 stages: - pre-build From 53b4082002966fb8cb98fbff4ce1edfcebc95eb1 Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Thu, 10 Mar 2022 14:20:49 +0100 Subject: [PATCH 12/13] Renamed FindGarfield.cmake to FindGarfieldOld.cmake to avoid conflicts with find_package --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 912b9d3bf..6195b3718 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,12 +15,12 @@ if (${REST_GARFIELD} MATCHES "ON") # find_package(Garfield REQUIRED) set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) set(external_libs ${external_libs} "-L${GARFIELD_INSTALL}/lib -lGarfield") - # recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script4 + # recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script elseif (DEFINED ENV{GARFIELD_HOME}) # Old way, for backwards compatibility message(STATUS "Using old Garfield CMake") set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) - include(FindGarfield) + include(FindGarfieldOld) set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Include) set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Heed) set(external_libs "${external_libs} ${Garfield_LIBRARIES}") From 7eddcc9b0079ecd46763dd22a133c534bc59dcce Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Thu, 10 Mar 2022 14:32:09 +0100 Subject: [PATCH 13/13] updated cmake for Garfield --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6195b3718..68d0f5c4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,11 +10,12 @@ if (${REST_GARFIELD} MATCHES "ON") add_definitions(-DUSE_Garfield) if (DEFINED ENV{GARFIELD_INSTALL}) + # Tested for Garfield af4a14516489babbd6e6df780edd58fedf7fa12b message(STATUS "Using new Garfield CMake") set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) - # find_package(Garfield REQUIRED) + find_package(Garfield REQUIRED) set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) - set(external_libs ${external_libs} "-L${GARFIELD_INSTALL}/lib -lGarfield") + set(external_libs ${external_libs} Garfield::Garfield) # recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script elseif (DEFINED ENV{GARFIELD_HOME}) # Old way, for backwards compatibility