From 5fbab70b16c3d16f921027b540c97d4cefe8710a Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Mon, 13 Nov 2023 10:13:02 +0100 Subject: [PATCH 1/7] Always convert EventHeader to lcio --- k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp index 5e242891..1d4b883d 100644 --- a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp +++ b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp @@ -319,6 +319,8 @@ StatusCode EDM4hep2LcioTool::convertCollections(lcio::LCEventImpl* lcio_event) { const auto collections = m_podioDataSvc->getEventFrame().getAvailableCollections(); // Start off with the pre-defined collection name mappings auto collsToConvert{m_collNames.value()}; + // We *always* want to convert the EventHeader + collsToConvert.emplace("EventHeader", "EventHeader"); if (m_convertAll) { info() << "Converting all collections from EDM4hep to LCIO" << endmsg; // And simply add the rest, exploiting the fact that emplace will not From b0e7dbfe28ff7cbd610f4ab2eda30e3af007ce9f Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Mon, 13 Nov 2023 11:01:04 +0100 Subject: [PATCH 2/7] read EventHeader in test --- test/gaudi_opts/test_global_converter_maps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/gaudi_opts/test_global_converter_maps.py b/test/gaudi_opts/test_global_converter_maps.py index 4d1758f5..95278dc7 100644 --- a/test/gaudi_opts/test_global_converter_maps.py +++ b/test/gaudi_opts/test_global_converter_maps.py @@ -38,7 +38,7 @@ ) podioInput = PodioInput("InputReader") -podioInput.collections = ["MCParticles"] +podioInput.collections = ["MCParticles", "EventHeader"] podioInput.OutputLevel = INFO PseudoRecoProc = MarlinProcessorWrapper("PseudoReco") From 01a795deddf7a94df37e4458454f7c4b7d7fd6d0 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Wed, 15 Nov 2023 09:20:37 +0100 Subject: [PATCH 3/7] Replace "EventHeader" by edm4hep::EventHeaderName --- k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp | 2 +- k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp index 1d4b883d..52e49002 100644 --- a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp +++ b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp @@ -320,7 +320,7 @@ StatusCode EDM4hep2LcioTool::convertCollections(lcio::LCEventImpl* lcio_event) { // Start off with the pre-defined collection name mappings auto collsToConvert{m_collNames.value()}; // We *always* want to convert the EventHeader - collsToConvert.emplace("EventHeader", "EventHeader"); + collsToConvert.emplace(edm4hep::EventHeaderName, ""); if (m_convertAll) { info() << "Converting all collections from EDM4hep to LCIO" << endmsg; // And simply add the rest, exploiting the fact that emplace will not diff --git a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp index e5cadfdf..d0f7222e 100644 --- a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp +++ b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp @@ -143,8 +143,8 @@ namespace { StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) { // Convert Event Header outside the collections loop - if (!collectionExist("EventHeader")) { - registerCollection("EventHeader", LCIO2EDM4hepConv::createEventHeader(the_event)); + if (!collectionExist(edm4hep::EventHeaderName)) { + registerCollection(edm4hep::EventHeaderName, LCIO2EDM4hepConv::createEventHeader(the_event)); } // Start off with the pre-defined collection name mappings From 3f420abd8051e36533e63dd306f718a71de98918 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Thu, 16 Nov 2023 08:05:43 +0100 Subject: [PATCH 4/7] removed explicit reading of EventHeader everywhere --- k4MarlinWrapper/examples/clicRec_e4h_input.py | 1 - k4MarlinWrapper/examples/event_display.py | 1 - test/gaudi_opts/fccRec_e4h_input.py | 1 - test/gaudi_opts/test_global_converter_maps.py | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/k4MarlinWrapper/examples/clicRec_e4h_input.py b/k4MarlinWrapper/examples/clicRec_e4h_input.py index f83664f9..98bb5619 100644 --- a/k4MarlinWrapper/examples/clicRec_e4h_input.py +++ b/k4MarlinWrapper/examples/clicRec_e4h_input.py @@ -51,7 +51,6 @@ inp = PodioInput('InputReader') inp.collections = [ - 'EventHeader', 'MCParticles', 'VertexBarrelCollection', 'VertexEndcapCollection', diff --git a/k4MarlinWrapper/examples/event_display.py b/k4MarlinWrapper/examples/event_display.py index a5e9af13..1b4c0c90 100644 --- a/k4MarlinWrapper/examples/event_display.py +++ b/k4MarlinWrapper/examples/event_display.py @@ -28,7 +28,6 @@ inp = PodioInput('InputReader') inp.collections = [ - 'EventHeader', 'MCParticles', 'VertexBarrelCollection', 'VertexEndcapCollection', diff --git a/test/gaudi_opts/fccRec_e4h_input.py b/test/gaudi_opts/fccRec_e4h_input.py index 55ddd992..7bf40218 100644 --- a/test/gaudi_opts/fccRec_e4h_input.py +++ b/test/gaudi_opts/fccRec_e4h_input.py @@ -41,7 +41,6 @@ inp = PodioInput('InputReader') inp.collections = [ - 'EventHeader', 'MCParticles', 'VertexBarrelCollection', 'VertexEndcapCollection', diff --git a/test/gaudi_opts/test_global_converter_maps.py b/test/gaudi_opts/test_global_converter_maps.py index 95278dc7..4d1758f5 100644 --- a/test/gaudi_opts/test_global_converter_maps.py +++ b/test/gaudi_opts/test_global_converter_maps.py @@ -38,7 +38,7 @@ ) podioInput = PodioInput("InputReader") -podioInput.collections = ["MCParticles", "EventHeader"] +podioInput.collections = ["MCParticles"] podioInput.OutputLevel = INFO PseudoRecoProc = MarlinProcessorWrapper("PseudoReco") From b706ca4278776a3476210cd246b9887667d42654 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Thu, 30 Nov 2023 15:21:27 +0100 Subject: [PATCH 5/7] add test --- test/CMakeLists.txt | 3 ++ test/gaudi_opts/createEventHeader.py | 50 ++++++++++++++++++++++++++++ test/scripts/event_header.sh | 24 +++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 test/gaudi_opts/createEventHeader.py create mode 100644 test/scripts/event_header.sh diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 77569e4b..f05706d9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -88,6 +88,8 @@ if (BASH_PROGRAM) # multiple processors add_test( global_converter_maps ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/global_converter_maps.sh ) + add_test( event_header ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/event_header.sh ) + set_tests_properties ( simple_processors simple_processors2 @@ -100,6 +102,7 @@ if (BASH_PROGRAM) clicRec_edm4hep_input clic_geo_test global_converter_maps + event_header PROPERTIES ENVIRONMENT "TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_INSTALL_PREFIX}/python:$ENV{PYTHONPATH};EXAMPLE_DIR=${PROJECT_SOURCE_DIR}/k4MarlinWrapper/examples;MARLIN_DLL=$ENV{MARLIN_DLL}:${CMAKE_CURRENT_BINARY_DIR}/libMarlinTestProcessors.so" ) diff --git a/test/gaudi_opts/createEventHeader.py b/test/gaudi_opts/createEventHeader.py new file mode 100644 index 00000000..6f39d558 --- /dev/null +++ b/test/gaudi_opts/createEventHeader.py @@ -0,0 +1,50 @@ +# +# Copyright (c) 2019-2023 Key4hep-Project. +# +# This file is part of Key4hep. +# See https://key4hep.github.io/key4hep-doc/ for further info. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +from Gaudi.Configuration import WARNING + +from Configurables import ( + EventHeaderCreator, + k4DataSvc, + MarlinProcessorWrapper, + ApplicationMgr, + EDM4hep2LcioTool, +) + +eventHeaderCreator = EventHeaderCreator("eventHeaderCreator", eventNumberOffset=42) + +podioevent = k4DataSvc("EventDataSvc") + +EDM4hep2Lcio = EDM4hep2LcioTool("EDM4hep2Lcio") +EDM4hep2Lcio.convertAll = False + +out = MarlinProcessorWrapper("out") +out.ProcessorType = "LCIOOutputProcessor" +out.Parameters = {"LCIOOutputFile": ["test.slcio"], "LCIOWriteMode": ["WRITE_NEW"]} +out.EDM4hep2LcioTool = EDM4hep2Lcio + +ApplicationMgr( + TopAlg=[ + eventHeaderCreator, + out, + ], + EvtSel="NONE", + EvtMax=2, + ExtSvc=[podioevent], + OutputLevel=WARNING, +) diff --git a/test/scripts/event_header.sh b/test/scripts/event_header.sh new file mode 100644 index 00000000..0b50499d --- /dev/null +++ b/test/scripts/event_header.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env sh +## +## Copyright (c) 2019-2023 Key4hep-Project. +## +## This file is part of Key4hep. +## See https://key4hep.github.io/key4hep-doc/ for further info. +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## + +set -eu + +k4run $TEST_DIR/gaudi_opts/createEventHeader.py +anajob test.slcio | grep "EVENT: 42" From 1c0f584bc44ce733a1321d3d06be8efb434b594e Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Fri, 1 Dec 2023 08:41:34 +0100 Subject: [PATCH 6/7] Make test name more descriptive --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f05706d9..f4645728 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -88,7 +88,7 @@ if (BASH_PROGRAM) # multiple processors add_test( global_converter_maps ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/global_converter_maps.sh ) - add_test( event_header ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/event_header.sh ) + add_test( event_header_conversion ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/event_header.sh ) set_tests_properties ( simple_processors From 028f1a9d913c9e5d12212b7dba9a9aec852c3235 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Fri, 1 Dec 2023 10:29:47 +0100 Subject: [PATCH 7/7] Make test name consistent --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f4645728..a5a47d53 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -102,7 +102,7 @@ if (BASH_PROGRAM) clicRec_edm4hep_input clic_geo_test global_converter_maps - event_header + event_header_conversion PROPERTIES ENVIRONMENT "TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_INSTALL_PREFIX}/python:$ENV{PYTHONPATH};EXAMPLE_DIR=${PROJECT_SOURCE_DIR}/k4MarlinWrapper/examples;MARLIN_DLL=$ENV{MARLIN_DLL}:${CMAKE_CURRENT_BINARY_DIR}/libMarlinTestProcessors.so" )