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

feat: Add compatibility for PODIO 1.x #3360

Merged
merged 8 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ set(_acts_dd4hep_version 1.21)
set(_acts_edm4hep_version 0.7)
set(_acts_geomodel_version 4.6.0)
set(_acts_eigen3_version 3.3.7)
set(_acts_podio_version 0.16)
set(_acts_podio_version 1.0.1) # will try this first
set(_acts_podio_fallback_version 0.16) # if not found, will try this one
set(_acts_doxygen_version 1.9.4)
set(_acts_hepmc3_version 3.2.1)
set(_acts_nlohmanjson_version 3.2.0)
Expand Down Expand Up @@ -396,7 +397,11 @@ if(ACTS_BUILD_PLUGIN_ONNX OR ACTS_EXATRKX_ENABLE_ONNX)
find_package(OnnxRuntime ${_acts_onnxruntime_version} REQUIRED)
endif()
if(ACTS_BUILD_PLUGIN_EDM4HEP OR ACTS_BUILD_PLUGIN_PODIO)
find_package(podio ${_acts_podio_version} REQUIRED CONFIG)
find_package(podio ${_acts_podio_version} CONFIG)
if(NOT podio_FOUND)
message(STATUS "Podio not found, trying ${_acts_podio_fallback_version} version")
find_package(podio ${_acts_podio_fallback_version} CONFIG REQUIRED)
endif()
find_package(ROOT ${_acts_root_version} REQUIRED CONFIG COMPONENTS Core)
endif()
if(ACTS_BUILD_PLUGIN_EDM4HEP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once

#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "ActsExamples/EventData/Cluster.hpp"
#include "ActsExamples/EventData/IndexSourceLink.hpp"
Expand All @@ -17,7 +18,6 @@
#include <memory>
#include <string>

#include <podio/ROOTFrameReader.h>
#include <tbb/enumerable_thread_specific.h>

namespace ActsExamples {
Expand Down Expand Up @@ -69,9 +69,9 @@ class EDM4hepMeasurementReader final : public IReader {
std::pair<std::size_t, std::size_t> m_eventsRange;
std::unique_ptr<const Acts::Logger> m_logger;

tbb::enumerable_thread_specific<podio::ROOTFrameReader> m_reader;
tbb::enumerable_thread_specific<Acts::PodioUtil::ROOTReader> m_reader;

podio::ROOTFrameReader& reader();
Acts::PodioUtil::ROOTReader& reader();

WriteDataHandle<MeasurementContainer> m_outputMeasurements{
this, "OutputMeasurements"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "ActsExamples/EventData/Cluster.hpp"
#include "ActsExamples/EventData/Measurement.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
Expand All @@ -17,7 +18,6 @@

#include <edm4hep/TrackerHitCollection.h>
#include <edm4hep/TrackerHitPlaneCollection.h>
#include <podio/ROOTFrameWriter.h>

namespace ActsExamples {

Expand Down Expand Up @@ -64,7 +64,7 @@ class EDM4hepMeasurementWriter final : public WriterT<MeasurementContainer> {
private:
Config m_cfg;

podio::ROOTFrameWriter m_writer;
Acts::PodioUtil::ROOTWriter m_writer;

std::mutex m_writeMutex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "ActsExamples/EventData/Trajectories.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
#include "ActsExamples/Framework/WriterT.hpp"
Expand All @@ -16,8 +17,6 @@

#include <string>

#include <podio/ROOTFrameWriter.h>

namespace ActsExamples {

/// Write out the tracks reconstructed using Combinatorial Kalman Filter to
Expand Down Expand Up @@ -69,7 +68,7 @@ class EDM4hepMultiTrajectoryWriter : public WriterT<TrajectoriesContainer> {
Config m_cfg;

std::mutex m_writeMutex;
podio::ROOTFrameWriter m_writer;
Acts::PodioUtil::ROOTWriter m_writer;

ReadDataHandle<IndexMultimap<ActsFatras::Barcode>>
m_inputMeasurementParticlesMap{this, "InputMeasurementParticlesMaps"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

#pragma once

#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsExamples/Framework/WriterT.hpp"

#include <mutex>
#include <string>

#include <podio/ROOTFrameWriter.h>

namespace ActsExamples {

/// Write particles to EDM4hep
Expand Down Expand Up @@ -58,7 +57,7 @@ class EDM4hepParticleWriter final : public WriterT<SimParticleContainer> {

std::mutex m_writeMutex;

podio::ROOTFrameWriter m_writer;
Acts::PodioUtil::ROOTWriter m_writer;
};

} // namespace ActsExamples
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "Acts/Utilities/Logger.hpp"
#include "ActsExamples/EventData/SimHit.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
Expand All @@ -21,7 +22,6 @@

#include <DD4hep/DetElement.h>
#include <edm4hep/MCParticleCollection.h>
#include <podio/ROOTFrameReader.h>
#include <tbb/enumerable_thread_specific.h>

namespace ActsExamples {
Expand Down Expand Up @@ -107,9 +107,9 @@ class EDM4hepReader final : public IReader {

std::unordered_map<unsigned int, const Acts::Surface*> m_surfaceMap;

tbb::enumerable_thread_specific<podio::ROOTFrameReader> m_reader;
tbb::enumerable_thread_specific<Acts::PodioUtil::ROOTReader> m_reader;

podio::ROOTFrameReader& reader();
Acts::PodioUtil::ROOTReader& reader();

WriteDataHandle<SimParticleContainer> m_outputParticlesInitial{
this, "OutputParticlesInitial"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "ActsExamples/EventData/SimHit.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
Expand All @@ -17,7 +18,6 @@

#include <edm4hep/MCParticleCollection.h>
#include <edm4hep/SimTrackerHitCollection.h>
#include <podio/ROOTFrameWriter.h>

namespace ActsExamples {

Expand Down Expand Up @@ -65,7 +65,7 @@ class EDM4hepSimHitWriter final : public WriterT<SimHitContainer> {
private:
Config m_cfg;

podio::ROOTFrameWriter m_writer;
Acts::PodioUtil::ROOTWriter m_writer;

std::mutex m_writeMutex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "ActsExamples/EventData/Track.hpp"
#include "ActsExamples/EventData/Trajectories.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
Expand All @@ -18,7 +19,6 @@

#include <string>

#include <podio/ROOTFrameReader.h>
#include <tbb/enumerable_thread_specific.h>

namespace ActsExamples {
Expand Down Expand Up @@ -61,9 +61,9 @@ class EDM4hepTrackReader : public IReader {

WriteDataHandle<ConstTrackContainer> m_outputTracks{this, "OutputTracks"};

tbb::enumerable_thread_specific<podio::ROOTFrameReader> m_reader;
tbb::enumerable_thread_specific<Acts::PodioUtil::ROOTReader> m_reader;

podio::ROOTFrameReader& reader();
Acts::PodioUtil::ROOTReader& reader();

std::unique_ptr<const Acts::Logger> m_logger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "ActsExamples/EventData/Track.hpp"
#include "ActsExamples/EventData/Trajectories.hpp"
#include "ActsExamples/Framework/DataHandle.hpp"
Expand All @@ -17,8 +18,6 @@

#include <string>

#include <podio/ROOTFrameWriter.h>

namespace ActsExamples {

class EDM4hepTrackWriter : public WriterT<ConstTrackContainer> {
Expand Down Expand Up @@ -58,7 +57,7 @@ class EDM4hepTrackWriter : public WriterT<ConstTrackContainer> {

std::mutex m_writeMutex;

podio::ROOTFrameWriter m_writer;
Acts::PodioUtil::ROOTWriter m_writer;
};

} // namespace ActsExamples
4 changes: 2 additions & 2 deletions Examples/Io/EDM4hep/src/EDM4hepMeasurementReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ActsExamples/Io/EDM4hep/EDM4hepMeasurementReader.hpp"

#include "Acts/Definitions/Units.hpp"
#include "Acts/Plugins/Podio/PodioUtil.hpp"
#include "ActsExamples/EventData/Cluster.hpp"
#include "ActsExamples/EventData/Measurement.hpp"
#include "ActsExamples/Framework/WhiteBoard.hpp"
Expand All @@ -21,7 +22,6 @@
#include <edm4hep/TrackerHitCollection.h>
#include <edm4hep/TrackerHitPlane.h>
#include <edm4hep/TrackerHitPlaneCollection.h>
#include <podio/Frame.h>

namespace ActsExamples {

Expand Down Expand Up @@ -85,7 +85,7 @@ ProcessCode EDM4hepMeasurementReader::read(const AlgorithmContext& ctx) {
return ProcessCode::SUCCESS;
}

podio::ROOTFrameReader& EDM4hepMeasurementReader::reader() {
Acts::PodioUtil::ROOTReader& EDM4hepMeasurementReader::reader() {
bool exists = false;
auto& reader = m_reader.local(exists);
if (!exists) {
Expand Down
3 changes: 1 addition & 2 deletions Examples/Io/EDM4hep/src/EDM4hepReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <edm4hep/SimTrackerHitCollection.h>
#include <podio/Frame.h>
#include <podio/ObjectID.h>
#include <podio/ROOTFrameReader.h>

namespace ActsExamples {

Expand Down Expand Up @@ -82,7 +81,7 @@ EDM4hepReader::EDM4hepReader(const Config& config, Acts::Logging::Level level)
});
}

podio::ROOTFrameReader& EDM4hepReader::reader() {
Acts::PodioUtil::ROOTReader& EDM4hepReader::reader() {
bool exists = false;
auto& reader = m_reader.local(exists);
if (!exists) {
Expand Down
2 changes: 1 addition & 1 deletion Examples/Io/EDM4hep/src/EDM4hepTrackReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ProcessCode EDM4hepTrackReader::read(const AlgorithmContext& ctx) {
return ProcessCode::SUCCESS;
}

podio::ROOTFrameReader& EDM4hepTrackReader::reader() {
Acts::PodioUtil::ROOTReader& EDM4hepTrackReader::reader() {
bool exists = false;
auto& reader = m_reader.local(exists);
if (!exists) {
Expand Down
2 changes: 1 addition & 1 deletion Plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ add_component_if(Detray PluginDetray ACTS_BUILD_PLUGIN_DETRAY)
# dependent plugins. depend either on a independent plugins or on one another
add_component_if(TGeo PluginTGeo ACTS_BUILD_PLUGIN_TGEO)
add_component_if(DD4hep PluginDD4hep ACTS_BUILD_PLUGIN_DD4HEP)
add_component_if(Podio PluginPodio ACTS_BUILD_PLUGIN_PODIO OR ACTS_PLUGIN_EDM4HEP)
add_component_if(EDM4hep PluginEDM4hep ACTS_BUILD_PLUGIN_EDM4HEP)
add_component_if(Podio PluginPodio ACTS_BUILD_PLUGIN_PODIO)

propagate_components_to_parent()
1 change: 1 addition & 0 deletions Plugins/EDM4hep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target_link_libraries(
ActsPluginEDM4hep
PUBLIC
ActsCore
ActsPluginPodio
EDM4HEP::edm4hep)

install(
Expand Down
11 changes: 7 additions & 4 deletions Plugins/Podio/include/Acts/Plugins/Podio/PodioTrackContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PodioTrackContainerBase {
if constexpr (EnsureConst) {
dataPtr = &track.getData();
} else {
dataPtr = &track.data();
dataPtr = &PodioUtil::getDataMutable(track);
}
auto& data = *dataPtr;
switch (key) {
Expand Down Expand Up @@ -213,7 +213,8 @@ class MutablePodioTrackContainer : public PodioTrackContainerBase {

IndexType addTrack_impl() {
auto track = m_collection->create();
track.referenceSurface().surfaceType = PodioUtil::kNoSurface;
PodioUtil::getReferenceSurfaceMutable(track).surfaceType =
PodioUtil::kNoSurface;
m_surfaces.emplace_back();
for (const auto& [key, vec] : m_dynamic) {
vec->add();
Expand All @@ -231,7 +232,8 @@ class MutablePodioTrackContainer : public PodioTrackContainerBase {
}

Parameters parameters(IndexType itrack) {
return Parameters{m_collection->at(itrack).data().parameters.data()};
return Parameters{
PodioUtil::getDataMutable(m_collection->at(itrack)).parameters.data()};
}

ConstParameters parameters(IndexType itrack) const {
Expand All @@ -240,7 +242,8 @@ class MutablePodioTrackContainer : public PodioTrackContainerBase {
}

Covariance covariance(IndexType itrack) {
return Covariance{m_collection->at(itrack).data().covariance.data()};
return Covariance{
PodioUtil::getDataMutable(m_collection->at(itrack)).covariance.data()};
}

ConstCovariance covariance(IndexType itrack) const {
Expand Down
Loading
Loading