ROOT logo
ROOT » GEOM » GDML » TGDMLWrite

class TGDMLWrite: public TObject

TGDMLWrite Class


This class contains implementation of converting ROOT's gGeoManager
geometry to GDML file. gGeoManager is the instance of TGeoManager class
containing tree of geometries creating resulting geometry. GDML is xml
based format of file mirroring the tree of geometries according to GDML
schema rules. For more information about GDML see http://gdml.web.cern.ch.
Each object in ROOT is represented by xml tag (=xml node/element) in GDML.

This class is not needed to be instanciated. It should always be called
by gGeoManager->Export("xyz.gdml") method. Export is driven by extenstion
that is why ".gdml" is important in resulting name.

Whenever a new ROOT geometry object is implemented or there is a change
in GDML schema this class is needed to be updated to ensure proper mapping
between ROOT objects and GDML elements.

Current status of mapping ROOT -> GDML is implemented in method called
TGDMLWrite::ChooseObject and it contains following "map":

Solids:
TGeoBBox               ->           <box ... >
TGeoParaboloid         ->           <paraboloid ...>
TGeoSphere             ->           <sphere ...>
TGeoArb8               ->           <arb8 ...>
TGeoConeSeg            ->           <cone ...>
TGeoCone               ->           <cone ...>
TGeoPara               ->           <para ...>
TGeoTrap               ->           <trap ...>   or
-                      ->           <arb8 ...>
TGeoGtra               ->           <twistedtrap ...>   or
-                      ->           <trap ...>          or
-                      ->           <arb8 ...>
TGeoTrd1               ->           <trd ...>
TGeoTrd2               ->           <trd ...>
TGeoTubeSeg            ->           <tube ...>
TGeoCtub               ->           <cutTube ...>
TGeoTube               ->           <tube ...>
TGeoPcon               ->           <polycone ...>
TGeoTorus              ->           <torus ...>
TGeoPgon               ->           <polyhedra ...>
TGeoEltu               ->           <eltube ...>
TGeoHype               ->           <hype ...>
TGeoXtru               ->           <xtru ...>
TGeoCompositeShape     ->           <union ...>            or
-                      ->           <subtraction ...>      or
-                      ->           <intersection ...>

Special cases of solids:
TGeoScaledShape        ->           <elcone ...>  if scaled TGeoCone or
-                      ->           element without scale
TGeoCompositeShape     ->           <ellipsoid ...>
-                                   intersection of:
-                                   scaled TGeoSphere and TGeoBBox

Materials:
TGeoIsotope            ->           <isotope ...>
TGeoElement            ->           <element ...>
TGeoMaterial           ->           <material ...>
TGeoMixture            ->           <material ...>

Structure
TGeoVolume             ->           <volume ...>   or
-                      ->           <assembly ...>
TGeoNode               ->           <physvol ...>
TGeoPatternFinder      ->           <divisionvol ...>

There are options that can be set to change resulting document
Options:
g - is set by default in gGeoManager, this option ensures compatibility
-   with Geant4. It means:
-   -> atomic number of material will be changed if <1 to 1
-   -> if polycone is set badly it will try to export it correctly
-   -> if widht * ndiv + offset is more then width of object being divided
-      (in divisions) then it will be rounded so it will not exceed or
-      if kPhi divsion then it will keep range of offset in -360 -> 0
f - if this option is set then names of volumes and solids will have
-   pointer as a suffix to ensure uniqness of names
n - if this option is set then names will not have suffix, but uniqness is
-   of names is not secured
- - if none of this two options (f,n) is set then default behaviour is so
-   that incremental suffix is added to the names.
-   (eg. TGeoBBox_0x1, TGeoBBox_0x2 ...)

USAGE:
gGeoManager->Export("output.gdml");
gGeoManager->Export("output.gdml","","vg"); //the same as previous just
options are set explicitly
gGeoManager->Export("output.gdml","","vgf");
gGeoManager->Export("output.gdml","","gn");
gGeoManager->Export("output.gdml","","f");


NB:
Options discussed above are used only for TGDMLWrite class. There are
other options in the TGeoManager::Export(...) method that can be used.
See that function for details.


Function Members (Methods)

