Skip to content

Commit

Permalink
Add small reproducer for type mismatch issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jan 17, 2025
1 parent ce56844 commit 31b537f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/k4FWCoreTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 18 additions & 0 deletions test/k4FWCoreTest/options/TypeMisMatchDemo.py
Original file line number Diff line number Diff line change
@@ -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,
)
26 changes: 26 additions & 0 deletions test/k4FWCoreTest/src/components/TypeMisMatchDemo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/TrackCollection.h"

#include "k4FWCore/Transformer.h"

#include <Gaudi/Property.h>
#include <GaudiKernel/ISvcLocator.h>

#include <string>

struct TypeMisMatchDemo final : k4FWCore::Transformer<edm4hep::MCParticleCollection(const edm4hep::TrackCollection&)> {
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)

0 comments on commit 31b537f

Please sign in to comment.