@@ -1310,7 +1310,6 @@ XMLNodePointer_t TGDMLParse::MatProcess(TXMLEngine *gdml, XMLNodePointer_t node,
13101310 TGeoMixture *mix = nullptr ;
13111311 TGeoMaterial *mat = nullptr ;
13121312 TString tempconst = " " ;
1313- TString matname;
13141313 Bool_t composite = kFALSE ;
13151314
13161315 if (z == 1 ) {
@@ -1546,25 +1545,29 @@ XMLNodePointer_t TGDMLParse::MatProcess(TXMLEngine *gdml, XMLNodePointer_t node,
15461545 Double_t weight;
15471546
15481547 for (fractions f = fracmap.begin (); f != fracmap.end (); ++f) {
1549- matname = f->first ;
1550- matname = NameShort (matname);
1551-
1552- TGeoMaterial *mattmp = (TGeoMaterial *)gGeoManager ->GetListOfMaterials ()->FindObject (matname);
1548+ TGeoMaterial *mattmp = nullptr ;
1549+ auto material = fmatmap.find (f->first );
1550+ if (material != fmatmap.end ())
1551+ mattmp = (TGeoMaterial *)material->second ;
1552+ else {
1553+ auto mixture = fmixmap.find (f->first );
1554+ if (mixture != fmixmap.end ())
1555+ mattmp = (TGeoMixture *)mixture->second ;
1556+ }
1557+ auto element = felemap.find (f->first );
15531558
1554- if (mattmp || ( felemap.find (f-> first ) ! = felemap.end ())) {
1559+ if ((composite && element != felemap.end ()) || (!composite && (mattmp || element ! = felemap.end () ))) {
15551560 if (composite) {
15561561 natoms = (Int_t)f->second ;
1557-
1558- mix->AddElement (felemap[f->first ], natoms);
1559-
1562+ mix->AddElement ((TGeoElement *)element->second , natoms);
15601563 }
15611564
15621565 else {
15631566 weight = f->second ;
15641567 if (mattmp) {
15651568 mix->AddElement (mattmp, weight);
15661569 } else {
1567- mix->AddElement (felemap[f-> first ] , weight);
1570+ mix->AddElement ((TGeoElement *)element-> second , weight);
15681571 }
15691572 }
15701573 }
@@ -1573,13 +1576,16 @@ XMLNodePointer_t TGDMLParse::MatProcess(TXMLEngine *gdml, XMLNodePointer_t node,
15731576
15741577 medid = medid + 1 ;
15751578
1579+ if (mixflag == 1 )
1580+ fmixmap[local_name.Data ()] = mix;
1581+ else if (mixflag == 0 )
1582+ fmatmap[local_name.Data ()] = mat;
1583+
15761584 TGeoMedium *med = mgr->GetMedium (NameShort (name));
15771585 if (!med) {
15781586 if (mixflag == 1 ) {
1579- fmixmap[local_name.Data ()] = mix;
15801587 med = new TGeoMedium (NameShort (name), medid, mix);
15811588 } else if (mixflag == 0 ) {
1582- fmatmap[local_name.Data ()] = mat;
15831589 med = new TGeoMedium (NameShort (name), medid, mat);
15841590 }
15851591 } else if (gDebug >= 2 ) {
0 commit comments