In order to use the GDMLWriter in your application you need to
instanciate the writer class specifying the location of the schema
(that location will then be stored in the .gdml file) and the name of
the output file
#include "G4Writer/G4GDMLWriter.h"
G4GDMLWriter g4writer("GDMLSchema/gdml.xsd", "geo.gdml");
In order to create the .gdml file you need to call DumpGeometryInfo
method, with the argument being the pointer to the top PhysicalVolume
of the geometry tree you want to store
try
{
g4writer.DumpGeometryInfo(g4TopVolume);
}
catch(std::logic_error &lerr)
{
std::cout << "Caught the exception: "
<< lerr.what () << std::endl;
}
Finally, when you build your executable, you need to link with two
libraries from CPPGDML: libWriter and libG4Writer (or the global libgdml library
containing the whole GDML system).