The question is about exporting of assemblies to gdml file using G4GDMLParser::Write(…)
It seems that if a given volume contains imprints of several (e.g two) different G4AssemblyVolume, then only one (the first) of them is exported to gdml <structure> section of that volume.
It looks like the choice of assemblies for gdml is made in recursively called G4GDMLWriteStructure::TraverseVolumeTree(…)
First it selects assembly based on its ID (e.g. 1) and the content of class variable addedAssemblies:
L691 if(std::find(addedAssemblies.cbegin(), addedAssemblies.cend(), assemblyID) == addedAssemblies.cend())
in order to add it to <structure> section as assembly (e.g. <assembly name=“Assembly_1”>…)
and then based on the imprint ID (e.g. 1), which is implemented as independent on assemblyID:
L704 if(std::find(addedImprints.cbegin(), addedImprints.cend(), imprintID) == addedImprints.cend())
the imprint of the assembly is added to the volume description.
If there are e.g. two assemblies Assembly_1 and Assembly_2 which are imprinted in the same volume V1, then for the assembly Assembly_2 and its imprint 1 the second condition (L704) is false as imprint 1 was added for Assembly_1 and the imprint 1 of Assembly_2 is skipped.
At least this is how it seems to work for my geometry.
I tried a simple change:
std::vector<int> addedImprints substituted by
std::map<int, std::vector<int> > addedImprints
and then in L704 and L760 accordingly:
if(std::find(addedImprints[assemblyID].begin(), addedImprints[assemblyID].end(), imprintID) == addedImprints[assemblyID].end()) …
That seemed to solve the problem.
Please could someone comment on these both problem and solution.
Many thanks in advance.