From c9ce71161f27bc754bcedd09b6618232d1c97e8b Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Mon, 16 Jan 2023 18:14:33 +0100 Subject: [PATCH] Add DDDigi/edm4hep input reader example. --- examples/DDDigi/CMakeLists.txt | 68 ++++++++++++--------- examples/DDDigi/scripts/TestEdm4hepInput.py | 7 ++- examples/DDDigi/scripts/TestWriteEdm4hep.py | 38 ------------ 3 files changed, 45 insertions(+), 68 deletions(-) delete mode 100644 examples/DDDigi/scripts/TestWriteEdm4hep.py diff --git a/examples/DDDigi/CMakeLists.txt b/examples/DDDigi/CMakeLists.txt index d03210604..be6f07590 100644 --- a/examples/DDDigi/CMakeLists.txt +++ b/examples/DDDigi/CMakeLists.txt @@ -41,7 +41,7 @@ dd4hep_add_test_reg(DDDigi_framework COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_DDDigi.sh" EXEC_ARGS ${Python_EXECUTABLE} ${DDDigiexamples_INSTALL}/scripts/TestFramework.py REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed." - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # # Test colored noise factory @@ -50,7 +50,7 @@ dd4hep_add_test_reg(DDDigi_colored_noise EXEC_ARGS geoPluginRun -ui -plugin DD4hep_FalphaNoise -shots 1000000 -variance 1 -alpha 0.5 DEPENDS DDDigi_framework REGEX_PASS "FalphaNoise INFO Distribution RMS 1.0" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # # Test new properties @@ -58,7 +58,7 @@ dd4hep_add_test_reg(DDDigi_properties COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_DDDigi.sh" EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestProperties.py REGEX_PASS "roperty test PASSED" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # if (DD4HEP_USE_GEANT4) @@ -68,7 +68,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/ClientTests/scripts/MiniTelGenerate.py -batch -events 30 -runs 8 REGEX_PASS "\\+\\+\\+ Finished run 7 after 30 events \\(240 events in total\\)." - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test basic input reading from DDG4 dd4hep_add_test_reg(DDDigi_test_input_reading @@ -76,7 +76,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestInput.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test DDDigi exception while processing dd4hep_add_test_reg(DDDigi_test_processing_exception @@ -92,7 +92,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestAttenuate.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test moving IP dd4hep_add_test_reg(DDDigi_test_move_IP @@ -100,7 +100,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestIPMove.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test deposit count dd4hep_add_test_reg(DDDigi_test_deposit_count @@ -108,7 +108,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestDepositCount.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test weighted deposit overlay dd4hep_add_test_reg(DDDigi_test_weighted_deposit_overlay @@ -116,7 +116,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestDepositWeighted.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test deposit energy smearing dd4hep_add_test_reg(DDDigi_test_deposit_smear_energy @@ -124,7 +124,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestDepositSmearEnergy.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test deposit time resolution smearing dd4hep_add_test_reg(DDDigi_test_deposit_smear_time @@ -132,7 +132,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestDepositSmearTime.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test deposit position resolution smearing dd4hep_add_test_reg(DDDigi_test_smear_position @@ -140,7 +140,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestPositionSmearResolution.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test deposit track position resolution smearing dd4hep_add_test_reg(DDDigi_test_smear_track @@ -148,7 +148,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestPositionSmearTrack.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test multiple interaction input dd4hep_add_test_reg(DDDigi_test_multi_interactions @@ -156,7 +156,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestMultiInteractions.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test spillover input (multi interactions with attenuation) dd4hep_add_test_reg(DDDigi_test_spillover @@ -164,7 +164,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestSpillover.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test container parellization dd4hep_add_test_reg(DDDigi_test_containers_parallel @@ -172,7 +172,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestMultiContainerParallel.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test hit resegmentation dd4hep_add_test_reg(DDDigi_test_detector_resegmentation @@ -180,7 +180,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestResegmentation.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test work splitting by segmentation dd4hep_add_test_reg(DDDigi_test_segmentation_split_1 @@ -188,7 +188,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestSegmentationSplit.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test work splitting by segmentation (2) dd4hep_add_test_reg(DDDigi_test_segmentation_split_2 @@ -196,7 +196,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestSegmentationSplit2.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # Test simple ADC response dd4hep_add_test_reg(DDDigi_test_simple_adc_response @@ -204,7 +204,7 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestSimpleADCResponse.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # # Test raw digi write @@ -213,27 +213,39 @@ if (DD4HEP_USE_GEANT4) EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestWriteDigi.py DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ Closing ROOT output file dddigi_write_digi_00000000.root after 5 events" - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" ) # # Test EDM4HEP output module if (DD4HEP_USE_EDM4HEP) - # Generate test data + # Generate edm4hep test data dd4hep_add_test_reg(DDDigi_generate_edm4hep_data COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_DDDigi.sh" EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/ClientTests/scripts/MiniTelGenerate.py - -batch -events 30 -runs 3 -output MiniTel_edm4hep_DDG4_data.root + -batch -events 30 -runs 3 -output MiniTel_DDG4_edm4hep_data.root + DEPENDS DDDigi_generate_ddg4_data REGEX_PASS "\\+\\+\\+ Finished run 2 after 30 events \\(90 events in total\\)." - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "Error;ERROR;FATAL;Exception" + ) + # Test reading EDM4HEP input written with DDG4 + dd4hep_add_test_reg(DDDigi_test_edm4hep_read + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_DDDigi.sh" + EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestEdm4hepInput.py + -num_events 15 -num_threads 10 -events_parallel 5 + DEPENDS DDDigi_generate_edm4hep_data + REGEX_PASS "\\+\\+\\+ 15 Events out of 15 processed." + REGEX_FAIL "ERROR;FATAL;Exception" ) - # Test EDM4HEP write from ddg4 input (needs to be expanded) - dd4hep_add_test_reg(DDDigi_test_edm4hep_write + # + # Test EDM4HEP writing OUTPUT from ddg4 input (needs to be expanded) + dd4hep_add_test_reg(DDDigi_test_edm4hep_output COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_DDDigi.sh" - EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestWriteEdm4hep.py + EXEC_ARGS ${Python_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/examples/DDDigi/scripts/TestEdm4hepOutput.py -num_events 5 -num_threads 10 -events_parallel 4 DEPENDS DDDigi_generate_ddg4_data + DEPENDS DDDigi_generate_edm4hep_data REGEX_PASS "\\+\\+\\+ 5 Events out of 5 processed." - REGEX_FAIL "Error;ERROR;Exception" + REGEX_FAIL "ERROR;FATAL;Exception" ) endif() # diff --git a/examples/DDDigi/scripts/TestEdm4hepInput.py b/examples/DDDigi/scripts/TestEdm4hepInput.py index 9f8bf8b68..ffc11184e 100644 --- a/examples/DDDigi/scripts/TestEdm4hepInput.py +++ b/examples/DDDigi/scripts/TestEdm4hepInput.py @@ -16,11 +16,14 @@ def run(): digi = DigiTest.Test(geometry=None, process_data=False) read = digi.input_action('DigiEdm4hepInput/SignalReader', mask=0x0, - input=['MiniTel_edm4hep_DDG4_data.run00000000.root']) + input=['MiniTel_DDG4_edm4hep_data.run00000000.root', + 'MiniTel_DDG4_edm4hep_data.run00000001.root', + 'MiniTel_DDG4_edm4hep_data.run00000002.root',]) read.input_section = 'events' read.objects_disabled = ['EventHeader'] + read.events_per_file = 5 digi.event_action('DigiStoreDump/StoreDump', parallel=False) - digi.run_checked(num_events=5, num_threads=1, parallel=1) + digi.run_checked(num_events=100, num_threads=10, parallel=10) if __name__ == '__main__': diff --git a/examples/DDDigi/scripts/TestWriteEdm4hep.py b/examples/DDDigi/scripts/TestWriteEdm4hep.py deleted file mode 100644 index bfe859479..000000000 --- a/examples/DDDigi/scripts/TestWriteEdm4hep.py +++ /dev/null @@ -1,38 +0,0 @@ -# ========================================================================== -# AIDA Detector description implementation -# -------------------------------------------------------------------------- -# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) -# All rights reserved. -# -# For the licensing terms see $DD4hepINSTALL/LICENSE. -# For the list of contributors see $DD4hepINSTALL/doc/CREDITS. -# -# ========================================================================== -from __future__ import absolute_import - - -# --------------------------------------------------------------------------- -def run(): - import DigiTest - digi = DigiTest.Test(geometry=None) - read = digi.input_action('DigiDDG4ROOT/SignalReader', mask=0x0, input=[digi.next_input()]) - dump = digi.event_action('DigiStoreDump/StoreDump', parallel=False) - writ = digi.output_action('Digi2edm4hepWriter/Writer', - parallel=True, - input_mask=0x0, - input_segment='input', - output='MiniTel_dddigi_edm4hep.root') - proc = digi.create_action('Digi2edm4hepProcessor/edm4hep') - hit_type = 'TrackerHits' - if digi.hit_type: - hit_type = digi.hit_type - cont = [c + '/' + hit_type for c in digi.containers()] - writ.adopt_container_processor(proc, cont) - writ.adopt_container_processor(proc, 'MCParticles/MCParticles') - digi.check_creation([read, dump]) - digi.run_checked(num_events=10, num_threads=10, parallel=3) - - -# --------------------------------------------------------------------------- -if __name__ == '__main__': - run() -- GitLab