Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing calohit contributions if all SimCalo hit collections are empty #157

Merged
merged 2 commits into from
Nov 2, 2023
Merged
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
11 changes: 9 additions & 2 deletions k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) {
std::vector<std::pair<std::string, EVENT::LCCollection*>> lcRelationColls{};
std::vector<std::tuple<std::string, EVENT::LCCollection*, std::string>> subsetColls{};

// If we convert any SimCalorimeterHit collection we also need the
// CaloHitContributions in the end, even if all SimCalorimeterHit collections
// were empty
bool needCaloHitContribs = false;

for (const auto& [lcioName, edm4hepName] : collsToConvert) {
try {
auto* lcio_coll = the_event->getCollection(lcioName);
Expand All @@ -183,6 +188,8 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) {
lcRelationColls.emplace_back(std::make_pair(edm4hepName, lcio_coll));
}

needCaloHitContribs = (lcio_coll_type_str == "SimCalorimeterHit") && !lcio_coll->isSubset();

for (auto&& e4hColl : LCIO2EDM4hepConv::convertCollection(edm4hepName, lcio_coll, lcio2edm4hepMaps)) {
if (std::get<1>(e4hColl)) {
registerCollection(std::move(e4hColl), lcio_coll);
Expand Down Expand Up @@ -225,11 +232,11 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) {
registerCollection(std::move(assocColl)); // TODO: Potentially handle metadata here?
}

if (!lcio2edm4hepMaps.simCaloHits.empty()) {
if (needCaloHitContribs) {
registerCollection(name() + "_CaloHitContributions",
LCIO2EDM4hepConv::createCaloHitContributions(
lcio2edm4hepMaps.simCaloHits,
lcio2edm4hepMaps.mcParticles)); // TODO: Can we do something about meta data here?
globalObjMap.mcParticles)); // TODO: Can we do something about meta data here?
}

return StatusCode::SUCCESS;
Expand Down