Skip to content

Commit f296261

Browse files
committed
Merge branch 'master' of github.com:rest-for-physics/detectorlib
2 parents 448766e + fef4296 commit f296261

5 files changed

+77
-40
lines changed

Diff for: .gitlab-ci.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
image: nkx1231/root6-geant4-garfield:0.8
1+
image: ghcr.io/lobis/root-geant4-garfield:cpp17_ROOT-v6-26-00_Geant4-v10.4.3_Garfield-af4a1451
2+
# image: nkx1231/root6-geant4-garfield:0.8
23

34
stages:
45
- pre-build

Diff for: CMakeLists.txt

+29-11
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,38 @@ set( LibraryVersion "1.6" )
22
add_definitions(-DLIBRARY_VERSION="${LibraryVersion}")
33

44
#find garfield libs and includes
5-
IF( NOT DEFINED REST_GARFIELD )
6-
set(REST_GARFIELD OFF)
7-
ENDIF()
5+
IF (NOT DEFINED REST_GARFIELD)
6+
set(REST_GARFIELD OFF)
7+
ENDIF ()
88

99
if (${REST_GARFIELD} MATCHES "ON")
1010
add_definitions(-DUSE_Garfield)
11-
include(FindGarfield)
12-
message(STATUS "GARFIELD " ${Garfield_INCLUDE_DIRS})
13-
set(external_include_dirs ${external_include_dirs} ${Garfield_INCLUDE_DIRS})
14-
set(external_libs "${external_libs} ${Garfield_LIBRARIES}")
15-
set(external_include_dirs ${external_include_dirs} ${Garfield_DIR}/Heed)
16-
message(STATUS "HEED Include " ${Garfield_DIR}/Heed)
17-
message(STATUS "ALL INCLUDES: " ${external_include_dirs})
18-
set(feature_added "Garfield")
11+
12+
if (DEFINED ENV{GARFIELD_INSTALL})
13+
# Tested for Garfield af4a14516489babbd6e6df780edd58fedf7fa12b
14+
message(STATUS "Using new Garfield CMake")
15+
set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL})
16+
find_package(Garfield REQUIRED)
17+
set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/include/Garfield)
18+
set(external_libs ${external_libs} Garfield::Garfield)
19+
# recommended CMake way does not work, we need to delete the "FindGarfield.cmake" script
20+
elseif (DEFINED ENV{GARFIELD_HOME})
21+
# Old way, for backwards compatibility
22+
message(STATUS "Using old Garfield CMake")
23+
set(GARFIELD_INSTALL $ENV{GARFIELD_HOME})
24+
include(FindGarfieldOld)
25+
set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Include)
26+
set(external_include_dirs ${external_include_dirs} ${GARFIELD_INSTALL}/Heed)
27+
set(external_libs "${external_libs} ${Garfield_LIBRARIES}")
28+
add_definitions(-DUSE_Garfield_OLD)
29+
else ()
30+
message(FATAL_ERROR "Garfield not found")
31+
endif ()
32+
33+
set(GARFIELD_INSTALL $ENV{GARFIELD_INSTALL})
34+
message(STATUS "GARFIELD INSTALLATION: ${GARFIELD_INSTALL}")
35+
36+
set(feature_added "Garfield")
1937
set(feature_added ${feature_added} PARENT_SCOPE)
2038
else ()
2139
set(REST_GARFIELD OFF)

Diff for: inc/TRestDetectorGarfieldDriftProcess.h

+13-9
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,25 @@
1717

1818
#include <TRestDetectorGas.h>
1919

20-
#if defined USE_Garfield
20+
#if defined USE_Garfield_OLD
2121
#include "AvalancheMC.hh"
2222
#include "ComponentBase.hh"
2323
#include "Sensor.hh"
24+
typedef AvalancheMC DRIFT_METHOD;
25+
#elif USE_Garfield
26+
#include "AvalancheMC.hh"
27+
#include "Component.hh"
28+
#include "Sensor.hh"
29+
typedef AvalancheMC DRIFT_METHOD;
2430
// TODO Could we have this as an option given through metadata?
25-
#define DRIFT_METHOD AvalancheMC
2631
#endif
2732

2833
#include <TRandom3.h>
2934

30-
#include <TRestDetectorGeometry.h>
31-
#include <TRestDetectorHitsEvent.h>
32-
#include <TRestDetectorReadout.h>
33-
#include <TRestDetectorSignalEvent.h>
34-
35+
#include "TRestDetectorGeometry.h"
36+
#include "TRestDetectorHitsEvent.h"
37+
#include "TRestDetectorReadout.h"
38+
#include "TRestDetectorSignalEvent.h"
3539
#include "TRestEventProcess.h"
3640

