diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eb4b9808563a1fefaa0e860881ae3cee9b4c9148..bf7f0bfd3a8979b89234495999a08c5028c9f2c4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -69,6 +69,7 @@ include: #- local: 'benchmarks/dvmp/config.yml' - local: 'benchmarks/dvcs/config.yml' - local: 'benchmarks/u_omega/config.yml' + - local: 'benchmarks/single/config.yml' summary: stage: finish diff --git a/benchmarks/single/analysis/analyze.cxx b/benchmarks/single/analysis/analyze.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a5d01692b504f758498b88616f495284aa19271b --- /dev/null +++ b/benchmarks/single/analysis/analyze.cxx @@ -0,0 +1,38 @@ +#include <iostream> +#include <string> + +#include <ROOT/RDataFrame.hxx> + +#include <eicd/ReconstructedParticleData.h> + +int analyze(std::string file) +{ + // open dataframe + ROOT::RDataFrame df("events", file, {"GeneratedParticles", "ReconstructedParticles"}); + + // count total events + auto count = df.Count(); + if (count == 0) { + std::cout << "Error: No events found" << std::endl; + return -1; + } + + auto n_tracks = [](const std::vector<eic::ReconstructedParticleData> &p) { return (int) p.size(); }; + + auto d = df + .Define("n_tracks_gen", n_tracks, {"GeneratedParticles"}) + .Define("n_tracks_rec", n_tracks, {"ReconstructedParticles"}) + ; + + auto stats_n_tracks_gen = d.Stats("n_tracks_gen"); + auto stats_n_tracks_rec = d.Stats("n_tracks_rec"); + if (stats_n_tracks_rec->GetMean() < 0.9) { + std::cout << "Error: too few tracks per events " << std::endl; + stats_n_tracks_gen->Print(); + stats_n_tracks_rec->Print(); + return -1; + } + + // success + return 0; +} diff --git a/benchmarks/single/config.yml b/benchmarks/single/config.yml new file mode 100644 index 0000000000000000000000000000000000000000..35ed2a0d046972fd4ccf7a18b60d9a334c79d155 --- /dev/null +++ b/benchmarks/single/config.yml @@ -0,0 +1,6 @@ +single:process: + extends: .phy_benchmark + timeout: 24 hours + stage: process + script: + - bash benchmarks/single/single.sh e-_1GeV_45to135deg diff --git a/benchmarks/single/e-_1GeV_45to135deg.steer b/benchmarks/single/e-_1GeV_45to135deg.steer new file mode 100644 index 0000000000000000000000000000000000000000..dff3f9515242b432ad37e648f222c7d6f3f7a243 --- /dev/null +++ b/benchmarks/single/e-_1GeV_45to135deg.steer @@ -0,0 +1,11 @@ +from DDSim.DD4hepSimulation import DD4hepSimulation +from g4units import mm, GeV, MeV, degree +SIM = DD4hepSimulation() + +SIM.gun.energy = 1*GeV +SIM.gun.particle = "e-" +SIM.gun.position = (0.0, 0.0, 0.0) +SIM.gun.direction = (0.0, 0.0, 1.0) +SIM.gun.distribution = "cos(theta)" +SIM.gun.thetaMin = 45*degree +SIM.gun.thetaMax = 135*degree \ No newline at end of file diff --git a/benchmarks/single/single.sh b/benchmarks/single/single.sh new file mode 100644 index 0000000000000000000000000000000000000000..d20bf7936c4cc9a7afb4d252561cf0d11affb703 --- /dev/null +++ b/benchmarks/single/single.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +if [[ ! -n "${JUGGLER_N_EVENTS}" ]] ; then + export JUGGLER_N_EVENTS=100 +fi + +export JUGGLER_FILE_NAME_TAG="${1:-e-_1GeV_45to135deg}" +export JUGGLER_GEN_FILE="benchmarks/single/${JUGGLER_FILE_NAME_TAG}.steer" +export JUGGLER_SIM_FILE="sim_${JUGGLER_FILE_NAME_TAG}.root" +export JUGGLER_REC_FILE="rec_${JUGGLER_FILE_NAME_TAG}.root" + +# Simulate +npsim --runType run \ + --printLevel WARNING \ + --enableGun \ + --steeringFile ${JUGGLER_GEN_FILE} \ + --numberOfEvents ${JUGGLER_N_EVENTS} \ + --part.minimalKineticEnergy 1*TeV \ + --compactFile ${DETECTOR_PATH}/${JUGGLER_DETECTOR}.xml \ + --outputFile ${JUGGLER_SIM_FILE} +if [[ "$?" -ne "0" ]] ; then + echo "ERROR running npsim" + exit 1 +fi + +# Reconstruct +for rec in options/*.py ; do + unset tag + [[ $(basename ${rec} .py) =~ (.*)\.(.*) ]] && tag=".${BASH_REMATCH[2]}" + JUGGLER_REC_FILE=${JUGGLER_REC_FILE/.root/${tag:-}.root} \ + gaudirun.py ${rec} + if [[ "$?" -ne "0" ]] ; then + echo "ERROR running juggler" + exit 1 + fi +done + +# Analysis +root -l -b -q "benchmarks/single/analysis/analyze.cxx(\"${JUGGLER_REC_FILE}\")" +if [[ "$?" -ne "0" ]] ; then + echo "ERROR analysis failed" + exit 1 +fi