Skip to content
Snippets Groups Projects
Commit 739e55d4 authored by Sylvester Joosten's avatar Sylvester Joosten
Browse files

Added and tested event generator integration

parent a6f560af
No related branches found
No related tags found
1 merge request!2DVMP work
......@@ -40,3 +40,6 @@ __pycache__/
calorimeters/test/
*.d
*.pcm
# output files
results/*
......@@ -15,7 +15,7 @@ dvmp:jpsi_central:generate:
paths:
- results
script:
- ./dvmp/scripts/jpsi_central-generate.sh
- ./dvmp/scripts/generate.sh --ebeam 10 --pbeam 100 --config jpsi_central --decay muon --decay electron
dvmp:jpsi_central:process:
stage: process
......
#!/bin/bash
## Generates different configurations from the master configuration
## for both electron and muon decay channels
echo "Generating generator configuration files for J/psi -> e+e- and mu+mu-"
CONFIG=
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-c|--config)
CONFIG="$2"
shift # past argument
shift # past value
;;
*) # unknown option
echo "unknown option"
exit 1
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if [[ -z ${CONFIG} ]] ; then
echo " ERROR: need argument -c/--config <config file> "
exit 1
fi
if [[ ! -f ${CONFIG} ]] ; then
echo " ERROR: cannot find config input file ${CONFIG}"
exit 1
fi
CONFIG_BASE=`basename ${CONFIG} .json.in`
echo "Generating ${CONFIG_BASE}_el.json"
sed "s/@TAG@/electron/" ${CONFIG} | \
sed "s/@DECAY_LEPTON@/11/" | sed "s/@BRANCHING@/0.05971/" > ${CONFIG_BASE}_el.json
echo "Generating ${CONFIG_BASE}_mu.json"
sed "s/@TAG@/muon/" ${CONFIG} | \
sed "s/@DECAY_LEPTON@/13/" | sed "s/@BRANCHING@/0.05961/" > ${CONFIG_BASE}_mu.json
echo "Configuration generation finished."
......@@ -3,6 +3,7 @@
"type" : "eic",
"tag" : "@TAG@",
"events" : "10000",
"output_hepmc": true,
"generator" : {
"type" : "ep-2gluon",
"vertex" : {"type" : "origin"},
......@@ -11,13 +12,13 @@
"type" : "constant",
"particle_type" : "e-",
"dir" : [ "0", "0", "-1" ],
"energy" : "10.0"
"energy" : "@EBEAM@"
},
"ion" : {
"type" : "constant",
"particle_type" : "proton",
"dir" : [ "0", "0", "1" ],
"energy" : "100"
"energy" : "@PBEAM@"
}
},
"target": {"type": "primary"},
......
......@@ -3,130 +3,13 @@
## Init the environment
source config/env.sh
## Generator configuration
## We use generator-level n-events, which needs to be larger or equal to
## the number of juggler events
export NEVENTS=1000
if [ ${JUGGLER_N_EVENTS} \> ${NEVENTS} ]; then
NEVENTS=${JUGGLER_N_EVENTS}
fi
## Our random seed
export RNG_SEED=1
## Setup local environment
export DATA_PATH=$RESULTS_PATH/data/dvmp
## Maximum number of generators to run in parallel
export MT=10
run_generator() {
EBEAM=
PBEAM=
DECAY=
CONFIG=
while [ $# -gt 0 ]; do
key=$1
case $key in
--ebeam)
EBEAM="$2"
shift
shift
;;
--pbeam)
PBEAM="$2"
shift
shift
;;
--decay)
DECAY="$2"
shift
shift
;;
--config)
CONFIG="$2"
shift
shift
;;
*)
echo "Unknown option $key to run_generator(), aborting..."
exit 1
esac
done
if [ -z $EBEAM ]; then
echo "EBEAM not defined in run_generator, aborting..."
exit 1
elif [ -z $PBEAM ]; then
echo "PBEAM not defined in run_generator, aborting..."
exit 1
elif [ -z $DECAY ]; then
echo "DECAY not defined in run_generator, aborting..."
exit 1
elif [ $DECAY != "electron" ] && [ $DECAY != "muon" ] ; then
echo "Unknown decay channel $DECAY, aborting..."
exit 1
elif [ -z $CONFIG ]; then
echo "CONFIG not defined in run_generator, aborting..."
fi
pushd dvmp
FNAME=`scripts/print_fname.sh \
--ebeam $EBEAM \
--pbeam $PBEAM \
--decay $DECAY \
--config $CONFIG \
--type gen`
if [ -f "${DATA_PATH}/${FNAME}.hepmc" ]; then
echo "Found cached generator output for $FNAME, no need to rerun"
return
fi
echo "Generator output for $FNAME not found in cache, need to run generator"
## 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="generator/${CONFIG}.json.in"
echo "Creating generator configuration file ${FNAME}.json"
if [ ! -f ${CONFIG_IN} ]; then
echo "ERROR: cannot find master config file ${CONFIG_IN}"
exit 1
fi
sed "s/@TAG@/${FNAME}/" $CONFIG_IN | \
sed "s/@EBEAM@/${EBEAM}/" | \
sed "s/@PBEAM@/${PBEAM}/" | \
sed "s/@DECAY_LEPTON@/${DECAY_PID}/" | \
sed "s/@BRANCHING@/${BRANCHING}/" > ${FNAME}.json
## New we can run the generator
echo "Running the generator"
lager -r ${RNG_SEED} -c ${FNAME}.json -e ${NEVENTS} -o .
## Finally, move relevant output into the artifacts directory
echo "Moving generator output into ${DATA_PATH}"
mkdir -p ${DATA_PATH}
for ext in hepmc json log root; do
mv *.${FNAME}.*.${ext} ${DATA_PATH}/${FNAME}.${ext}
done
}
## Generates different configurations from the master configuration
## for both electron and muon decay channels
echo "Generating generator configuration files for J/psi -> e+e- and mu+mu-"
echo "Generating DVMP event samples using lAger"
EBEAM=
PBEAM=
......@@ -181,7 +64,7 @@ fi
## loop over all our configurations and run the generator in parallel
parallel -j ${MT} \
run_generator --ebeam ${EBEAM} --pbeam ${PBEAM} --config {1} --decay {2} \
"dvmp/scripts/run_generator_instance.sh --ebeam ${EBEAM} --pbeam ${PBEAM} --config {1} --decay {2}" \
::: "${CONFS[@]}" ::: "${DECAYS[@]}"
CONFIG_BASE=`basename ${CONFIG} .json.in`
......
#!/bin/bash
## Init the environment
source config/env.sh
## Generator configuration
export NEVENTS=100
export RNG_SEED=1
export DVMP_RESULTS_PATH=$RESULTS_PATH/dvmp
export FNAME_EL="${DVMP_RESULTS_PATH}/jpsi_central_el-gen"
export FNAME_MU="${DVMP_RESULTS_PATH}/jpsi_central_mu-gen"
## Check if we already have our MC files in the cache
if [ -f "${FNAME_EL}.hepmc" ] && [ -f "${FNAME_MU}.hepmc"]; then
echo "Found cached generator output, no need to rerun"
else
echo "Need to generate our event sample"
pushd dvmp
## First generate our actual configuration files. We run for both electron
## and muon configurations
./generator/config_jpsi_decay.sh -c generator/jpsi_central.json.in
## This generates our jpsi_central_el.json and jpsi_central_mu.json files
## Now we can run the generator in parallel for both configurations
echo "Running the generator"
lager -r ${RNG_SEED} -c jpsi_central_el.json -e ${NEVENTS} -o . &
lager -r ${RNG_SEED} -c jpsi_central_mu.json -e ${NEVENTS} -o . &
wait
## Finally, we move our output into the artifacts directory
echo "Moving generator output into ${DVMP_RESULTS_PATH}"
mkdir -p ${DVMP_RESULTS_PATH}
mv *electron*.json ${FNAME_EL}.json
mv *electron*.root ${FNAME_EL}.root
mv *electron*.hepmc ${FNAME_EL}.hepmc
mv *electron*.log ${FNAME_EL}.log
mv *muon*.json ${FNAME_MU}.json
mv *muon*.root ${FNAME_MU}.root
mv *muon*.hepmc ${FNAME_MU}.hepmc
mv *muon*.log ${FNAME_MU}.log
fi
......@@ -31,7 +31,7 @@ while [ $# -gt 0 ]; do
shift
shift
;;
--stage)
--type)
TYPE="$2"
shift
shift
......
#!/bin/bash
## Init the environment
source config/env.sh
## Generator configuration
## We use generator-level n-events, which needs to be larger or equal to
## the number of juggler events
export NEVENTS=1000
if [ ${JUGGLER_N_EVENTS} \> ${NEVENTS} ]; then
NEVENTS=${JUGGLER_N_EVENTS}
fi
## Our random seed
export RNG_SEED=1
## Setup local environment
export DATA_PATH=$RESULTS_PATH/data/dvmp
EBEAM=
PBEAM=
DECAY=
CONFIG=
while [ $# -gt 0 ]; do
key=$1
case $key in
--ebeam)
EBEAM="$2"
shift
shift
;;
--pbeam)
PBEAM="$2"
shift
shift
;;
--decay)
DECAY="$2"
shift
shift
;;
--config)
CONFIG="$2"
shift
shift
;;
*)
echo "Unknown option $key to run_generator(), aborting..."
exit 1
esac
done
if [ -z $EBEAM ]; then
echo "EBEAM not defined in run_generator, aborting..."
exit 1
elif [ -z $PBEAM ]; then
echo "PBEAM not defined in run_generator, aborting..."
exit 1
elif [ -z $DECAY ]; then
echo "DECAY not defined in run_generator, aborting..."
exit 1
elif [ $DECAY != "electron" ] && [ $DECAY != "muon" ] ; then
echo "Unknown decay channel $DECAY, aborting..."
exit 1
elif [ -z $CONFIG ]; then
echo "CONFIG not defined in run_generator, aborting..."
fi
pushd dvmp
FNAME=`scripts/print_fname.sh \
--ebeam $EBEAM \
--pbeam $PBEAM \
--decay $DECAY \
--config $CONFIG \
--type gen`
if [ -f "${DATA_PATH}/${FNAME}.hepmc" ]; then
echo "Found cached generator output for $FNAME, no need to rerun"
exit
fi
echo "Generator output for $FNAME not found in cache, need to run generator"
## 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="generator/${CONFIG}.json.in"
echo "Creating generator configuration file ${FNAME}.json"
if [ ! -f ${CONFIG_IN} ]; then
echo "ERROR: cannot find master config file ${CONFIG_IN}"
exit 1
fi
sed "s/@TAG@/${FNAME}/" $CONFIG_IN | \
sed "s/@EBEAM@/${EBEAM}/" | \
sed "s/@PBEAM@/${PBEAM}/" | \
sed "s/@DECAY_LEPTON@/${DECAY_PID}/" | \
sed "s/@BRANCHING@/${BRANCHING}/" > ${FNAME}.json
## New we can run the generator
echo "Running the generator"
lager -r ${RNG_SEED} -c ${FNAME}.json -e ${NEVENTS} -o .
## Finally, move relevant output into the artifacts directory
echo "Moving generator output into ${DATA_PATH}"
mkdir -p ${DATA_PATH}
for ext in hepmc json log root; do
mv *.${FNAME}.*.${ext} ${DATA_PATH}/${FNAME}.${ext}
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment