Skip to content
Snippets Groups Projects
Commit 264c9ae3 authored by Wouter Deconinck's avatar Wouter Deconinck
Browse files

Resolve "Include synchrotron radiation benchmark"

parent 73b6e0b8
No related branches found
No related tags found
1 merge request!106Resolve "Include synchrotron radiation benchmark"
...@@ -70,6 +70,7 @@ include: ...@@ -70,6 +70,7 @@ include:
- local: 'benchmarks/dvcs/config.yml' - local: 'benchmarks/dvcs/config.yml'
- local: 'benchmarks/u_omega/config.yml' - local: 'benchmarks/u_omega/config.yml'
- local: 'benchmarks/single/config.yml' - local: 'benchmarks/single/config.yml'
- local: 'benchmarks/synchrotron/config.yml'
summary: summary:
stage: finish stage: finish
......
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include "ROOT/RDataFrame.hxx"
#include "Math/Vector4D.h"
#include "TCanvas.h"
#include <nlohmann/json.hpp>
using json = nlohmann::json;
R__LOAD_LIBRARY(libfmt.so)
#include "fmt/core.h"
#include "fmt/color.h"
R__LOAD_LIBRARY(libeicd.so)
R__LOAD_LIBRARY(libDD4pod.so)
#include "eicd/ReconstructedParticleCollection.h"
void synchrotron_raw(const char* fname = "rec_synchrotron.raw.root"){
fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green), "Running synchrotron analysis...\n");
// Run this in multi-threaded mode if desired
ROOT::EnableImplicitMT();
ROOT::RDataFrame df("events", fname);
}
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include "ROOT/RDataFrame.hxx"
#include "Math/Vector4D.h"
#include "TCanvas.h"
#include <nlohmann/json.hpp>
using json = nlohmann::json;
R__LOAD_LIBRARY(libfmt.so)
#include "fmt/core.h"
#include "fmt/color.h"
R__LOAD_LIBRARY(libeicd.so)
R__LOAD_LIBRARY(libDD4pod.so)
#include "eicd/ReconstructedParticleCollection.h"
void synchrotron_sim(const char* fname = "sim_synchrotron.root"){
fmt::print(fmt::emphasis::bold | fg(fmt::color::forest_green), "Running synchrotron analysis...\n");
// Run this in multi-threaded mode if desired
ROOT::EnableImplicitMT();
ROOT::RDataFrame df("events", fname);
// Define variables
auto df0 = df
.Define("n_VertexBarrelHits", "VertexBarrelHits.size()")
.Define("n_VertexEndcapHits", "VertexEndcapHits.size()")
;
auto n_VertexBarrelHits = df0.Mean("n_VertexBarrelHits");
auto n_VertexEndcapHits = df0.Mean("n_VertexEndcapHits");
std::cout << "n_VertexBarrelHits = " << *n_VertexBarrelHits << " / ev" << std::endl;
std::cout << "n_VertexEndcapHits = " << *n_VertexEndcapHits << " / ev" << std::endl;
}
synchrotron:process:
stage: process
extends: .phy_benchmark
tags:
- s3
needs: ["common:detector"]
script:
- compile_analyses.py synchrotron
- bash benchmarks/synchrotron/synchrotron.sh --all
synchrotron:results:
stage: collect
needs: ["synchrotron:process"]
script:
- ls -lrth
#!/bin/bash
function print_the_help {
echo "USAGE: ${0} [--rec] [--sim] [--ana] [--all] "
echo " The default options are to run all steps (sim,rec,ana) "
echo "OPTIONS: "
echo " --data-init download the input event data"
echo " --sim,-s Runs the Geant4 simulation"
echo " --rec,-r Run the juggler reconstruction"
echo " --ana,-a Run the analysis scripts"
echo " --all (default) Do all steps. Argument is included so usage can convey intent."
exit
}
DO_ALL=1
DATA_INIT=
DO_SIM=
DO_REC=
DO_ANA=
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
shift # past argument
print_the_help
;;
--all)
DO_ALL=2
if [[ ! "${DO_REC}${DO_SIM}${DO_ANA}" -eq "" ]] ; then
echo "Error: cannot use --all with other arguments." 1>&2
print_the_help
exit 1
fi
shift # past value
;;
-s|--sim)
DO_SIM=1
DO_ALL=
shift # past value
;;
--data-init)
DATA_INIT=1
DO_ALL=
shift # past value
;;
-r|--rec)
DO_REC=1
DO_ALL=
shift # past value
;;
-a|--analysis)
DO_ANA=1
DO_ALL=
shift # past value
;;
*) # unknown option
#POSITIONAL+=("$1") # save it in an array for later
echo "unknown option $1"
print_the_help
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# assuming something like .local/bin/env.sh has already been sourced.
print_env.sh
FILE_NAME_TAG="synchrotron"
DATA_URL="S3/eictest/ATHENA/EVGEN/SR/SR.10GeV_5kVthreshold_hepmc/25098.hepmc"
export JUGGLER_MC_FILE="${LOCAL_DATA_PATH}/mc_${FILE_NAME_TAG}.hepmc"
export JUGGLER_SIM_FILE="${LOCAL_DATA_PATH}/sim_${FILE_NAME_TAG}.root"
export JUGGLER_REC_FILE="${LOCAL_DATA_PATH}/rec_${FILE_NAME_TAG}.root"
echo "FILE_NAME_TAG = ${FILE_NAME_TAG}"
echo "JUGGLER_N_EVENTS = ${JUGGLER_N_EVENTS}"
echo "JUGGLER_DETECTOR = ${JUGGLER_DETECTOR}"
## To run the reconstruction, we need the following global variables:
## - JUGGLER_INSTALL_PREFIX: Install prefix for Juggler (simu/recon)
## - JUGGLER_DETECTOR: the detector package we want to use for this benchmark
## - DETECTOR_PATH: full path to the detector definitions
## Step 1. Get the data
if [[ -n "${DATA_INIT}" || -n "${DO_ALL}" ]] ; then
mc -C . config host add S3 https://dtn01.sdcc.bnl.gov:9000 $S3_ACCESS_KEY $S3_SECRET_KEY
mc -C . head -n $((2+5*${JUGGLER_N_EVENTS})) --insecure ${DATA_URL} > ${JUGGLER_MC_FILE}
if [[ "$?" -ne "0" ]] ; then
echo "Failed to download hepmc files"
exit 1
fi
fi
### Step 2. Run the simulation (geant4)
if [[ -n "${DO_SIM}" || -n "${DO_ALL}" ]] ; then
## run geant4 simulations
npsim --runType batch \
--part.minimalKineticEnergy 1000*GeV \
--filter.tracker edep0 \
-v ERROR \
--numberOfEvents ${JUGGLER_N_EVENTS} \
--compactFile ${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml \
--inputFiles ${JUGGLER_MC_FILE} \
--outputFile ${JUGGLER_SIM_FILE}
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running npsim"
exit 1
fi
fi
### Step 3. Run the reconstruction (juggler)
if [[ -n "${DO_REC}" || -n "${DO_ALL}" ]] ; then
for rec in options/*.py ; do
unset tag
[[ $(basename ${rec} .py) =~ (.*)\.(.*) ]] && tag=".${BASH_REMATCH[2]}"
JUGGLER_REC_FILE=${JUGGLER_REC_FILE/.root/${tag:-}.root} \
xenv -x ${JUGGLER_INSTALL_PREFIX}/Juggler.xenv \
gaudirun.py ${rec}
done
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running juggler"
exit 1
fi
root_filesize=$(stat --format=%s "${JUGGLER_REC_FILE}")
if [[ "${JUGGLER_N_EVENTS}" -lt "500" ]] ; then
# file must be less than 10 MB to upload
if [[ "${root_filesize}" -lt "10000000" ]] ; then
cp ${JUGGLER_REC_FILE} results/.
fi
fi
fi
### Step 4. Run the analysis code
if [[ -n "${DO_ANA}" || -n "${DO_ALL}" ]] ; then
echo "Running analysis scripts"
rootls -t ${JUGGLER_REC_FILE}
# Store all plots here (preferribly png and pdf files)
mkdir -p results/synchrotron
# here you can add as many scripts as you want.
root -b -q "benchmarks/synchrotron/analysis/synchrotron_sim.cxx+(\"${JUGGLER_SIM_FILE}\")"
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running root script"
exit 1
fi
root -b -q "benchmarks/synchrotron/analysis/synchrotron_raw.cxx+(\"${JUGGLER_REC_FILE/.root/.raw.root}\")"
if [[ "$?" -ne "0" ]] ; then
echo "ERROR running root script"
exit 1
fi
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment