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

Make sure to always put a CaloHitContribution collection into the event #79

Merged
merged 3 commits into from
Jul 4, 2024
Merged
Changes from 2 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
16 changes: 15 additions & 1 deletion standalone/lcio2edm4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ int main(int argc, char* argv[]) {
UTIL::CheckCollections colPatcher{};
std::vector<NamesType> namesTypes{};
const bool patching = !args.patchFile.empty();
// Keep track of whether we have any SimCalorimeterHits
tmadlener marked this conversation as resolved.
Show resolved Hide resolved
if (patching) {
namesTypes = getNamesAndTypes(args.patchFile);
if (namesTypes.empty()) {
Expand Down Expand Up @@ -208,6 +209,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 +220,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
Loading