From 1add3c890d10773b9a41a9e857ce9fa7ea225e49 Mon Sep 17 00:00:00 2001 From: Leonhard Reichenbach Date: Wed, 19 Apr 2023 09:28:41 +0200 Subject: [PATCH] Add support for EventHeader conversion (#13) --- .../k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h | 2 ++ k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h index 487d7ee1..a575e353 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h @@ -140,6 +140,8 @@ lcio::LCCollectionVec* convMCParticles( const edm4hep::MCParticleCollection* const mcparticle_coll, vec_pair& mc_particles_vec); +void convEventHeader(const edm4hep::EventHeaderCollection* const header_coll, lcio::LCEventImpl* const lcio_event); + void FillMissingCollections(CollectionsPairVectors& collection_pairs); bool collectionExist(const std::string& collection_name, const lcio::LCEventImpl* lcio_event); diff --git a/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp b/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp index 499d20a8..8988441b 100644 --- a/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp +++ b/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp @@ -699,6 +699,20 @@ lcio::LCCollectionVec* convMCParticles( return mcparticles; } +// The EventHeaderCollection should be of length 1 +void convEventHeader(const edm4hep::EventHeaderCollection* const header_coll, lcio::LCEventImpl* const lcio_event) +{ + if (header_coll->size() != 1) { + return; + } + + const auto& header = header_coll->at(0); + lcio_event->setEventNumber(header.getEventNumber()); + lcio_event->setRunNumber(header.getRunNumber()); + lcio_event->setTimeStamp(header.getTimeStamp()); + lcio_event->setWeight(header.getWeight()); +} + // Depending on the order of the collections in the parameters, // and for the mutual dependencies between some collections, // go over the possible missing associated collections and fill them.