Detector will not show in any examples

I’ve downloaded geant4 multiple times from the source code but I haven’t had an updated video to look at. The steps I’ve done to download are as follows:

  1. Run Oracle VM Virtualbox
  2. Download geant4 source code from website
  3. Create a directory named “software” for geant4 to be downloaded in.
  4. Create a directory named “geant4”
  5. Untar the geant4 source code download file
  6. “cd” into geant4.11.1.2 file
  7. Download all g++, Qt5, cmake gui, etc. packages.
  8. Make a “build” directory, then cd into it, then “ccmake”
  9. Change the installation file directory to “geant4.11.1.2-install”
  10. Turn on the “install data” and necessary software libraries like “Qt” and “raytracing mode”
  11. compile and generate a make file then

_Geant4 Version:11.1.2
_Operating System: Oracle VM Virtualbox: Ubuntu 22.04
_Compiler/Version: GCC
_CMake Version:3.22.1


Could you be a little more specific? With what options did you build Geant4, and which examples did you build and run?

Sorry, I updated my response, but to be much more specific, I did the exact steps that was done in this video on youtube. It’s a little outdated and I don’t know if there was anything I had to do beforehand. But I followed his exact steps.

O.k., thanks! When you start an example from the terminal, let’s say basic/B1 for clarity, what output do you get, and what, if any window pops up? You can post the terminal output in fenced code blocks, and it’s o.k. to post a screenshot of the created GUI window, if any.


Geant4 version Name: geant4-11-01-patch-02 (15-June-2023)
Copyright : Geant4 Collaboration
References : NIM A 506 (2003), 250-303
: IEEE-TNS 53 (2006), 270-278
: NIM A 835 (2016), 186-225
WWW : http://geant4.org/


<<< Reference Physics List QBBC
Visualization Manager instantiating with verbosity “warnings (3)”…
Visualization Manager initialising…
Registering graphics systems…

You have successfully registered the following graphics systems.
Registered graphics systems are:
ASCIITree (ATree)
DAWNFILE (DAWNFILE)
G4HepRepFile (HepRepFile)
RayTracer (RayTracer)
VRML2FILE (VRML2FILE)
gMocrenFile (gMocrenFile)
TOOLSSG_OFFSCREEN (TSG_OFFSCREEN)
TOOLSSG_OFFSCREEN (TSG_OFFSCREEN, TSG_FILE)
OpenGLImmediateQt (OGLIQt, OGLI)
OpenGLStoredQt (OGLSQt, OGL, OGLS)
OpenGLImmediateX (OGLIX, OGLIQt_FALLBACK)
OpenGLStoredX (OGLSX, OGLSQt_FALLBACK)
RayTracerX (RayTracerX)
TOOLSSG_X11_GLES (TSG_X11_GLES, TSGX11, TSG_QT_GLES_FALLBACK)
TOOLSSG_QT_GLES (TSG_QT_GLES, TSGQt, TSG)

Registering model factories…

You have successfully registered the following model factories.
Registered model factories:
generic
drawByAttribute
drawByCharge
drawByOriginVolume
drawByParticleID
drawByEncounteredVolume

Registered models:
None

Registered filter factories:
attributeFilter
chargeFilter
originVolumeFilter
particleFilter
encounteredVolumeFilter

Registered filters:
None

You have successfully registered the following user vis actions.
Run Duration User Vis Actions: none
End of Event User Vis Actions: none
End of Run User Vis Actions: none

Some /vis commands (optionally) take a string to specify colour.
“/vis/list” to see available colours.
/control/saveHistory
/run/verbose 2

Change the default number of threads (in multi-threaded mode)

#/run/numberOfThreads 4

Initialize kernel

/run/initialize
userDetector->Construct() start.
Checking overlaps for volume Envelope:0 (G4Box) … OK!
Checking overlaps for volume Shape1:0 (G4Cons) … OK!
Checking overlaps for volume Shape2:0 (G4Trd) … OK!
World is registered to the default region.
physicsList->Construct() start.

HadronInelasticQBBC Construct Process:

Emin(FTFP)= 3 GeV; Emax(FTFP)= 100000 GeV
Emin(BERT)= 1 GeV; Emax(BERT)= 6 GeV; Emax(BERTpions)= 12 GeV;
Emin(BIC) = 0 GeV; Emax(BIC)= 1.5 GeV.

