Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move main ALLEGRO tests to ddsim+k4run #109

Merged
27 changes: 4 additions & 23 deletions RecFCCeeCalorimeter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,11 @@ install(TARGETS k4RecFCCeeCalorimeterPlugins

install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/tests DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/RecFCCeeCalorimeter)

add_test(NAME FCCeeLAr_simulateForReco
COMMAND k4run RecFCCeeCalorimeter/tests/options/runCaloSim.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
set_test_env(FCCeeLAr_simulateForReco)

add_test(NAME FCCeeLAr_simRecoAllegroV3
COMMAND k4run RecFCCeeCalorimeter/tests/options/run_thetamodulemerged.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
set_test_env(FCCeeLAr_simRecoAllegroV3)

add_test(NAME FCCeeLAr_slidingWindowClustering
COMMAND k4run RecFCCeeCalorimeter/tests/options/runFullCaloSystem_ReconstructionSW_noiseFromFile.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
add_test(NAME ALLEGRO_o1_v03_sim_reco
COMMAND ${PROJECT_SOURCE_DIR}/RecFCCeeCalorimeter/tests/options/ALLEGRO_o1_v03.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/build/Testing/Temporary
)
set_test_env(FCCeeLAr_slidingWindowClustering)
set_tests_properties(FCCeeLAr_slidingWindowClustering PROPERTIES DEPENDS "FCCeeLAr_simulateForReco")
set_test_env(ALLEGRO_o1_v03_sim_reco)

add_test(NAME FCCeeLAr_benchmarkCalibration
COMMAND k4run RecFCCeeCalorimeter/tests/options/fcc_ee_caloBenchmarkCalibration.py
Expand All @@ -63,9 +50,3 @@ add_test(NAME FCCeeLAr_benchmarkCorrection
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
set_test_env(FCCeeLAr_benchmarkCorrection)

add_test(NAME FCCeeLAr_runxtalk
COMMAND k4run RecCalorimeter/tests/options/runEcalBarrel_ReconstructionTopoClusters_crosstalk.py
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
set_test_env(FCCeeLAr_runxtalk)
66 changes: 66 additions & 0 deletions RecFCCeeCalorimeter/tests/options/ALLEGRO_o1_v03.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

# Define the function for downloading files
download_file() {
local url="$1"

# Attempt to download the file using wget
wget "$url"

# Check the exit status of wget
if [ $? -ne 0 ]; then
# if wget failed, exit the script with status code 1
echo "Download failed."
exit 1
fi
}

# set-up the Key4hep environment if not already set
if [[ -z "${KEY4HEP_STACK}" ]]; then
echo "Error: Key4hep environment not set"
return 1
fi

# download the events to reconstruct
if ! -test ./pythia_ee_z_qq_10evt.hepmc; then
echo "Downloading files needed for simulation"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/gen/pythia_ee_z_qq_10evt.hepmc"
fi

# run the SIM step (for debug do not run it if files already present. Comment the if and fi lines for production)
# if ! test -f ALLEGRO_sim_ee_z_qq.root; then
echo "Performing the Geant4 simulation with ddsim"
ddsim --inputFiles pythia_ee_z_qq_10evt.hepmc --numberOfEvents -1 --outputFile ALLEGRO_sim_ee_z_qq.root --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ALLEGRO_o1_v03.xml
giovannimarchiori marked this conversation as resolved.
Show resolved Hide resolved
# fi
#if ! test -f ALLEGRO_sim_e_barrel.root; then
#echo "Generating events and performing the Geant4 simulation with ddsim"
#ddsim --enableGun --gun.distribution uniform --gun.energy "10*GeV" --gun.particle e- --numberOfEvents 10 --outputFile ALLEGRO_sim_e_barrel.root --random.enableEventSeed --random.seed 42 --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ALLEGRO_o1_v03.xml
#ddsim --enableGun --gun.distribution uniform --gun.energy "10*GeV" --gun.particle e- --numberOfEvents 10 --outputFile ALLEGRO_sim_e_endcap.root --random.enableEventSeed --random.seed 42 --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ALLEGRO_o1_v03.xml
#ddsim --enableGun --gun.distribution uniform --gun.energy "10*GeV" --gun.particle pi- --numberOfEvents 10 --outputFile ALLEGRO_sim_pi_barrel.root --random.enableEventSeed --random.seed 42 --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ALLEGRO_o1_v03.xml
#ddsim --enableGun --gun.distribution uniform --gun.energy "10*GeV" --gun.particle pi- --numberOfEvents 10 --outputFile ALLEGRO_sim_pi_endcap.root --random.enableEventSeed --random.seed 42 --compactFile $K4GEO/FCCee/ALLEGRO/compact/ALLEGRO_o1_v03/ALLEGRO_o1_v03.xml
#fi

retcode=$?
if [ $retcode -ne 0 ]; then
echo "Simulation failed"
exit $retcode
fi
Comment on lines +43 to +47
Copy link
Contributor

@kjvbrt kjvbrt Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is easier to check for the non-zero return value with:

ddsim .... || exit 1

This will exit the script with 1 if ddsim returnns non zero value (the commands for or are evaluated from left to right and if the result of the first command is already true the second command is skipped).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will fix in next PR


# get the files needed for calibration, noise, neighbor finding, etc
if ! test -f ./neighbours_map_ecalB_thetamodulemerged_hcalB_thetaphi.root; then # assumes that if the last file exists, all the other as well
echo "Downloading files needed for reconstruction"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/ALLEGRO/ALLEGRO_o1_v03/capacitances_ecalBarrelFCCee_theta.root"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/ALLEGRO/ALLEGRO_o1_v03/cellNoise_map_electronicsNoiseLevel_ecalB_thetamodulemerged.root"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/ALLEGRO/ALLEGRO_o1_v03/cellNoise_map_electronicsNoiseLevel_ecalB_thetamodulemerged_hcalB_thetaphi.root"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/ALLEGRO/ALLEGRO_o1_v03/elecNoise_ecalBarrelFCCee_theta.root"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/ALLEGRO/ALLEGRO_o1_v03/lgbm_calibration-CaloClusters.onnx"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/ALLEGRO/ALLEGRO_o1_v03/lgbm_calibration-CaloTopoClusters.onnx"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/ALLEGRO/ALLEGRO_o1_v03/neighbours_map_ecalB_thetamodulemerged.root"
download_file "https://fccsw.web.cern.ch/fccsw/filesForSimDigiReco/ALLEGRO/ALLEGRO_o1_v03/neighbours_map_ecalB_thetamodulemerged_hcalB_thetaphi.root"

# add here the lines to get the files for the photon ID
fi

# run the RECO step
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) # workaround to have ctests working
k4run $SCRIPT_DIR/ALLEGRO_o1_v03_digi_reco.py
Loading
Loading