ROOT TGeometry not visualized correctly

Hello everyone,

i am quite new to G4. I currently started to work on an older project from our group, one where no visualization was implemented. My first goal was to get any vis to run, this i managed. But for some reason the geometry, which is constructed in ROOT as a TGeo is not correctly displayed in the viewer. I assume this to come from some missing Translation from ROOT to G4-Geometries, as e.g. a TGeoTube is shown as a Box.

As far as i understand the structure of the project, the TGeometry is loaded using TG4RootNavMgr, and then VirtualMonteCarlo(?) is used for the calculations. I tried using GDML instead of .root files, this fixed the visualization of the TGeoTubes, but crashed the simulations.

I have also read that this might have something to do with VGM not being complete?

Has anyone maybe encountered this problem before and can point me in the right direction?

Thanks in advance :slight_smile:

Geant4 Version: 11.3.0
Operating System: Ubuntu
Compiler/Version: g++ 13.3.0
CMake Version: 3.28.3


Hello,

Can you, please, let us know first, how you define your Geant4 application ? Do you define it in a standard Geant4 way, via user classes derived from Geant4 classes, or in the VirtualMonteCarlo framework, via user classes derived from TVirtualMCApplication, etc. ?

Thank you,

Hello Ivana,

i hope these Snippets answer your question.

The Detector Construction uses TVirtual Classes, but the rest of the programm uses G4 classes.

class PostDetConstruction: public TVirtualUserPostDetConstruction {...}

class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction{...}

The Geometry is initialized like this:

  TGeoManager  *geom = TGeoManager::Import(conf->GetGeomFileName().data());
  TG4RootNavMgr *mgr = TG4RootNavMgr::GetInstance(geom);
  
  G4RunManager* runManager = new G4RunManager;

  PostDetConstruction *pdc=new PostDetConstruction;
  mgr->Initialize(pdc);
  mgr->ConnectToG4();

Hello,

Thank you for clarification, so you have standard Geant4 application using geometry defined via ROOT TGeo with the G4Root navigator.

This means that your geometry is not translated fully in Geant4 geometry, and so Geant4 visualization does not work properly.

If you perform full conversion, either using VGM or via GDML file export/import, this would result in a complete Geant4 geometry and Geant4 visualization should work ok.

Best regards,