public:
TGDMLWrite()
TGDMLWrite(const TGDMLWrite&)
virtual~TGDMLWrite()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTObject::Clear(Option_t* = "")
virtual TObject*TObject::Clone(const char* newname = "") const
virtual Int_tTObject::Compare(const TObject* obj) const
virtual voidTObject::Copy(TObject& object) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
virtual const char*TObject::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
virtual const char*TObject::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTObject::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTObject::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTObject::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
TGDMLWrite&operator=(const TGDMLWrite&)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTObject::Print(Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidSetG4Compatibility(Bool_t G4Compatible)
voidSetNamingSpeed(TGDMLWrite::ENamingType naming)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector&)
static voidStartGDMLWriting(TGeoManager* geomanager, const char* filename, TString option)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
voidWriteGDMLfile(TGeoManager* geomanager, const char* filename = "test.gdml", TString option = "")
protected:
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
Bool_tCanProcess(TObject* pointer)
XMLNodePointer_tChooseObject(TGeoShape* geoShape)
XMLNodePointer_tCreateArb8N(TGeoArb8* geoShape)
XMLNodePointer_tCreateAtomN(Double_t atom, const char* unit = "g/mole")
XMLNodePointer_tCreateBoxN(TGeoBBox* geoShape)
XMLNodePointer_tCreateCommonBoolN(TGeoCompositeShape* geoShape)
XMLNodePointer_tCreateConeN(TGeoConeSeg* geoShape)
XMLNodePointer_tCreateConeN(TGeoCone* geoShape)
XMLNodePointer_tCreateCutTubeN(TGeoCtub* geoShape)
XMLNodePointer_tCreateDivisionN(Double_t offset, Double_t width, Int_t number, const char* axis, const char* unit, const char* volref)
XMLNodePointer_tCreateDN(Double_t density, const char* unit = "g/cm3")
XMLNodePointer_tCreateElConeN(TGeoScaledShape* geoShape)
XMLNodePointer_tCreateElementN(TGeoElement* element, XMLNodePointer_t materials, const char* name)
XMLNodePointer_tCreateEllipsoidN(TGeoCompositeShape* geoShape, TString elName)
XMLNodePointer_tCreateEltubeN(TGeoEltu* geoShape)
TGeoCompositeShape*CreateFakeCtub(TGeoCtub* geoShape)
XMLNodePointer_tCreateFractionN(Double_t percentage, const char* refName)
XMLNodePointer_tCreateHypeN(TGeoHype* geoShape)
XMLNodePointer_tCreateIsotopN(TGeoIsotope* isotope, const char* name)
XMLNodePointer_tCreateMaterialN(TGeoMaterial* material, TString mname)
XMLNodePointer_tCreateMixtureN(TGeoMixture* mixture, XMLNodePointer_t materials, TString mname)
XMLNodePointer_tCreateParaboloidN(TGeoParaboloid* geoShape)
XMLNodePointer_tCreateParaN(TGeoPara* geoShape)
XMLNodePointer_tCreatePhysVolN(const char* volref, const char* posref, const char* rotref, XMLNodePointer_t scaleN)
XMLNodePointer_tCreatePolyconeN(TGeoPcon* geoShape)
XMLNodePointer_tCreatePolyhedraN(TGeoPgon* geoShape)
XMLNodePointer_tCreatePositionN(const char* name, TGDMLWrite::Xyz position, const char* type = "position", const char* unit = "cm")
XMLNodePointer_tCreateRotationN(const char* name, TGDMLWrite::Xyz rotation, const char* type = "rotation", const char* unit = "deg")
XMLNodePointer_tCreateSetupN(const char* topVolName, const char* name = "default", const char* version = "1.0")
XMLNodePointer_tCreateSphereN(TGeoSphere* geoShape)
XMLNodePointer_tCreateTorusN(TGeoTorus* geoShape)
XMLNodePointer_tCreateTrapN(TGeoTrap* geoShape)
XMLNodePointer_tCreateTrdN(TGeoTrd1* geoShape)
XMLNodePointer_tCreateTrdN(TGeoTrd2* geoShape)
XMLNodePointer_tCreateTubeN(TGeoTubeSeg* geoShape)
XMLNodePointer_tCreateTubeN(TGeoTube* geoShape)
XMLNodePointer_tCreateTwistedTrapN(TGeoGtra* geoShape)
XMLNodePointer_tCreateXtrusionN(TGeoXtru* geoShape)
XMLNodePointer_tCreateZplaneN(Double_t z, Double_t rmin, Double_t rmax)
XMLNodePointer_tExtractMaterials(TList* materialsLst)
TStringExtractSolid(TGeoShape* volShape)
voidExtractVolumes(TGeoVolume* volume)
TStringGenName(TString oldname)
TStringGenName(TString oldname, TString objPointer)
TStringGetPattAxis(Int_t divAxis, const char* pattName, TString& unit)
TGDMLWrite::XyzGetXYZangles(const Double_t* rotationMatrix)
Bool_tIsInList(TGDMLWrite::NameList list, TString name2check)
Bool_tIsNullParam(Double_t parValue, TString parName, TString objName)
XMLNodePointer_tStartAssemblyN(const char* name)
XMLNodePointer_tStartVolumeN(const char* name, const char* solid, const char* material)
voidUnsetTemporaryBits(TGeoManager* geoMng)

