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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eaabf016..1f8624918 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,20 +2,38 @@ set( LibraryVersion "1.6" ) 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}) + # Tested for Garfield af4a14516489babbd6e6df780edd58fedf7fa12b + message(STATUS "Using new Garfield CMake") + set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) + find_package(Garfield REQUIRED) + set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield) + 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 + message(STATUS "Using old Garfield CMake") + set(GARFIELD_INSTALL $ENV{GARFIELD_HOME}) + 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}") + add_definitions(-DUSE_Garfield_OLD) + else () + message(FATAL_ERROR "Garfield not found") + endif () + + set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL}) + message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}") + + set(feature_added "Garfield") set(feature_added ${feature_added} PARENT_SCOPE) else () set(REST_GARFIELD OFF) diff --git a/inc/TRestDetectorGarfieldDriftProcess.h b/inc/TRestDetectorGarfieldDriftProcess.h index f8e73dc78..6c8cce099 100644 --- a/inc/TRestDetectorGarfieldDriftProcess.h +++ b/inc/TRestDetectorGarfieldDriftProcess.h @@ -17,21 +17,25 @@ #include -#if defined USE_Garfield +#if defined USE_Garfield_OLD #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 -#include -#include -#include -#include - +#include "TRestDetectorGeometry.h" +#include "TRestDetectorHitsEvent.h" +#include "TRestDetectorReadout.h" +#include "TRestDetectorSignalEvent.h" #include "TRestEventProcess.h" class TRestDetectorGarfieldDriftProcess : public TRestEventProcess { @@ -48,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(); 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 5df6af110..d8ecefbd0 100644 --- a/inc/TRestDetectorGeometry.h +++ b/inc/TRestDetectorGeometry.h @@ -16,20 +16,33 @@ #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" +#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; @@ -37,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: @@ -55,6 +69,7 @@ class TRestDetectorGeometry : public TGeoManager { void InitGfGeometry(); #if defined USE_Garfield + /// Return pointer to Garfield::GeometryRoot geometry object Garfield::GeometryRoot* GetGfGeometry() { return fGfGeometry; } @@ -64,7 +79,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); } @@ -89,15 +104,15 @@ class TRestDetectorGeometry : public TGeoManager { if (i < vReadoutElec.size()) return vReadoutElec[i]; else - return 0; + return nullptr; } /// Get i^th Gf component - Garfield::ComponentBase* GetGfComponent(unsigned int i) { + Component* GetGfComponent(unsigned int i) { if (i < vGfComponent.size()) return vGfComponent[i]; else - return 0; + return nullptr; } /// Getnumber of Gf components @@ -108,7 +123,7 @@ class TRestDetectorGeometry : public TGeoManager { if (i < vGfSensor.size()) return vGfSensor[i]; else - return 0; + return nullptr; } /// Getnumber of Gf sensors