Accessing TGeoVolume by name and copy number

So, this is a question about Geant4 and ROOT. I am new to Geant4 and working with gdml.

I have a Geant4 code (not mine) which generates multiple copies of SiPM detector, like this:

G4Box* Sipm = new G4Box("SiPM", SiPM_X/2, SiPM_Y/2, SiPM_Z/2);
G4LogicalVolume* lSipm = new G4LogicalVolume(Sipm, Optmat, "SiPM");
 
for(G4int i=0; i<52; i++) {
    new G4PVPlacement(0, G4ThreeVector(SP_X[i], SP_Y[i], SiPM_Z[i]),
                                       "Physi_SiPM", lSipm, physiWorld, true, i);
  }

and I added exporting the geometry to gdml:

Geant4GM::Factory factory;
factory.SetDebug(1);
factory.Import(physiWorld);
XmlVGM::GDMLExporter xmlExporter2(&factory);
xmlExporter2.GenerateXMLGeometry();

It works nice, I have gdml file (this is only part related to SiPM):

   <solids>
      <box  lunit="cm" aunit="degree"
         name="SiPM_s"
         x="    0.6000"  y="    0.6000"  z="    0.0500" />
   </solids>
   <structure>
      <volume name="SiPM">
         <materialref ref="optgelmat"/>
         <solidref ref="SiPM_s"/>
      </volume>
      <volume name="World">
         <physvol>
            <volumeref ref="SiPM"/>
               <positionref ref="pos_6"/>
               <rotationref ref="rot_0"/>
         </physvol>
         <physvol>
            <volumeref ref="SiPM"/>
               <positionref ref="pos_7"/>
               <rotationref ref="rot_0"/>
         </physvol>
         <!-- and so on... -->
      </volume>
   </structure>

I can import it into ROOT and TEve:

Info in <TGeoManager::Import>: Reading geometry from file: World.gdml
Info in <TGeoManager::TGeoManager>: Geometry GDMLImport, Geometry imported from GDML created
Info in <TGeoManager::SetTopVolume>: Top volume is World. Master volume is World
Info in <TGeoNavigator::BuildCache>: --- Maximum geometry depth set to 100
Info in <TGeoManager::CheckGeometry>: Fixing runtime shapes...
Info in <TGeoManager::CheckGeometry>: ...Nothing to fix
Info in <TGeoManager::CloseGeometry>: Counting nodes...
Info in <TGeoManager::Voxelize>: Voxelizing...
Info in <TGeoManager::CloseGeometry>: Building cache...
Info in <TGeoManager::CountLevels>: max level = 2, max placements = 88
Info in <TGeoManager::CloseGeometry>: 117 nodes/ 11 volume UID's in Geometry imported from GDML
Info in <TGeoManager::CloseGeometry>: ----------------modeler ready----------------

and when displayed in TEve I see that all SiPMs have the same name SiPM_0:

How can I access each copy of the SiPMs? I can access only single volume using the SiPM name (not even SiPM_0 or any other number).

root [1] auto vol = aGeom->GetVolume("SiPM")
(TGeoVolume *) 0x55a41b7bf2c0
root [2] auto vol = aGeom->GetVolume("SiPM_0")
(TGeoVolume *) nullptr

What I would liek to be able to have/access e.g. SiPM clone nr 15 directly. How can it be done?
Perhaps can I somehow export from Geant4 the name already as SiPM_0, SiPM_1, etc.

Hi @rlalik,

I think this might be more of a question to the GEANT4 team. Have you tried at their forum: https://geant4-forum.web.cern.ch?

Cheers,

Marta

Maybe sth like;

TIter next(aGeom->GetListOfVolumes());

could help

there is also GetListOfMatrices and GetListOfNodes but not sure.

Thanks for reply. I will try, I though it can be somehow done via TGeoManager that’s why I asked here. But now I see that what gdml has is just plain list of all elements and I think the issue must be resolved in G4 or during export to GDML.