Data Members

public:
enum ENamingType { kelegantButSlow
kwithoutSufixNotUniq
kfastButUglySufix
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
private:
TGDMLWrite::StructLst*fAccPattlist of accepted patterns for division
UInt_tfActNameErrcount of name errors
XMLNodePointer_tfDefineNodemain <define> node...
TGDMLWrite::StructLst*fElementListlist of elements
TXMLEngine*fGdmlExml engine pointer
XMLDocPointer_tfGdmlFilepointer storing xml file
TGDMLWrite::StructLst*fIsotopeListlist of isotopes
XMLNodePointer_tfMaterialsNodemain <materials> node...
TGDMLWrite::NameLst*fNameListlist of names (pointer mapped)
Int_tfPhysVolCntcount of physical volumes
TGDMLWrite::StructLst*fRejShapelist of rejected shapes
UInt_tfSolCntcount of name solids
XMLNodePointer_tfSolidsNodemain <solids> node...
XMLNodePointer_tfStructureNodemain <structure> node...
TStringfTopVolumeNamename of top volume
Int_tfVolCntcount of volumes
Bool_tfgG4Compatibilityinput option for Geant4 compatibility
static TGDMLWrite*fgGDMLWritepointer to gdml writer
Int_tfgNamingSpeedinput option for volume and solid naming
static const UInt_tfgkMaxNameErrmaximum number of errors for naming
static const UInt_tfgkProcBit14th bit is set when solid is processed
static const UInt_tfgkProcBitVol19th bit is set when volume is processed

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TGDMLWrite()
 Default constructor.
~TGDMLWrite()
 Destructor.
void SetNamingSpeed(TGDMLWrite::ENamingType naming)
 Set convetion of naming solids and volumes
void WriteGDMLfile(TGeoManager* geomanager, const char* filename = "test.gdml", TString option = "")
 Wrapper of all exporting methods
 Creates blank GDML file and fills it with gGeoManager structure converted
 to GDML structure of xml nodes
XMLNodePointer_t ExtractMaterials(TList* materialsLst)
 Method exporting materials
TString ExtractSolid(TGeoShape* volShape)
 Method creating solid to xml file and returning its name
void ExtractVolumes(TGeoVolume* volume)
 Method extracting geometry structure recursively
XMLNodePointer_t CreateAtomN(Double_t atom, const char* unit = "g/mole")
 Creates "atom" node for GDML
XMLNodePointer_t CreateDN(Double_t density, const char* unit = "g/cm3")
 Creates "D" density node for GDML
XMLNodePointer_t CreateFractionN(Double_t percentage, const char* refName)
 Creates "fraction" node for GDML
XMLNodePointer_t CreateIsotopN(TGeoIsotope* isotope, const char* name)
 Creates "isotope" node for GDML
XMLNodePointer_t CreateElementN(TGeoElement* element, XMLNodePointer_t materials, const char* name)
 Creates "element" node for GDML
element node and attribute
XMLNodePointer_t CreateMixtureN(TGeoMixture* mixture, XMLNodePointer_t materials, TString mname)
 Creates "material" node for GDML with references to other sub elements
XMLNodePointer_t CreateMaterialN(TGeoMaterial* material, TString mname)
 Creates "material" node for GDML
XMLNodePointer_t CreateBoxN(TGeoBBox* geoShape)
 Creates "box" node for GDML
XMLNodePointer_t CreateParaboloidN(TGeoParaboloid* geoShape)
 Creates "paraboloid" node for GDML
XMLNodePointer_t CreateSphereN(TGeoSphere* geoShape)
 Creates "sphere" node for GDML
XMLNodePointer_t CreateArb8N(TGeoArb8* geoShape)
 Creates "arb8" node for GDML
XMLNodePointer_t CreateConeN(TGeoConeSeg* geoShape)
 Creates "cone" node for GDML from TGeoConeSeg object
XMLNodePointer_t CreateConeN(TGeoCone* geoShape)
 Creates "cone" node for GDML from TGeoCone object
XMLNodePointer_t CreateParaN(TGeoPara* geoShape)
 Creates "para" node for GDML
XMLNodePointer_t CreateTrapN(TGeoTrap* geoShape)
 Creates "trap" node for GDML
XMLNodePointer_t CreateTwistedTrapN(TGeoGtra* geoShape)
 Creates "twistedtrap" node for GDML
XMLNodePointer_t CreateTrdN(TGeoTrd1* geoShape)
 Creates "trd" node for GDML from object TGeoTrd1
XMLNodePointer_t CreateTrdN(TGeoTrd2* geoShape)
 Creates "trd" node for GDML from object TGeoTrd2
XMLNodePointer_t CreateTubeN(TGeoTubeSeg* geoShape)
 Creates "tube" node for GDML  from  object TGeoTubeSeg
XMLNodePointer_t CreateCutTubeN(TGeoCtub* geoShape)
 Creates "cutTube" node for GDML
XMLNodePointer_t CreateTubeN(TGeoTube* geoShape)
 Creates "tube" node for GDML from  object TGeoTube
XMLNodePointer_t CreateZplaneN(Double_t z, Double_t rmin, Double_t rmax)
 Creates "zplane" node for GDML
XMLNodePointer_t CreatePolyconeN(TGeoPcon* geoShape)
 Creates "polycone" node for GDML
XMLNodePointer_t CreateTorusN(TGeoTorus* geoShape)
 Creates "torus" node for GDML
XMLNodePointer_t CreatePolyhedraN(TGeoPgon* geoShape)
 Creates "polyhedra" node for GDML
XMLNodePointer_t CreateEltubeN(TGeoEltu* geoShape)
 Creates "eltube" node for GDML
XMLNodePointer_t CreateHypeN(TGeoHype* geoShape)
 Creates "hype" node for GDML
XMLNodePointer_t CreateXtrusionN(TGeoXtru* geoShape)
 Creates "xtru" node for GDML
XMLNodePointer_t CreateEllipsoidN(TGeoCompositeShape* geoShape, TString elName)
 Creates "ellipsoid" node for GDML
 this is a special case, because ellipsoid is not defined in ROOT
 so when intersection of scaled sphere and TGeoBBox is found,
 it is considered as an ellipsoid
XMLNodePointer_t CreateElConeN(TGeoScaledShape* geoShape)
 Creates "elcone" (elliptical cone) node for GDML
 this is a special case, because elliptical cone is not defined in ROOT
 so when scaled cone is found, it is considered as a elliptical cone
XMLNodePointer_t CreateCommonBoolN(TGeoCompositeShape* geoShape)
 Creates common part of union intersection and subtraction nodes
XMLNodePointer_t CreatePositionN(const char* name, TGDMLWrite::Xyz position, const char* type = "position", const char* unit = "cm")
 Creates "position" kind of node for GDML
XMLNodePointer_t CreateRotationN(const char* name, TGDMLWrite::Xyz rotation, const char* type = "rotation", const char* unit = "deg")
 Creates "rotation" kind of node for GDML
XMLNodePointer_t CreateSetupN(const char* topVolName, const char* name = "default", const char* version = "1.0")
 Creates "setup" node for GDML
XMLNodePointer_t StartVolumeN(const char* name, const char* solid, const char* material)
 Creates "volume" node for GDML
XMLNodePointer_t StartAssemblyN(const char* name)
 Creates "assembly" node for GDML
XMLNodePointer_t CreatePhysVolN(const char* volref, const char* posref, const char* rotref, XMLNodePointer_t scaleN)
 Creates "physvol" node for GDML
XMLNodePointer_t CreateDivisionN(Double_t offset, Double_t width, Int_t number, const char* axis, const char* unit, const char* volref)
 Creates "divisionvol" node for GDML
XMLNodePointer_t ChooseObject(TGeoShape* geoShape)
 Chooses the object and method that should be used for processing object
TGeoCompositeShape* CreateFakeCtub(TGeoCtub* geoShape)
 Method creating cutTube as an intersection of tube and two boxes
 - not used anymore because cutube is supported in Geant4 9.5
Bool_t IsInList(TGDMLWrite::NameList list, TString name2check)
 Checks whether name2check is in (NameList) list
TString GenName(TString oldname)
NCNAME basic restrictions
Replace "$" character with empty character etc.
TString GenName(TString oldname, TString objPointer)
 Important function which is responsible for naming volumes, solids and materials
Bool_t CanProcess(TObject* pointer)
 Method which tests whether solids can be processed
TString GetPattAxis(Int_t divAxis, const char* pattName, TString& unit)
 Method that retrieves axis and unit along which object is divided
Bool_t IsNullParam(Double_t parValue, TString parName, TString objName)
 Check for null parameter to skip the NULL objects
void UnsetTemporaryBits(TGeoManager* geoMng)
 Unsetting bits that were changed in gGeoManager during export so that export
 can be run more times with the same instance of gGeoManager.
TGDMLWrite()
void StartGDMLWriting(TGeoManager* geomanager, const char* filename, TString option)
static function -
options:
  g - set by default - geant4 compatibility
  f,n - if none of this two is set then naming convention is
        with incremental suffix, if "f" then suffix is pointer
        if "n" then there is no suffix, but uniqness of names
        is not secured.
void SetG4Compatibility(Bool_t G4Compatible)
Xyz GetXYZangles(const Double_t* rotationMatrix)
II. Utility methods