Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include "k4MarlinWrapper/converters/IEDMConverter.h"

#include <edm4hep/utils/ParticleIDUtils.h>

#include <lcio.h>

#include <map>
Expand Down Expand Up @@ -64,6 +66,9 @@ class Lcio2EDM4hepTool : public AlgTool, virtual public IEDMConverter {
SmartIF<IMetadataSvc> m_metadataSvc;
PodioDataSvc* m_podioDataSvc;

std::map<std::string, std::string> m_cellIDEncodings{};
std::map<std::string, edm4hep::utils::ParticleIDMeta> m_pidMetas{};

// **********************************
// Check if a collection was already registered to skip it
// **********************************
Expand Down
29 changes: 11 additions & 18 deletions k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ StatusCode Lcio2EDM4hepTool::initialize() {
return AlgTool::initialize();
}

StatusCode Lcio2EDM4hepTool::finalize() { return AlgTool::finalize(); }
StatusCode Lcio2EDM4hepTool::finalize() {
for (const auto& [key, value] : m_cellIDEncodings) {
k4FWCore::putParameter(key, value, this);
}
for (const auto& [coll, pidMeta] : m_pidMetas) {
k4FWCore::putParameter(coll, pidMeta, this);
}
return AlgTool::finalize();
}

// **********************************
// Check if a collection was already registered to skip it
Expand Down Expand Up @@ -115,8 +123,7 @@ void Lcio2EDM4hepTool::registerCollection(
mdFrame.putParameter(podio::collMetadataParamName(name, edm4hep::labels::CellIDEncoding),
lcio_coll_cellid_str);
} else {
k4FWCore::putParameter(podio::collMetadataParamName(name, edm4hep::labels::CellIDEncoding),
lcio_coll_cellid_str);
m_cellIDEncodings[podio::collMetadataParamName(name, edm4hep::labels::CellIDEncoding)] = lcio_coll_cellid_str;
}
debug() << "Storing CellIDEncoding " << podio::collMetadataParamName(name, edm4hep::labels::CellIDEncoding)
<< " value: " << lcio_coll_cellid_str << endmsg;
Expand Down Expand Up @@ -191,8 +198,6 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) {
// were empty
bool needCaloHitContribs = false;

std::map<std::string, edm4hep::utils::ParticleIDMeta> pidInfos{};

for (const auto& [lcioName, edm4hepName] : collsToConvert) {
try {
auto* lcio_coll = the_event->getCollection(lcioName);
Expand All @@ -217,7 +222,7 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) {
// Collect the ParticleID meta information because that has to go to the
// ParticleID collections
for (const auto& pidInfo : LCIO2EDM4hepConv::getPIDMetaInfo(lcio_coll)) {
pidInfos.try_emplace(LCIO2EDM4hepConv::getPIDCollName(lcioName, pidInfo.algoName), pidInfo);
m_pidMetas.try_emplace(LCIO2EDM4hepConv::getPIDCollName(lcioName, pidInfo.algoName), pidInfo);
}
}

Expand All @@ -237,18 +242,6 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) {
}
}

// Set the ParticleID meta information
if (m_podioDataSvc) {
auto& metadataFrame = m_podioDataSvc->getMetaDataFrame();
for (const auto& [collName, pidInfo] : pidInfos) {
edm4hep::utils::PIDHandler::setAlgoInfo(metadataFrame, collName, pidInfo);
}
} else {
for (const auto& [collName, pidInfo] : pidInfos) {
m_metadataSvc->put(collName, pidInfo);
}
}

auto& globalObjMap = getGlobalObjectMap(this);

globalObjMap.update(lcio2edm4hepMaps);
Expand Down
Loading