Klaus Zenker

What is Garfield++

Garfield++ is a toolkit for a detailed simulation of particle detectors that use gas and semi-conductors as sensitive medium. The main area of application is currently in micropattern gaseous detectors. More information can be found on the official website:

http://garfieldpp.web.cern.ch/garfieldpp/
Most often non constant fields are involved in particle detector. Such fields can be calculated using finite element based software like CST STUDIO (CST). In order to use the field information calculated with CST within Garfield++ both programs need to be interfaced. In the following, it will be shown how to extract data simulated with CST, that can be imported later with Garfield++.

How to extract field information from CST

The data export from CST is based on the C++ interface provided by CST. This interface consists of the following files:

 $ CST STUDIO SUITE 2013/ResultReaderDLL/CSTResultReaderInterf.h
 $ CST STUDIO SUITE 2013/ResultReaderDLL/CSTResultReader.lib
 $ CST STUDIO SUITE 2013/CSTResultReader.dll
 $ CST STUDIO SUITE 2013/libiomp5md.dll
While dll files are needed during runtime, the header file and the library are needed to build a program based on the interface provided by CST. There is a C++ class called CSTResultsReader, that provides all methods for the data export and data handling. The documentation of this class can be found here:
CSTDataExport class documentation
There are two ways of using the data export class, that are introduced in the following.

Precompiled GUI

The easy way is a GUI, which is based on the CSTDataExport class. You can download the executable ( CSTDataExport.exe) and all you need to do in addition, is to add the CST installation directory to your PATH variable, meaning the dll files mentioned above need to be found by the program. You can check your path variable e.g. in a powershell using the command $ENV:PATH. If you want to add the CST path use the Control Panel in Windows and search for "environment" and you will find a System tool called something like "Edit environment variables for your account". Here you can add your own Path variable. Furthermore, you need to have Visual C++ Redistributable for Visual Studio 2012 installed. A screen shot of the GUI is shown in the picture below.

Screen shot of the CSTDataEport GUI.

The GUI should be self explaining, but if you need more information or if you have problems please read also the documentation of the CSTDataExport class, especially if you have problems exporting the potentials from CST. This Materials.xml file shows you the expected file format of the material information needed to export data. The GUI assumes that the CST tree that includes the data to be exported is named Potentials. This can be achieved by copying the potentials into a new tree using a CST post processing macro. This is illustrated in the figure below.

Screen shot of CST illustrating the macro path and settings used to copy potentials into a new tree called Potentials.

Command line based program

If the GUI does not work for you, the second possibility is to compile the command line based program Run_Readout or ExportFieldData (includes some dialogs to choose directories). This requires a C++ compiler for Windows, since there is only a Windows version of the CST library available. The source code for the program as well as for the CSTDataExport class can be found in the following svn repository:
https://svnsrv.desy.de/public/flctpcsw/public/CSTDataExport/

How to use Garfield++

In Garfield++ the class called ComponentCST handles the binary files produced in the data export step. There is a Users Guide for Garfield++ explaining all features of Garfield++.
In addition more details about the Garfield++ interface for CST can be found in this note:
"A Garfield++ interface for CST", LC-TOOL-2013-022, 07/2013