3741
class TRestDetectorGarfieldDriftProcess : public TRestEventProcess {
@@ -48,8 +52,8 @@ class TRestDetectorGarfieldDriftProcess : public TRestEventProcess {
4852
TRestDetectorGas* fGas; //!
4953
TRestDetectorGeometry* fGeometry; //!
5054

51-
Garfield::Sensor* fGfSensor; //!
52-
Garfield::DRIFT_METHOD* fGfDriftMethod; //!
55+
Garfield::Sensor* fGfSensor; //!
56+
DRIFT_METHOD* fGfDriftMethod; //!
5357

5458
void InitFromConfigFile();
5559

Diff for: inc/TRestDetectorGas.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#ifndef RestCore_TRestDetectorGas
2424
#define RestCore_TRestDetectorGas
2525
#include <TROOT.h>
26-
#include <stdlib.h>
2726

27+
#include <cstdlib>
2828
#include <fstream>
2929
#include <iostream>
3030

@@ -40,7 +40,6 @@
4040
#include "TSystem.h"
4141
#include "TVector3.h"
4242

43-
//#define USE_Garfield
4443
#if defined USE_Garfield
4544
#include "ComponentConstant.hh"
4645
#include "GeometrySimple.hh"

Diff for: inc/TRestDetectorGeometry.h

+32-17
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,47 @@
1616
#ifndef RestCore_TRestDetectorGeometry
1717
#define RestCore_TRestDetectorGeometry
1818

19+
#include <TGeoManager.h>
20+
#include <TGeoMaterial.h>
21+
#include <TGeoVolume.h>
22+
#include <TObject.h>
23+
1924
#include <iostream>
2025
#include <vector>
2126

22-
#include "TGeoManager.h"
23-
#include "TGeoMaterial.h"
24-
#include "TGeoVolume.h"
25-
#include "TObject.h"
26-
27-
#include <TRestDetectorGas.h>
27+
#include "TRestDetectorGas.h"
2828

2929
#if defined USE_Garfield
30+
31+
#if defined USE_Garfield_OLD
3032
#include "ComponentBase.hh"
33+
#else
34+
#include "Component.hh"
35+
#endif
36+
3137
#include "GeometryRoot.hh"
3238
#include "Sensor.hh"
39+
40+
#if defined USE_Garfield_OLD
41+
typedef Garfield::ComponentBase Component;
42+
#else
43+
typedef Garfield::Component Component;
44+
#endif
45+
3346
#endif
3447

3548
using namespace std;
3649

3750
class TRestDetectorGeometry : public TGeoManager {
3851
protected:
3952
#if defined USE_Garfield
40-
Garfield::GeometryRoot* fGfGeometry; //!///< Pointer to Garfield::GeometryRoot object of the
41-
//! geometry
42-
vector<Garfield::ComponentBase*> vGfComponent; //!///< Vector of pointers to Garfield Component object
43-
vector<Garfield::Sensor*> vGfSensor; //!///< Vector of pointers to Garfield Sensor object
44-
TGeoNode* fDriftElec; //!///< pointer to drift electrode
45-
vector<TGeoNode*> vReadoutElec; //!///< vector of pointers to readout planes
53+
Garfield::GeometryRoot* fGfGeometry; //!///< Pointer to Garfield::GeometryRoot object of the
54+
//! geometry
55+
vector<Component*> vGfComponent; //!///< Vector of pointers to Garfield Component object
56+
vector<Garfield::Sensor*> vGfSensor; //!///< Vector of pointers to Garfield Sensor object
57+
TGeoNode* fDriftElec; //!///< pointer to drift electrode
58+
vector<TGeoNode*> vReadoutElec; //!///< vector of pointers to readout planes
59+
4660
#endif
4761

4862
public:
@@ -55,6 +69,7 @@ class TRestDetectorGeometry : public TGeoManager {
5569
void InitGfGeometry();
5670

5771
#if defined USE_Garfield
72+
5873
/// Return pointer to Garfield::GeometryRoot geometry object
5974
Garfield::GeometryRoot* GetGfGeometry() { return fGfGeometry; }
6075

@@ -64,7 +79,7 @@ class TRestDetectorGeometry : public TGeoManager {
6479
}
6580

6681
/// Set Garfield field component
67-
void AddGfComponent(Garfield::ComponentBase* c) {
82+
void AddGfComponent(Component* c) {
6883
c->SetGeometry(fGfGeometry);
6984
vGfComponent.push_back(c);
7085
}
@@ -89,15 +104,15 @@ class TRestDetectorGeometry : public TGeoManager {
89104
if (i < vReadoutElec.size())
90105
return vReadoutElec[i];
91106
else
92-
return 0;
107+
return nullptr;
93108
}
94109

95110
/// Get i^th Gf component
96-
Garfield::ComponentBase* GetGfComponent(unsigned int i) {
111+
Component* GetGfComponent(unsigned int i) {
97112
if (i < vGfComponent.size())
98113
return vGfComponent[i];
99114
else
100-
return 0;
115+
return nullptr;
101116
}
102117

103118
/// Getnumber of Gf components
@@ -108,7 +123,7 @@ class TRestDetectorGeometry : public TGeoManager {
108123
if (i < vGfSensor.size())
109124
return vGfSensor[i];
110125
else
111-
return 0;
126+
return nullptr;
112127
}
113128

114129
/// Getnumber of Gf sensors

0 commit comments

Comments
 (0)