HOWTO View Geometry and test volumes with a geantino
View and Test the Geometry
The purpose of this page is to show how to look at a geometry and use a geantino to test the implemented geometry that helps you to verify that all the volumes defined are actually visible to a particle when passing through the detector. If there are intersections between different volumes it can lead to unexpected behaviors for particles passing through such areas as some of the volumes may not be detected by the tracker depending on the direction the particle passes through this space.
Basic Requirements
The approach taken here is to use "hdgeant4", github repo., and run it with the options "-v", to create a graphics window, "-i" to run interactive and "-V #" to set the tracking verbose level (note, "-V4" does not work but "-V 4" does!). The command line looks something like this:
hdgeant4 -v -V 4 -i
There are two environment variables that define from where to read the geometry. These are:
HDDS_HOME
JANA_GEOMETRY_URL
If the URL is set for the data base then the geometry corresponding the the run number defined in "control.in" will be used. If the URL is set for a file as "xmlfile://main_HDDS.xml" the HDDS_HOME directory will be used to read in the geometry as found in that directory. Note the run number given in control.in can be overwritten on the command line with "-r N" where N is the desired run number.
The program hdgeant4 in such a startup requires two input files "control.in" and vis.mac. When hdgeant4 starts up it will read control.in and later searches to read in the file "vis.mac" by default. If "vis.mac" is not found it will write out a warning, if control.in is not found the code will quite with an error message.
There are two important cards in control.in that need to be defined as desired, KINE and SCAP. These two define the particle type, momentum and direction (KINE) and the event/track starting point (SCAP), respectively. At the time of this writing these parameters seem to be "frozen" in the hdteant4 session and no "/gun/position" and "/gun/momentum" command can overwrite these parameters.
The content of the initial vis.mac file could look something like this:
# file vis.mac /control/verbose 2 /run/verbose 2 /vis/verbose all /tracking/verbose 5 /vis/open OGLSX 600x600+10+50 /vis/ogl/set/displayListLimit 150000 /vis/viewer/set/autoRefresh false /vis/viewer/set/background white
To get a view of a specific section and viewpoint of the detector geometry one can use the following example script and modify it accordingly:
# # Before invoking this macro, make sure you first # initialize the visualization system, eg. /control/execute vis.mac # if it hasn't be done already # /vis/viewer/set/autoRefresh false /vis/viewer/set/sectionPlane off # the following defines the view on how the geometry is looked at # the first three points define the plane the second three points define the viewing directionq # (0 0 0) defines a plane that cuts the detector at the center along its length # (50 0 0) defines the same cut but shifted in x by 50cm /vis/viewer/set/sectionPlane on 0 0 0 cm 1 0 0 /vis/viewer/set/upVector 0 1 0 /vis/viewer/set/style wireframe /vis/verbose warnings /vis/drawVolume worlds # The following set the center location to be viewed /vis/viewer/set/targetPoint 0 0 600 cm # the following set the direction from where to look at the # viewoint defined above In this case (90 degree) looking along the x-axis # and (0) beam is coming from the right. /vis/viewer/set/viewpointThetaPhi 90 0 /vis/viewer/zoomTo 70 /vis/viewer/set/picking true /vis/viewer/set/autoRefresh true
These command will create the following picture:
In the "control.in" file the KINE card was set as (148 == geantino, 10. GeV momentum, all angles and delta momentum and angle zero):
KINE 148 10. 0.0 0. 0. 0. 0.
The SCAP card defines the vertex (starting point of the geantino in this context) as follows (x=0, y=-8.8, z=595):
SCAP 0. -8.8 595.
If we run now a "geantino" it will start at position 0,-8.8,595 and will go straight in the z-direction as defined by KINE. The following script will initiate this process and plot the track on the display.
# file name one.mac # important: the following command will capture stdout into file for further examinations. /control/cout/setCoutFile testfile.log /vis/scene/add/trajectories /run/verbose 2 /tracking/verbose 5 /material/verbose 1 # generate one particle /run/beamOn 1
by executing the above script with:
Idle> /control/execute one.mac
one get the following picture of the geometry with the updated geantino track (in green):
In addition you will find in the local directory a file "G4W_0_testfile.log" that contains the output of the trajectory step by step. Search for the string "Step#" to find each step where the geantino encountered a volume. This will allow you to investigate if all the volumes are present that the genatino was supposed to traverse.
So for example with the command "grep -A1 "Step#" G4W_0_testfile.log you will get a list of all volumes the genantino traverse and what these volume names are. In the above example the output look like this:
Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 0 0 fm -9.8 cm 5.95 m 10 GeV 0 eV 0 fm 0 fm DCMV:1 initStep -- #Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 1 0 fm -9.8 cm 5.976 m 10 GeV 0 eV 2.6 cm 2.6 cm HALL::1:1 ParallelWorld1 GeomBoundary -- #Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 2 0 fm -9.8 cm 5.9864 m 10 GeV 0 eV 1.0359 cm 3.6359 cm SHLH:1 ParallelWorld1 GeomBoundary -- #Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 3 0 fm -9.8 cm 6.0435 m 10 GeV 0 eV 5.715 cm 9.3509 cm HALL::1:1 ParallelWorld1 GeomBoundary -- #Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 4 0 fm -9.8 cm 6.0436 m 10 GeV 0 eV 75 um 9.3584 cm yd13:1 ParallelWorld1 GeomBoundary -- #Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 5 0 fm -9.8 cm 6.0436 m 10 GeV 0 eV 50 um 9.3634 cm FTOL:1 ParallelWorld1 GeomBoundary -- #Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 6 0 fm -9.8 cm 6.069 m 10 GeV 0 eV 2.54 cm 11.903 cm yd13:1 ParallelWorld1 GeomBoundary -- #Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 7 0 fm -9.8 cm 6.0691 m 10 GeV 0 eV 50 um 11.908 cm HALL::1:1 ParallelWorld1 GeomBoundary -- #Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 8 0 fm -9.8 cm 6.0694 m 10 GeV 0 eV 300 um 11.938 cm yd14:1 ParallelWorld1 GeomBoundary -- .....