Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
## =============================================================================
## Run a single instance of the DVMP generator (lAger)
## Runs in 5 steps:
## 1. Parse the command line and setup the environment
## 2. Check if we can load the requested file from the cache
## 3. Create our configuration fil
## 4. Run the actual generator
## 5. Finalize
## =============================================================================
## make sure we launch this script from the project root directory
PROJECT_ROOT="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"/..
pushd ${PROJECT_ROOT}
## =============================================================================
## Step 1: Setup the environment variables
##
## First parse the command line flags.
## This sets the following environment variables:
## - CONFIG: The specific generator configuration
## - EBEAM: The electron beam energy
## - PBEAM: The ion beam energy
## - DECAY: The decay particle for the generator
export REQUIRE_DECAY=1
source util/parse_cmd.sh $@
## To run the generator, we need the following global variables:
##
## - LOCAL_PREFIX: Place to cache local packages and data
## - JUGGLER_N_EVENTS: Number of events to process
## - JUGGLER_RNG_SEED: Random seed for event generation.
##
## You can read config/env.sh for more in-depth explanations of the variables
## and how they can be controlled.
source config/env.sh
## We also need the following benchmark-specific variables:
##
## - BENCHMARK_TAG: Unique identified for this benchmark process.

Sylvester Joosten
committed
## - INPUT_PATH: Path for generator-level input to the benchmarks
## - TMP_PATH: Path for temporary data (not exported as artifacts)
##
## You can read dvmp/env.sh for more in-depth explanations of the variables.
source dvmp/env.sh

Sylvester Joosten
committed
## Get a unique file name prefix based on the configuration options

Sylvester Joosten
committed
GEN_TAG=gen-${CONFIG}_${DECAY}_${JUGGLER_N_EVENTS} ## Generic file prefix
## =============================================================================
## Step 2: Check if we really need to run, or can use the cache.

Sylvester Joosten
committed
if [ -f "${INPUT_PATH}/${GEN_TAG}.hepmc" ]; then
echo "Found cached generator output for $GEN_TAG, no need to rerun"

Sylvester Joosten
committed
exit 0

Sylvester Joosten
committed
echo "Generator output for $GEN_TAG not found in cache, need to run generator"
## =============================================================================
## Step 3: Create generator configuration file
## process decay info
BRANCHING=
DECAY_PID=
if [ $DECAY = "electron" ]; then
BRANCHING="0.05971"
DECAY_PID="11"
elif [ $DECAY = "muon" ]; then
BRANCHING="0.05961"
DECAY_PID="13"
fi
## generate the config file for this generator setup
CONFIG_IN="${BENCHMARK_TAG}/generator/${CONFIG}.json.in"

Sylvester Joosten
committed
echo "Creating generator configuration file ${GEN_TAG}.json"
if [ ! -f ${CONFIG_IN} ]; then
echo "ERROR: cannot find master config file ${CONFIG_IN}"
exit 1
fi

Sylvester Joosten
committed
sed "s/@TAG@/${GEN_TAG}/" $CONFIG_IN | \
sed "s/@EBEAM@/${EBEAM}/" | \
sed "s/@PBEAM@/${PBEAM}/" | \
sed "s/@DECAY_LEPTON@/${DECAY_PID}/" | \

Sylvester Joosten
committed
sed "s/@BRANCHING@/${BRANCHING}/" > ${TMP_PATH}/${GEN_TAG}.json
## =============================================================================
## Step 4: Run the event generator
echo "Running the generator"

Sylvester Joosten
committed
lager -r ${JUGGLER_RNG_SEED} \

Sylvester Joosten
committed
-c ${TMP_PATH}/${GEN_TAG}.json \

Sylvester Joosten
committed
-e ${JUGGLER_N_EVENTS} \
-o ${TMP_PATH}
if [ "$?" -ne "0" ] ; then
echo "ERROR running lAger"
exit 1
fi
## =============================================================================
## Step 5: Finally, move relevant output into the artifacts directory and clean up

Sylvester Joosten
committed
echo "Moving generator output into ${INPUT_PATH}"

Sylvester Joosten
committed
mv ${TMP_PATH}/*.${GEN_TAG}.*.${ext} ${INPUT_PATH}/${GEN_TAG}.${ext}

Sylvester Joosten
committed
## this step only matters for local execution

Sylvester Joosten
committed
rm ${TMP_PATH}/${GEN_TAG}.json