From 31b537f73c9c80265ce760cfc4c3c4d5e243e5dd Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Fri, 17 Jan 2025 15:15:36 +0100 Subject: [PATCH] Add small reproducer for type mismatch issue --- test/k4FWCoreTest/CMakeLists.txt | 2 ++ test/k4FWCoreTest/options/TypeMisMatchDemo.py | 18 +++++++++++++ .../src/components/TypeMisMatchDemo.cpp | 26 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 test/k4FWCoreTest/options/TypeMisMatchDemo.py create mode 100644 test/k4FWCoreTest/src/components/TypeMisMatchDemo.cpp diff --git a/test/k4FWCoreTest/CMakeLists.txt b/test/k4FWCoreTest/CMakeLists.txt index 4302c583..a863cdbb 100644 --- a/test/k4FWCoreTest/CMakeLists.txt +++ b/test/k4FWCoreTest/CMakeLists.txt @@ -204,3 +204,5 @@ add_test_with_env(GaudiFunctional options/ExampleGaudiFunctional.py PROPERTIES F add_custom_command(TARGET k4FWCoreTestPlugins POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/python/k4FWCore/ ${PROJECT_BINARY_DIR}/k4FWCore/genConfDir/k4FWCore) + +add_test_with_env(TypeMisMatchDemo options/TypeMisMatchDemo.py) diff --git a/test/k4FWCoreTest/options/TypeMisMatchDemo.py b/test/k4FWCoreTest/options/TypeMisMatchDemo.py new file mode 100644 index 00000000..b355d3df --- /dev/null +++ b/test/k4FWCoreTest/options/TypeMisMatchDemo.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +from Gaudi.Configuration import INFO, DEBUG +from Configurables import ExampleFunctionalProducer, TypeMisMatchDemo, EventDataSvc + +from k4FWCore import ApplicationMgr + +producer = ExampleFunctionalProducer("Producer", OutputCollection=["MCParticles"]) + +mismatch = TypeMisMatchDemo(InputCollection=["MCParticles"], OutputLevel=DEBUG) + +ApplicationMgr( + TopAlg=[producer, mismatch], + EvtSel="NONE", + EvtMax=1, + ExtSvc=[EventDataSvc("EventDataSvc")], + OutputLevel=INFO, +) diff --git a/test/k4FWCoreTest/src/components/TypeMisMatchDemo.cpp b/test/k4FWCoreTest/src/components/TypeMisMatchDemo.cpp new file mode 100644 index 00000000..29c1f9de --- /dev/null +++ b/test/k4FWCoreTest/src/components/TypeMisMatchDemo.cpp @@ -0,0 +1,26 @@ +#include "edm4hep/MCParticleCollection.h" +#include "edm4hep/TrackCollection.h" + +#include "k4FWCore/Transformer.h" + +#include +#include + +#include + +struct TypeMisMatchDemo final : k4FWCore::Transformer { + TypeMisMatchDemo(const std::string& name, ISvcLocator* svcLoc) + : Transformer(name, svcLoc, {KeyValues("InputCollection", {"MCParticles"})}, + {KeyValues("OutputCollection", {"MCParticles2"})}) {} + + edm4hep::MCParticleCollection operator()(const edm4hep::TrackCollection& inputs) const final { + debug() << inputs.size() << " type = " << inputs.getTypeName() << endmsg; + auto track = inputs[0]; + // The next line goes boom + debug() << track.getTrackerHits().size() << endmsg; + + return edm4hep::MCParticleCollection{}; + } +}; + +DECLARE_COMPONENT(TypeMisMatchDemo)