From 3bb7f773ccbe7a60aa8f552ad47439901da342eb Mon Sep 17 00:00:00 2001 From: Juan Miguel Carceller <22276694+jmcarcell@users.noreply.github.com> Date: Mon, 26 Feb 2024 22:21:12 +0100 Subject: [PATCH] Fix tests (#56) --- gaudi_opts/clue_gaudi_wrapper.py | 22 ++++++++++--------- src/k4clue/CMakeLists.txt | 15 +++++++++---- ...GeV_uniform_10events_reco_edm4hep.root.md5 | 1 + 3 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 test/input_files/20240226_gammaFromVertex_10GeV_uniform_10events_reco_edm4hep.root.md5 diff --git a/gaudi_opts/clue_gaudi_wrapper.py b/gaudi_opts/clue_gaudi_wrapper.py index 7bd4caf..36683cb 100644 --- a/gaudi_opts/clue_gaudi_wrapper.py +++ b/gaudi_opts/clue_gaudi_wrapper.py @@ -16,15 +16,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from Gaudi.Configuration import * +from Gaudi.Configuration import WARNING, DEBUG -from Configurables import LcioEvent, k4DataSvc, MarlinProcessorWrapper -from k4MarlinWrapper.parseConstants import * -algList = [] +from Configurables import k4DataSvc, MarlinProcessorWrapper from Configurables import PodioInput +from Configurables import ClueGaudiAlgorithmWrapper +from Configurables import CLUENtuplizer +from Configurables import THistSvc +from Configurables import PodioOutput +from Configurables import ApplicationMgr + +algList = [] + + evtsvc = k4DataSvc('EventDataSvc') -evtsvc.input = 'https://key4hep.web.cern.ch/testFiles/k4clue/inputData/clic/20230825_gammaFromSurface_10GeV_uniform_500events_reco_edm4hep.root' +# evtsvc.input = inp = PodioInput('InputReader') inp.collections = [ @@ -44,7 +51,6 @@ } -from Configurables import ClueGaudiAlgorithmWrapper MyClueGaudiAlgorithmWrapper = ClueGaudiAlgorithmWrapper("ClueGaudiAlgorithmWrapperName") MyClueGaudiAlgorithmWrapper.BarrelCaloHitsCollection = "ECALBarrel" @@ -54,7 +60,6 @@ MyClueGaudiAlgorithmWrapper.OutlierDeltaFactor = 3.00 MyClueGaudiAlgorithmWrapper.OutputLevel = DEBUG -from Configurables import CLUENtuplizer MyCLUENtuplizer = CLUENtuplizer("CLUEAnalysis") MyCLUENtuplizer.ClusterCollection = "CLUEClusters" MyCLUENtuplizer.BarrelCaloHitsCollection = "ECALBarrel" @@ -62,14 +67,12 @@ MyCLUENtuplizer.SingleMCParticle = True MyCLUENtuplizer.OutputLevel = WARNING -from Configurables import THistSvc THistSvc().Output = ["rec DATAFILE='k4clue_analysis_output.root' TYP='ROOT' OPT='RECREATE'"] THistSvc().OutputLevel = WARNING THistSvc().PrintAll = False THistSvc().AutoSave = True THistSvc().AutoFlush = True -from Configurables import PodioOutput out = PodioOutput("out") MyClueGaudiAlgorithmWrapper.BarrelCaloHitsCollection = "ECALBarrel" MyClueGaudiAlgorithmWrapper.EndcapCaloHitsCollection = "ECALEndcap" @@ -82,7 +85,6 @@ algList.append(MyCLUENtuplizer) algList.append(out) -from Configurables import ApplicationMgr ApplicationMgr( TopAlg = algList, EvtSel = 'NONE', EvtMax = 3, diff --git a/src/k4clue/CMakeLists.txt b/src/k4clue/CMakeLists.txt index 83bbff8..e0f1b46 100644 --- a/src/k4clue/CMakeLists.txt +++ b/src/k4clue/CMakeLists.txt @@ -19,6 +19,11 @@ limitations under the License. # CLUE as Gaudi algorithm +include(ExternalData) +set(ExternalData_URL_TEMPLATES + "https://key4hep.web.cern.ch:443/testFiles/k4clue/inputData/clic/%(hash)" +) + gaudi_add_module(ClueGaudiAlgorithmWrapper SOURCES ${PROJECT_SOURCE_DIR}/src/ClueGaudiAlgorithmWrapper.cpp @@ -36,12 +41,14 @@ gaudi_add_module(ClueGaudiAlgorithmWrapper target_include_directories(ClueGaudiAlgorithmWrapper PUBLIC $ ) - -add_test(NAME gaudiWrapper +ExternalData_Add_Test(k4clue_tests NAME gaudiWrapper WORKING_DIRECTORY ${PROJECT_BINARY_DIR} - COMMAND bash -c "source k4clueenv.sh; \ - k4run ${PROJECT_SOURCE_DIR}/gaudi_opts/clue_gaudi_wrapper.py --ClueGaudiAlgorithmWrapperName.OutputLevel 2 --CLUEAnalysis.OutputLevel 2") + COMMAND bash -c "k4run ${PROJECT_SOURCE_DIR}/gaudi_opts/clue_gaudi_wrapper.py --EventDataSvc.input DATA{${PROJECT_SOURCE_DIR}/test/input_files/20240226_gammaFromVertex_10GeV_uniform_10events_reco_edm4hep.root} --ClueGaudiAlgorithmWrapperName.OutputLevel 2 --CLUEAnalysis.OutputLevel 2") set_tests_properties(gaudiWrapper PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR;Failed") +set_property(TEST gaudiWrapper APPEND PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}:${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}:${PROJECT_BINARY_DIR}/src/k4clue:$<$:$>:$<$:$>:$<$:$>:$ENV{LD_LIBRARY_PATH}") +set_property(TEST gaudiWrapper APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${PROJECT_BINARY_DIR}/${CMAKE_PROJECT_NAME}/genConfDir:${PROJECT_BINARY_DIR}/src/k4clue/genConfDir:$ENV{PYTHONPATH}") + +ExternalData_Add_Target(k4clue_tests) diff --git a/test/input_files/20240226_gammaFromVertex_10GeV_uniform_10events_reco_edm4hep.root.md5 b/test/input_files/20240226_gammaFromVertex_10GeV_uniform_10events_reco_edm4hep.root.md5 new file mode 100644 index 0000000..56cf345 --- /dev/null +++ b/test/input_files/20240226_gammaFromVertex_10GeV_uniform_10events_reco_edm4hep.root.md5 @@ -0,0 +1 @@ +534c086df3c125d3d0328b6565115729 \ No newline at end of file