Skip to content

Using Garfield++ with Python sometimes failes!

Hi,

first of, I am not sure if this is a problem with ROOT/Python in general, or just with Garfield++, but I observed it with Garfield++.

When trying to use the Python binding of Garfield++, sometimes very simple code fails. I observed this with the following example:

import ROOT
import Garfield
import ctypes

diode = ROOT.Garfield.ComponentTcad2d()
si = ROOT.Garfield.MediumSilicon()

This very simple file, when executed with Python gives the following errors:

input_line_25:1:21: error: 'Garfield' is not a class, namespace, or enumeration
template class std::Garfield::ComponentTcadBase<2>;
                    ^
libGarfieldDict dictionary forward declarations' payload:57:11: note: 'Garfield' declared here
namespace Garfield{class __attribute__((annotate("$clingAutoload$Garfield/ViewSignal.hh")))  ViewSignal;}
          ^
input_line_25:1:31: error: explicit instantiation of non-template class 'ComponentTcadBase'
template class std::Garfield::ComponentTcadBase<2>;
                              ^                ~~~

On the other hand, when switching around the definition of diode and si as

import ROOT
import Garfield
import ctypes

si = ROOT.Garfield.MediumSilicon()
diode = ROOT.Garfield.ComponentTcad2d()

no error occurs!