From 5890c7edc1c3356ed9cc1d6043bdccbf2f03eb50 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Thu, 22 May 2025 14:56:27 +0200 Subject: [PATCH 1/2] Adapt test case to exhibit failure --- .../test_link_conversion_edm4hep.py | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/test/gaudi_opts/test_link_conversion_edm4hep.py b/test/gaudi_opts/test_link_conversion_edm4hep.py index 7661dde0..a95b0aae 100644 --- a/test/gaudi_opts/test_link_conversion_edm4hep.py +++ b/test/gaudi_opts/test_link_conversion_edm4hep.py @@ -99,7 +99,30 @@ mcLinkConverter.OutputLevel = DEBUG MarlinMCLinkChecker.EDM4hep2LcioTool = mcLinkConverter -algList = [PseudoRecoAlg, MCRecoLinker, MarlinMCLinkChecker] +# Another link checker and converter +# We use this to avoid regressions for the fix in #237 +AnotherLinkChecker = MarlinProcessorWrapper( + "AnotherLinkChecker", + ProcessorType="MarlinMCRecoLinkChecker", + Parameters={ + "MCRecoLinks": ["TrivialMCRecoLinks"], + "InputMCs": ["MCParticles"], + "InputRecos": ["PseudoRecoParticles"], + }, +) + +anotherLinkConverter = EDM4hep2LcioTool("AnotherLinkConverter") +anotherLinkConverter.convertAll = True +anotherLinkConverter.collNameMapping = { + "TrivialMCRecoLinks": "TrivialMCRecoLinks", + "MCParticles": "MCParticles", + "PseudoRecoParticles": "PseudoRecoParticles", +} +anotherLinkConverter.OutputLevel = DEBUG +AnotherLinkChecker.EDM4hep2LcioTool = anotherLinkConverter + + +algList = [PseudoRecoAlg, MCRecoLinker, MarlinMCLinkChecker, AnotherLinkChecker] if args.no_iosvc: algList = [podioInput] + algList From da3e3186b7e2710574364408159bf54160039f4b Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Wed, 21 May 2025 19:52:25 +0200 Subject: [PATCH 2/2] Make sure to not double convert link collections --- k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp index 6b14b303..581946a2 100644 --- a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp +++ b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp @@ -429,14 +429,14 @@ StatusCode EDM4hep2LcioTool::convertCollections(lcio::LCEventImpl* lcio_event) { std::vector> linkCollections{}; for (const auto& [edm4hepName, lcioName] : m_collsToConvert) { - const auto coll = getEDM4hepCollection(edm4hepName); - if (coll->getTypeName().find("LinkCollection") != std::string_view::npos) { - debug() << edm4hepName << " is a link collection, converting it later" << endmsg; - linkCollections.emplace_back(lcioName, coll); - continue; - } debug() << "Converting collection " << edm4hepName << " (storing it as " << lcioName << ")" << endmsg; if (!EDM4hep2LCIOConv::collectionExist(lcioName, lcio_event)) { + const auto coll = getEDM4hepCollection(edm4hepName); + if (coll->getTypeName().find("LinkCollection") != std::string_view::npos) { + debug() << edm4hepName << " is a link collection, converting it later" << endmsg; + linkCollections.emplace_back(lcioName, coll); + continue; + } convertAdd(edm4hepName, lcioName, lcio_event, collection_pairs, pidCollections, dQdxCollections); } else { debug() << " Collection " << lcioName << " already in place, skipping conversion. " << endmsg;