Skip to content

Commit

Permalink
Create an EventHeader and also compare it
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Oct 5, 2023
1 parent 55e117c commit caff3e9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
14 changes: 9 additions & 5 deletions tests/edm4hep_to_lcio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ int main()
const auto edmEvent = createExampleEvent();
const auto lcioEvent = EDM4hep2LCIOConv::convEvent(edmEvent);

// if (!compareEventHeader(lcioEvent.get(), &edmEvent)) {
// return 1;
// }
if (!compareEventHeader(lcioEvent.get(), &edmEvent)) {
return 1;
}

for (const auto& name : edmEvent.getAvailableCollections()) {
const auto edmColl = edmEvent.get(name);
const auto typeName = edmColl->getValueTypeName();
if (typeName == "edm4hep::CaloHitContribution" || typeName == "edm4hep::ParticleID") {
if (
typeName == "edm4hep::CaloHitContribution" || typeName == "edm4hep::ParticleID" ||
typeName == "edm4hep::EventHeader") {
continue;
}
try {
Expand All @@ -41,7 +43,9 @@ int main()

for (const auto& name : edmEvent.getAvailableCollections()) {
const auto type = edmEvent.get(name)->getTypeName();
if (type == "edm4hep::CaloHitContributionCollection" || type == "edm4hep::ParticleIDCollection") {
if (
type == "edm4hep::CaloHitContributionCollection" || type == "edm4hep::ParticleIDCollection" ||
type == "edm4hep::EventHeaderCollection") {
continue;
}
const auto* lcioColl = lcioEvent->getCollection(name);
Expand Down
15 changes: 15 additions & 0 deletions tests/src/EDM4hep2LCIOUtilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "edm4hep/RawCalorimeterHitCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"
#include "edm4hep/TrackerHitCollection.h"
#include <edm4hep/EventHeaderCollection.h>
#include <edm4hep/RawTimeSeriesCollection.h>
#include "edm4hep/TrackCollection.h"
#include "edm4hep/SimCalorimeterHitCollection.h"
Expand Down Expand Up @@ -252,10 +253,24 @@ std::pair<edm4hep::SimCalorimeterHitCollection, edm4hep::CaloHitContributionColl
return {std::move(simcalohit_coll), std::move(contrib_coll)};
}

edm4hep::EventHeaderCollection createEventHeader()
{
auto evtHeaderColl = edm4hep::EventHeaderCollection {};
auto evtHeader = evtHeaderColl.create();

evtHeader.setWeight(3.14f);
evtHeader.setEventNumber(123456789);
evtHeader.setRunNumber(42);
evtHeader.setTimeStamp(0x71AAE);

return evtHeaderColl;
}

podio::Frame createExampleEvent()
{
podio::Frame event;

event.put(createEventHeader(), "EventHeader");
const auto& mcParticles =
event.put(createMCParticles(test_config::nMCParticles, test_config::mcpParentIdcs), "mcParticles");
const auto& caloHits = event.put(createCalorimeterHits(test_config::nCaloHits), "caloHits");
Expand Down
3 changes: 3 additions & 0 deletions tests/src/EDM4hep2LCIOUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace edm4hep {
class TrackCollection;
class SimCalorimeterHitCollection;
class CaloHitContributionCollection;
class EventHeaderCollection;
} // namespace edm4hep

namespace podio {
Expand Down Expand Up @@ -120,6 +121,8 @@ std::pair<edm4hep::SimCalorimeterHitCollection, edm4hep::CaloHitContributionColl
const edm4hep::MCParticleCollection& mcParticles,
const std::vector<test_config::CaloContIdx>& link_mcparticles_idcs);

edm4hep::EventHeaderCollection createEventHeader();

/**
* Create an example event that can be used to test the converter.
*
Expand Down

0 comments on commit caff3e9

Please sign in to comment.