@@ -156,7 +156,10 @@ See that function for details.
156156#include " TGeoElement.h"
157157#include " TGeoShape.h"
158158#include " TGeoCompositeShape.h"
159+ #include " TGeoExtension.h"
159160#include " TGeoOpticalSurface.h"
161+ #include " TMap.h"
162+ #include " TObjString.h"
160163#include < cstdlib>
161164#include < string>
162165#include < map>
@@ -759,6 +762,41 @@ void TGDMLWrite::ExtractVolumes(TGeoNode *node)
759762 fGdmlE ->AddChild (volumeN, childN);
760763 }
761764
765+ // export auxiliary user-data if present (TMap of TObjString->TObjString)
766+ {
767+ TGeoRCExtension *rcext = (TGeoRCExtension *)volume->GrabUserExtension ();
768+ if (rcext) {
769+ TMap *auxmap = nullptr ;
770+ TObject *userObj = rcext->GetUserObject ();
771+ if (userObj && userObj->InheritsFrom (" TMap" )) {
772+ TMap *auxmap = (TMap *)userObj;
773+ TIterator *it = auxmap->MakeIterator ();
774+ TObject *k = nullptr ;
775+ while (k = it->Next ()) {
776+ TObject *valobj = auxmap->GetValue (k);
777+ if (!valobj || !k->InheritsFrom (" TObjString" ) || !valobj->InheritsFrom (" TObjString" ))
778+ continue ;
779+ TObjString *key = (TObjString *)k;
780+ TObjString *val = (TObjString *)valobj;
781+ TString auxtype = key->GetString ();
782+ TString auxvalue = val->GetString ();
783+ TString auxunit = " " ;
784+ Int_t pos = auxvalue.Index (' *' );
785+ if (pos >= 0 ) {
786+ auxunit = auxvalue (pos + 1 , auxvalue.Length ());
787+ auxvalue = auxvalue (0 , pos);
788+ }
789+ XMLNodePointer_t auxN = fGdmlE ->NewChild (nullptr , nullptr , " auxiliary" , nullptr );
790+ fGdmlE ->NewAttr (auxN, nullptr , " auxtype" , auxtype.Data ());
791+ fGdmlE ->NewAttr (auxN, nullptr , " auxvalue" , auxvalue.Data ());
792+ if (!auxunit.IsNull ())
793+ fGdmlE ->NewAttr (auxN, nullptr , " auxunit" , auxunit.Data ());
794+ fGdmlE ->AddChild (volumeN, auxN);
795+ }
796+ }
797+ }
798+ }
799+
762800 fVolCnt ++;
763801 // add volume/assembly node into the <structure> node
764802 fGdmlE ->AddChild (fStructureNode , volumeN);
0 commit comments