From ef4aaf03d8fcfcec568dba18745b8fac986aa42a Mon Sep 17 00:00:00 2001 From: Brieuc Francois Date: Fri, 9 Feb 2024 09:25:43 +0100 Subject: [PATCH] Fix tests (#15) * Fix tests * Disable ARCdigi test for now * Only test with the nightlies --- .github/workflows/test.yml | 2 +- ARCdigi/CMakeLists.txt | 5 +- ARCdigi/test/runARCdigitizer.py | 1 + CMakeLists.txt | 18 ++++--- DCHdigi/CMakeLists.txt | 21 +++++--- DCHdigi/test/runDCHsimpleDigitizer.py | 8 +-- .../test/runDCHsimpleDigitizerExtendedEdm.py | 6 +-- ...nGenFitTrackingOnSimplifiedDriftChamber.py | 18 ++++--- VTXdigi/CMakeLists.txt | 3 +- VTXdigi/test/runVTXdigitizer.py | 52 +++++++++---------- 10 files changed, 77 insertions(+), 57 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73e9415..661a1f9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - SETUP: ['/cvmfs/sw.hsf.org/key4hep/setup.sh', '/cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh'] + SETUP: ['/cvmfs/sw-nightlies.hsf.org/key4hep/setup.sh'] steps: - uses: actions/checkout@v2 - uses: cvmfs-contrib/github-action-cvmfs@v2 diff --git a/ARCdigi/CMakeLists.txt b/ARCdigi/CMakeLists.txt index 9f3ce56..541b67f 100644 --- a/ARCdigi/CMakeLists.txt +++ b/ARCdigi/CMakeLists.txt @@ -43,5 +43,6 @@ install(TARGETS ${PackageName} install(FILES ${scripts} DESTINATION test) -SET(test_name "test_runARCdigitizer") -ADD_TEST(NAME t_${test_name} COMMAND k4run test/runARCdigitizer.py) +#SET(test_name "test_runARCdigitizer") +#ADD_TEST(NAME ${test_name} COMMAND k4run test/runARCdigitizer.py) +#set_test_env(${test_name}) diff --git a/ARCdigi/test/runARCdigitizer.py b/ARCdigi/test/runARCdigitizer.py index 0d0d4ee..712a3bb 100644 --- a/ARCdigi/test/runARCdigitizer.py +++ b/ARCdigi/test/runARCdigitizer.py @@ -1,3 +1,4 @@ +import os from Gaudi.Configuration import * from Configurables import ApplicationMgr diff --git a/CMakeLists.txt b/CMakeLists.txt index b1677cb..4ab62b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,14 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.12) +CMAKE_MINIMUM_REQUIRED(VERSION 3.12 FATAL_ERROR) -project(k4RecTracker) +set( PackageName k4RecTracker ) +project(${PackageName}) # please keep this layout for version setting, used by the automatic tagging script -set(PACKAGE_VERSION_MAJOR 1) -set(PACKAGE_VERSION_MINOR 2) -set(PACKAGE_VERSION_PATCH 3) +set(${PackageName}_VERSION_MAJOR 0) +set(${PackageName}_VERSION_MINOR 1) +set(${PackageName}_VERSION_PATCH 0) -set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}") +set(${PackageName}_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}") # dependencies # For some reason, the find_package with DD4hep must be the first one @@ -52,6 +53,11 @@ if("${isSystemDir}" STREQUAL "-1") endif("${isSystemDir}" STREQUAL "-1") include(CTest) +function(set_test_env _testname) + set_property(TEST ${test_name} APPEND PROPERTY ENVIRONMENT "ROOT_INCLUDE_PATH=$<$:$/../include>:$<$:$/../include>:$ENV{ROOT_INCLUDE_PATH}") + set_property(TEST ${test_name} APPEND PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}:${PROJECT_BINARY_DIR}/genConfDir/${PackageName}:$<$:$>:$<$:$>:$<$:$>:$ENV{LD_LIBRARY_PATH}") + set_property(TEST ${test_name} APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}:${PROJECT_BINARY_DIR}/genConfDir:$ENV{PYTHONPATH}") +endfunction() add_subdirectory(DCHdigi) add_subdirectory(ARCdigi) diff --git a/DCHdigi/CMakeLists.txt b/DCHdigi/CMakeLists.txt index b882431..b753c26 100644 --- a/DCHdigi/CMakeLists.txt +++ b/DCHdigi/CMakeLists.txt @@ -1,4 +1,6 @@ -project(DCHdigi) +set(PackageName DCHdigi) + +project(${PackageName}) # Build the extension data model and link it against the upstream model PODIO_GENERATE_DATAMODEL(extension dataFormatExtension/driftChamberHit.yaml ext_headers ext_sources @@ -40,7 +42,7 @@ file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h ) -gaudi_add_module(DCHdigi +gaudi_add_module(${PackageName} SOURCES ${sources} LINK Gaudi::GaudiKernel @@ -50,13 +52,13 @@ gaudi_add_module(DCHdigi DD4hep::DDRec ) -target_include_directories(DCHdigi PUBLIC +target_include_directories(${PackageName} PUBLIC $ $ ${CMAKE_INSTALL_PREFIX}/extension ) -set_target_properties(DCHdigi PROPERTIES PUBLIC_HEADER "${headers}") +set_target_properties(${PackageName} PROPERTIES PUBLIC_HEADER "${headers}") file(GLOB scripts ${PROJECT_SOURCE_DIR}/test/*.py @@ -64,7 +66,7 @@ file(GLOB scripts file(COPY ${scripts} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) -install(TARGETS DCHdigi +install(TARGETS ${PackageName} EXPORT ${CMAKE_PROJECT_NAME}Targets RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib @@ -73,5 +75,10 @@ install(TARGETS DCHdigi install(FILES ${scripts} DESTINATION test) -ADD_TEST(NAME "t_DCHsimpleDigitizer" COMMAND k4run test/runDCHsimpleDigitizer.py) -ADD_TEST(NAME "t_DCHsimpleDigitizerExtendedEdm" COMMAND k4run test/runDCHsimpleDigitizerExtendedEdm.py) +SET(test_name "test_DCHsimpleDigitizer") +ADD_TEST(NAME ${test_name} COMMAND k4run test/runDCHsimpleDigitizer.py) +set_test_env(${test_name}) + +SET(test_name "test_DCHsimpleDigitizerExtendedEdm") +ADD_TEST(NAME ${test_name} COMMAND k4run test/runDCHsimpleDigitizerExtendedEdm.py) +set_test_env(${test_name}) diff --git a/DCHdigi/test/runDCHsimpleDigitizer.py b/DCHdigi/test/runDCHsimpleDigitizer.py index 765e387..e16b382 100644 --- a/DCHdigi/test/runDCHsimpleDigitizer.py +++ b/DCHdigi/test/runDCHsimpleDigitizer.py @@ -43,10 +43,10 @@ from Configurables import GeoSvc geoservice = GeoSvc("GeoSvc") # if FCC_DETECTORS is empty, this should use relative path to working directory -path_to_detector = os.environ.get("FCCDETECTORS", "") +path_to_detector = os.environ.get("K4GEO", "") print(path_to_detector) detectors_to_use=[ - 'Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml' + 'FCCee/IDEA/compact/IDEA_o1_v02/IDEA_o1_v02.xml' ] # prefix all xmls with path_to_detector geoservice.detectors = [os.path.join(path_to_detector, _det) for _det in detectors_to_use] @@ -88,7 +88,7 @@ particle_converter.GenParticles.Path = genParticlesOutputName from Configurables import SimG4SaveTrackerHits -savetrackertool = SimG4SaveTrackerHits("SimG4SaveTrackerHits", readoutNames=["CDCHHits"]) +savetrackertool = SimG4SaveTrackerHits("SimG4SaveTrackerHits", readoutName="CDCHHits") savetrackertool.SimTrackHits.Path = "DC_simTrackerHits" @@ -144,7 +144,7 @@ out ], EvtSel = 'NONE', - EvtMax = 100, + EvtMax = 10, ExtSvc = [geoservice, podioevent, geantservice, audsvc], StopOnSignal = True, ) diff --git a/DCHdigi/test/runDCHsimpleDigitizerExtendedEdm.py b/DCHdigi/test/runDCHsimpleDigitizerExtendedEdm.py index d051383..12251c2 100644 --- a/DCHdigi/test/runDCHsimpleDigitizerExtendedEdm.py +++ b/DCHdigi/test/runDCHsimpleDigitizerExtendedEdm.py @@ -43,10 +43,10 @@ from Configurables import GeoSvc geoservice = GeoSvc("GeoSvc") # if FCC_DETECTORS is empty, this should use relative path to working directory -path_to_detector = os.environ.get("FCCDETECTORS", "") +path_to_detector = os.environ.get("K4GEO", "") print(path_to_detector) detectors_to_use=[ - 'Detector/DetFCCeeIDEA/compact/IDEA_o1_v01/FCCee_DectMaster_v01.xml' + 'FCCee/IDEA/compact/IDEA_o1_v02/IDEA_o1_v02.xml' ] # prefix all xmls with path_to_detector geoservice.detectors = [os.path.join(path_to_detector, _det) for _det in detectors_to_use] @@ -106,7 +106,7 @@ particle_converter.GenParticles.Path = genParticlesOutputName from Configurables import SimG4SaveTrackerHits -savetrackertool = SimG4SaveTrackerHits("SimG4SaveTrackerHits", readoutNames=["CDCHHits"]) +savetrackertool = SimG4SaveTrackerHits("SimG4SaveTrackerHits", readoutName="CDCHHits") savetrackertool.SimTrackHits.Path = "DC_simTrackerHits" diff --git a/Tracking/test/runGenFitTrackingOnSimplifiedDriftChamber.py b/Tracking/test/runGenFitTrackingOnSimplifiedDriftChamber.py index 180fd69..e726835 100644 --- a/Tracking/test/runGenFitTrackingOnSimplifiedDriftChamber.py +++ b/Tracking/test/runGenFitTrackingOnSimplifiedDriftChamber.py @@ -43,10 +43,10 @@ from Configurables import GeoSvc geoservice = GeoSvc("GeoSvc") # if FCC_DETECTORS is empty, this should use relative path to working directory -path_to_detector = os.environ.get("FCCDETECTORS", "") +path_to_detector = os.environ.get("K4GEO", "") print(path_to_detector) detectors_to_use=[ - 'Detector/DetFCCeeIDEA/compact/FCCee_DectMaster.xml', + 'FCCee/IDEA/compact/IDEA_o1_v02/IDEA_o1_v02.xml', ] # prefix all xmls with path_to_detector geoservice.detectors = [os.path.join(path_to_detector, _det) for _det in detectors_to_use] @@ -88,16 +88,16 @@ particle_converter.GenParticles.Path = genParticlesOutputName from Configurables import SimG4SaveTrackerHits -saveDCHsimHitTool = SimG4SaveTrackerHits("saveDCHsimHitTool", readoutNames=["SimplifiedDriftChamberCollection"]) +saveDCHsimHitTool = SimG4SaveTrackerHits("saveDCHsimHitTool", readoutName="CDCHHits") saveDCHsimHitTool.SimTrackHits.Path = "DC_simTrackerHits" -saveVTXIBsimHitTool = SimG4SaveTrackerHits("saveVTXIBsimHitTool", readoutNames=["VTXIBCollection"]) +saveVTXIBsimHitTool = SimG4SaveTrackerHits("saveVTXIBsimHitTool", readoutName="VTXIBCollection") saveVTXIBsimHitTool.SimTrackHits.Path = "VTXIB_simTrackerHits" -saveVTXOBsimHitTool = SimG4SaveTrackerHits("saveVTXOBsimHitTool", readoutNames=["VTXOBCollection"]) +saveVTXOBsimHitTool = SimG4SaveTrackerHits("saveVTXOBsimHitTool", readoutName="VTXOBCollection") saveVTXOBsimHitTool.SimTrackHits.Path = "VTXOB_simTrackerHits" -saveVTXDsimHitTool = SimG4SaveTrackerHits("saveVTXDsimHitTool", readoutNames=["VTXDCollection"]) +saveVTXDsimHitTool = SimG4SaveTrackerHits("saveVTXDsimHitTool", readoutName="VTXDCollection") saveVTXDsimHitTool.SimTrackHits.Path = "VTXD_simTrackerHits" from Configurables import SimG4Alg @@ -113,6 +113,7 @@ from Configurables import VTXdigitizer vtxib_digitizer = VTXdigitizer("VTXIBdigitizer", inputSimHits = saveVTXIBsimHitTool.SimTrackHits.Path, + readoutName = "VTXIBCollection", outputDigiHits = vtxib_reco_hit_name ) @@ -120,12 +121,14 @@ from Configurables import VTXdigitizer vtxob_digitizer = VTXdigitizer("VTXOBdigitizer", inputSimHits = saveVTXOBsimHitTool.SimTrackHits.Path, + readoutName = "VTXOBCollection", outputDigiHits = vtxob_reco_hit_name ) vtxd_reco_hit_name = saveVTXDsimHitTool.SimTrackHits.Path.replace("sim", "reco") vtxd_digitizer = VTXdigitizer("VTXDdigitizer", inputSimHits = saveVTXDsimHitTool.SimTrackHits.Path, + readoutName = "VTXDCollection", outputDigiHits = vtxd_reco_hit_name ) @@ -133,6 +136,7 @@ from Configurables import DCHsimpleDigitizer dch_digitizer = DCHsimpleDigitizer("DCHsimpleDigitizer", inputSimHits = saveDCHsimHitTool.SimTrackHits.Path, + readoutName = "CDCHHits", outputDigiHits = dch_reco_hit_name ) @@ -170,7 +174,7 @@ genAlg, hepmc_converter, geantsim, - vtxb_digitizer, + vtxib_digitizer, vtxd_digitizer, dch_digitizer, genfitter, diff --git a/VTXdigi/CMakeLists.txt b/VTXdigi/CMakeLists.txt index fc2a98e..58ace97 100644 --- a/VTXdigi/CMakeLists.txt +++ b/VTXdigi/CMakeLists.txt @@ -42,4 +42,5 @@ install(TARGETS ${PackageName} install(FILES ${scripts} DESTINATION test) SET(test_name "test_runVTXdigitizer") -ADD_TEST(NAME t_${test_name} COMMAND k4run test/runVTXdigitizer.py) +ADD_TEST(NAME ${test_name} COMMAND k4run test/runVTXdigitizer.py) +set_test_env(${test_name}) diff --git a/VTXdigi/test/runVTXdigitizer.py b/VTXdigi/test/runVTXdigitizer.py index 7360e83..b217704 100644 --- a/VTXdigi/test/runVTXdigitizer.py +++ b/VTXdigi/test/runVTXdigitizer.py @@ -149,7 +149,7 @@ # IDEA geantsim = SimG4Alg("SimG4Alg", outputs= [SimG4SaveTrackerHitsIB, SimG4SaveTrackerHitsOB, SimG4SaveTrackerHitsD, - SimG4SaveTrackerHitsSiWrB, SimG4SaveTrackerHitsSiWrD, + #SimG4SaveTrackerHitsSiWrB, SimG4SaveTrackerHitsSiWrD, #saveHistTool ], eventProvider=particle_converter, @@ -221,29 +221,29 @@ OutputLevel = INFO ) -siwrb_digitizer = VTXdigitizer("SiWrBdigitizer", - inputSimHits = SimG4SaveTrackerHitsSiWrB.SimTrackHits.Path, - outputDigiHits = SimG4SaveTrackerHitsSiWrB.SimTrackHits.Path.replace("sim", "digi"), - detectorName = "SiliconWrapper", - readoutName = "SiWrBCollection", - xResolution = siWrapperResolution_x, # mm, r direction - yResolution = siWrapperResolution_y, # mm, phi direction - tResolution = siWrapperResolution_t, # ns - forceHitsOntoSurface = False, - OutputLevel = INFO -) - -siwrd_digitizer = VTXdigitizer("SiWrDdigitizer", - inputSimHits = SimG4SaveTrackerHitsSiWrD.SimTrackHits.Path, - outputDigiHits = SimG4SaveTrackerHitsSiWrD.SimTrackHits.Path.replace("sim", "digi"), - detectorName = "SiliconWrapper", - readoutName = "SiWrDCollection", - xResolution = siWrapperResolution_x, # mm, r direction - yResolution = siWrapperResolution_y, # mm, phi direction - tResolution = siWrapperResolution_t, # ns - forceHitsOntoSurface = False, - OutputLevel = INFO -) +#siwrb_digitizer = VTXdigitizer("SiWrBdigitizer", +# inputSimHits = SimG4SaveTrackerHitsSiWrB.SimTrackHits.Path, +# outputDigiHits = SimG4SaveTrackerHitsSiWrB.SimTrackHits.Path.replace("sim", "digi"), +# detectorName = "SiliconWrapper", +# readoutName = "SiWrBCollection", +# xResolution = siWrapperResolution_x, # mm, r direction +# yResolution = siWrapperResolution_y, # mm, phi direction +# tResolution = siWrapperResolution_t, # ns +# forceHitsOntoSurface = False, +# OutputLevel = INFO +#) +# +#siwrd_digitizer = VTXdigitizer("SiWrDdigitizer", +# inputSimHits = SimG4SaveTrackerHitsSiWrD.SimTrackHits.Path, +# outputDigiHits = SimG4SaveTrackerHitsSiWrD.SimTrackHits.Path.replace("sim", "digi"), +# detectorName = "SiliconWrapper", +# readoutName = "SiWrDCollection", +# xResolution = siWrapperResolution_x, # mm, r direction +# yResolution = siWrapperResolution_y, # mm, phi direction +# tResolution = siWrapperResolution_t, # ns +# forceHitsOntoSurface = False, +# OutputLevel = INFO +#) # run the genfit tracking # from Configurables import GenFitter @@ -298,11 +298,11 @@ hepmc_converter, geantsim, vtxib_digitizer, vtxob_digitizer, vtxd_digitizer, - siwrb_digitizer, siwrd_digitizer, + #siwrb_digitizer, siwrd_digitizer, out ], EvtSel = 'NONE', - EvtMax = 100000, + EvtMax = 10, ExtSvc = [geoservice, podioevent, geantservice, audsvc], StopOnSignal = True )