Add per-step Spawning ntuple, Geant4 submodule superbuild, and standalone dataset executables #1

Merged
lbogner merged 33 commits from spawning-ntuple into main 2026-07-13 14:06:25 +02:00
23 changed files with 1 additions and 2433 deletions
Showing only changes of commit 2a0a23a45b - Show all commits
+1 -29
View File
@@ -55,38 +55,10 @@ target_link_libraries(minicalo PUBLIC ${Geant4_LIBRARIES} ${Python3_LIBRARIES})
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 and Python libraries
#
add_executable(exampleB4a exampleB4a.cc ${sources} ${headers})
target_link_libraries(exampleB4a ${Geant4_LIBRARIES} ${Python3_LIBRARIES})
add_executable(run_pbwo4 run_pbwo4.cc ${sources} ${headers})
target_link_libraries(run_pbwo4 ${Geant4_LIBRARIES} ${Python3_LIBRARIES})
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build B4a. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(EXAMPLEB4A_SCRIPTS
exampleB4a.out
exampleB4.in
gui.mac
init_vis.mac
plotHisto.C
plotNtuple.C
run1.mac
run2.mac
vis.mac
)
foreach(_script ${EXAMPLEB4A_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
#install(TARGETS exampleB4a DESTINATION bin)
#install(TARGETS run_pbwo4 DESTINATION bin)
-21
View File
@@ -1,21 +0,0 @@
# --------------------------------------------------------------
# GNUmakefile for examples module. Gabriele Cosmo, 06/04/98.
# --------------------------------------------------------------
name := exampleB4a
G4TARGET := $(name)
G4EXLIB := true
ifndef G4INSTALL
G4INSTALL = ../../..
endif
.PHONY: all
all: lib bin
include $(G4INSTALL)/config/binmake.gmk
visclean:
rm -f g4*.prim g4*.eps g4*.wrl
rm -f .DAWN_*
-139
View File
@@ -1,139 +0,0 @@
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu22.04
SHELL ["/bin/sh", "-c"]
USER root
ENV DEBIAN_FRONTEND=noninteractive
RUN /usr/bin/ls
RUN sed -i "s,# deb http://archive.canonical.com/ubuntu,deb http://archive.canonical.com/ubuntu,g" /etc/apt/sources.list
## Install some deps
#RUN ls /etc/apt/
RUN apt-get update -y
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y python3 python3-dev python3-venv python3-pip
#RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 100
RUN apt-get install -y dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev libssl-dev
#RUN python3 --version && python3 -m ensurepip
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install pandas numpy matplotlib MarkupSafe wandb uproot setuptools awkward-pandas plotly
RUN python3 -m pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
RUN python3 -m pip install torch_geometric
RUN python3 -m pip install torch-cluster -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
# # # # GEANT
RUN apt-get -y install libxmu-dev \
libgl1-mesa-dev \
libxerces-c-dev \
libexpat1 \
libx11-dev \
libglu1-mesa-dev \
freeglut3-dev \
mesa-common-dev \
imagemagick \
gv wget autotools-dev libicu-dev libbz2-dev
## DAWN FOR VIS
RUN mkdir dawn-source \
&& wget -q -O - http://geant4.kek.jp/~tanaka/src/dawn_3_91a.tgz | tar xzf - -C "dawn-source" \
&& export DAWN_PS_PREVIEWER=NONE && cd dawn-source/dawn_3_91a \
&& make clean && make guiclean && make && make install \
&& cd - && rm -rf "dawn-source"
## main package — build Geant4 from submodule source
ADD minicalosim/lib/geant4 /tmp/geant4-src
RUN rm -f /tmp/geant4-src/.git && \
cmake \
-S /tmp/geant4-src \
-B /tmp/geant4-build \
-DCMAKE_INSTALL_PREFIX=/opt/geant4-v11.1.2 \
-DCMAKE_RULE_MESSAGES=OFF \
-DGEANT4_INSTALL_DATA=ON \
-DGEANT4_USE_GDML=ON \
-DGEANT4_USE_OPENGL_X11=ON \
-DGEANT4_BUILD_MULTITHREADED=OFF \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
-DGEANT4_USE_RAYTRACER_X11=ON \
>/dev/null && \
cmake --build /tmp/geant4-build --parallel $(( $(nproc) < 16 ? $(nproc) : 16 )) >/dev/null && \
cmake --install /tmp/geant4-build >/dev/null && \
rm -rf /tmp/geant4-src /tmp/geant4-build
RUN python3 -m pip install geant4-pybind
ENV LD_LIBRARY_PATH="/opt/geant4-v11.1.2/lib:${LD_LIBRARY_PATH}"
RUN apt-get install -y git
RUN python3 -m pip install ipython
RUN apt-get install -y tk # for dawn
# add jupyter packages for UC2 on top so they don't need to be installed every time
RUN python3 -m pip install jupyterlab jupyterhub==4.1.5 batchspawner
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN python3 -m pip install torch-scatter -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
#finally the package; use the commit hash to check out the correct version and only get them here, such that the rest can be cached
ARG BUILD_DATE
LABEL org.label-schema.build-date=$BUILD_DATE
ARG COMMIT
ARG USER
# copy minicalosim and checkout the correct commit
ADD minicalosim /root/minicalosim
RUN cd /root/minicalosim && git checkout $COMMIT && \
git submodule update --init lib/pybind11 && \
mkdir -p build && cd build && rm -rf * && cmake ../ && make -j$(( $(nproc) < 16 ? $(nproc) : 16 ))
RUN echo "commit = '${COMMIT}'" > /root/minicalosim/bind/minicalo_version.py
RUN cp /root/minicalosim/build/minicalo* /root/minicalosim/bind/G4Calo.py /root/minicalosim/bind/minicalo_tools.py /root/minicalosim/bind/minipandas.py /root/minicalosim/bind/minicalo_version.py /usr/local/lib/python3.10/dist-packages/
RUN cp /root/minicalosim/bind/G4Calo_exec.py /usr/local/bin/
RUN cp -r /root/minicalosim/bind /examples
RUN cp /root/minicalosim/docker/start-notebook.py /usr/local/bin/
RUN cp /root/minicalosim/docker/start-notebook.sh /usr/local/bin/
RUN cp /root/minicalosim/docker/start-singleuser.py /usr/local/bin/
RUN cp /root/minicalosim/docker/start-singleuser.sh /usr/local/bin/
RUN cp /root/minicalosim/docker/fix-permissions /usr/local/bin/
RUN cp /root/minicalosim/docker/check_cuda_torch.py /usr/local/bin/
ARG NB_USER="jovyan"
ARG NB_UID="1000"
ARG NB_GID="100"
USER root
#RUN groupadd -g ${NB_GID} ${NB_USER} && \
RUN useradd -m -s /bin/bash -N -u ${NB_UID} -g ${NB_GID} ${NB_USER}
RUN mkdir /etc/jupyter
RUN fix-permissions /etc/jupyter/
# clean up
RUN rm -rf /root/minicalosim
RUN pip3 install pyarrow fastparquet
USER ${NB_UID}
CMD ["bash"]
-132
View File
@@ -1,132 +0,0 @@
FROM ubuntu:20.04
SHELL ["/bin/sh", "-c"]
USER root
ENV DEBIAN_FRONTEND=noninteractive
RUN /usr/bin/ls
RUN sed -i "s,# deb http://archive.canonical.com/ubuntu,deb http://archive.canonical.com/ubuntu,g" /etc/apt/sources.list
## Install some deps
#RUN ls /etc/apt/
RUN apt-get update -y
RUN apt-get install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y python3 python3-dev python3-venv python3-pip
#RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 100
RUN apt-get install -y dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev libssl-dev
#RUN python3 --version && python3 -m ensurepip
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install pandas numpy matplotlib MarkupSafe wandb uproot setuptools awkward-pandas plotly
RUN python3 -m pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
RUN python3 -m pip install torch_geometric
RUN python3 -m pip install torch-cluster -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
# # # # GEANT
RUN apt-get -y install libxmu-dev \
libgl1-mesa-dev \
libxerces-c-dev \
libexpat1 \
libx11-dev \
libglu1-mesa-dev \
freeglut3-dev \
mesa-common-dev \
imagemagick \
gv wget autotools-dev libicu-dev libbz2-dev
## DAWN FOR VIS
RUN mkdir dawn-source \
&& wget -q -O - http://geant4.kek.jp/~tanaka/src/dawn_3_91a.tgz | tar xzf - -C "dawn-source" \
&& export DAWN_PS_PREVIEWER=NONE && cd dawn-source/dawn_3_91a \
&& make clean && make guiclean && make && make install \
&& cd - && rm -rf "dawn-source"
## main package — build Geant4 from submodule source
ADD minicalosim/lib/geant4 /tmp/geant4-src
RUN rm -f /tmp/geant4-src/.git && \
cmake \
-S /tmp/geant4-src \
-B /tmp/geant4-build \
-DCMAKE_INSTALL_PREFIX=/opt/geant4-v11.1.2 \
-DCMAKE_RULE_MESSAGES=OFF \
-DGEANT4_INSTALL_DATA=ON \
-DGEANT4_USE_GDML=ON \
-DGEANT4_USE_OPENGL_X11=ON \
-DGEANT4_BUILD_MULTITHREADED=ON \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
-DGEANT4_USE_RAYTRACER_X11=ON \
>/dev/null && \
cmake --build /tmp/geant4-build --parallel $(( $(nproc) < 16 ? $(nproc) : 16 )) >/dev/null && \
cmake --install /tmp/geant4-build >/dev/null && \
rm -rf /tmp/geant4-src /tmp/geant4-build
RUN python3 -m pip install geant4-pybind
ENV LD_LIBRARY_PATH="/opt/geant4-v11.1.2/lib:${LD_LIBRARY_PATH}"
RUN apt-get install -y git
RUN python3 -m pip install ipython
RUN apt-get install -y tk # for dawn
# add jupyter packages for UC2 on top so they don't need to be installed every time
RUN python3 -m pip install jupyterlab jupyterhub==4.1.5 batchspawner
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN python3 -m pip install torch-scatter -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
#finally the package; use the commit hash to check out the correct version and only get them here, such that the rest can be cached
ARG BUILD_DATE
LABEL org.label-schema.build-date=$BUILD_DATE
ARG COMMIT
ARG USER
# copy minicalosim and checkout the correct commit
ADD minicalosim /root/minicalosim
RUN cd /root/minicalosim && git checkout $COMMIT && \
git submodule update --init lib/pybind11 && \
mkdir -p build && cd build && rm -rf * && cmake ../ && make -j$(( $(nproc) < 16 ? $(nproc) : 16 )) &&\
echo "commit = '${COMMIT}'" > ../bind/minicalo_version.py && \
cp minicalo* ../bind/G4Calo.py ../bind/minicalo_version.py /usr/local/lib/python3.8/dist-packages/
RUN cp /root/minicalosim/docker/start-notebook.py /usr/local/bin/
RUN cp /root/minicalosim/docker/start-notebook.sh /usr/local/bin/
RUN cp /root/minicalosim/docker/start-singleuser.py /usr/local/bin/
RUN cp /root/minicalosim/docker/start-singleuser.sh /usr/local/bin/
RUN cp /root/minicalosim/docker/fix-permissions /usr/local/bin/
RUN cp /root/minicalosim/docker/check_cuda_torch.py /usr/local/bin/
ARG NB_USER="jovyan"
ARG NB_UID="1000"
ARG NB_GID="100"
USER root
#RUN groupadd -g ${NB_GID} ${NB_USER} && \
RUN useradd -m -s /bin/bash -N -u ${NB_UID} -g ${NB_GID} ${NB_USER}
RUN mkdir /etc/jupyter
RUN fix-permissions /etc/jupyter/
# clean up
RUN rm -rf /root/minicalosim
USER ${NB_UID}
CMD ["start-notebook.sh"]
-95
View File
@@ -1,95 +0,0 @@
#!/usr/bin/bash
# a simple parser for the args <commit> and --no-cache
# if no commit is given, the latest commit is used
# if --no-cache is given, the --no-cache flag is passed to the docker build command
# if only --no-cache is given, the latest commit is used
# check if commit is given as argument, if not use the latest commit
# check if an argument is given at all
if [ -n "$1" ]; then
#check if the first arg is --no-cache
if [ "$1" == "--no-cache" ]; then
FORCE_NO_CACHE="--no-cache"
COMMIT=$(git rev-parse --short HEAD)
else
COMMIT=$1
#check if this is a valid commit
if ! git cat-file -e $COMMIT^{commit} 2>/dev/null; then
echo "ERROR: Commit $COMMIT not found in local repository."
exit 1
fi
fi
else #default to last commit
COMMIT=$(git rev-parse --short HEAD)
fi
# COMMIT is a valid commit at this point. If COMMIT is the last commit and changes are not commited, the user is warned.
#check if the commit is the last commit
if [ "$COMMIT" == "$(git rev-parse --short HEAD)" ]; then
# check if we have uncommitted changes and if so warn the user.
if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: You are building the latest commit ${COMMIT}, but you have uncommitted changes."
echo " This means that the image will not be reproducible."
echo " If you want to build the latest commit, please commit your changes first."
read -p "Do you want to continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
fi
check_remote_commit_exists() {
# Usage: check_remote_commit_exists <repo-url> <commit-sha>
local url="$1"
local commit="$2"
# Create a temporary directory for a shallow fetch
local tmpdir
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' RETURN # auto-cleanup on function exit
git -C "$tmpdir" init -q
git -C "$tmpdir" remote add origin "$url"
if git -C "$tmpdir" fetch --quiet --depth=1 origin "$commit" 2>/dev/null; then
echo "✅ Commit $commit exists on remote."
return 0
else
echo "❌ ERROR: Commit $commit not found on remote."
echo "Refs currently visible on remote:"
git ls-remote --heads --tags "$url"
return 1
fi
}
# check if the commit has been pushed
if ! check_remote_commit_exists https://github.com/jkiesele/minicalosim $COMMIT; then
echo "ERROR: Commit $COMMIT not found in remote repository."
fi
# check if no-cache is given as second argument
if [ "$2" == "--no-cache" ]; then
FORCE_NO_CACHE="--no-cache"
fi
#switch to directory this script is located in
cd "$(dirname "$0")"
cd ../../ #switch to the root directory of the project
echo "Building minicalosim:$COMMIT"
#print the current working directory
echo "Current working directory: $(pwd)"
docker build $FORCE_NO_CACHE -t jkiesele/minicalosim:$COMMIT --build-arg USER=$USER --build-arg BUILD_DATE="$(date)" --build-arg COMMIT=$COMMIT -f minicalosim/docker/Dockerfile .
echo "sucessfully built container jkiesele/minicalosim:${COMMIT}"
docker tag jkiesele/minicalosim:$COMMIT jkiesele/minicalosim:latest
echo "also tagged as jkiesele/minicalosim:latest"
-73
View File
@@ -1,73 +0,0 @@
#!/usr/bin/bash
# a simple parser for the args <commit> and --no-cache
# if no commit is given, the latest commit is used
# if --no-cache is given, the --no-cache flag is passed to the docker build command
# if only --no-cache is given, the latest commit is used
# check if commit is given as argument, if not use the latest commit
# check if an argument is given at all
if [ -n "$1" ]; then
#check if the first arg is --no-cache
if [ "$1" == "--no-cache" ]; then
FORCE_NO_CACHE="--no-cache"
COMMIT=$(git rev-parse --short HEAD)
else
COMMIT=$1
#check if this is a valid commit
if ! git cat-file -e $COMMIT^{commit} 2>/dev/null; then
echo "ERROR: Commit $COMMIT not found in local repository."
exit 1
fi
fi
else #default to last commit
COMMIT=$(git rev-parse --short HEAD)
fi
# COMMIT is a valid commit at this point. If COMMIT is the last commit and changes are not commited, the user is warned.
#check if the commit is the last commit
if [ "$COMMIT" == "$(git rev-parse --short HEAD)" ]; then
# check if we have uncommitted changes and if so warn the user.
if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: You are building the latest commit ${COMMIT}, but you have uncommitted changes."
echo " This means that the image will not be reproducible."
echo " If you want to build the latest commit, please commit your changes first."
read -p "Do you want to continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
fi
# check if the commit has been pushed
REMOTE_COMMIT=$(git ls-remote https://gitlab.etp.kit.edu/jkiesele/minicalosim.git | grep $COMMIT)
if [ -z "$REMOTE_COMMIT" ]; then
echo "ERROR: Commit $COMMIT not found in remote repository."
exit 1
fi
# check if no-cache is given as second argument
if [ "$2" == "--no-cache" ]; then
FORCE_NO_CACHE="--no-cache"
fi
#switch to directory this script is located in
cd "$(dirname "$0")"
cd ../../ #switch to the root directory of the project
echo "Building minicalosim_cpu:$COMMIT"
#print the current working directory
echo "Current working directory: $(pwd)"
docker build $FORCE_NO_CACHE -t jkiesele/minicalosim_cpu:$COMMIT --build-arg USER=$USER --build-arg BUILD_DATE="$(date)" --build-arg COMMIT=$COMMIT -f minicalosim/docker/Dockerfile-cpu .
echo "sucessfully built container jkiesele/minicalosim_cpu:${COMMIT}"
docker tag jkiesele/minicalosim_cpu:$COMMIT jkiesele/minicalosim_cpu:latest
echo "also tagged as jkiesele/minicalosim_cpu:latest"
-74
View File
@@ -1,74 +0,0 @@
#!/usr/bin/bash
if [ -n "$1" ]; then
if [ "$1" == "--no-cache" ]; then
FORCE_NO_CACHE="--no-cache"
COMMIT=$(git rev-parse --short HEAD)
else
COMMIT=$1
if ! git cat-file -e $COMMIT^{commit} 2>/dev/null; then
echo "ERROR: Commit $COMMIT not found in local repository."
exit 1
fi
fi
else
COMMIT=$(git rev-parse --short HEAD)
fi
if [ "$COMMIT" == "$(git rev-parse --short HEAD)" ]; then
if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: You are building the latest commit ${COMMIT}, but you have uncommitted changes."
echo " This means that the image will not be reproducible."
echo " If you want to build the latest commit, please commit your changes first."
read -p "Do you want to continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
fi
check_remote_commit_exists() {
local url="$1"
local commit="$2"
local tmpdir
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' RETURN
git -C "$tmpdir" init -q
git -C "$tmpdir" remote add origin "$url"
if git -C "$tmpdir" fetch --quiet --depth=1 origin "$commit" 2>/dev/null; then
echo "✅ Commit $commit exists on remote."
return 0
else
echo "❌ ERROR: Commit $commit not found on remote."
echo "Refs currently visible on remote:"
git ls-remote --heads --tags "$url"
return 1
fi
}
if ! check_remote_commit_exists https://github.com/jkiesele/minicalosim $COMMIT; then
echo "WARNING: Commit $COMMIT not found in remote repository."
fi
if [ "$2" == "--no-cache" ]; then
FORCE_NO_CACHE="--no-cache"
fi
cd "$(dirname "$0")"
cd ../../
echo "Building minicalosim-mini:$COMMIT"
echo "Current working directory: $(pwd)"
docker build $FORCE_NO_CACHE \
-t jkiesele/minicalosim-mini:$COMMIT \
--build-arg USER=$USER \
--build-arg BUILD_DATE="$(date)" \
--build-arg COMMIT=$COMMIT \
-f minicalosim/docker/Dockerfile-mini .
echo "successfully built container jkiesele/minicalosim-mini:${COMMIT}"
docker tag jkiesele/minicalosim-mini:$COMMIT jkiesele/minicalosim-mini:latest
echo "also tagged as jkiesele/minicalosim-mini:latest"
-26
View File
@@ -1,26 +0,0 @@
#!/usr/bin/env python
'''
little script to check if cuda is available in pytorch and working
organised as a check that raises an exception if cuda is not available, and data cannot be moved to the gpu
'''
import torch
import numpy as np
import os
def check_cuda():
if not torch.cuda.is_available():
raise Exception("CUDA is not available. Please check if you have installed the correct version of CUDA and the correct version of the NVIDIA driver.")
try:
a = torch.tensor([1,2,3])
a = a.cuda()
a = a*a
except:
raise Exception("Cannot move data to the GPU. Please check if you have installed the correct version of CUDA and the correct version of the NVIDIA driver.")
print("CUDA is available and working correctly.")
if __name__ == '__main__':
check_cuda()
print("All checks passed.")
os._exit(0)
-33
View File
@@ -1,33 +0,0 @@
#!/bin/bash
# Set permissions on a directory
# After any installation, if a directory needs to be (human) user-writable, run this script on it.
# It will make everything in the directory owned by the group ${NB_GID} and writable by that group.
# Deployments that want to set a specific user id can preserve permissions
# by adding the `--group-add users` line to `docker run`.
# Uses find to avoid touching files that already have the right permissions,
# which would cause a massive image explosion
# Right permissions are:
# group=${NB_GID}
# AND permissions include group rwX (directory-execute)
# AND directories have setuid,setgid bits set
set -e
for d in "$@"; do
find "${d}" \
! \( \
-group "${NB_GID}" \
-a -perm -g+rwX \
\) \
-exec chgrp "${NB_GID}" -- {} \+ \
-exec chmod g+rwX -- {} \+
# setuid, setgid *on directories only*
find "${d}" \
\( \
-type d \
-a ! -perm -6000 \
\) \
-exec chmod +6000 -- {} \+
done
-44
View File
@@ -1,44 +0,0 @@
#!/usr/bin/env python
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import shlex
import sys
# If we are in a JupyterHub, we pass on to `start-singleuser.py` instead so it does the right thing
if "JUPYTERHUB_API_TOKEN" in os.environ:
print(
"WARNING: using start-singleuser.py instead of start-notebook.py to start a server associated with JupyterHub."
)
command = ["/usr/local/bin/start-singleuser.py"] + sys.argv[1:]
os.execvp(command[0], command)
# Entrypoint is start.sh
command = []
# If we want to survive restarts, launch the command using `run-one-constantly`
if os.environ.get("RESTARTABLE") == "yes":
command.append("run-one-constantly")
# We always launch a jupyter subcommand from this script
command.append("jupyter")
# Launch the configured subcommand.
# Note that this should be a single string, so we don't split it.
# We default to `lab`.
jupyter_command = os.environ.get("DOCKER_STACKS_JUPYTER_CMD", "lab")
command.append(jupyter_command)
# Append any optional NOTEBOOK_ARGS we were passed in.
# This is supposed to be multiple args passed on to the notebook command,
# so we split it correctly with shlex
if "NOTEBOOK_ARGS" in os.environ:
command += shlex.split(os.environ["NOTEBOOK_ARGS"])
# Pass through any other args we were passed on the command line
command += sys.argv[1:]
# Execute the command!
print("Executing: " + " ".join(command))
os.execvp(command[0], command)
-35
View File
@@ -1,35 +0,0 @@
#!/bin/bash
# Shim to emit warning and call start-notebook.py
echo "WARNING: Use start-notebook.py instead"
if id jovyan &> /dev/null; then
if ! usermod --home "/home/${NB_USER}" --login "${NB_USER}" jovyan 2>&1 | grep "no changes" > /dev/null; then
echo "Updated the jovyan user:"
echo "- username: jovyan -> ${NB_USER}"
echo "- home dir: /home/jovyan -> /home/${NB_USER}"
fi
elif ! id -u "${NB_USER}" &> /dev/null; then
echo "ERROR: Neither the jovyan user nor '${NB_USER}' exists. This could be the result of stopping and starting, the container with a different NB_USER environment variable."
exit 1
fi
# Ensure the desired user (NB_USER) gets its desired user id (NB_UID) and is
# a member of the desired group (NB_GROUP, NB_GID)
if [ "${NB_UID}" != "$(id -u "${NB_USER}")" ] || [ "${NB_GID}" != "$(id -g "${NB_USER}")" ]; then
echo "Update ${NB_USER}'s UID:GID to ${NB_UID}:${NB_GID}"
# Ensure the desired group's existence
if [ "${NB_GID}" != "$(id -g "${NB_USER}")" ]; then
groupadd --force --gid "${NB_GID}" --non-unique "${NB_GROUP:-${NB_USER}}"
fi
# Recreate the desired user as we want it
userdel "${NB_USER}"
useradd --no-log-init --home "/home/${NB_USER}" --shell /bin/bash --uid "${NB_UID}" --gid "${NB_GID}" --groups 100 "${NB_USER}"
fi
# if root change user to jovyan
if [ "$EUID" -eq 0 ]; then
echo "WARNING: Running as root. Use start-notebook.py to run as ${NB_USER} user"
exec su ${NB_USER} -c "exec /usr/local/bin/start-notebook.py $@"
else
exec /usr/local/bin/start-notebook.py "$@"
fi
-26
View File
@@ -1,26 +0,0 @@
#!/usr/bin/env python
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import os
import shlex
import sys
# Entrypoint is start.sh
command = ["jupyterhub-singleuser"]
# set default ip to 0.0.0.0
if "--ip=" not in os.environ.get("NOTEBOOK_ARGS", ""):
command.append("--ip=0.0.0.0")
# Append any optional NOTEBOOK_ARGS we were passed in.
# This is supposed to be multiple args passed on to the notebook command,
# so we split it correctly with shlex
if "NOTEBOOK_ARGS" in os.environ:
command += shlex.split(os.environ["NOTEBOOK_ARGS"])
# Pass any other args we have been passed through
command += sys.argv[1:]
# Execute the command!
print("Executing: " + " ".join(command))
os.execvp(command[0], command)
-5
View File
@@ -1,5 +0,0 @@
#!/bin/bash
# Shim to emit warning and call start-singleuser.py
echo "WARNING: Use start-singleuser.py instead"
exec /usr/local/bin/start-singleuser.py "$@"
-23
View File
@@ -1,23 +0,0 @@
# Macro file for example B4 test
/run/initialize
# e+ 300MeV
/gun/particle e+
/gun/energy 300 MeV
/run/beamOn 1
#
# list the existing physics processes
/process/list
#
# switch off MultipleScattering
/process/inactivate msc
/run/beamOn 1
#
# switch on MultipleScattering
/process/activate msc
#
# change detector parameter
/gun/particle gamma
/gun/energy 500 MeV
/run/beamOn 1
-285
View File
@@ -1,285 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file exampleB4a.cc
/// \brief Main program of the B4a example
#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.hh"
#include "G4UIcommand.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "FTFP_BERT.hh"
#include "Randomize.hh"
#include "GeometryDescriptor.hh"
#include "G4System.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace {
void PrintUsage() {
G4cerr << " Usage: " << G4endl;
G4cerr << " exampleB4a [-m macro ] [-u UIsession] [-t nThreads] [-vDefault]"
<< G4endl;
G4cerr << " note: -t option is available only for multi-threaded mode."
<< G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main2(int argc,char** argv)
{
// Evaluate arguments
//
if ( argc > 7 ) {
PrintUsage();
return 1;
}
G4String macro;
G4String session;
G4bool verboseBestUnits = true;
#ifdef G4MULTITHREADED
G4int nThreads = 0;
#endif
for ( G4int i=1; i<argc; i=i+2 ) {
if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
#ifdef G4MULTITHREADED
else if ( G4String(argv[i]) == "-t" ) {
nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
}
#endif
else if ( G4String(argv[i]) == "-vDefault" ) {
verboseBestUnits = false;
--i; // this option is not followed with a parameter
}
else {
PrintUsage();
return 1;
}
}
// Detect interactive mode (if no macro provided) and define UI session
//
G4UIExecutive* ui = nullptr;
if ( ! macro.size() ) {
ui = new G4UIExecutive(argc, argv, session);
}
// Optionally: choose a different Random engine...
// G4Random::setTheEngine(new CLHEP::MTwistEngine);
// Use G4SteppingVerboseWithUnits
if ( verboseBestUnits ) {
G4int precision = 4;
G4SteppingVerbose::UseBestUnit(precision);
}
// Construct the default run manager
//
auto* runManager =
G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
#ifdef G4MULTITHREADED
if ( nThreads > 0 ) {
runManager->SetNumberOfThreads(nThreads);
}
#endif
GeometryDescriptor * cw = new GeometryDescriptor();
cw->addLayer(1, "G4_Pb", false);
cw->addLayer(10, "G4_Si", true, 9);
cw->addLayer(1, "G4_Pb", false);
cw->addLayer(20, "G4_Si", true, 15);
cw->addLayer(4, "G4_Pb", false);
cw->addLayer(3, "G4_Si", true, 23);
// Set mandatory initialization classes
//
auto detConstruction = new B4::DetectorConstruction(cw);
runManager->SetUserInitialization(detConstruction);
auto physicsList = new FTFP_BERT;
runManager->SetUserInitialization(physicsList);
auto actionInitialization = new B4a::ActionInitialization(detConstruction);
runManager->SetUserInitialization(actionInitialization);
actionInitialization->setGeneratorProperties(100, 1000, "e-");
// Initialize visualization
//
auto visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
// Get the pointer to the User Interface manager
auto UImanager = G4UImanager::GetUIpointer();
// Process macro or start UI session
//
if ( macro.size() ) {
// batch mode
G4String command = "/control/execute ";
UImanager->ApplyCommand(command+macro);
}
else {
// interactive mode : define UI session
UImanager->ApplyCommand("/control/execute init_vis.mac");
if (ui->IsGUI()) {
UImanager->ApplyCommand("/control/execute gui.mac");
}
ui->SessionStart();
delete ui;
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
delete visManager;
delete runManager;
delete cw;
return 0;
}
//later
//class Runner {
//public:
// void initialize(GeometryDescriptor CW, bool gui=false);
// void run(int nEvents, std::string partSpecies, double minEnergy, double maxEnergy);
//}
void run(GeometryDescriptor CW, int nEvents, std::string partSpecies, double minEnergy, double maxEnergy, bool gui=false){
char* argv[]={(char*)"dummy"};
// Construct the default run manager
//
auto* runManager =
G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
runManager->SetNumberOfThreads(1);
GeometryDescriptor * cw = &CW;
G4String session;
G4UIExecutive* ui = nullptr;
if ( gui ) {
ui = new G4UIExecutive((int)1, argv, session);
}
// Set mandatory initialization classes
//
auto detConstruction = new B4::DetectorConstruction(cw);
runManager->SetUserInitialization(detConstruction);
auto physicsList = new FTFP_BERT;
runManager->SetUserInitialization(physicsList);
auto actionInitialization = new B4a::ActionInitialization(detConstruction);
runManager->SetUserInitialization(actionInitialization);
actionInitialization->setGeneratorProperties(minEnergy, maxEnergy, partSpecies);
// Initialize visualization
//
auto visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
// Get the pointer to the User Interface manager
auto UImanager = G4UImanager::GetUIpointer();
// Process macro or start UI session
//
if ( gui ) {
// interactive mode : define UI session
UImanager->ApplyCommand("/control/execute init_vis.mac");
if (ui->IsGUI()) {
UImanager->ApplyCommand("/control/execute gui.mac");
}
ui->SessionStart();
delete ui;
}
else {
G4String command = "/control/execute run1.mac";
UImanager->ApplyCommand("/run/initialize");
UImanager->ApplyCommand("/run/beamOn "+ std::to_string(nEvents));
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
delete visManager;
delete runManager;
}
int main(){
GeometryDescriptor cw;
//to be moved
cw.addLayer(1, "G4_Pb", false);
cw.addLayer(10, "G4_Si", true, 9);
cw.addLayer(1, "G4_Pb", false);
cw.addLayer(20, "G4_Si", true, 15);
cw.addLayer(4, "G4_Pb", false);
cw.addLayer(3, "G4_Si", true, 23);
G4System builder(true);
builder.init(cw);
//builder.run_gui();
std::vector<std::string> parts = {"e-"};
builder.run_batch(10000,parts , 1, 100);
//run(cw, 1000, "e-", 1, 100, true);
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
-1111
View File
File diff suppressed because it is too large Load Diff
-37
View File
@@ -1,37 +0,0 @@
#
# This file permits to customize, with commands,
# the menu bar of the G4UIXm, G4UIQt, G4UIWin32 sessions.
# It has no effect with G4UIterminal.
#
# File menu :
/gui/addMenu file File
/gui/addButton file Quit exit
#
# Run menu :
/gui/addMenu run Run
/gui/addButton run "beamOn 1" "/run/beamOn 1"
/gui/addButton run run1 "/control/execute run1.mac"
#
# Gun menu :
/gui/addMenu gun Gun
/gui/addButton gun "50 MeV" "/gun/energy 50 MeV"
/gui/addButton gun "1 GeV" "/gun/energy 1 GeV"
/gui/addButton gun "10 GeV" "/gun/energy 10 GeV"
/gui/addButton gun "e-" "/gun/particle e-"
/gui/addButton gun "pi0" "/gun/particle pi0"
/gui/addButton gun "pi+" "/gun/particle pi+"
/gui/addButton gun "neutron" "/gun/particle neutron"
/gui/addButton gun "proton" "/gun/particle proton"
#
# Viewer menu :
/gui/addMenu viewer Viewer
/gui/addButton viewer "Set style surface" "/vis/viewer/set/style surface"
/gui/addButton viewer "Set style wireframe" "/vis/viewer/set/style wireframe"
/gui/addButton viewer "Refresh viewer" "/vis/viewer/refresh"
/gui/addButton viewer "Update viewer (interaction or end-of-file)" "/vis/viewer/update"
/gui/addButton viewer "Flush viewer (= refresh + update)" "/vis/viewer/flush"
/gui/addButton viewer "Update scene" "/vis/scene/notifyHandlers"
#
# To limit the output flow in the "dump" widget :
/run/printProgress 100
#
-17
View File
@@ -1,17 +0,0 @@
# Macro file for the initialization of example B4
# 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
-43
View File
@@ -1,43 +0,0 @@
// ROOT macro file for plotting example B4 histograms
//
// Can be run from ROOT session:
// root[0] .x plotHisto.C
{
gROOT->Reset();
gROOT->SetStyle("Plain");
// Draw histos filled by Geant4 simulation
//
// Open file filled by Geant4 simulation
TFile f("B4.root");
// Create a canvas and divide it into 2x2 pads
TCanvas* c1 = new TCanvas("c1", "", 20, 20, 1000, 1000);
c1->Divide(2,2);
// Draw Eabs histogram in the pad 1
c1->cd(1);
TH1D* hist1 = (TH1D*)f.Get("Eabs");
hist1->Draw("HIST");
// Draw Labs histogram in the pad 2
c1->cd(2);
TH1D* hist2 = (TH1D*)f.Get("Labs");
hist2->Draw("HIST");
// Draw Egap histogram in the pad 3
// with logaritmic scale for y
TH1D* hist3 = (TH1D*)f.Get("Egap");
c1->cd(3);
gPad->SetLogy(1);
hist3->Draw("HIST");
// Draw Lgap histogram in the pad 4
// with logaritmic scale for y
c1->cd(4);
gPad->SetLogy(1);
TH1D* hist4 = (TH1D*)f.Get("Lgap");
hist4->Draw("HIST");
}
-42
View File
@@ -1,42 +0,0 @@
// ROOT macro file for plotting example B4 ntuple
//
// Can be run from ROOT session:
// root[0] .x plotNtuple.C
{
gROOT->Reset();
gROOT->SetStyle("Plain");
// Draw histos filled by Geant4 simulation
//
// Open file filled by Geant4 simulation
TFile f("B4.root");
// Create a canvas and divide it into 2x2 pads
TCanvas* c1 = new TCanvas("c1", "", 20, 20, 1000, 1000);
c1->Divide(2,2);
// Get ntuple
TNtuple* ntuple = (TNtuple*)f.Get("B4");
// Draw Eabs histogram in the pad 1
c1->cd(1);
ntuple->Draw("Eabs");
// Draw Labs histogram in the pad 2
c1->cd(2);
ntuple->Draw("Labs");
// Draw Egap histogram in the pad 3
// with logaritmic scale for y ?? how to do this?
c1->cd(3);
gPad->SetLogy(1);
ntuple->Draw("Egap");
// Draw Lgap histogram in the pad 4
// with logaritmic scale for y ?? how to do this?
c1->cd(4);
gPad->SetLogy(1);
ntuple->Draw("Egap");
}
-44
View File
@@ -1,44 +0,0 @@
# Macro file for example B4
#
# Can be run in batch, without graphic
# or interactively: Idle> /control/execute run1.mac
#
# Change the default number of workers (in multi-threading mode)
#/run/numberOfThreads 4
#
# Initialize kernel
/run/initialize
#
# Default kinematics:
# electron 50 MeV in direction (0.,0.,1.)
# 1 event with tracking/verbose
#
/tracking/verbose 1
/run/beamOn 1
#
#
# muon 300 MeV in direction (0.,0.,1.)
# 3 events
#
/gun/particle mu+
/gun/energy 3 MeV
/run/beamOn 3
#
# 20 events
#
/tracking/verbose 0
/run/printProgress 5
/run/beamOn 20
#
# Magnetic field
#
/globalField/setValue 0.2 0 0 tesla
/run/beamOn 3
#
# Activate/inactivate physics processes
#
/process/list
/process/inactivate eBrem
#
/run/beamOn 20
#
-17
View File
@@ -1,17 +0,0 @@
# Macro file for example B4
#
# To be run preferably in batch, without graphics:
# % exampleB4[a,b,c,d] run2.mac
#
#/run/numberOfThreads 4
#/control/cout/ignoreThreadsExcept 0
#
/run/initialize
#
# Default kinemtics:
# electron 50 MeV in direction (0.,0.,1.)
# 1000 events
#
/run/printProgress 100
/run/beamOn 1000
-82
View File
@@ -1,82 +0,0 @@
# Macro file for the visualization setting for the initialization phase
# of the B4 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
#
# Use this open statement to create an OpenInventor view:
#/vis/open OIX
#
# 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
#
# Draw geometry:
/vis/drawVolume
#
# Specify view angle:
/vis/viewer/set/viewpointThetaPhi 90. 180.
#
# Specify zoom value:
#/vis/viewer/zoom 2.
#
# Specify style (surface, wireframe, auxiliary edges,...)
#/vis/viewer/set/style wireframe
#/vis/viewer/set/auxiliaryEdge true
#/vis/viewer/set/lineSegmentsPerCircle 100
#
# Draw coordinate axes:
#/vis/scene/add/axes 0 0 0 1 m
#
# Draw smooth trajectories at end of event, showing trajectory points
# as markers 2 pixels wide:
/vis/scene/add/trajectories smooth
/vis/modeling/trajectories/create/drawByCharge
/vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true
/vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 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
#
# Re-establish auto refreshing and verbosity:
/vis/viewer/set/autoRefresh true
/vis/verbose warnings
#
# For file-based drivers, use this to create an empty detector view:
#/vis/viewer/flush