diff --git a/.gitignore b/.gitignore
index fc58c11b6a1c796c31b5ed56353db1397376dbfd..07c1fa68f9f28f85e7038e01064c3d86249863f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,6 @@ __pycache__/
 calorimeters/test/
 *.d
 *.pcm
+
+# output files
+results/*
diff --git a/dvmp/config.yml b/dvmp/config.yml
index e36716efae00da362284d39af598a428429ddb89..40d38ac88f2ff9808f9ebb60591d4cc7f15a484e 100644
--- a/dvmp/config.yml
+++ b/dvmp/config.yml
@@ -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
diff --git a/dvmp/generator/config_jpsi_decay.sh b/dvmp/generator/config_jpsi_decay.sh
deleted file mode 100755
index 81016e726b3a12b6b03921d97197784a038ac616..0000000000000000000000000000000000000000
--- a/dvmp/generator/config_jpsi_decay.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/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."
diff --git a/dvmp/generator/jpsi_central.json.in b/dvmp/generator/jpsi_central.json.in
index 989bac5508f680ba16fb75ba6bcf61130f110313..b35e5fdc69938e32d43887405e0de4eeb33e826b 100644
--- a/dvmp/generator/jpsi_central.json.in
+++ b/dvmp/generator/jpsi_central.json.in
@@ -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"},
diff --git a/dvmp/scripts/generate.sh b/dvmp/scripts/generate.sh
index 76a62a52c374d71e150cb42a1169447aef53a919..172ed237db03a22ee1a439b92647313b6e9fb1f3 100755
--- a/dvmp/scripts/generate.sh
+++ b/dvmp/scripts/generate.sh
@@ -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`
diff --git a/dvmp/scripts/jpsi_central-generate.sh b/dvmp/scripts/jpsi_central-generate.sh
deleted file mode 100755
index 47168ddb72b30cba1df79e94fc1a3ff4c5b9d331..0000000000000000000000000000000000000000
--- a/dvmp/scripts/jpsi_central-generate.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/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
diff --git a/dvmp/scripts/print_fname.sh b/dvmp/scripts/print_fname.sh
index 3f29866634c2b3b031e9d3037f18f350f182a905..7648678315b1072ee62bb0acb50aa0be15b4ad99 100755
--- a/dvmp/scripts/print_fname.sh
+++ b/dvmp/scripts/print_fname.sh
@@ -31,7 +31,7 @@ while [ $# -gt 0 ]; do
       shift
       shift
       ;;
-    --stage)
+    --type)
       TYPE="$2"
       shift
       shift
diff --git a/dvmp/scripts/run_generator_instance.sh b/dvmp/scripts/run_generator_instance.sh
new file mode 100755
index 0000000000000000000000000000000000000000..88102d5c0b66c977312e973f6e2349aec55ab654
--- /dev/null
+++ b/dvmp/scripts/run_generator_instance.sh
@@ -0,0 +1,118 @@
+#!/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