Hello,
I am running Geant4 version 10.7.p01 on Windows 10.
I am trying to view electron trajectories with electrons flying in an electric field. I can see the electron trajectories while the program runs (see screenshots), but when the program reaches the end of the run, the trajectories disappear.
I had tried this before on Linux and I found the trajectories disappeared rapidly, but now they disappear only at the end of the run. The difference could be due to me now running on Windows (as opposed to Linux before) or using the latest release of Geant4.
I had previously solved my problems by simulating electron trajectories in vacuum using COMSOL and in a material using Geant4 and pass the trajectory information between them. This works fine (albeit rather slow) for simple geometries (e.g. a flat plane), but becomes difficult for complex geometries. Hence, my return to trying to see if I can get this to work solely within Geant4.
I find that if I set the electric field to zero, the electron trajectories do not disappear at the end of the run.
Previously, the problems appeared to have something to do with my use of GDML input files. I am back to using the GDML input again as it is needed for the complex geometries.
Any help appreciated.
Chris
Output to screen (after all the trajectory information is output to screen) is below.
Run terminated.
Run Summary
Number of events processed : 200
User=1.328000s Real=4.138877s Sys=0.703000s
Energy deposited in detector Sample = 1.7358114275e+05 eV
100 events have been kept for refreshing and/or reviewing.
“/vis/reviewKeptEvents” to review them one by one.
“/vis/enable”, then “/vis/viewer/flush” or “/vis/viewer/rebuild” to see them accumulated.
WARNING: G4VisManager::EndOfRun: Automatic event keeping was suspended.
The number of events in the run exceeded the maximum, 100, that may be
kept by the vis manager.
The number of events kept by the vis manager can be changed with
"/vis/scene/endOfEventAction accumulate ", where N is the
maximum number you wish to allow. N < 0 means “unlimited”.
/detectors/PlaneR/outputCounts results/YieldR_Silicon.dat
Detector counts written to file results/YieldR_Silicon.dat
/detectors/PlaneT/outputCounts results/YieldT_Silicon.dat
Detector counts written to file results/YieldT_Silicon.dat
#/detectors/PlaneR/outputEnergyPDF {directory}/EnergyPDF_{material}{energy}.dat
#/detectors/PlaneR/outputEnergyHistogram {directory}/EnergyHistogram{material}{energy}.dat
/detectors/PlaneR/outputHits results/EmissionR_Silicon_1000eV.dat
Detector hits written to file results/EmissionR_Silicon_1000eV.dat
/detectors/PlaneT/outputHits results/EmissionT_Silicon_1000eV.dat
Detector hits written to file results/EmissionT_Silicon_1000eV.dat
/detectors/Sample/outputHits results/EmissionSample_Silicon_1000.dat
Detector hits written to file results/EmissionSample_Silicon_1000.dat
##/detectors/PlaneR/PDFFilename {directory}/PlanePDF{material}{energy}.dat
##/detectors/PlaneR/detHistFilename {directory}/Hist{material}.dat
/control/execute init_vis.mac
Macro file for the initialization of example B1
in interactive session
Set some default verbose
/control/verbose 2
/control/saveHistory
/run/verbose 2
Change the default number of threads (in multi-threaded mode)
#/run/numberOfThreads 4
Initialize kernel
/run/initialize
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/open OGLIWin32 600x600-0+0
/vis/sceneHandler/create OGLIWin32
/vis/sceneHandler/attach
/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
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
-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception : visman0202
issued by : G4Scene::CalculateExtent
Scene has no extent. Please activate or add something.
The camera needs to have something to point at!
Add a volume. (You may need “/run/initialize”.)
Or use “/vis/scene/add/extent”.
“/vis/scene/list” to see list of models.
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------
/vis/sceneHandler/attach
set extents
/vis/scene/add/extent -3 3 -3 3 -3 3 cm
/vis/scene/notifyHandlers
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
/vis/scene/add/trajectories
/tracking/storeTrajectory 1
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
G4Trajectory:
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
G4TrajectoryPoint:
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/scene/notifyHandlers scene-1
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 2
/vis/scene/notifyHandlers scene-0
/vis/scene/notifyHandlers scene-1
(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 samplecontainer 0 false
/vis/scene/notifyHandlers
“Envelope” is transparent blue to represent water
/vis/geometry/set/colour LogSample 0 0 0 1 .3
/vis/scene/notifyHandlers
#/vis/scene/create
#/vis/scene/add/extent -3 3 -3 3 -3 3 cm
#/vis/sceneHandler/attach
/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