Cannot display TGeoNode in Eve

Hi, I am new to Eve, and I am having troubles displaying a super simplistic geometry. I generate a single box in a top volume using:

void worldMake() {
gSystem->Load("libGeom");
new TGeoManager("TPC", "TPC box");
TGeoMaterial *mat = new TGeoMaterial("Vacuum", 0, 0, 0 );
mat->SetTransparency( 50 );
TGeoMedium *med = new TGeoMedium("Vacuum", 1, mat );
TGeoVolume *top = gGeoManager->MakeBox("Top", med, 390. , 240., 1040. );
gGeoManager->SetTopVolume( top );
TGeoVolume *box = gGeoManager->MakeBox("Box", med, 257., 233., 1038. );
TGeoTranslation *tr1 = new TGeoTranslation( -130., 0., 0. );
top->AddNode( box, 1, tr1 );
gGeoManager->CloseGeometry();
gGeoManager->SetTopVisible();
TFile *tf = new TFile("worldgeom.root", "RECREATE");
gGeoManager->Write();
tf->Close();

}

then I try to read it in and try to display it with:

void world_test()
{
TEveManager::Create();
TFile::SetCacheFileDir(".");
gGeoManager = gEve->GetGeometry("worldgeom.root");
TGeoVolume* top = gGeoManager->GetTopVolume();
TEveGeoTopNode* box = new TEveGeoTopNode(gGeoManager,top->FindNode("Box"));
gEve->AddGlobalElement(box);
gEve->FullRedraw3D(kTRUE);
TGLViewer *v = gEve->GetDefaultGLViewer();
v->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0);
v->RefreshPadEditor(v);
v->DoDraw();
}

but it crashes at the TEveGeoTopNode constructor. Note, I am able to display both the top volume and the box with TGeoVolume::Draw(), but not with with TEveManager.
Any advice on what I am doing wrong?

@matevz can help you the Eve questions.

Note that the right to post code on the forum is described here:
https://root-forum.cern.ch/t/tips-for-efficient-and-successful-posting/28292/2

May be you can edit your post accordingly.

Hi,

If it crashes, I’d suspect top->FindNode("Box") returns 0. I’ll try running your code now.

Cheers,
Matevz

Yup, that was it … if I replace it with gGeoManager->GetTopNode() it shows up ok.

\m

1 Like

Hiding as per Newbie section rules.