physicsList->CheckParticleList() start.
physicsList->setCut() start.

Visualization setting

/control/execute vis.mac

Macro file for the visualization setting in the initialization phase

of the B1 example when running in interactive mode

Use these open statements to open selected visualization

Use this open statement to create an OpenGL view:

/vis/open OGL 600x600-0+0
/vis/sceneHandler/create OGL
/vis/viewer/create ! ! 600x600-0+0
/vis/viewer/refresh

Use this open statement to create an OpenInventor view:

#/vis/open OI

Use this open statement to create a .prim file suitable for

viewing in DAWN:

#/vis/open DAWNFILE

Use this open statement to create a .heprep file suitable for

viewing in HepRApp:

#/vis/open HepRepFile

Use this open statement to create a .wrl file suitable for

viewing in a VRML viewer:

#/vis/open VRML2FILE

Use this open statement to create an offscreen file with TSG:

#/vis/open TSG_OFFSCREEN 1200x1200

See the tsg_offscreen.mac file for more commands to change

the file format, file name, picture size, etc.

Disable auto refresh and quieten vis messages whilst scene and

trajectories are established:

/vis/viewer/set/autoRefresh false
/vis/verbose errors
Visualization verbosity changed to errors (2)

Draw geometry:

/vis/drawVolume
/vis/scene/create
/vis/scene/add/volume world -1 -1 none m 0 0 0 0 0 0
/vis/sceneHandler/attach

Specify view angle:

/vis/viewer/set/viewpointVector -1 0 0
/vis/viewer/set/lightsVector -1 0 0

Specify style (surface, wireframe, auxiliary edges,…)

/vis/viewer/set/style wireframe
/vis/viewer/set/auxiliaryEdge true
/vis/viewer/set/lineSegmentsPerCircle 100

Draw smooth trajectories at end of event, showing trajectory points

as markers 2 pixels wide:

/vis/scene/add/trajectories smooth
/tracking/storeTrajectory 2
Attributes available for modeling and filtering with
“/vis/modeling/trajectories/create/drawByAttribute” and
“/vis/filtering/trajectories/create/attributeFilter” commands:
G4TrajectoriesModel:
Event ID (EventID): G4int
Run ID (RunID): G4int
G4SmoothTrajectory:
Charge (Ch): unit: e+ (G4double)
Track ID (ID): G4int
Initial kinetic energy (IKE): G4BestUnit (G4double)
Initial momentum magnitude (IMag): G4BestUnit (G4double)
Initial momentum (IMom): G4BestUnit (G4ThreeVector)
No. of points (NTP): G4int
PDG Encoding (PDG): G4int
Parent ID (PID): G4int
Particle Name (PN): G4String
G4SmoothTrajectoryPoint:
Auxiliary Point Position (Aux): G4BestUnit (G4ThreeVector)
Step Position (Pos): G4BestUnit (G4ThreeVector)
/vis/scene/notifyHandlers
/vis/modeling/trajectories/create/drawByCharge
/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true
/vis/scene/notifyHandlers scene-0
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2
/vis/scene/notifyHandlers scene-0

(if too many tracks cause core dump => /tracking/storeTrajectory 0)

Draw hits at end of event:

#/vis/scene/add/hits

To draw only gammas:

#/vis/filtering/trajectories/create/particleFilter
#/vis/filtering/trajectories/particleFilter-0/add gamma

To invert the above, drawing all particles except gammas,

keep the above two lines but also add:

#/vis/filtering/trajectories/particleFilter-0/invert true

Many other options are available with /vis/modeling and /vis/filtering.

For example, to select colour by particle ID:

#/vis/modeling/trajectories/create/drawByParticleID
#/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true

To select or override default colours (note: e+ is blue by default):

#/vis/modeling/trajectories/list
#/vis/modeling/trajectories/drawByParticleID-0/set e+ yellow

To superimpose all of the events from a given run:

/vis/scene/endOfEventAction accumulate

Decorations

Name

/vis/set/textColour green
/vis/set/textLayout right
/vis/scene/add/text2D 0.9 -.9 24 ! ! exampleB1
/vis/scene/notifyHandlers

or, if your system does not support right-adjustment

#/vis/scene/add/text2D 0 -.9 24 ! ! exampleB1
/vis/set/textLayout
/vis/set/textColour

Axes, scale, etc.

