From 7620f687fe38e7d8b973355d47840cb087a1b202 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Wed, 4 Dec 2024 21:39:34 -0500 Subject: [PATCH 1/2] Fix podio deprecation warnings --- src/examples/PodioExample/PodioExample.cc | 15 +++++++++++++-- src/examples/PodioFileReader/PodioFileReader.cc | 12 ++++++++++-- src/examples/PodioFileWriter/PodioFileWriter.cc | 13 +++++++++++-- src/examples/TimesliceExample/MyFileWriter.h | 17 ++++++++++++----- src/libraries/JANA/JEvent.h | 2 +- src/libraries/JANA/Podio/JFactoryPodioT.h | 4 ++-- 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/src/examples/PodioExample/PodioExample.cc b/src/examples/PodioExample/PodioExample.cc index 54b73718b..f53ead3ac 100644 --- a/src/examples/PodioExample/PodioExample.cc +++ b/src/examples/PodioExample/PodioExample.cc @@ -6,8 +6,19 @@ #include "PodioDatamodel/EventInfoCollection.h" #include "PodioDatamodel/ExampleHitCollection.h" +#include + +#if podio_VERSION_MAJOR == 0 && podio_VERSION_MINOR < 99 #include #include +namespace podio { + using ROOTWriter = podio::ROOTFrameWriter; + using ROOTReader = podio::ROOTFrameReader; +} +#else +#include +#include +#endif #include #include @@ -36,7 +47,7 @@ void create_hits_file() { event1.put(std::move(hits1), "hits"); event1.put(std::move(eventinfos1), "eventinfos"); - podio::ROOTFrameWriter writer("hits.root"); + podio::ROOTWriter writer("hits.root"); writer.writeFrame(event1, "events"); MutableEventInfo eventinfo2(8, 0, 22); @@ -59,7 +70,7 @@ void create_hits_file() { } void verify_clusters_file() { - podio::ROOTFrameReader reader; + podio::ROOTReader reader; reader.openFile("podio_output.root"); auto event0 = podio::Frame(reader.readEntry("events", 0)); diff --git a/src/examples/PodioFileReader/PodioFileReader.cc b/src/examples/PodioFileReader/PodioFileReader.cc index a8a7cc17d..e2157e4d9 100644 --- a/src/examples/PodioFileReader/PodioFileReader.cc +++ b/src/examples/PodioFileReader/PodioFileReader.cc @@ -11,7 +11,15 @@ #include #include +#include +#if podio_VERSION_MAJOR == 0 && podio_VERSION_MINOR < 99 #include +namespace podio { + using ROOTReader = podio::ROOTFrameReader; +} +#else +#include +#endif @@ -19,8 +27,8 @@ class PodioFileReader : public JEventSource { private: uint64_t m_entry_count = 0; - podio::ROOTFrameReader m_reader; - // ROOTFrameReader emits a lot of deprecation warnings, but the supposed replacement + podio::ROOTReader m_reader; + // ROOTReader emits a lot of deprecation warnings, but the supposed replacement // won't actually be a replacement until the next version public: diff --git a/src/examples/PodioFileWriter/PodioFileWriter.cc b/src/examples/PodioFileWriter/PodioFileWriter.cc index 14ac91899..c0a58af0f 100644 --- a/src/examples/PodioFileWriter/PodioFileWriter.cc +++ b/src/examples/PodioFileWriter/PodioFileWriter.cc @@ -3,7 +3,16 @@ // Author: Nathan Brei #include + +#include +#if podio_VERSION_MAJOR == 0 && podio_VERSION_MINOR < 99 #include +namespace podio { +using ROOTWriter = podio::ROOTFrameWriter; +} +#else +#include +#endif class PodioFileWriter : public JEventProcessor { @@ -23,7 +32,7 @@ class PodioFileWriter : public JEventProcessor { "events", "Name of branch to store data in the output file"}; - std::unique_ptr m_writer; + std::unique_ptr m_writer; public: @@ -33,7 +42,7 @@ class PodioFileWriter : public JEventProcessor { } void Init() override { - m_writer = std::make_unique(*m_output_filename); + m_writer = std::make_unique(*m_output_filename); } void Finish() override { diff --git a/src/examples/TimesliceExample/MyFileWriter.h b/src/examples/TimesliceExample/MyFileWriter.h index 109e13f4d..b1881c90e 100644 --- a/src/examples/TimesliceExample/MyFileWriter.h +++ b/src/examples/TimesliceExample/MyFileWriter.h @@ -4,11 +4,18 @@ #pragma once -#include -#include "CollectionTabulators.h" #include +#include "CollectionTabulators.h" -#include +#include +#if podio_VERSION_MAJOR == 0 && podio_VERSION_MINOR < 99 +#include +namespace podio { +using ROOTWriter = podio::ROOTFrameWriter; +} +#else +#include +#endif @@ -25,7 +32,7 @@ struct MyFileWriter : public JEventProcessor { .level = JEventLevel::Timeslice, .is_optional = true }}; - std::unique_ptr m_writer = nullptr; + std::unique_ptr m_writer = nullptr; std::mutex m_mutex; MyFileWriter() { @@ -34,7 +41,7 @@ struct MyFileWriter : public JEventProcessor { } void Init() { - m_writer = std::make_unique("output.root"); + m_writer = std::make_unique("output.root"); } void Process(const JEvent& event) { diff --git a/src/libraries/JANA/JEvent.h b/src/libraries/JANA/JEvent.h index c570e239d..6a15c957d 100644 --- a/src/libraries/JANA/JEvent.h +++ b/src/libraries/JANA/JEvent.h @@ -470,7 +470,7 @@ template JFactoryPodioT* JEvent::InsertCollectionAlreadyInFrame(const podio::CollectionBase* collection, std::string name) { /// InsertCollection inserts the provided PODIO collection into a JFactoryPodioT. It assumes that the collection pointer /// is _already_ owned by the podio::Frame corresponding to this JEvent. This is meant to be used if you are starting out - /// with a PODIO frame (e.g. a JEventSource that uses podio::ROOTFrameReader). + /// with a PODIO frame (e.g. a JEventSource that uses podio::ROOTReader). const auto* typed_collection = dynamic_cast(collection); if (typed_collection == nullptr) { diff --git a/src/libraries/JANA/Podio/JFactoryPodioT.h b/src/libraries/JANA/Podio/JFactoryPodioT.h index 9ff5a60ad..eec803c83 100644 --- a/src/libraries/JANA/Podio/JFactoryPodioT.h +++ b/src/libraries/JANA/Podio/JFactoryPodioT.h @@ -165,7 +165,7 @@ void JFactoryPodioT::Create(const std::shared_ptr& event) { catch (...) { if (mCollection == nullptr) { // If calling Create() excepts, we still create an empty collection - // so that podio::ROOTFrameWriter doesn't segfault on the null mCollection pointer + // so that podio::ROOTWriter doesn't segfault on the null mCollection pointer SetCollection(CollectionT()); } throw; @@ -173,7 +173,7 @@ void JFactoryPodioT::Create(const std::shared_ptr& event) { if (mCollection == nullptr) { SetCollection(CollectionT()); // If calling Process() didn't result in a call to Set() or SetCollection(), we create an empty collection - // so that podio::ROOTFrameWriter doesn't segfault on the null mCollection pointer + // so that podio::ROOTWriter doesn't segfault on the null mCollection pointer } } From 350aa81f89efa8febb604723ee576955bf0655b0 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 5 Dec 2024 11:29:01 -0500 Subject: [PATCH 2/2] Fix more warnings --- .../InteractiveStreamingExample/DecodeDASSource.cc | 9 ++++----- src/libraries/JANA/Utils/JCpuInfo.cc | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/examples/InteractiveStreamingExample/DecodeDASSource.cc b/src/examples/InteractiveStreamingExample/DecodeDASSource.cc index ea00dddc3..32ee443cc 100644 --- a/src/examples/InteractiveStreamingExample/DecodeDASSource.cc +++ b/src/examples/InteractiveStreamingExample/DecodeDASSource.cc @@ -21,20 +21,19 @@ DecodeDASSource::~DecodeDASSource() { void DecodeDASSource::Open() { // open the file stream - ifs.open(GetName()); - if (!ifs) throw JException("Unable to open '%s'", GetName().c_str()); + ifs.open(GetResourceName()); + if (!ifs) throw JException("Unable to open '%s'", GetResourceName().c_str()); } void DecodeDASSource::Close() { // Close the file/stream here. - std::cout << "Closing " << GetName() << std::endl; + std::cout << "Closing " << GetResourceName() << std::endl; ifs.close(); } JEventSource::Result DecodeDASSource::Emit(JEvent& event) { - // TODO: Put these somewhere that makes sense size_t MAX_CHANNELS = 80; size_t MAX_SAMPLES = 1024; // open the file stream and parse the data @@ -59,7 +58,7 @@ JEventSource::Result DecodeDASSource::Emit(JEvent& event) { return Result::Success; } // close file stream when the end of file is reached - std::cout << "Reached end of file/stream " << GetName() << std::endl; + std::cout << "Reached end of file/stream " << GetResourceName() << std::endl; } return Result::FailureFinished; diff --git a/src/libraries/JANA/Utils/JCpuInfo.cc b/src/libraries/JANA/Utils/JCpuInfo.cc index 3349a8b9d..6bd72b432 100644 --- a/src/libraries/JANA/Utils/JCpuInfo.cc +++ b/src/libraries/JANA/Utils/JCpuInfo.cc @@ -63,10 +63,10 @@ uint32_t GetCpuID() { #ifdef __cpuid_count GETCPU(cpuid); #else // __cpuid_count -#warning __cpuid_count is not defined on this system. + // cpuid_count is not defined on this system. + return 0; #endif // __cpuid_count return cpuid; - // TODO: Clean this up #else //__APPLE__ return sched_getcpu();