From b93af429a568b80b6d29b34cef5e1dda0a052cd0 Mon Sep 17 00:00:00 2001 From: Sylvester Joosten <sylvester.joosten@gmail.com> Date: Mon, 23 Nov 2020 20:25:46 -0600 Subject: [PATCH] disabled debug logging for now, will re-enable after having established that running many jobs works --- dvmp/analysis/util.h | 11 ++--- dvmp/config.yml | 13 +++++- dvmp/dvmp.sh | 31 ++++++++++---- dvmp/env.sh | 2 +- dvmp/gen.sh | 20 ++++----- dvmp/generator/jpsi_barrel.json.in | 67 ++++++++++++++++++++++++++++++ {util => tools}/download.sh | 0 {util => tools}/start_dev_shell.sh | 0 util/run_many.py | 6 +-- 9 files changed, 122 insertions(+), 28 deletions(-) create mode 100644 dvmp/generator/jpsi_barrel.json.in rename {util => tools}/download.sh (100%) rename {util => tools}/start_dev_shell.sh (100%) diff --git a/dvmp/analysis/util.h b/dvmp/analysis/util.h index 874b7024..2eabcece 100644 --- a/dvmp/analysis/util.h +++ b/dvmp/analysis/util.h @@ -61,12 +61,13 @@ momenta_from_tracking(const std::vector<eic::TrackParametersData>& tracks, [mass](const auto& track) { // make sure we don't divide by zero if (fabs(track.qOverP) < 1e-9) { - return ROOT::Math::PtEtaPhiMVector{}; + return ROOT::Math::PxPyPzMVector{}; } - const double pt = 1. / track.qOverP * sin(track.theta); - const double eta = -log(tan(track.theta / 2)); - const double phi = track.phi; - return ROOT::Math::PtEtaPhiMVector{pt, eta, phi, mass}; + const double p = fabs(1. / track.qOverP); + const double px = p * cos(track.phi) * sin(track.theta); + const double py = p * sin(track.phi) * sin(track.theta); + const double pz = p * cos(track.theta); + return ROOT::Math::PxPyPzMVector{px, py, pz, mass}; }); return momenta; } diff --git a/dvmp/config.yml b/dvmp/config.yml index c646d6dd..ac25f6fb 100644 --- a/dvmp/config.yml +++ b/dvmp/config.yml @@ -15,14 +15,23 @@ dvmp:generate: paths: - input script: - - ./util/run_many.py ./dvmp/gen.sh --energy 10x100 --config jpsi_central --decay muon --decay electron + - ./util/run_many.py ./dvmp/gen.sh + -c jpsi_barrel + -e 5x41 -e 10x100 -e 18x275 + --decay muon --decay electron + --nproc 5 dvmp:process: stage: process needs: ["detector", "dvmp:generate"] timeout: 1 hour script: - - ./util/run_many.py dvmp/dvmp.sh --energy 10x100 --config jpsi_central --decay muon --decay electron --leading jpsi + - ./util/run_many.py ./dvmp/dvmp.sh + -c jpsi_barrel + -e 5x41 -e 10x100 -e 18x275 + --decay muon --decay electron + --leading jpsi + --nproc 5 artifacts: paths: - results diff --git a/dvmp/dvmp.sh b/dvmp/dvmp.sh index 6930fc02..6d4e1844 100755 --- a/dvmp/dvmp.sh +++ b/dvmp/dvmp.sh @@ -51,9 +51,14 @@ source dvmp/env.sh ## Get a unique file names based on the configuration options GEN_FILE=${INPUT_PATH}/gen-${CONFIG}_${DECAY}.hepmc + SIM_FILE=${TMP_PATH}/sim-${CONFIG}_${DECAY}.root +SIM_LOG=${TMP_PATH}/sim-${CONFIG}_${DECAY}.log + REC_FILE=${TMP_PATH}/rec-${CONFIG}_${DECAY}.root -PLOT_PREFIX=${CONFIG}_${DECAY} +REC_LOG=${TMP_PATH}/sim-${CONFIG}_${DECAY}.log + +PLOT_TAG=${CONFIG}_${DECAY} ## ============================================================================= ## Step 2: Run the simulation @@ -64,7 +69,8 @@ npsim --runType batch \ --numberOfEvents ${JUGGLER_N_EVENTS} \ --compactFile ${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml \ --inputFiles ${GEN_FILE} \ - --outputFile ${SIM_FILE} + --outputFile ${SIM_FILE} \ + 2>&1 > ${SIM_LOG} if [ "$?" -ne "0" ] ; then echo "ERROR running npsim" exit 1 @@ -85,10 +91,19 @@ export JUGGLER_SIM_FILE=${SIM_FILE} export JUGGLER_REC_FILE=${REC_FILE} export JUGGLER_DETECTOR_PATH=${DETECTOR_PATH} xenv -x ${JUGGLER_INSTALL_PREFIX}/Juggler.xenv \ - gaudirun.py options/tracker_reconstruction.py + gaudirun.py options/tracker_reconstruction.py \ + 2>&1 > ${REC_LOG} +## on-error, first retry running juggler again as there is still a random +## crash we need to address FIXME if [ "$?" -ne "0" ] ; then - echo "ERROR running juggler" - exit 1 + echo "Juggler crashed, retrying..." + xenv -x ${JUGGLER_INSTALL_PREFIX}/Juggler.xenv \ + gaudirun.py options/tracker_reconstruction.py \ + 2>&1 > ${REC_LOG} + if [ "$?" -ne "0" ] ; then + echo "ERROR running juggler, both attempts failed" + exit 1 + fi fi ls -l @@ -99,8 +114,7 @@ root -b -q "dvmp/analysis/vm_mass.cxx(\ \"${LEADING}\", \ \"${DECAY}\", \ \"${JUGGLER_DETECTOR}\", \ - \"${RESULTS_PATH}/${PLOT_PREFIX}\")" - + \"${RESULTS_PATH}/${PLOT_TAG}\")" if [ "$?" -ne "0" ] ; then echo "ERROR running root script" @@ -117,6 +131,9 @@ if [ "${JUGGLER_N_EVENTS}" -lt "500" ] ; then cp ${REC_FILE} ${RESULTS_PATH} fi +## Always move over log files to the results path +mv ${SIM_LOG} ${REC_LOG} ${RESULTS_PATH} + ## cleanup output files rm -f ${REC_FILE} ${SIM_FILE} diff --git a/dvmp/env.sh b/dvmp/env.sh index 9c543b34..d449f479 100644 --- a/dvmp/env.sh +++ b/dvmp/env.sh @@ -29,7 +29,7 @@ echo "INPUT_PATH: ${INPUT_PATH}" ## Data path for temporary data (not exported as artifacts) -TMP_PATH=${LOCAL_PREFIX} +TMP_PATH=${LOCAL_PREFIX}/tmp/${EBEAM}on${PBEAM} mkdir -p ${TMP_PATH} export TMP_PATH=`realpath ${TMP_PATH}` echo "TMP_PATH: ${TMP_PATH}" diff --git a/dvmp/gen.sh b/dvmp/gen.sh index 0eaefda7..5560ca02 100755 --- a/dvmp/gen.sh +++ b/dvmp/gen.sh @@ -46,16 +46,16 @@ source config/env.sh source dvmp/env.sh ## Get a unique file name prefix based on the configuration options -GEN_PREFIX=gen-${CONFIG}_${DECAY} +GEN_TAG=gen-${CONFIG}_${DECAY} ## Generic file prefix ## ============================================================================= ## Step 2: Check if we really need to run, or can use the cache. -if [ -f "${INPUT_PATH}/${GEN_PREFIX}.hepmc" ]; then - echo "Found cached generator output for $GEN_PREFIX, no need to rerun" +if [ -f "${INPUT_PATH}/${GEN_TAG}.hepmc" ]; then + echo "Found cached generator output for $GEN_TAG, no need to rerun" exit 0 fi -echo "Generator output for $GEN_PREFIX not found in cache, need to run generator" +echo "Generator output for $GEN_TAG not found in cache, need to run generator" ## ============================================================================= ## Step 3: Create generator configuration file @@ -73,22 +73,22 @@ fi ## generate the config file for this generator setup CONFIG_IN="${BENCHMARK_TAG}/generator/${CONFIG}.json.in" -echo "Creating generator configuration file ${GEN_PREFIX}.json" +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 -sed "s/@TAG@/${GEN_PREFIX}/" $CONFIG_IN | \ +sed "s/@TAG@/${GEN_TAG}/" $CONFIG_IN | \ sed "s/@EBEAM@/${EBEAM}/" | \ sed "s/@PBEAM@/${PBEAM}/" | \ sed "s/@DECAY_LEPTON@/${DECAY_PID}/" | \ - sed "s/@BRANCHING@/${BRANCHING}/" > ${TMP_PATH}/${GEN_PREFIX}.json + sed "s/@BRANCHING@/${BRANCHING}/" > ${TMP_PATH}/${GEN_TAG}.json ## ============================================================================= ## Step 4: Run the event generator echo "Running the generator" lager -r ${JUGGLER_RNG_SEED} \ - -c ${TMP_PATH}/${GEN_PREFIX}.json \ + -c ${TMP_PATH}/${GEN_TAG}.json \ -e ${JUGGLER_N_EVENTS} \ -o ${TMP_PATH} if [ "$?" -ne "0" ] ; then @@ -100,10 +100,10 @@ fi ## Step 5: Finally, move relevant output into the artifacts directory and clean up echo "Moving generator output into ${INPUT_PATH}" for ext in hepmc json log root ; do - mv ${TMP_PATH}/*.${GEN_PREFIX}.*.${ext} ${INPUT_PATH}/${GEN_PREFIX}.${ext} + mv ${TMP_PATH}/*.${GEN_TAG}.*.${ext} ${INPUT_PATH}/${GEN_TAG}.${ext} done ## this step only matters for local execution echo "Cleaning up" -rm ${TMP_PATH}/${GEN_PREFIX}.json +rm ${TMP_PATH}/${GEN_TAG}.json ## All done! diff --git a/dvmp/generator/jpsi_barrel.json.in b/dvmp/generator/jpsi_barrel.json.in new file mode 100644 index 00000000..768683e9 --- /dev/null +++ b/dvmp/generator/jpsi_barrel.json.in @@ -0,0 +1,67 @@ +{ + "mc" : { + "type" : "eic", + "tag" : "@TAG@", + "events" : "10000", + "output_hepmc": true, + "generator" : { + "type" : "ep-2gluon", + "vertex" : {"type" : "origin"}, + "beam": { + "lepton" : { + "type" : "constant", + "particle_type" : "e-", + "dir" : [ "0", "0", "-1" ], + "energy" : "@EBEAM@" + }, + "ion" : { + "type" : "constant", + "particle_type" : "proton", + "dir" : [ "0", "0", "1" ], + "energy" : "@PBEAM@" + } + }, + "target": {"type": "primary"}, + "photon" : { + "type" : "vphoton", + "y_range" : [ "0.01", "1" ], + "Q2_range": [ "1.0", "1000"] + }, + "process_0" : { + "type" : "brodsky_2vmX", + "vm_type" : "J/psi", + "recoil_type" : "proton", + "photo_b" : "4.50", + "photo_c2g" : "6.0e4", + "photo_c3g" : "0.0", + "R_vm_c" : "2.164", + "R_vm_n" : "2.131", + "dipole_n" : "2.575", + "note": "b from the H1 paper, c2g adjusted to fit HERA points" + } + }, + "detector" : { + "type" : "composite", + "components" : { + "barrel" : { + "id" : "1", + "name" : "barrel", + "type" : "cone", + "acceptance" : { + "acceptance" : "1.0", + "p" : [ "1", "1000" ], + "theta" : [ "45", "135" ], + "pid" : [ "e+", "e-", "mu+", "mu-" ] + }, + "smearing" : {"p" : "0.0", "theta" : "0.0", "phi" : "0.0"} + } + } + }, + "reconstruction" : {"require_leading" : "true"}, + "decay" : { + "vm_decay_lepton_type" : "@DECAY_LEPTON@", + "vm_branching_ratio" : "@BRANCHING@", + "do_radiative_decay_vm" : "true" + } + } +} diff --git a/util/download.sh b/tools/download.sh similarity index 100% rename from util/download.sh rename to tools/download.sh diff --git a/util/start_dev_shell.sh b/tools/start_dev_shell.sh similarity index 100% rename from util/start_dev_shell.sh rename to tools/start_dev_shell.sh diff --git a/util/run_many.py b/util/run_many.py index 13796e4a..45150c08 100755 --- a/util/run_many.py +++ b/util/run_many.py @@ -19,13 +19,13 @@ parser.add_argument( 'command', help="Script to be launched in parallel") parser.add_argument( - '--energy', + '--energy', '-e', dest='energies', action='append', help='One or more beam energy pairs (e.g. 10x100)', required=True) parser.add_argument( - '--config', + '--config', '-c', dest='configs', action='append', help='One or more configurations', @@ -55,7 +55,7 @@ def worker(command): ## use a temporary file to capture the terminal output, and then ## print the terminal output once the command finishes with NamedTemporaryFile() as f: - cmd = [command, '2>1 >', f.name] + cmd = [command, ' 2>&1 >', f.name] cmd = ' '.join(cmd) print("Executing '{}'".format(cmd)) os.system(cmd) -- GitLab