To build the project you need
Instructions for installing ROOT can be found here or here.
On lxplus (or another system with access to cvmfs
)
you can select a coherent set of packages through an LCG view by sourcing,
for example,
source /cvmfs/sft.cern.ch/lcg/views/LCG_104c/x86_64-el9-gcc13-opt/setup.sh
or, if you are using a (t)csh-type shell,
source /cvmfs/sft.cern.ch/lcg/views/LCG_104c/x86_64-el9-gcc13-opt/setup.csh
Other combinations of architectures and compilers are also available.
xcode-select --install
),xcode-select --install
),sudo port install gcc13
sudo port install root6
sudo port install gsl
To profit from the latest developments and bug fixes, it is recommended
to use the HEAD of the repository and build the project yourself following
the instructions below. Alternatively, if you have access to
cvmfs
, you can pick up a Garfield++ installation
from an LCG view, e. g.
source /cvmfs/sft.cern.ch/lcg/views/LCG_104c/x86_64-el9-gcc13-opt/setup.sh
source /cvmfs/sft.cern.ch/lcg/views/LCG_104c/x86_64-el9-gcc13-opt/share/Garfield/setupGarfield.sh
Instead of a release, it is also possible to use the LCG nightly builds
source /cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/latest/x86_64-el9-gcc13-opt/setup.sh
source /cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/latest/x86_64-el9-gcc13-opt/share/Garfield/setupGarfield.sh
To get hold of the source files, please follow the steps below.
$GARFIELD_HOME
pointing to the directory where the Garfield++ source files should be located.
Note that this directory must be empty or non-existing.
If you are using bash, type
export GARFIELD_HOME=/home/mydir/garfield
(replace /home/mydir/garfield
by the path of your choice). For (t)csh-type shells, type
setenv GARFIELD_HOME /home/mydir/garfield
You might also want to add the above lines to your
.bashrc
(or .cshrc
).
git clone ssh://git@gitlab.cern.ch:7999/garfield/garfieldpp.git $GARFIELD_HOME
git clone https://gitlab.cern.ch/garfield/garfieldpp.git $GARFIELD_HOME
thisroot.sh
(or thisroot.csh
) script.$GARFIELD_HOME
.
cd $GARFIELD_HOME
mkdir build
cd build
cmake $GARFIELD_HOME
make install
step) is set to
$GARFIELD_HOME/install
.
This default can be overriden using the flag CMAKE_INSTALL_PREFIX
:
cmake -DCMAKE_INSTALL_PREFIX=<installdir> $GARFIELD_HOME
WITH_EXAMPLES
specifies whether (some of) the example applications should be built
at the same time as the project itself. It defaults to ON
.
If you want to skip building the examples, set this flag to OFF
:
cmake -DWITH_EXAMPLES=OFF $GARFIELD_HOME
WITH_DOCS
is optional,
and should be passed if you wish to build the
Doxygen based documentation.
Please note that this requires an existing installation of Doxygen.
If CMake cannot locate Doxygen, its install location should be added into
CMAKE_PREFIX_PATH
.
cmake -DWITH_DOCS=ON $GARFIELD_HOME
make -j <number of cores on your machine>
make install
install
directory should now contain
the headers and the library.
setupGarfield.(c)sh
.
If you are using bash, type
source $GARFIELD_HOME/install/share/Garfield/setupGarfield.sh
If you are using a (t)csh-type shell, type
source $GARFIELD_HOME/install/share/Garfield/setupGarfield.csh
You might want to add these lines to your .bashrc
(or .cshrc
).
The script will set the environment variable
GARFIELD_INSTALL
pointing to the Garfield++ install
folder,
the environment variable
HEED_DATABASE
pointing to the directory containing the photoabsorption cross-section data,
and will prepend the install
directory to the
CMAKE_PREFIX_PATH
environment variable.
At present, the code is still frequently modified.
To obtain the latest version, use the command
git pull origin master
and rebuild the project.
As an example for building an application, we consider the
GEM example
located in $GARFIELD_HOME/Examples/Gem
.
cp -r $GARFIELD_HOME/Examples/Gem .
Gem
folder contains the source code
of the example, the CMakeLists.txt
file
for building the executable, and the field map files needed for running it.
thisroot.(c)sh
and setupGarfield.(c)sh
.
mkdir Gem/build; cd Gem/build
Makefile
and build the executable.
cmake ..
make
./gem
Thanks to PyROOT,
one can also use the Garfield++ classes in Python. After building the
project and setting up the environment following the instructions above (i. e. sourcing the setupGarfield.(c)sh
script),
one can load the library in the Python interpreter using
import ROOT
import Garfield
Examples can be found here (pythonized version of the drift tube example) and here (GEM example).
Please contact me to be added as a developer of the project.