Difference between revisions of "HOWTO build and run PHASM on Geant4 examples"

From epsciwiki
Jump to navigation Jump to search
(Created page with " source /etc/profile.d/modules.sh module load singularity singularity shell -B/cvmfs:/cvmfs /cvmfs/oasis.opensciencegrid.org/jlab/epsci/singularity/images/epsci-ubuntu...")
 
Line 1: Line 1:
  
 
+
Here are some instructions for using singularity to build a Geant4 example and run it.
  
 
   source /etc/profile.d/modules.sh
 
   source /etc/profile.d/modules.sh
Line 6: Line 6:
 
   singularity shell -B/cvmfs:/cvmfs /cvmfs/oasis.opensciencegrid.org/jlab/epsci/singularity/images/epsci-ubuntu-22.04.img
 
   singularity shell -B/cvmfs:/cvmfs /cvmfs/oasis.opensciencegrid.org/jlab/epsci/singularity/images/epsci-ubuntu-22.04.img
 
   Singularity> source /cvmfs/oasis.opensciencegrid.org/jlab/epsci/ubuntu/22.04/share/spack/setup-env.sh
 
   Singularity> source /cvmfs/oasis.opensciencegrid.org/jlab/epsci/ubuntu/22.04/share/spack/setup-env.sh
 +
  Singularity> spack env activate phasm
 +
 +
The source for the Geant4 examples is available in the container though it has not been compiled. Compile it in your own directory like this:
 +
 +
  # Define G4EX as the source directory of the example we want to build.
 +
  # This just makes the cmake and other commands a little more readable.
 +
  # The G4EX envar is not actually used by any of the software.
 +
  # B4 is a simple sampling calorimeter example.
 +
  export G4EX=$SPACK_ROOT/opt/spack/linux-*/*/geant4-*/share/Geant4/examples/basic/B4
 +
 
 +
  cmake -S $G4EX -B build -DCMAKE_INSTALL_PREFIX=install -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=1
 +
  cmake --build build --target install -- -j8
 +
 +
There are actually 4 variants of this example that are built. All will be installed in ''install/bin''. The examples expect you to use macros that came with the source. Copy the macros to your working directory and run an example like this:
 +
 +
  cp -rp $G4EX/macros  .
 +
  cd macros
 +
  ../install/bin/exampleB4d
 +
 
 +
  # A lot of output will be printed and a graphics window will open.
 +
  # Eventually, you will be given a prompt where you may enter commands.
 +
  # Enter the command run/beamOn 1 to simulated a single event.
 +
 
 +
  Idle> run/beamOn 1
 +
 
 +
  # Quit the simulation
 +
 
 +
  Idle> exit
 +
 +
Note: You can control the number of threads and turn off visualization by editing the file ''init_vis.mac'' before starting the example.

Revision as of 20:46, 29 December 2022

Here are some instructions for using singularity to build a Geant4 example and run it.

 source /etc/profile.d/modules.sh
 module load singularity
 singularity shell -B/cvmfs:/cvmfs /cvmfs/oasis.opensciencegrid.org/jlab/epsci/singularity/images/epsci-ubuntu-22.04.img
 Singularity> source /cvmfs/oasis.opensciencegrid.org/jlab/epsci/ubuntu/22.04/share/spack/setup-env.sh
 Singularity> spack env activate phasm

The source for the Geant4 examples is available in the container though it has not been compiled. Compile it in your own directory like this:

 # Define G4EX as the source directory of the example we want to build.
 # This just makes the cmake and other commands a little more readable.
 # The G4EX envar is not actually used by any of the software.
 # B4 is a simple sampling calorimeter example.
 export G4EX=$SPACK_ROOT/opt/spack/linux-*/*/geant4-*/share/Geant4/examples/basic/B4
 
 cmake -S $G4EX -B build -DCMAKE_INSTALL_PREFIX=install -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=1
 cmake --build build --target install -- -j8

There are actually 4 variants of this example that are built. All will be installed in install/bin. The examples expect you to use macros that came with the source. Copy the macros to your working directory and run an example like this:

 cp -rp $G4EX/macros  .
 cd macros
 ../install/bin/exampleB4d
 
 # A lot of output will be printed and a graphics window will open.
 # Eventually, you will be given a prompt where you may enter commands.
 # Enter the command run/beamOn 1 to simulated a single event.
 
 Idle> run/beamOn 1
 
 # Quit the simulation
 
 Idle> exit

Note: You can control the number of threads and turn off visualization by editing the file init_vis.mac before starting the example.