Skip to content

Commit

Permalink
Merge branch 'main' into datatypes_table
Browse files Browse the repository at this point in the history
  • Loading branch information
m-fila authored Feb 23, 2024
2 parents 1d1b33f + 213115d commit da6897d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
10 changes: 5 additions & 5 deletions test/read_events.cc
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#include "read_events.h"
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
#include "podio/podioVersion.h"
#if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
#include "podio/ROOTReader.h"
#else
#include "podio/ROOTFrameReader.h"
namespace podio {
using ROOTReader = podio::ROOTFrameReader;
}
#endif

int main() {
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
read_events<podio::ROOTReader>("edm4hep_events.root");
#else
read_events<podio::ROOTFrameReader>("edm4hep_events.root");
#endif

return 0;
}
26 changes: 13 additions & 13 deletions test/read_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ void processEvent(const podio::Frame& event) {
auto d1 = mcp1.getDaughters(1);
auto d2 = mcp1.getDaughters(2);

if (!(d0 == mcps[2]))
if (d0 != mcps[2])
throw std::runtime_error(" error: 1. daughter of particle 0 is not particle 2 ");
if (!(d1 == mcps[4]))
if (d1 != mcps[4])
throw std::runtime_error(" error: 2. daughter of particle 0 is not particle 4 ");
if (!(d2 == mcps[5]))
if (d2 != mcps[5])
throw std::runtime_error(" error: 3. daughter of particle 0 is not particle 5 ");

auto mcp2 = mcps[1];
Expand Down Expand Up @@ -90,19 +90,19 @@ void processEvent(const podio::Frame& event) {
throw std::runtime_error("cellID != 0xabadcaffee");
if (sth1.getEDep() != j * 0.000001f)
throw std::runtime_error("e_dep != j * 0.000001");
if (!(sth1.getPosition() == edm4hep::Vector3d(j * 10., j * 20., j * 5.)))
if (sth1.getPosition() != edm4hep::Vector3d(j * 10., j * 20., j * 5.))
throw std::runtime_error("position != ( j*10. , j*20., j*5. )");
if (!(sth1.getMCParticle() == mcps[6]))
if (sth1.getParticle() != mcps[6])
throw std::runtime_error("mcp != mcps[6]");

auto sth2 = sths[2 * j + 1];
if (sth2.getCellID() != 0xcaffeebabe)
throw std::runtime_error("cellID != 0xcaffeebabe");
if (sth2.getEDep() != j * 0.001f)
throw std::runtime_error("e_dep != j * 0.001");
if (!(sth2.getPosition() == edm4hep::Vector3d(-j * 10., -j * 20., -j * 5.)))
if (sth2.getPosition() != edm4hep::Vector3d(-j * 10., -j * 20., -j * 5.))
throw std::runtime_error("position != ( -j*10. , -j*20., -j*5. )");
if (!(sth2.getMCParticle() == mcps[7]))
if (sth2.getParticle() != mcps[7])
throw std::runtime_error("mcp != mcps[7]");
}

Expand Down Expand Up @@ -137,14 +137,14 @@ void processEvent(const podio::Frame& event) {
throw std::runtime_error("cellID != 0xabadcaffee");
if (sch1.getEnergy() != j * 0.1f)
throw std::runtime_error("energy != j*0.1f");
if (!(sch1.getPosition() == edm4hep::Vector3f(j * 100.f, j * 200.f, j * 50.f)))
if (sch1.getPosition() != edm4hep::Vector3f(j * 100.f, j * 200.f, j * 50.f))
throw std::runtime_error("position != ( j*100. , j*200., j*50. )");

auto cont1 = sch1.getContributions(0);

if (!(cont1.getPDG() == 11) || !(cont1.getEnergy() == j * 0.1f) || !(cont1.getTime() == j * 1e-9f) ||
if (cont1.getPDG() != 11 || cont1.getEnergy() != j * 0.1f || cont1.getTime() != j * 1e-9f ||
!(cont1.getStepPosition() == edm4hep::Vector3f(j * 100.01f, j * 200.01f, j * 50.01f)) ||
!(cont1.getParticle() == mcps[6])) {
cont1.getParticle() != mcps[6]) {
throw std::runtime_error("contribution1 does not match ");
}

Expand All @@ -153,14 +153,14 @@ void processEvent(const podio::Frame& event) {
throw std::runtime_error("cellID != 0xcaffeebabe");
if (sch2.getEnergy() != j * 0.2f)
throw std::runtime_error("energy != j*0.2");
if (!(sch2.getPosition() == edm4hep::Vector3f(-j * 100.f, -j * 200.f, -j * 50.f)))
if (sch2.getPosition() != edm4hep::Vector3f(-j * 100.f, -j * 200.f, -j * 50.f))
throw std::runtime_error("position != ( -j*100.f , -j*200.f, -j*50.f )");

auto cont2 = sch2.getContributions(0);

if (!(cont2.getPDG() == -11) || !(cont2.getEnergy() == j * 0.2f) || !(cont2.getTime() == j * 1e-9f) ||
if (cont2.getPDG() != -11 || cont2.getEnergy() != j * 0.2f || cont2.getTime() != j * 1e-9f ||
!(cont2.getStepPosition() == edm4hep::Vector3f(-j * 100.01f, -j * 200.01f, -j * 50.01f)) ||
!(cont2.getParticle() == mcps[7])) {
cont2.getParticle() != mcps[7]) {
throw std::runtime_error("contribution2 does not match ");
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/write_events.cc
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include "write_events.h"
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
#include "podio/podioVersion.h"
#if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
#include "podio/ROOTWriter.h"
#else
#include "podio/ROOTFrameWriter.h"
namespace podio {
using ROOTWriter = podio::ROOTFrameWriter;
}
#endif

int main(int, char*[]) {

#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
write<podio::ROOTWriter>("edm4hep_events.root");
#else
write<podio::ROOTFrameWriter>("edm4hep_events.root");
#endif
}
4 changes: 2 additions & 2 deletions test/write_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ void write(std::string outfilename) {
sth1.setCellID(0xabadcaffee);
sth1.setEDep(j * 0.000001f);
sth1.setPosition({j * 10., j * 20., j * 5.});
sth1.setMCParticle(mcp7);
sth1.setParticle(mcp7);

auto sth2 = sths.create();
sth2.setCellID(0xcaffeebabe);
sth2.setPosition({-j * 10., -j * 20., -j * 5.});
sth2.setEDep(j * .001f);
sth2.setMCParticle(mcp8);
sth2.setParticle(mcp8);
}

std::cout << "\n collection: "
Expand Down
11 changes: 5 additions & 6 deletions tools/src/edm4hep2json.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
#include "TFile.h"

// podio
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
#include "podio/podioVersion.h"
#if PODIO_BUILD_VERSION >= PODIO_VERSION(0, 99, 0)
#include "podio/ROOTReader.h"
#else
#include "podio/ROOTFrameReader.h"
namespace podio {
using ROOTReader = podio::ROOTFrameReader;
}
#endif
#include "podio/ROOTLegacyReader.h"

Expand Down Expand Up @@ -135,13 +139,8 @@ int main(int argc, char** argv) {
return read_frames<podio::ROOTLegacyReader>(inFilePath, outFilePath, requestedCollections, requestedEvents,
frameName, nEventsMax, verboser);
} else {
#if PODIO_VERSION_MAJOR > 0 || (PODIO_VERSION_MAJOR == 0 && PODIO_VERSION_MINOR >= 99)
return read_frames<podio::ROOTReader>(inFilePath, outFilePath, requestedCollections, requestedEvents, frameName,
nEventsMax, verboser);
#else
return read_frames<podio::ROOTFrameReader>(inFilePath, outFilePath, requestedCollections, requestedEvents,
frameName, nEventsMax, verboser);
#endif
}

return EXIT_SUCCESS;
Expand Down

0 comments on commit da6897d

Please sign in to comment.