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 -- .....
Starting up hdgeant4 with option "-V 2", the output is somewhat reduced and you will see:
455 ********************************************************************************************************* 456 * G4Track Information: Particle = geantino, Track ID = 1, Parent ID = 0 457 ********************************************************************************************************* 458 459 Step# X Y Z KineE dEStep StepLeng TrakLeng Volume Process Status 460 0 0 fm -9.8 cm 5.95 m 10 GeV 0 eV 0 fm 0 fm DCMV:1 initStep 461 1 0 fm -9.8 cm 5.976 m 10 GeV 0 eV 2.6 cm 2.6 cm HALL::1:1 ParallelWorld1 GeomBoundary 462 2 0 fm -9.8 cm 5.9864 m 10 GeV 0 eV 1.0359 cm 3.6359 cm SHLH:1 ParallelWorld1 GeomBoundary 463 3 0 fm -9.8 cm 6.0435 m 10 GeV 0 eV 5.715 cm 9.3509 cm HALL::1:1 ParallelWorld1 GeomBoundary 464 4 0 fm -9.8 cm 6.0436 m 10 GeV 0 eV 75 um 9.3584 cm yd13:1 ParallelWorld1 GeomBoundary 465 5 0 fm -9.8 cm 6.0436 m 10 GeV 0 eV 50 um 9.3634 cm FTOL:1 ParallelWorld1 GeomBoundary 466 6 0 fm -9.8 cm 6.069 m 10 GeV 0 eV 2.54 cm 11.903 cm yd13:1 ParallelWorld1 GeomBoundary 467 7 0 fm -9.8 cm 6.0691 m 10 GeV 0 eV 50 um 11.908 cm HALL::1:1 ParallelWorld1 GeomBoundary 468 8 0 fm -9.8 cm 6.0694 m 10 GeV 0 eV 300 um 11.938 cm yd14:1 ParallelWorld1 GeomBoundary 469 9 0 fm -9.8 cm 6.0694 m 10 GeV 0 eV 50 um 11.943 cm FTOH:1 ParallelWorld1 GeomBoundary 470 10 0 fm -9.8 cm 6.0948 m 10 GeV 0 eV 2.54 cm 14.483 cm yd14:1 ParallelWorld1 GeomBoundary 471 11 0 fm -9.8 cm 6.0949 m 10 GeV 0 eV 50 um 14.488 cm HALL::1:1 ParallelWorld1 GeomBoundary 472 12 0 fm -9.8 cm 6.2216 m 10 GeV 0 eV 12.673 cm 27.161 cm FCLC:1 ParallelWorld1 GeomBoundary 473 13 0 fm -9.8 cm 6.2248 m 10 GeV 0 eV 3.175 mm 27.479 cm HALL::1:1 ParallelWorld1 GeomBoundary 474 14 0 fm -9.8 cm 6.2432 m 10 GeV 0 eV 1.8413 cm 29.32 cm FCAL::1:1 CoupledTransportation GeomBoundary 475 15 0 fm -9.8 cm 6.3691 m 10 GeV 0 eV 12.589 cm 41.909 cm XTMD:620 ParallelWorld1 GeomBoundary 476 16 0 fm -9.8 cm 6.5691 m 10 GeV 0 eV 20 cm 61.909 cm FCAL::1:1 ParallelWorld1 GeomBoundary 477 17 0 fm -9.8 cm 6.7512 m 10 GeV 0 eV 18.211 cm 80.12 cm HALL::1:1 CoupledTransportation GeomBoundary 478 18 0 fm -9.8 cm 8.195 m 10 GeV 0 eV 1.4437 m 2.2449 m DBEW:1 ParallelWorld1 GeomBoundary 479 19 0 fm -9.8 cm 8.195 m 10 GeV 0 eV 100 um 2.245 m HALL::1:1 ParallelWorld1 GeomBoundary 480 20 0 fm -9.8 cm 9.7297 m 10 GeV 0 eV 1.5347 m 3.7797 m PPWD:1 ParallelWorld1 GeomBoundary 481 21 0 fm -9.8 cm 9.73 m 10 GeV 0 eV 254 um 3.78 m PPIV:1 ParallelWorld1 GeomBoundary 482 22 0 fm -9.8 cm 13.26 m 10 GeV 0 eV 3.53 m 7.31 m PPWD:2 ParallelWorld1 GeomBoundary 483 23 0 fm -9.8 cm 13.26 m 10 GeV 0 eV 254 um 7.3103 m HALL::1:1 ParallelWorld1 GeomBoundary 484 24 0 fm -9.8 cm 13.293 m 10 GeV 0 eV 3.3246 cm 7.3435 m PPPW:1 ParallelWorld1 GeomBoundary 485 25 0 fm -9.8 cm 13.296 m 10 GeV 0 eV 3 mm 7.3465 m HALL::1:1 ParallelWorld1 GeomBoundary 486 26 0 fm -9.8 cm 17.02 m 10 GeV 0 eV 3.7235 m 11.07 m TAC1:1 ParallelWorld1 GeomBoundary 487 27 0 fm -9.8 cm 17.47 m 10 GeV 0 eV 45 cm 11.52 m HALL::1:1 ParallelWorld1 GeomBoundary 488 28 0 fm -9.8 cm 18.985 m 10 GeV 0 eV 1.515 m 13.035 m DET5:1 ParallelWorld1 GeomBoundary 489 29 0 fm -9.8 cm 19.005 m 10 GeV 0 eV 2 cm 13.055 m HALL::1:1 ParallelWorld1 GeomBoundary 490 30 0 fm -9.8 cm 22.045 m 10 GeV 0 eV 3.04 m 16.095 m World:0 CoupledTransportation GeomBoundary