/vis/scene/add/scale
/vis/scene/notifyHandlers
/vis/scene/add/axes
/vis/scene/notifyHandlers
/vis/scene/add/eventID
/vis/scene/notifyHandlers
/vis/scene/add/date
/vis/scene/notifyHandlers
/vis/scene/add/logo2D
/vis/scene/notifyHandlers
/vis/scene/add/logo
/vis/scene/notifyHandlers

Frame

/vis/set/colour red
/vis/set/lineWidth 2
/vis/scene/add/frame
/vis/scene/notifyHandlers
/vis/set/colour
/vis/set/lineWidth

Attach text to one edge of Shape1, with a small, fixed offset

/vis/scene/add/text 0 6 -4 cm 18 4 4 Shape1
/vis/scene/notifyHandlers

Attach text to one corner of Shape2, with a small, fixed offset

/vis/scene/add/text 6 7 10 cm 18 4 4 Shape2
/vis/scene/notifyHandlers

To get nice view

Make the “World” box invisible

/vis/geometry/set/visibility World 0 false
/vis/scene/notifyHandlers

“Envelope” is transparent blue to represent water

/vis/geometry/set/colour Envelope 0 0 0 1 .3
/vis/scene/notifyHandlers
/vis/viewer/set/style surface
/vis/viewer/set/hiddenMarker true
/vis/viewer/set/viewpointThetaPhi 120 150

Re-establish auto refreshing and verbosity:

/vis/viewer/set/autoRefresh true
/vis/viewer/refresh
/vis/verbose warnings
Visualization verbosity changed to warnings (3)

For file-based drivers, use this to create an empty detector view:

#/vis/viewer/flush
Changing export format to “jpg”

It looks like B1 is running fine. you can give it commands such as

/run/beamOn 100

or any of the commands listed. If you want a gui/visualizer (such as in the video) you have to specify what gui you will use in the install commands. I believe that you can still open a gui based on your install, you will just have to look at what commands are run in the vis.mac and init_vis.mac macro files

Indeed, that output looks like things are running fine, and that all the relevant drivers for Qt are present. Could you try running with

$ G4UI_USE_TCSH=1 ./exampleB1

please? That should disable creation of the GUI, and just start things in the terminal with a normal command prompt, with the last few lines like:

# Re-establish auto refreshing and verbosity:
/vis/viewer/set/autoRefresh true
ERROR: G4VisCommandsViewerSet::SetNewValue: no current viewer.
/vis/verbose warnings
Visualization verbosity changed to warnings (3)
#
# For file-based drivers, use this to create an empty detector view:
#/vis/viewer/flush
Idle>

This is just to confirm the overall functionality of the executable. Similarly, it can be run in batch mode as:

$ ./exampleB1 ./exampleB1.in

with the last few lines of output looking like

--------------------End of Global Run-----------------------
 The run consists of 1000 
 Cumulated dose per run, in scoring volume : 5.38296 nanoGy  rms = 144.721 picoGy 
------------------------------------------------------------

Graphics systems deleted.
Visualization Manager deleting...
$

If this works, then there’s likely something wrong with the graphics setup of the virtual machine, but let’s see if things work without Vis first.

No, I typed that in and it didn’t change. Here’s what pops up as usual.

Going to move this to the Vis category purely for exposure there. I think there have been similar issues in the past with VMs like this, so people there may be able to assist better!

Mmm. What happens if you try one (or more) of the other drivers? E.g:

/vis/open TSG

or, to be really sure this is only a graphics problem,

/vis/open TSG_OFFSCREEN

and at end of run

/vis/viewer/refresh

This should create a file something like g4tsg_offscreen_zb_png_1.png which should show the detector and, if you have /run/beamOn with trajectories activated (/vis/scene/add/trajectories), should show trajectories as well.

There have been issues when building both Qt and X11 on some systems. Try rebuilding without X11.

Here is what happened when I did them both, but do I put the name of the visualizer after like “/vis/viewer/refresh[TSG]” or leave it blank, because it didn’t do anything,


I think.

So…it’s definitely a problem with the graphics on your system, Oracle VM Virtualbox.

One more thing to try - as I said:

Otherwise, your options are to get a native Unix system, or build and run under Windows using Visual C++, or try another virtual machine. I have no personal experience of virtual machines, but I have heard the Windows Subsystem for Linux, WSL, works.

Hope this helps.

John