diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp index 0d5b5d9..fba8fcb 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp @@ -817,35 +817,47 @@ std::unique_ptr createLCRelationCollection(const AssocCollT& using FromLCIOT = std::remove_pointer_t>; using ToLCIOT = std::remove_pointer_t>; - auto relNav = UTIL::LCRelationNavigator(detail::getTypeName(), detail::getTypeName()); + auto lcioColl = std::make_unique(lcio::LCIO::LCRELATION); + lcioColl->parameters().setValue("FromType", detail::getTypeName()); + lcioColl->parameters().setValue("ToType", detail::getTypeName()); for (const auto assoc : associations) { + auto lcioRel = new lcio::LCRelationImpl{}; + lcioRel->setWeight(assoc.getWeight()); + + const auto edm4hepFrom = assoc.getRec(); + const auto lcioFrom = k4EDM4hep2LcioConv::detail::mapLookupFrom(edm4hepFrom, fromMap); + if (lcioFrom) { + lcioRel->setFrom(lcioFrom.value()); + } else { + std::cerr << "Cannot find an object for building an LCRelation of type " << detail::getTypeName() + << std::endl; + } + if constexpr (std::is_same_v) { const auto edm4hepTo = assoc.getVertex(); - const auto edm4hepFrom = assoc.getRec(); const auto lcioTo = k4EDM4hep2LcioConv::detail::mapLookupFrom(edm4hepTo, toMap); - const auto lcioFrom = k4EDM4hep2LcioConv::detail::mapLookupFrom(edm4hepFrom, fromMap); - if (lcioTo && lcioFrom) { - relNav.addRelation(lcioFrom.value(), lcioTo.value(), assoc.getWeight()); + if (lcioTo) { + lcioRel->setTo(lcioTo.value()); } else { - std::cerr << "Cannot find all objects for building an LCRelation between " << detail::getTypeName() - << " and " << detail::getTypeName() << std::endl; + std::cerr << "Cannot find an objects for building an LCRelation of type " << detail::getTypeName() + << std::endl; } } else { const auto edm4hepTo = assoc.getSim(); - const auto edm4hepFrom = assoc.getRec(); const auto lcioTo = k4EDM4hep2LcioConv::detail::mapLookupFrom(edm4hepTo, toMap); - const auto lcioFrom = k4EDM4hep2LcioConv::detail::mapLookupFrom(edm4hepFrom, fromMap); - if (lcioTo && lcioFrom) { - relNav.addRelation(lcioFrom.value(), lcioTo.value(), assoc.getWeight()); + if (lcioTo) { + lcioRel->setTo(lcioTo.value()); } else { - - std::cerr << "Cannot find all objects for building an LCRelation between " << detail::getTypeName() - << " and " << detail::getTypeName() << std::endl; + std::cerr << "Cannot find an objects for building an LCRelation of type " << detail::getTypeName() + << std::endl; } } + + lcioColl->addElement(lcioRel); } - return std::unique_ptr(relNav.createLCCollection()); + + return lcioColl; } } // namespace EDM4hep2LCIOConv