Skip to content

Commit

Permalink
Make sure to always put a CaloHitContribution collection into the eve…
Browse files Browse the repository at this point in the history
…nt (#79)

* Make sure that CaloHitContributions are present

* Write contributions only if we convert sim calo hits
  • Loading branch information
tmadlener authored Jul 4, 2024
1 parent e102e37 commit f5ed885
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion standalone/lcio2edm4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ int main(int argc, char* argv[]) {
}

const int nEvt = args.nEvents > 0 ? args.nEvents : lcreader->getNumberOfEvents();
bool haveSimCaloHits{false};
for (int i = 0; i < nEvt; ++i) {
int percEvt = i * 100 / (nEvt - 1);
if (percEvt % 10 == 0) {
Expand All @@ -218,7 +219,19 @@ int main(int argc, char* argv[]) {
if (patching == true) {
colPatcher.patchCollections(evt);
}
const auto edmEvent = LCIO2EDM4hepConv::convertEvent(evt, collsToConvert);
if (i == 0) {
for (const auto& name : *evt->getCollectionNames()) {
if (evt->getCollection(name)->getTypeName() == "SimCalorimeterHit") {
haveSimCaloHits = true;
break;
}
}
}

auto edmEvent = LCIO2EDM4hepConv::convertEvent(evt, collsToConvert);
if (haveSimCaloHits && edmEvent.get("AllCaloHitContributionsCombined") == nullptr) {
edmEvent.put(edm4hep::CaloHitContributionCollection(), "AllCaloHitContributionsCombined");
}

// For the first event we also convert some meta information for the
// ParticleID handling
Expand Down

0 comments on commit f5ed885

Please sign in to comment.