diff --git a/README.md b/README.md index d661f6671..c41dc0f7b 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,9 @@ - **Note**: You need to [setup an SSH-key with your GitHub account](https://docs.github.com/en/authentication/connecting-to-github-with-ssh) on the computer you are using. - Setup the environment (in bash): `source ldmx-sw/scripts/ldmx-env.sh` - **Note**: If you are working with ldmx-sw at SLAC's SDF, you will need to set the `TMPDIR` environment variable so that program running the container has more than ~5GB of space to write intermediate files. The default temporary space (`/tmp`) is often full of other files already. A decent replacement is `TMPDIR=${SCRATCH}` which gives the program plenty of room for the files it needs to manipulate. -- Make a build directory: `cd ldmx-sw; mkdir build; cd build;` -- Configure the build: `ldmx cmake ..` -- Build and Install: `ldmx make install -j2` +- Configure and compile: `ldmx compile` - Now you can run any processor in _ldmx-sw_ through `ldmx fire myconfig.py` +- If you are developing and need to recompile and run `ldmx fire`, you can use `ldmx recompFire myconfig.py` ## Documentation The full documentation for **ldmx-sw** is available on [github pages](https://ldmx-software.github.io/). @@ -40,7 +39,9 @@ Command | Purpose `ldmx cmake ..` | Configure the ldmx-sw build `ldmx make` | Compile/build ldmx-sw `ldmx make install` | Install ldmx-sw +`ldmx compile` | Configure and compile ldmx-sw `ldmx fire config.py` | Use ldmx-sw application and processors with input python configuration +`ldmx recompFire config.py` | Recompile and run fire on a config file `ldmx python3 analysis.py` | Run python-based analysis `ldmx ./bin/mg5_aMC` | Run MadGraph5 inside (ubuntu-based) container diff --git a/scripts/ldmx-compile.sh b/scripts/ldmx-compile.sh new file mode 100755 index 000000000..57e7f7751 --- /dev/null +++ b/scripts/ldmx-compile.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +############################# Usage ############################# +# ldmx ./scripts/ldmx-compile.sh +# for changing the defaults +# ldmx setenv LDMX_COMPILE_CORES=, i.e. +# ldmx setenv LDMX_COMPILE_CORES=16 +# or +# ldmx setenv LDMX_COMPILE_BUILD= + +if [ -z "$LDMX_COMPILE_CORES" ]; then + LDMX_COMPILE_CORES=$(nproc) +fi + +if [ -z "$LDMX_COMPILE_BUILD" ]; then + LDMX_COMPILE_BUILD=${LDMX_BASE}/ldmx-sw/ +fi + +echo "-- Compiling ldmx-sw in ${LDMX_COMPILE_BUILD} with ${LDMX_COMPILE_CORES} cores" + +# Compile ldmx-sw +cmake -B ${LDMX_COMPILE_BUILD}/build -S ${LDMX_COMPILE_BUILD} $@ +cmake --build ${LDMX_COMPILE_BUILD}/build --target install -j=${LDMX_COMPILE_CORES} diff --git a/scripts/ldmx-env.sh b/scripts/ldmx-env.sh index 807bd3ca3..d9fc1b716 100644 --- a/scripts/ldmx-env.sh +++ b/scripts/ldmx-env.sh @@ -465,6 +465,8 @@ __ldmx_clean() { return ${rc} } + + ############################################################################### # __ldmx_source # Run all the sub-commands in the provided file from the directory it is in. @@ -537,6 +539,24 @@ __ldmx_checkout() { return 0 } +############################################################################### +# __ldmx_compile +# Compile ldmx-sw +############################################################################### + +__ldmx_compile() { + ldmx . ${LDMX_BASE}/ldmx-sw/scripts/ldmx-compile.sh +} + +############################################################################### +# __ldmx_recompFire +# Recompile ldmx-sw and run fire on the first argument +############################################################################### + +__ldmx_recompFire() { + ldmx . ${LDMX_BASE}/ldmx-sw/scripts/ldmx-recompileAndFire.sh $@ +} + ############################################################################### # __ldmx_help # Print some helpful message to the terminal @@ -550,6 +570,8 @@ __ldmx_help() { COMMANDS: help : print this help message and exit ldmx help + compile : Compile ldmx-sw + ldmx compile list : List the tag options for the input container repository ldmx list (dev | pro | local) clean : Reset ldmx computing environment @@ -579,6 +601,7 @@ __ldmx_help() { ldmx cmake .. ldmx make install ldmx fire config.py + ldmx recompFire config.py ldmx python3 ana.py HELP @@ -599,7 +622,7 @@ ldmx() { [[ "$#" == "0" ]] && { __ldmx_help; return $?; } # divide commands by number of arguments case $1 in - help|config) + help|config|compile) if [[ "$#" != "1" ]]; then __ldmx_${1} echo "ERROR: 'ldmx ${1}' takes no arguments." @@ -635,7 +658,7 @@ ldmx() { __ldmx_use "$2" "$3" return $? ;; - run|checkout) + run|checkout|recompFire) __ldmx_${1} ${@:2} return $? ;; @@ -775,12 +798,12 @@ __ldmx_complete() { if [[ "$COMP_CWORD" = "1" ]]; then # tab completing a main argument - __ldmx_complete_command "list clean config checkout pull use run mount setenv base source" + __ldmx_complete_command "list clean config checkout pull use run mount setenv base source compile recompFire" elif [[ "$COMP_CWORD" = "2" ]]; then # tab complete a sub-argument, # depends on the main argument case "${COMP_WORDS[1]}" in - config|setenv) + config|setenv|compile) # no more arguments __ldmx_dont_complete ;; @@ -809,7 +832,7 @@ __ldmx_complete() { # check base argument to see if we should continue case "${COMP_WORDS[1]}" in list|base|clean|config|pull|use|mount|setenv|source) - # these commands shouldn't have tab complete for the third argument + # these commands shouldn't have tab complete for the third argument # (or shouldn't have the third argument at all) __ldmx_dont_complete ;; diff --git a/scripts/ldmx-recompileAndFire.sh b/scripts/ldmx-recompileAndFire.sh new file mode 100755 index 000000000..573275265 --- /dev/null +++ b/scripts/ldmx-recompileAndFire.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +############################# Usage ############################# +# ldmx ./scripts/ldmx-recompileAndFire.sh +# for changing the defaults +# ldmx setenv LDMX_COMPILE_CORES=, i.e. +# ldmx setenv LDMX_COMPILE_CORES=16 +# or +# ldmx setenv LDMX_COMPILE_BUILD= + + +if [ -z "$LDMX_COMPILE_CORES" ]; then + LDMX_COMPILE_CORES=$(nproc) +fi + +if [ -z "$LDMX_COMPILE_BUILD" ]; then + LDMX_COMPILE_BUILD=${LDMX_BASE}/ldmx-sw/ +fi + +echo "-- Compiling ldmx-sw in ${LDMX_COMPILE_BUILD} with ${LDMX_COMPILE_CORES} cores, and running " + +# Compile ldmx-sw +cmake -B ${LDMX_COMPILE_BUILD}/build -S ${LDMX_COMPILE_BUILD} +cmake --build ${LDMX_COMPILE_BUILD}/build --target install -j=${LDMX_COMPILE_CORES} +# Run fire on the input config +fire $@