From b97b8aa38568c602639a3528707354a4252b3884 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Wed, 10 Apr 2024 13:27:49 -0400 Subject: [PATCH 01/13] JOmniFactoryGenerator configures event levels --- src/libraries/JANA/Omni/JHasInputs.h | 67 +++++++++------ src/libraries/JANA/Omni/JOmniFactory.h | 23 +++--- .../JANA/Omni/JOmniFactoryGeneratorT.h | 81 ++++++++++--------- 3 files changed, 98 insertions(+), 73 deletions(-) diff --git a/src/libraries/JANA/Omni/JHasInputs.h b/src/libraries/JANA/Omni/JHasInputs.h index d389e9a34..89c7d3d50 100644 --- a/src/libraries/JANA/Omni/JHasInputs.h +++ b/src/libraries/JANA/Omni/JHasInputs.h @@ -23,8 +23,8 @@ struct JHasInputs { struct InputBase { std::string type_name; - JEventLevel level; std::vector collection_names; + std::vector collection_levels; bool is_variadic = false; virtual void GetCollection(const JEvent& event) = 0; @@ -41,7 +41,7 @@ struct JHasInputs { owner->RegisterInput(this); this->collection_names.push_back(default_tag); this->type_name = JTypeInfo::demangle(); - this->level = level; + this->collection_levels.push_back(level); } const std::vector& operator()() { return m_data; } @@ -50,7 +50,8 @@ struct JHasInputs { friend class JComponentT; void GetCollection(const JEvent& event) { - if (this->level == event.GetLevel() || this->level == JEventLevel::None) { + auto& level = this->collection_levels[0]; + if (level == event.GetLevel() || level == JEventLevel::None) { m_data = event.Get(this->collection_names[0]); } else { @@ -58,11 +59,13 @@ struct JHasInputs { } } void PrefetchCollection(const JEvent& event) { - if (this->level == event.GetLevel() || this->level == JEventLevel::None) { - event.Get(this->collection_names[0]); + auto& level = this->collection_levels[0]; + auto& name = this->collection_names[0]; + if (level == event.GetLevel() || level == JEventLevel::None) { + event.Get(name); } else { - event.GetParent(level).template Get(this->collection_names[0]); + event.GetParent(level).template Get(name); } } }; @@ -78,8 +81,8 @@ struct JHasInputs { PodioInput(JHasInputs* owner, std::string default_collection_name="", JEventLevel level=JEventLevel::None) { owner->RegisterInput(this); this->collection_names.push_back(default_collection_name); + this->collection_levels.push_back(level); this->type_name = JTypeInfo::demangle(); - this->level = level; } const typename PodioTypeMap::collection_t* operator()() { @@ -87,20 +90,24 @@ struct JHasInputs { } void GetCollection(const JEvent& event) { - if (this->level == event.GetLevel() || this->level == JEventLevel::None) { - m_data = event.GetCollection(this->collection_names[0]); + auto& level = this->collection_levels[0]; + auto& name = this->collection_names[0]; + if (level == event.GetLevel() || level == JEventLevel::None) { + m_data = event.GetCollection(name); } else { - m_data = event.GetParent(this->level).GetCollection(this->collection_names[0]); + m_data = event.GetParent(level).template GetCollection(name); } } void PrefetchCollection(const JEvent& event) { - if (this->level == event.GetLevel() || this->level == JEventLevel::None) { - event.GetCollection(this->collection_names[0]); + auto& level = this->collection_levels[0]; + auto& name = this->collection_names[0]; + if (level == event.GetLevel() || level == JEventLevel::None) { + event.GetCollection(name); } else { - event.GetParent(this->level).GetCollection(this->collection_names[0]); + event.GetParent(level).template GetCollection(name); } } }; @@ -118,7 +125,9 @@ struct JHasInputs { this->collection_names = default_names; this->type_name = JTypeInfo::demangle(); this->is_variadic = true; - this->level = level; + for (int i=0; icollection_levels.push_back(level); + } } const std::vector::collection_t*> operator()() { @@ -127,27 +136,33 @@ struct JHasInputs { void GetCollection(const JEvent& event) { m_data.clear(); - if (this->level == event.GetLevel() || this->level == JEventLevel::None) { - for (auto& coll_name : this->collection_names) { + if (collection_names.size() != collection_levels.size()) { + throw JException("Misconfigured VariadicPodioInput: collection_names.size()=%d, collection_levels.size()=%d", collection_names.size(), collection_levels.size()); + } + for (size_t i=0; i(coll_name)); } - } - else { - for (auto& coll_name : this->collection_names) { - m_data.push_back(event.GetParent(this->level).GetCollection(this->collection_names[0])); + else { + m_data.push_back(event.GetParent(level).GetCollection(coll_name)); } } } void PrefetchCollection(const JEvent& event) { - if (this->level == event.GetLevel() || this->level == JEventLevel::None) { - for (auto& coll_name : this->collection_names) { + if (collection_names.size() != collection_levels.size()) { + throw JException("Misconfigured VariadicPodioInput: collection_names.size()=%d, collection_levels.size()=%d", collection_names.size(), collection_levels.size()); + } + for (size_t i=0; i(coll_name); } - } - else { - for (auto& coll_name : this->collection_names) { - event.GetParent(this->level).GetCollection(this->collection_names[0]); + else { + event.GetParent(level).GetCollection(coll_name); } } } diff --git a/src/libraries/JANA/Omni/JOmniFactory.h b/src/libraries/JANA/Omni/JOmniFactory.h index cb70d28f8..1d8d9abc6 100644 --- a/src/libraries/JANA/Omni/JOmniFactory.h +++ b/src/libraries/JANA/Omni/JOmniFactory.h @@ -196,16 +196,19 @@ class JOmniFactory : public JMultifactory, public jana::omni::JHasInputs { } inline void PreInit(std::string tag, - std::vector default_input_collection_names, - std::vector default_output_collection_names ) { + JEventLevel level, + std::vector input_collection_names, + std::vector input_collection_levels, + std::vector output_collection_names ) { // TODO: NWB: JMultiFactory::GetTag,SetTag are not currently usable m_prefix = (this->GetPluginName().empty()) ? tag : this->GetPluginName() + ":" + tag; + m_level = level; // Obtain collection name overrides if provided. // Priority = [JParameterManager, JOmniFactoryGenerator] - m_app->SetDefaultParameter(m_prefix + ":InputTags", default_input_collection_names, "Input collection names"); - m_app->SetDefaultParameter(m_prefix + ":OutputTags", default_output_collection_names, "Output collection names"); + m_app->SetDefaultParameter(m_prefix + ":InputTags", input_collection_names, "Input collection names"); + m_app->SetDefaultParameter(m_prefix + ":OutputTags", output_collection_names, "Output collection names"); // Figure out variadic inputs size_t variadic_input_count = 0; @@ -214,7 +217,7 @@ class JOmniFactory : public JMultifactory, public jana::omni::JHasInputs { variadic_input_count += 1; } } - size_t variadic_input_collection_count = FindVariadicCollectionCount(m_inputs.size(), variadic_input_count, default_input_collection_names.size(), true); + size_t variadic_input_collection_count = FindVariadicCollectionCount(m_inputs.size(), variadic_input_count, input_collection_names.size(), true); // Set input collection names size_t i = 0; @@ -222,11 +225,11 @@ class JOmniFactory : public JMultifactory, public jana::omni::JHasInputs { input->collection_names.clear(); if (input->is_variadic) { for (size_t j = 0; j<(variadic_input_collection_count/variadic_input_count); ++j) { - input->collection_names.push_back(default_input_collection_names[i++]); + input->collection_names.push_back(input_collection_names[i++]); } } else { - input->collection_names.push_back(default_input_collection_names[i++]); + input->collection_names.push_back(input_collection_names[i++]); } } @@ -237,7 +240,7 @@ class JOmniFactory : public JMultifactory, public jana::omni::JHasInputs { variadic_output_count += 1; } } - size_t variadic_output_collection_count = FindVariadicCollectionCount(m_outputs.size(), variadic_output_count, default_output_collection_names.size(), true); + size_t variadic_output_collection_count = FindVariadicCollectionCount(m_outputs.size(), variadic_output_count, output_collection_names.size(), true); // Set output collection names and create corresponding helper factories i = 0; @@ -245,11 +248,11 @@ class JOmniFactory : public JMultifactory, public jana::omni::JHasInputs { output->collection_names.clear(); if (output->is_variadic) { for (size_t j = 0; j<(variadic_output_collection_count/variadic_output_count); ++j) { - output->collection_names.push_back(default_output_collection_names[i++]); + output->collection_names.push_back(output_collection_names[i++]); } } else { - output->collection_names.push_back(default_output_collection_names[i++]); + output->collection_names.push_back(output_collection_names[i++]); } output->CreateHelperFactory(*this); } diff --git a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h index 3595db8a4..1fef176d6 100644 --- a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h +++ b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h @@ -13,34 +13,39 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { public: using FactoryConfigType = typename FactoryT::ConfigType; -private: struct TypedWiring { - std::string m_tag; - std::vector m_default_input_tags; - std::vector m_default_output_tags; - FactoryConfigType m_default_cfg; /// Must be properly copyable! + std::string tag; + JEventLevel level = JEventLevel::Event; + std::vector input_tags; + std::vector input_levels; + std::vector output_tags; + FactoryConfigType configs; /// Must be copyable! }; struct UntypedWiring { - std::string m_tag; - std::vector m_default_input_tags; - std::vector m_default_output_tags; - std::map m_config_params; + std::string tag; + JEventLevel level = JEventLevel::Event; + std::vector input_tags; + std::vector input_levels; + std::vector output_tags; + std::map configs; }; public: + explicit JOmniFactoryGeneratorT(JApplication* app) : m_app(app) { + } explicit JOmniFactoryGeneratorT(std::string tag, std::vector default_input_tags, std::vector default_output_tags, - FactoryConfigType cfg, + FactoryConfigType configs, JApplication* app) { m_app = app; - m_wirings.push_back({.m_tag=tag, - .m_default_input_tags=default_input_tags, - .m_default_output_tags=default_output_tags, - .m_default_cfg=cfg + m_typed_wirings.push_back({.tag=tag, + .input_tags=default_input_tags, + .output_tags=default_output_tags, + .configs=configs }); }; @@ -49,50 +54,52 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { std::vector default_output_tags, JApplication* app) { m_app = app; - m_wirings.push_back({.m_tag=tag, - .m_default_input_tags=default_input_tags, - .m_default_output_tags=default_output_tags, - .m_default_cfg={} - }); + m_typed_wirings.push_back({.tag=tag, + .input_tags=default_input_tags, + .output_tags=default_output_tags, + .configs={} + }); } - explicit JOmniFactoryGeneratorT(JApplication* app) : m_app(app) { - } void AddWiring(std::string tag, std::vector default_input_tags, std::vector default_output_tags, - FactoryConfigType cfg) { + FactoryConfigType configs) { - m_wirings.push_back({.m_tag=tag, + m_typed_wirings.push_back({.m_tag=tag, .m_default_input_tags=default_input_tags, .m_default_output_tags=default_output_tags, - .m_default_cfg=cfg + .configs=configs }); } void AddWiring(std::string tag, - std::vector default_input_tags, - std::vector default_output_tags, - std::map config_params={}) { + std::vector input_tags, + std::vector output_tags, + std::map configs={}) { // Create throwaway factory so we can populate its config using our map. FactoryT factory; - factory.ConfigureAllParameters(config_params); - auto config = factory.config(); + factory.ConfigureAllParameters(configs); + auto configs_typed = factory.config(); - m_wirings.push_back({.m_tag=tag, - .m_default_input_tags=default_input_tags, - .m_default_output_tags=default_output_tags, - .m_default_cfg=config + m_typed_wirings.push_back({.tag=tag, + .input_tags=input_tags, + .output_tags=output_tags, + .configs=configs_typed }); } + void AddWiring(TypedWiring wiring) { + m_typed_wirings.push_back(wiring); + } + void GenerateFactories(JFactorySet *factory_set) override { - for (const auto& wiring : m_wirings) { + for (const auto& wiring : m_typed_wirings) { FactoryT *factory = new FactoryT; @@ -102,12 +109,12 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { // factory->SetTag(wiring.m_tag); // We do NOT want to do this because JMF will use the tag to suffix the collection names // TODO: NWB: Change this in JANA - factory->config() = wiring.m_default_cfg; + factory->config() = wiring.configs; // Set up all of the wiring prereqs so that Init() can do its thing // Specifically, it needs valid input/output tags, a valid logger, and // valid default values in its Config object - factory->PreInit(wiring.m_tag, wiring.m_default_input_tags, wiring.m_default_output_tags); + factory->PreInit(wiring.tag, wiring.level, wiring.input_tags, wiring.input_levels, wiring.output_tags); // Factory is ready factory_set->Add(factory); @@ -115,7 +122,7 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { } private: - std::vector m_wirings; + std::vector m_typed_wirings; JApplication* m_app; }; From c2642c4f108130c4a817a7f339f00c52e678efac Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 18 Apr 2024 19:32:32 -0400 Subject: [PATCH 02/13] JEventSourceGenerator configures event levels --- src/libraries/JANA/JEventSourceGenerator.h | 4 ++++ src/libraries/JANA/JEventSourceGeneratorT.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/libraries/JANA/JEventSourceGenerator.h b/src/libraries/JANA/JEventSourceGenerator.h index f85eb5300..760647443 100644 --- a/src/libraries/JANA/JEventSourceGenerator.h +++ b/src/libraries/JANA/JEventSourceGenerator.h @@ -51,8 +51,12 @@ class JEventSourceGenerator{ /// GetPluginName is called by JANA itself and should not be exposed to the user. std::string GetPluginName() const { return mPluginName; } + JEventLevel GetLevel() { return mLevel; } + void SetLevel(JEventLevel level) { mLevel = level; } + JApplication* mApplication{nullptr}; std::string mPluginName; + JEventLevel mLevel = JEventLevel::None; }; #endif // _JEventSourceGenerator_h_ diff --git a/src/libraries/JANA/JEventSourceGeneratorT.h b/src/libraries/JANA/JEventSourceGeneratorT.h index ebaf3f3da..00b2ed77f 100644 --- a/src/libraries/JANA/JEventSourceGeneratorT.h +++ b/src/libraries/JANA/JEventSourceGeneratorT.h @@ -61,7 +61,13 @@ class JEventSourceGeneratorT:public JEventSourceGenerator{ std::string GetDescription(void) const { return T::GetDescription(); } /// Create an instance of the source type this generates - JEventSource* MakeJEventSource( std::string source ){ return new T( source, mApplication ); } + JEventSource* MakeJEventSource( std::string resource_name ){ + auto source = new T( resource_name, mApplication ); + if (mLevel != JEventLevel::None) { + source->SetLevel(mLevel); + } + return source; + } /// Check how likely a source of the type this generates is to read /// the specified source. This mechanism is to allow a single executable From 33d52ac6c1bd2582d51092eccfc84d4ae71e6085 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 18 Apr 2024 23:03:43 -0400 Subject: [PATCH 03/13] Give TimesliceExample components friendlier names --- .../{MyEventFactory.h => MyClusterFactory.h} | 6 +-- .../{MyTimesliceSource.h => MyFileReader.h} | 16 +++---- .../{MyEventProcessor.h => MyFileWriter.h} | 7 ++- ...sliceFactory.h => MyProtoclusterFactory.h} | 6 +-- ...esliceUnfolder.h => MyTimesliceSplitter.h} | 6 +-- .../TimesliceExample/TimesliceExample.cc | 46 +++++++++++++++---- 6 files changed, 52 insertions(+), 35 deletions(-) rename src/examples/TimesliceExample/{MyEventFactory.h => MyClusterFactory.h} (86%) rename src/examples/TimesliceExample/{MyTimesliceSource.h => MyFileReader.h} (61%) rename src/examples/TimesliceExample/{MyEventProcessor.h => MyFileWriter.h} (94%) rename src/examples/TimesliceExample/{MyTimesliceFactory.h => MyProtoclusterFactory.h} (84%) rename src/examples/TimesliceExample/{MyTimesliceUnfolder.h => MyTimesliceSplitter.h} (91%) diff --git a/src/examples/TimesliceExample/MyEventFactory.h b/src/examples/TimesliceExample/MyClusterFactory.h similarity index 86% rename from src/examples/TimesliceExample/MyEventFactory.h rename to src/examples/TimesliceExample/MyClusterFactory.h index 807877e1a..57f849c0e 100644 --- a/src/examples/TimesliceExample/MyEventFactory.h +++ b/src/examples/TimesliceExample/MyClusterFactory.h @@ -7,16 +7,12 @@ #include -struct MyEventFactory : public JOmniFactory { +struct MyClusterFactory : public JOmniFactory { PodioInput m_protoclusters_in {this, "evt_protoclusters"}; PodioOutput m_clusters_out {this, "clusters"}; - MyEventFactory() { - SetLevel(JEventLevel::Event); - } - void Configure() { } diff --git a/src/examples/TimesliceExample/MyTimesliceSource.h b/src/examples/TimesliceExample/MyFileReader.h similarity index 61% rename from src/examples/TimesliceExample/MyTimesliceSource.h rename to src/examples/TimesliceExample/MyFileReader.h index d77cc70ad..cedf6da18 100644 --- a/src/examples/TimesliceExample/MyTimesliceSource.h +++ b/src/examples/TimesliceExample/MyFileReader.h @@ -8,28 +8,28 @@ #include "CollectionTabulators.h" -struct MyTimesliceSource : public JEventSource { +struct MyFileReader : public JEventSource { PodioOutput m_hits_out {this, "hits"}; - MyTimesliceSource() { + MyFileReader() { + SetTypeName(NAME_OF_THIS); SetLevel(JEventLevel::Timeslice); - SetTypeName("MyTimesliceSource"); } void Open() override { } void GetEvent(std::shared_ptr event) override { - auto ts_nr = event->GetEventNumber(); + auto event_nr = event->GetEventNumber(); auto hits_out = std::make_unique(); // ExampleHit(unsigned long long cellID, double x, double y, double z, double energy, std::uint64_t time); - hits_out->push_back(ExampleHit(ts_nr, 0, 22, 22, 22, 0)); - hits_out->push_back(ExampleHit(ts_nr, 0, 49, 49, 49, 1)); - hits_out->push_back(ExampleHit(ts_nr, 0, 7.6, 7.6, 7.6, 2)); + hits_out->push_back(ExampleHit(event_nr, 0, 22, 22, 22, 0)); + hits_out->push_back(ExampleHit(event_nr, 0, 49, 49, 49, 1)); + hits_out->push_back(ExampleHit(event_nr, 0, 7.6, 7.6, 7.6, 2)); - LOG_DEBUG(GetLogger()) << "MyTimesliceSource: Timeslice " << event->GetEventNumber() << "\n" + LOG_DEBUG(GetLogger()) << "MySource: Emitted " << GetLevel() << " " << event->GetEventNumber() << "\n" << TabulateHits(hits_out.get()) << LOG_END; diff --git a/src/examples/TimesliceExample/MyEventProcessor.h b/src/examples/TimesliceExample/MyFileWriter.h similarity index 94% rename from src/examples/TimesliceExample/MyEventProcessor.h rename to src/examples/TimesliceExample/MyFileWriter.h index ff6341331..f17261adc 100644 --- a/src/examples/TimesliceExample/MyEventProcessor.h +++ b/src/examples/TimesliceExample/MyFileWriter.h @@ -13,7 +13,7 @@ -struct MyEventProcessor : public JEventProcessor { +struct MyFileWriter : public JEventProcessor { PodioInput m_ts_hits_in {this, "hits", JEventLevel::Timeslice}; PodioInput m_ts_protoclusters_in {this, "ts_protoclusters", JEventLevel::Timeslice}; @@ -29,9 +29,8 @@ struct MyEventProcessor : public JEventProcessor { std::mutex m_mutex; - MyEventProcessor() { - SetLevel(JEventLevel::Event); - SetTypeName("MyEventProcessor"); + MyFileWriter() { + SetTypeName(NAME_OF_THIS); } void Init() { diff --git a/src/examples/TimesliceExample/MyTimesliceFactory.h b/src/examples/TimesliceExample/MyProtoclusterFactory.h similarity index 84% rename from src/examples/TimesliceExample/MyTimesliceFactory.h rename to src/examples/TimesliceExample/MyProtoclusterFactory.h index 4cf4ff767..c1039957c 100644 --- a/src/examples/TimesliceExample/MyTimesliceFactory.h +++ b/src/examples/TimesliceExample/MyProtoclusterFactory.h @@ -7,15 +7,11 @@ #include -struct MyTimesliceFactory : public JOmniFactory { +struct MyProtoclusterFactory : public JOmniFactory { PodioInput hits_in {this, "hits"}; PodioOutput clusters_out {this, "protoclusters"}; - MyTimesliceFactory() { - SetLevel(JEventLevel::Timeslice); - } - void Configure() { } diff --git a/src/examples/TimesliceExample/MyTimesliceUnfolder.h b/src/examples/TimesliceExample/MyTimesliceSplitter.h similarity index 91% rename from src/examples/TimesliceExample/MyTimesliceUnfolder.h rename to src/examples/TimesliceExample/MyTimesliceSplitter.h index 0efbf2ab0..e280acbf8 100644 --- a/src/examples/TimesliceExample/MyTimesliceUnfolder.h +++ b/src/examples/TimesliceExample/MyTimesliceSplitter.h @@ -8,14 +8,14 @@ #include #include "CollectionTabulators.h" -struct MyTimesliceUnfolder : public JEventUnfolder { +struct MyTimesliceSplitter : public JEventUnfolder { PodioInput m_timeslice_clusters_in {this, "ts_protoclusters", JEventLevel::Timeslice}; PodioOutput m_event_clusters_out {this, "evt_protoclusters"}; size_t next_time_bucket = 0; - MyTimesliceUnfolder() { + MyTimesliceSplitter() { SetTypeName(NAME_OF_THIS); SetParentLevel(JEventLevel::Timeslice); SetChildLevel(JEventLevel::Event); @@ -34,7 +34,7 @@ struct MyTimesliceUnfolder : public JEventUnfolder { event_clusters_out->setSubsetCollection(true); event_clusters_out->push_back(m_timeslice_clusters_in()->at(child_idx)); - LOG_DEBUG(GetLogger()) << "MyTimesliceUnfolder: Timeslice " << parent.GetEventNumber() + LOG_DEBUG(GetLogger()) << "MyTimesliceSplitter: Timeslice " << parent.GetEventNumber() << ", Event " << child.GetEventNumber() << "\nTimeslice clusters in:\n" << TabulateClusters(m_timeslice_clusters_in()) diff --git a/src/examples/TimesliceExample/TimesliceExample.cc b/src/examples/TimesliceExample/TimesliceExample.cc index 4cd48b732..0d257151a 100644 --- a/src/examples/TimesliceExample/TimesliceExample.cc +++ b/src/examples/TimesliceExample/TimesliceExample.cc @@ -2,11 +2,11 @@ // Subject to the terms in the LICENSE file found in the top-level directory. -#include "MyTimesliceSource.h" -#include "MyTimesliceUnfolder.h" -#include "MyEventProcessor.h" -#include "MyTimesliceFactory.h" -#include "MyEventFactory.h" +#include "MyFileReader.h" +#include "MyFileWriter.h" +#include "MyTimesliceSplitter.h" +#include "MyProtoclusterFactory.h" +#include "MyClusterFactory.h" #include @@ -18,12 +18,38 @@ void InitPlugin(JApplication *app) { InitJANAPlugin(app); - app->Add(new MyTimesliceSource); - app->Add(new MyTimesliceUnfolder); - app->Add(new MyEventProcessor); - app->Add(new JOmniFactoryGeneratorT("protoclusterizer", {"hits"}, {"ts_protoclusters"}, app)); - app->Add(new JOmniFactoryGeneratorT("clusterizer", {"evt_protoclusters"}, {"clusters"}, app)); + // Unfolder that takes timeslices and splits them into physics events. + app->Add(new MyTimesliceSplitter()); + + // Factory that produces timeslice-level protoclusters from timeslice-level hits + app->Add(new JOmniFactoryGeneratorT( + { .tag = "timeslice_protoclusterizer", + .level = JEventLevel::Timeslice, + .input_tags = {"hits"}, + .output_tags = {"timeslice_protoclusters"}}, + app)); + + // Factory that produces event-level protoclusters from event-level hits + app->Add(new JOmniFactoryGeneratorT( + { .tag = "event_protoclusterizer", + .input_tags = {"hits"}, + .output_tags = {"protoclusters"}}, + app)); + + // Factory that produces event-level clusters from event-level protoclusters + app->Add(new JOmniFactoryGeneratorT( + { .tag = "clusterizer", + .input_tags = {"protoclusters"}, + .output_tags = {"clusters"}}, + app)); + + // Event source that can read files containing either timeslices or events + // Either way, these files contain just hits + app->Add(new MyFileReader()); + + // Processor that writes events (and timeslices, if they are present) to file + app->Add(new MyFileWriter()); app->SetParameterValue("jana:extended_report", 0); } From bc2700714ee3ba80176374797524d14c42a3cad7 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 18 Apr 2024 23:02:59 -0400 Subject: [PATCH 04/13] More OmniFactoryGenerator improvements --- src/libraries/JANA/Omni/JOmniFactory.h | 12 ++++++++++++ src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/libraries/JANA/Omni/JOmniFactory.h b/src/libraries/JANA/Omni/JOmniFactory.h index 1d8d9abc6..02b463257 100644 --- a/src/libraries/JANA/Omni/JOmniFactory.h +++ b/src/libraries/JANA/Omni/JOmniFactory.h @@ -226,10 +226,22 @@ class JOmniFactory : public JMultifactory, public jana::omni::JHasInputs { if (input->is_variadic) { for (size_t j = 0; j<(variadic_input_collection_count/variadic_input_count); ++j) { input->collection_names.push_back(input_collection_names[i++]); + if (!input_collection_levels.empty()) { + input->collection_levels.push_back(input_collection_levels[i++]); + } + else { + input->collection_levels.push_back(level); + } } } else { input->collection_names.push_back(input_collection_names[i++]); + if (!input_collection_levels.empty()) { + input->collection_levels.push_back(input_collection_levels[i++]); + } + else { + input->collection_levels.push_back(level); + } } } diff --git a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h index 1fef176d6..38eec641b 100644 --- a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h +++ b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h @@ -62,6 +62,12 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { } + explicit JOmniFactoryGeneratorT(TypedWiring&& wiring, + JApplication* app) { + m_typed_wirings.push_back(std::move(wiring)); + m_app = app; + } + void AddWiring(std::string tag, std::vector default_input_tags, From fbe1ce3ec650545b418131cec8b1757e5e0ca9fb Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Thu, 18 Apr 2024 23:40:09 -0400 Subject: [PATCH 05/13] TimesliceExample wiring works again --- src/examples/TimesliceExample/MyFileWriter.h | 4 ++-- src/examples/TimesliceExample/TimesliceExample.cc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/examples/TimesliceExample/MyFileWriter.h b/src/examples/TimesliceExample/MyFileWriter.h index f17261adc..084e84eb2 100644 --- a/src/examples/TimesliceExample/MyFileWriter.h +++ b/src/examples/TimesliceExample/MyFileWriter.h @@ -17,8 +17,8 @@ struct MyFileWriter : public JEventProcessor { PodioInput m_ts_hits_in {this, "hits", JEventLevel::Timeslice}; PodioInput m_ts_protoclusters_in {this, "ts_protoclusters", JEventLevel::Timeslice}; - PodioInput m_evt_protoclusters_in {this, "evt_protoclusters", JEventLevel::Event}; - PodioInput m_evt_clusters_in {this, "clusters", JEventLevel::Event}; + PodioInput m_evt_protoclusters_in {this, "evt_protoclusters"}; + PodioInput m_evt_clusters_in {this, "clusters"}; Input m_evt_frame_in {this, "", JEventLevel::Event}; Input m_ts_frame_in {this, "", JEventLevel::Timeslice}; diff --git a/src/examples/TimesliceExample/TimesliceExample.cc b/src/examples/TimesliceExample/TimesliceExample.cc index 0d257151a..97f1dddd8 100644 --- a/src/examples/TimesliceExample/TimesliceExample.cc +++ b/src/examples/TimesliceExample/TimesliceExample.cc @@ -27,20 +27,20 @@ void InitPlugin(JApplication *app) { { .tag = "timeslice_protoclusterizer", .level = JEventLevel::Timeslice, .input_tags = {"hits"}, - .output_tags = {"timeslice_protoclusters"}}, + .output_tags = {"ts_protoclusters"}}, app)); // Factory that produces event-level protoclusters from event-level hits app->Add(new JOmniFactoryGeneratorT( { .tag = "event_protoclusterizer", .input_tags = {"hits"}, - .output_tags = {"protoclusters"}}, + .output_tags = {"evt_protoclusters"}}, app)); // Factory that produces event-level clusters from event-level protoclusters app->Add(new JOmniFactoryGeneratorT( { .tag = "clusterizer", - .input_tags = {"protoclusters"}, + .input_tags = {"evt_protoclusters"}, .output_tags = {"clusters"}}, app)); From 4fe13db6a70a543ebe5ff8958766ece9d7a9afc1 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 19 Apr 2024 08:09:48 -0400 Subject: [PATCH 06/13] JOmniFactoryGenerator no longer needs JApplication* arg --- .../TimesliceExample/TimesliceExample.cc | 13 ++++++------- .../JANA/Omni/JOmniFactoryGeneratorT.h | 19 +++++-------------- src/programs/unit_tests/JComponentTests.cc | 3 ++- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/examples/TimesliceExample/TimesliceExample.cc b/src/examples/TimesliceExample/TimesliceExample.cc index 97f1dddd8..9fd14ce3f 100644 --- a/src/examples/TimesliceExample/TimesliceExample.cc +++ b/src/examples/TimesliceExample/TimesliceExample.cc @@ -27,22 +27,22 @@ void InitPlugin(JApplication *app) { { .tag = "timeslice_protoclusterizer", .level = JEventLevel::Timeslice, .input_tags = {"hits"}, - .output_tags = {"ts_protoclusters"}}, - app)); + .output_tags = {"ts_protoclusters"} + })); // Factory that produces event-level protoclusters from event-level hits app->Add(new JOmniFactoryGeneratorT( { .tag = "event_protoclusterizer", .input_tags = {"hits"}, - .output_tags = {"evt_protoclusters"}}, - app)); + .output_tags = {"evt_protoclusters"}} + )); // Factory that produces event-level clusters from event-level protoclusters app->Add(new JOmniFactoryGeneratorT( { .tag = "clusterizer", .input_tags = {"evt_protoclusters"}, - .output_tags = {"clusters"}}, - app)); + .output_tags = {"clusters"}} + )); // Event source that can read files containing either timeslices or events // Either way, these files contain just hits @@ -51,7 +51,6 @@ void InitPlugin(JApplication *app) { // Processor that writes events (and timeslices, if they are present) to file app->Add(new MyFileWriter()); - app->SetParameterValue("jana:extended_report", 0); } } // "C" diff --git a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h index 38eec641b..19cc81853 100644 --- a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h +++ b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h @@ -33,15 +33,12 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { public: - explicit JOmniFactoryGeneratorT(JApplication* app) : m_app(app) { - } + explicit JOmniFactoryGeneratorT() = default; explicit JOmniFactoryGeneratorT(std::string tag, std::vector default_input_tags, std::vector default_output_tags, - FactoryConfigType configs, - JApplication* app) { - m_app = app; + FactoryConfigType configs) { m_typed_wirings.push_back({.tag=tag, .input_tags=default_input_tags, .output_tags=default_output_tags, @@ -51,9 +48,7 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { explicit JOmniFactoryGeneratorT(std::string tag, std::vector default_input_tags, - std::vector default_output_tags, - JApplication* app) { - m_app = app; + std::vector default_output_tags) { m_typed_wirings.push_back({.tag=tag, .input_tags=default_input_tags, .output_tags=default_output_tags, @@ -62,10 +57,8 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { } - explicit JOmniFactoryGeneratorT(TypedWiring&& wiring, - JApplication* app) { + explicit JOmniFactoryGeneratorT(TypedWiring&& wiring) { m_typed_wirings.push_back(std::move(wiring)); - m_app = app; } @@ -109,7 +102,7 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { FactoryT *factory = new FactoryT; - factory->SetApplication(m_app); + factory->SetApplication(GetApplication()); factory->SetPluginName(this->GetPluginName()); factory->SetFactoryName(JTypeInfo::demangle()); // factory->SetTag(wiring.m_tag); @@ -129,6 +122,4 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { private: std::vector m_typed_wirings; - JApplication* m_app; - }; diff --git a/src/programs/unit_tests/JComponentTests.cc b/src/programs/unit_tests/JComponentTests.cc index 5b9a6df42..437888ad2 100644 --- a/src/programs/unit_tests/JComponentTests.cc +++ b/src/programs/unit_tests/JComponentTests.cc @@ -132,9 +132,10 @@ TEST_CASE("JOmniFactoryParametersTests") { SECTION("JOmniFactory using default parameters") { app.Initialize(); - JOmniFactoryGeneratorT facgen (&app); + JOmniFactoryGeneratorT facgen; facgen.AddWiring("ECalTestAlg", {}, {"specific_clusters_out"}); JFactorySet facset; + facgen.SetApplication(&app); facgen.GenerateFactories(&facset); auto sut = RetrieveMultifactory(&facset, "specific_clusters_out"); // RetrieveMultifactory() will call DoInitialize() for us From 4c17e8e6443c5f2bd2939961782cd7b51532ad29 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 19 Apr 2024 09:10:02 -0400 Subject: [PATCH 07/13] TimesliceExample: Add source generator --- src/examples/TimesliceExample/MyFileReader.h | 1 - .../TimesliceExample/MyFileReaderGenerator.h | 36 +++++++++++++++++++ .../TimesliceExample/TimesliceExample.cc | 15 ++++---- src/libraries/JANA/JEvent.h | 4 +-- src/libraries/JANA/JEventSourceGenerator.h | 4 +-- 5 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 src/examples/TimesliceExample/MyFileReaderGenerator.h diff --git a/src/examples/TimesliceExample/MyFileReader.h b/src/examples/TimesliceExample/MyFileReader.h index cedf6da18..ebc087a38 100644 --- a/src/examples/TimesliceExample/MyFileReader.h +++ b/src/examples/TimesliceExample/MyFileReader.h @@ -14,7 +14,6 @@ struct MyFileReader : public JEventSource { MyFileReader() { SetTypeName(NAME_OF_THIS); - SetLevel(JEventLevel::Timeslice); } void Open() override { } diff --git a/src/examples/TimesliceExample/MyFileReaderGenerator.h b/src/examples/TimesliceExample/MyFileReaderGenerator.h new file mode 100644 index 000000000..454ba78ba --- /dev/null +++ b/src/examples/TimesliceExample/MyFileReaderGenerator.h @@ -0,0 +1,36 @@ + +#include +#include "MyFileReader.h" + + +class MyFileReaderGenerator : public JEventSourceGenerator { + + JEventSource* MakeJEventSource(std::string resource_name) override { + + auto source = new MyFileReader; + + // Check if the string "timeslices" appears anywhere in our filename. + // If so, we assume the file contains timeslices, otherwise it contains physics events. + // Another approach might be to peek at the file's contents + if (resource_name.find("timeslices") != std::string::npos) { + source->SetLevel(JEventLevel::Timeslice); + } + else { + source->SetLevel(JEventLevel::Event); + } + return source; + } + + double CheckOpenable(std::string resource_name) override { + // In theory, we should check whether PODIO can open the file and + // whether it contains an 'events' or 'timeslices' tree. If not, return 0. + if (resource_name.find(".root") != std::string::npos) { + return 0.01; + } + else { + return 0; + } + } +}; + + diff --git a/src/examples/TimesliceExample/TimesliceExample.cc b/src/examples/TimesliceExample/TimesliceExample.cc index 9fd14ce3f..45ec694f8 100644 --- a/src/examples/TimesliceExample/TimesliceExample.cc +++ b/src/examples/TimesliceExample/TimesliceExample.cc @@ -2,7 +2,7 @@ // Subject to the terms in the LICENSE file found in the top-level directory. -#include "MyFileReader.h" +#include "MyFileReaderGenerator.h" #include "MyFileWriter.h" #include "MyTimesliceSplitter.h" #include "MyProtoclusterFactory.h" @@ -18,6 +18,13 @@ void InitPlugin(JApplication *app) { InitJANAPlugin(app); + // Event source generator instantiates a FileReader for each filename passed to jana. + // The event source it produces is configured to either produce Timeslices or Events. + // Either way, these files contain just hits + app->Add(new MyFileReaderGenerator()); + + // Event processor that writes events (and timeslices, if they are present) to file + app->Add(new MyFileWriter()); // Unfolder that takes timeslices and splits them into physics events. app->Add(new MyTimesliceSplitter()); @@ -44,12 +51,6 @@ void InitPlugin(JApplication *app) { .output_tags = {"clusters"}} )); - // Event source that can read files containing either timeslices or events - // Either way, these files contain just hits - app->Add(new MyFileReader()); - - // Processor that writes events (and timeslices, if they are present) to file - app->Add(new MyFileWriter()); } } // "C" diff --git a/src/libraries/JANA/JEvent.h b/src/libraries/JANA/JEvent.h index 749c5fd70..2d848c624 100644 --- a/src/libraries/JANA/JEvent.h +++ b/src/libraries/JANA/JEvent.h @@ -137,13 +137,13 @@ class JEvent : public std::enable_shared_from_this for (const auto& pair : mParents) { if (pair.first == level) return *(*(pair.second)); } - throw JException("Unable to find parent at level %s", level); + throw JException("Unable to find parent at level %s", toString(level)); } void SetParent(std::shared_ptr* parent) { JEventLevel level = parent->get()->GetLevel(); for (const auto& pair : mParents) { - if (pair.first == level) throw JException("Event already has a parent at level %s", parent->get()->GetLevel()); + if (pair.first == level) throw JException("Event already has a parent at level %s", toString(parent->get()->GetLevel())); } mParents.push_back({level, parent}); parent->get()->mReferenceCount.fetch_add(1); diff --git a/src/libraries/JANA/JEventSourceGenerator.h b/src/libraries/JANA/JEventSourceGenerator.h index 760647443..386bb0b4b 100644 --- a/src/libraries/JANA/JEventSourceGenerator.h +++ b/src/libraries/JANA/JEventSourceGenerator.h @@ -32,8 +32,8 @@ class JEventSourceGenerator{ virtual ~JEventSourceGenerator(){} // Default versions of these are defined in JEventSourceGeneratorT.h - virtual std::string GetType(void) const = 0; ///< Return name of the source type this will generate - virtual std::string GetDescription(void) const = 0; ///< Return description of the source type this will generate + virtual std::string GetType(void) const { return "Unknown";} ///< Return name of the source type this will generate + virtual std::string GetDescription(void) const { return ""; } ///< Return description of the source type this will generate virtual JEventSource* MakeJEventSource( std::string source ) = 0; ///< Create an instance of the source type this generates virtual double CheckOpenable( std::string source ) = 0; ///< See JEventSourceGeneratorT for description From 2a4011d513b2f112717ffad50d1f8034fe95660d Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 19 Apr 2024 09:44:19 -0400 Subject: [PATCH 08/13] Fix 'missing initializer' warnings --- .../JANA/Omni/JOmniFactoryGeneratorT.h | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h index 19cc81853..644b96559 100644 --- a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h +++ b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h @@ -14,21 +14,21 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { using FactoryConfigType = typename FactoryT::ConfigType; struct TypedWiring { - std::string tag; + std::string tag = ""; JEventLevel level = JEventLevel::Event; - std::vector input_tags; - std::vector input_levels; - std::vector output_tags; - FactoryConfigType configs; /// Must be copyable! + std::vector input_tags = {}; + std::vector input_levels = {}; + std::vector output_tags = {}; + FactoryConfigType configs = {}; /// Must be copyable! }; struct UntypedWiring { - std::string tag; + std::string tag = ""; JEventLevel level = JEventLevel::Event; - std::vector input_tags; - std::vector input_levels; - std::vector output_tags; - std::map configs; + std::vector input_tags = {}; + std::vector input_levels = {}; + std::vector output_tags = {}; + std::map configs = {}; }; public: From 03c37c82f7360c1ef8549ff92b23c4d12119f9bc Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 19 Apr 2024 10:43:50 -0400 Subject: [PATCH 09/13] Improve log output and error messages --- src/libraries/JANA/Engine/JTopologyBuilder.h | 49 ++++++------------- src/libraries/JANA/JEvent.h | 9 ++-- .../JANA/Services/JParameterManager.cc | 2 +- src/libraries/JANA/Services/JPluginLoader.cc | 6 ++- src/libraries/JANA/Utils/JProcessorMapping.cc | 4 +- 5 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/libraries/JANA/Engine/JTopologyBuilder.h b/src/libraries/JANA/Engine/JTopologyBuilder.h index c79e11b93..0091bbace 100644 --- a/src/libraries/JANA/Engine/JTopologyBuilder.h +++ b/src/libraries/JANA/Engine/JTopologyBuilder.h @@ -45,10 +45,10 @@ class JTopologyBuilder : public JService { std::string print_topology() { JTablePrinter t; - t.AddColumn("Arrow name", JTablePrinter::Justify::Left, 0); - t.AddColumn("Arrow type", JTablePrinter::Justify::Left, 0); + t.AddColumn("Arrow", JTablePrinter::Justify::Left, 0); + t.AddColumn("Parallel", JTablePrinter::Justify::Center, 0); t.AddColumn("Direction", JTablePrinter::Justify::Left, 0); - t.AddColumn("Place type", JTablePrinter::Justify::Left, 0); + t.AddColumn("Place", JTablePrinter::Justify::Left, 0); t.AddColumn("ID", JTablePrinter::Justify::Left, 0); // Build index lookup for queues @@ -73,29 +73,11 @@ class JTopologyBuilder : public JService { for (PlaceRefBase* place : arrow->m_places) { if (show_row) { t | arrow->get_name(); - if (dynamic_cast(arrow) != nullptr) { - t | "JEventSourceArrow"; - } - else if (dynamic_cast(arrow) != nullptr) { - t | "JEventProcessorArrow"; - - } - else if (dynamic_cast(arrow) != nullptr) { - t | "JEventMapArrow"; - } - else if (dynamic_cast(arrow) != nullptr) { - t | "JUnfoldArrow"; - } - else if (dynamic_cast(arrow) != nullptr) { - t | "JFoldArrow"; - } - else { - t | "Unknown"; - } + t | arrow->is_parallel(); show_row = false; } else { - t | "" | ""; + t | "" | "" ; } t | ((place->is_input) ? "Input ": "Output"); @@ -134,11 +116,11 @@ class JTopologyBuilder : public JService { m_limit_total_events_in_flight); m_topology->event_pool->init(); attach_top_level(JEventLevel::Run); - LOG_DEBUG(m_builder_logger) << "Arrow topology is:\n" << print_topology() << LOG_END; + LOG_INFO(m_builder_logger) << "Arrow topology is:\n" << print_topology() << LOG_END; if (m_configure_topology) { m_topology = m_configure_topology(m_topology); - LOG_DEBUG(m_builder_logger) << "Found custom topology configurator! Modified arrow topology is: \n" << print_topology() << LOG_END; + LOG_WARN(m_builder_logger) << "Found custom topology configurator! Modified arrow topology is: \n" << print_topology() << LOG_END; } } int id=0; @@ -269,7 +251,7 @@ class JTopologyBuilder : public JService { auto q2 = new EventQueue(m_event_queue_threshold, m_topology->mapping.get_loc_count(), m_enable_stealing); m_topology->queues.push_back(q2); - auto* proc_arrow = new JEventProcessorArrow(ss.str()+"Proc", q1, q2, nullptr); + auto* proc_arrow = new JEventProcessorArrow(ss.str()+"Tap", q1, q2, nullptr); m_topology->arrows.push_back(proc_arrow); proc_arrow->set_chunksize(m_event_processor_chunksize); proc_arrow->set_logger(m_arrow_logger); @@ -294,6 +276,7 @@ class JTopologyBuilder : public JService { std::stringstream ss; ss << current_level; + auto level_str = ss.str(); std::vector sources_at_level; for (JEventSource* source : m_components->get_evt_srces()) { @@ -358,11 +341,11 @@ class JTopologyBuilder : public JService { auto queue = new EventQueue(m_event_queue_threshold, m_topology->mapping.get_loc_count(), m_enable_stealing); m_topology->queues.push_back(queue); - auto* src_arrow = new JEventSourceArrow("sources", sources_at_level, queue, pool_at_level); + auto* src_arrow = new JEventSourceArrow(level_str+"Source", sources_at_level, queue, pool_at_level); m_topology->arrows.push_back(src_arrow); src_arrow->set_chunksize(m_event_source_chunksize); - auto* proc_arrow = new JEventProcessorArrow("processors", queue, nullptr, pool_at_level); + auto* proc_arrow = new JEventProcessorArrow(level_str+"Tap", queue, nullptr, pool_at_level); m_topology->arrows.push_back(proc_arrow); proc_arrow->set_chunksize(m_event_processor_chunksize); @@ -382,24 +365,24 @@ class JTopologyBuilder : public JService { m_topology->queues.push_back(q1); m_topology->queues.push_back(q2); - auto *src_arrow = new JEventSourceArrow(ss.str()+"Src", sources_at_level, q1, pool_at_level); + auto *src_arrow = new JEventSourceArrow(level_str+"Source", sources_at_level, q1, pool_at_level); m_topology->arrows.push_back(src_arrow); src_arrow->set_chunksize(m_event_source_chunksize); - auto *map_arrow = new JEventMapArrow(ss.str()+"Map", q1, q2);; + auto *map_arrow = new JEventMapArrow(level_str+"Map", q1, q2);; m_topology->arrows.push_back(map_arrow); map_arrow->set_chunksize(m_event_source_chunksize); src_arrow->attach(map_arrow); // TODO: We are using q2 temporarily knowing that it will be overwritten in attach_lower_level. // It would be better to rejigger how we validate PlaceRefs and accept empty placerefs/fewer ctor args - auto *unfold_arrow = new JUnfoldArrow(ss.str()+"Unfold", unfolders_at_level[0], q2, pool_at_level, q2); + auto *unfold_arrow = new JUnfoldArrow(level_str+"Unfold", unfolders_at_level[0], q2, pool_at_level, q2); m_topology->arrows.push_back(unfold_arrow); unfold_arrow->set_chunksize(m_event_source_chunksize); map_arrow->attach(unfold_arrow); // child_in, child_out, parent_out - auto *fold_arrow = new JFoldArrow(ss.str()+"Fold", current_level, unfolders_at_level[0]->GetChildLevel(), q2, pool_at_level, pool_at_level); + auto *fold_arrow = new JFoldArrow(level_str+"Fold", current_level, unfolders_at_level[0]->GetChildLevel(), q2, pool_at_level, pool_at_level); // TODO: Support user-provided folders fold_arrow->set_chunksize(m_event_source_chunksize); @@ -414,7 +397,7 @@ class JTopologyBuilder : public JService { auto q3 = new EventQueue(m_event_queue_threshold, m_topology->mapping.get_loc_count(), m_enable_stealing); m_topology->queues.push_back(q3); - auto* proc_arrow = new JEventProcessorArrow(ss.str()+"Proc", q3, nullptr, pool_at_level); + auto* proc_arrow = new JEventProcessorArrow(level_str+"Tap", q3, nullptr, pool_at_level); m_topology->arrows.push_back(proc_arrow); proc_arrow->set_chunksize(m_event_processor_chunksize); diff --git a/src/libraries/JANA/JEvent.h b/src/libraries/JANA/JEvent.h index 2d848c624..e37d64ae9 100644 --- a/src/libraries/JANA/JEvent.h +++ b/src/libraries/JANA/JEvent.h @@ -137,13 +137,15 @@ class JEvent : public std::enable_shared_from_this for (const auto& pair : mParents) { if (pair.first == level) return *(*(pair.second)); } - throw JException("Unable to find parent at level %s", toString(level)); + throw JException("Unable to find parent at level %s", + toString(level).c_str()); } void SetParent(std::shared_ptr* parent) { JEventLevel level = parent->get()->GetLevel(); for (const auto& pair : mParents) { - if (pair.first == level) throw JException("Event already has a parent at level %s", toString(parent->get()->GetLevel())); + if (pair.first == level) throw JException("Event already has a parent at level %s", + toString(parent->get()->GetLevel()).c_str()); } mParents.push_back({level, parent}); parent->get()->mReferenceCount.fetch_add(1); @@ -155,7 +157,8 @@ class JEvent : public std::enable_shared_from_this } auto pair = mParents.back(); if (pair.first != level) { - throw JException("JEvent::ReleaseParent called out of level order: Caller expected %d, but parent was actually %d", level, pair.first); + throw JException("JEvent::ReleaseParent called out of level order: Caller expected %s, but parent was actually %s", + toString(level).c_str(), toString(pair.first).c_str()); } mParents.pop_back(); auto remaining_refs = pair.second->get()->mReferenceCount.fetch_sub(1); diff --git a/src/libraries/JANA/Services/JParameterManager.cc b/src/libraries/JANA/Services/JParameterManager.cc index b4630261f..1b07574b4 100644 --- a/src/libraries/JANA/Services/JParameterManager.cc +++ b/src/libraries/JANA/Services/JParameterManager.cc @@ -125,7 +125,7 @@ void JParameterManager::PrintParameters(bool show_defaulted, bool show_advanced, } table.AddColumn("Value", JTablePrinter::Justify::Left, 20); table.AddColumn("Default", JTablePrinter::Justify::Left, 20); - table.AddColumn("Description", JTablePrinter::Justify::Left, 80); + table.AddColumn("Description", JTablePrinter::Justify::Left, 50); for (JParameter* p: params_to_print) { if (warnings_present) { diff --git a/src/libraries/JANA/Services/JPluginLoader.cc b/src/libraries/JANA/Services/JPluginLoader.cc index eee7c5eee..f654ffae3 100644 --- a/src/libraries/JANA/Services/JPluginLoader.cc +++ b/src/libraries/JANA/Services/JPluginLoader.cc @@ -11,6 +11,7 @@ #include #include #include +#include class JApplication; @@ -125,12 +126,13 @@ void JPluginLoader::attach_plugins(JComponentManager* jcm) { std::string plugin_fullname; if (plugin.substr(plugin.size() - 3) != ".so") { plugin_fullname = plugin + ".so"; - plugin_shortname = plugin; } else { plugin_fullname = plugin; - plugin_shortname = plugin.substr(0, plugin.size()-3); } + + plugin_shortname = std::filesystem::path(plugin_fullname).filename().stem().string(); + if (exclusions.find(plugin_shortname) != exclusions.end() || exclusions.find(plugin_fullname) != exclusions.end()) { diff --git a/src/libraries/JANA/Utils/JProcessorMapping.cc b/src/libraries/JANA/Utils/JProcessorMapping.cc index 553e5913b..831e8d02b 100644 --- a/src/libraries/JANA/Utils/JProcessorMapping.cc +++ b/src/libraries/JANA/Utils/JProcessorMapping.cc @@ -169,9 +169,9 @@ std::ostream& operator<<(std::ostream& os, const JProcessorMapping& m) { if (m.m_locality_strategy != JProcessorMapping::LocalityStrategy::Global) { os << " (" << m.m_loc_count << " locations)"; } - os << std::endl; if (m.m_initialized) { + os << std::endl; JTablePrinter table; table.AddColumn("worker", JTablePrinter::Justify::Right); table.AddColumn("location", JTablePrinter::Justify::Right); @@ -187,7 +187,7 @@ std::ostream& operator<<(std::ostream& os, const JProcessorMapping& m) { table.Render(os); } else if (!m.m_error_msg.empty()) { - os << " Error: " << m.m_error_msg << std::endl; + os << std::endl << " Error: " << m.m_error_msg << std::endl; } return os; } From 8590cd6fb4abca50dccd948c2eeaa024e7b7e50e Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 19 Apr 2024 11:19:47 -0400 Subject: [PATCH 10/13] TimesliceExample filewriter handles no-timeslice case --- src/examples/TimesliceExample/MyFileWriter.h | 63 ++++++++++---------- src/libraries/JANA/JEvent.h | 7 +++ 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/examples/TimesliceExample/MyFileWriter.h b/src/examples/TimesliceExample/MyFileWriter.h index 084e84eb2..4869fba60 100644 --- a/src/examples/TimesliceExample/MyFileWriter.h +++ b/src/examples/TimesliceExample/MyFileWriter.h @@ -15,18 +15,16 @@ struct MyFileWriter : public JEventProcessor { - PodioInput m_ts_hits_in {this, "hits", JEventLevel::Timeslice}; - PodioInput m_ts_protoclusters_in {this, "ts_protoclusters", JEventLevel::Timeslice}; - PodioInput m_evt_protoclusters_in {this, "evt_protoclusters"}; + // Trigger the creation of clusters PodioInput m_evt_clusters_in {this, "clusters"}; + // Retrieve the PODIO frame so we can write it directly Input m_evt_frame_in {this, "", JEventLevel::Event}; - Input m_ts_frame_in {this, "", JEventLevel::Timeslice}; - std::unique_ptr m_writer = nullptr; - std::set m_seen_event_nrs; - int m_expected_timeslice_count; + // TODO: Support optional inputs + // Input m_ts_frame_in {this, "", JEventLevel::Timeslice}; + std::unique_ptr m_writer = nullptr; std::mutex m_mutex; MyFileWriter() { @@ -35,44 +33,43 @@ struct MyFileWriter : public JEventProcessor { void Init() { m_writer = std::make_unique("output.root"); - m_expected_timeslice_count = GetApplication()->GetParameterValue("jana:nevents"); } void Process(const std::shared_ptr& event) { - auto ts_nr = event->GetParent(JEventLevel::Timeslice).GetEventNumber(); - m_seen_event_nrs.insert(event->GetEventNumber()); + if (event->HasParent(JEventLevel::Timeslice)) { + + auto& ts = event->GetParent(JEventLevel::Timeslice); + auto ts_nr = ts.GetEventNumber(); + + if (event->GetEventIndex() == 0) { + // m_writer->writeFrame(*(m_ts_frame_in().at(0)), "timeslices"); + auto ts_frame_in = ts.Get(); + m_writer->writeFrame(*(ts_frame_in.at(0)), "timeslices"); + } + + LOG_DEBUG(GetLogger()) + << "Event " << event->GetEventNumber() << " from Timeslice " << ts_nr + << "\nClusters\n" + << TabulateClusters(m_evt_clusters_in()) + << LOG_END; + } + else { + + LOG_DEBUG(GetLogger()) + << "Event " << event->GetEventNumber() + << "\nClusters\n" + << TabulateClusters(m_evt_clusters_in()) + << LOG_END; + } std::lock_guard guard(m_mutex); m_writer->writeFrame(*(m_evt_frame_in().at(0)), "events"); - if (event->GetEventIndex() == 0) { - m_writer->writeFrame(*(m_ts_frame_in().at(0)), "timeslices"); - } - LOG_DEBUG(GetLogger()) - << "MyEventProcessor: Event " << event->GetEventNumber() << " from Timeslice " << ts_nr - << "\nTimeslice-level hits\n" - << TabulateHits(m_ts_hits_in()) - << "\nTimeslice-level protoclusters\n" - << TabulateClusters(m_ts_protoclusters_in()) - << "\nEvent-level protoclusters\n" - << TabulateClusters(m_evt_protoclusters_in()) - << "\nEvent-level clusters\n" - << TabulateClusters(m_evt_clusters_in()) - << LOG_END; } void Finish() { m_writer->finish(); - for (int tsnr=0; tsnr void SetEventIndex(int event_index) { mEventIndex = event_index; } int64_t GetEventIndex() const { return mEventIndex; } + bool HasParent(JEventLevel level) const { + for (const auto& pair : mParents) { + if (pair.first == level) return true; + } + return false; + } + const JEvent& GetParent(JEventLevel level) const { for (const auto& pair : mParents) { if (pair.first == level) return *(*(pair.second)); From 12c38b937cc558035bec4f7aabf54b42c8efbfbb Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 19 Apr 2024 16:16:42 -0400 Subject: [PATCH 11/13] TimesliceExample: Put event, timeslice numbers in file --- src/examples/PodioExample/DatamodelGlue.h | 15 ++++++++++++--- src/examples/PodioExample/PodioExample.cc | 4 ++-- src/examples/PodioExample/layout.yaml | 8 ++++++++ src/examples/TimesliceExample/MyFileReader.h | 13 +++++++++++++ .../TimesliceExample/MyTimesliceSplitter.h | 8 ++++++-- 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/examples/PodioExample/DatamodelGlue.h b/src/examples/PodioExample/DatamodelGlue.h index e9307f020..741be3c8c 100644 --- a/src/examples/PodioExample/DatamodelGlue.h +++ b/src/examples/PodioExample/DatamodelGlue.h @@ -8,12 +8,10 @@ #include -#include #include -#include #include -#include #include +#include /// Legacy PODIO support template @@ -38,6 +36,12 @@ struct PodioTypeMap { using collection_t = EventInfoCollection; }; +template <> +struct PodioTypeMap { + using mutable_t = MutableTimesliceInfo; + using collection_t = TimesliceInfoCollection; +}; + template struct Overload : Ts ... { @@ -51,6 +55,9 @@ void visitPodioType(const std::string& podio_typename, F& helper, ArgsT... args) if (podio_typename == "EventInfo") { return helper.template operator()(std::forward(args)...); } + if (podio_typename == "TimesliceInfo") { + return helper.template operator()(std::forward(args)...); + } else if (podio_typename == "ExampleHit") { return helper.template operator()(std::forward(args)...); } @@ -81,6 +88,8 @@ struct VisitExampleDatamodel { const auto podio_typename = collection.getTypeName(); if (podio_typename == "EventInfoCollection") { return visitor(static_cast(collection)); + } else if (podio_typename == "TimesliceInfoCollection") { + return visitor(static_cast(collection)); } else if (podio_typename == "ExampleHitCollection") { return visitor(static_cast(collection)); } else if (podio_typename == "ExampleClusterCollection") { diff --git a/src/examples/PodioExample/PodioExample.cc b/src/examples/PodioExample/PodioExample.cc index 05a642776..dc22c1cc1 100644 --- a/src/examples/PodioExample/PodioExample.cc +++ b/src/examples/PodioExample/PodioExample.cc @@ -21,7 +21,7 @@ void create_hits_file() { - EventInfo eventinfo1(7, 22); + EventInfo eventinfo1(7, 0, 22); EventInfoCollection eventinfos1; eventinfos1.push_back(eventinfo1); @@ -38,7 +38,7 @@ void create_hits_file() { podio::ROOTFrameWriter writer("hits.root"); writer.writeFrame(event1, "events"); - EventInfo eventinfo2(8, 22); + EventInfo eventinfo2(8, 0, 22); EventInfoCollection eventinfos2; eventinfos2.push_back(eventinfo2); diff --git a/src/examples/PodioExample/layout.yaml b/src/examples/PodioExample/layout.yaml index 9c0b65a46..6542f6805 100644 --- a/src/examples/PodioExample/layout.yaml +++ b/src/examples/PodioExample/layout.yaml @@ -15,6 +15,14 @@ datatypes : Author : "N. Brei" Members : - int EventNumber // event number + - int TimesliceNumber // timeslice number + - int RunNumber // run number + + TimesliceInfo: + Description : "Timeslice info" + Author : "N. Brei" + Members : + - int TimesliceNumber // timeslice number - int RunNumber // run number ExampleHit : diff --git a/src/examples/TimesliceExample/MyFileReader.h b/src/examples/TimesliceExample/MyFileReader.h index ebc087a38..10e5f989e 100644 --- a/src/examples/TimesliceExample/MyFileReader.h +++ b/src/examples/TimesliceExample/MyFileReader.h @@ -21,6 +21,7 @@ struct MyFileReader : public JEventSource { void GetEvent(std::shared_ptr event) override { auto event_nr = event->GetEventNumber(); + auto hits_out = std::make_unique(); // ExampleHit(unsigned long long cellID, double x, double y, double z, double energy, std::uint64_t time); @@ -33,5 +34,17 @@ struct MyFileReader : public JEventSource { << LOG_END; m_hits_out() = std::move(hits_out); + + // Furnish this event with info object + if (GetLevel() == JEventLevel::Timeslice) { + TimesliceInfoCollection info; + info.push_back(TimesliceInfo(event_nr, 0)); // event nr, run nr + event->InsertCollection(std::move(info), "ts_info"); + } + else { + EventInfoCollection info; + info.push_back(EventInfo(event_nr, 0, 0)); // event nr, timeslice nr, run nr + event->InsertCollection(std::move(info), "evt_info"); + } } }; diff --git a/src/examples/TimesliceExample/MyTimesliceSplitter.h b/src/examples/TimesliceExample/MyTimesliceSplitter.h index e280acbf8..4a867c8b2 100644 --- a/src/examples/TimesliceExample/MyTimesliceSplitter.h +++ b/src/examples/TimesliceExample/MyTimesliceSplitter.h @@ -11,9 +11,9 @@ struct MyTimesliceSplitter : public JEventUnfolder { PodioInput m_timeslice_clusters_in {this, "ts_protoclusters", JEventLevel::Timeslice}; - PodioOutput m_event_clusters_out {this, "evt_protoclusters"}; - size_t next_time_bucket = 0; + PodioOutput m_event_clusters_out {this, "evt_protoclusters"}; + PodioOutput m_event_info_out {this, "evt_info"}; MyTimesliceSplitter() { SetTypeName(NAME_OF_THIS); @@ -34,6 +34,9 @@ struct MyTimesliceSplitter : public JEventUnfolder { event_clusters_out->setSubsetCollection(true); event_clusters_out->push_back(m_timeslice_clusters_in()->at(child_idx)); + auto event_info_out = std::make_unique(); + event_info_out->push_back(EventInfo(event_nr, timeslice_nr, 0)); + LOG_DEBUG(GetLogger()) << "MyTimesliceSplitter: Timeslice " << parent.GetEventNumber() << ", Event " << child.GetEventNumber() << "\nTimeslice clusters in:\n" @@ -43,6 +46,7 @@ struct MyTimesliceSplitter : public JEventUnfolder { << LOG_END; m_event_clusters_out() = std::move(event_clusters_out); + m_event_info_out() = std::move(event_info_out); return (child_idx == 2) ? Result::NextChildNextParent : Result::NextChildKeepParent; } From 8687fb01d92c10a7f7b9eb7d791964881a13b464 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 19 Apr 2024 12:21:42 -0400 Subject: [PATCH 12/13] Bugfix: podio::writeFrame() protected by mutex --- src/examples/TimesliceExample/MyFileWriter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/examples/TimesliceExample/MyFileWriter.h b/src/examples/TimesliceExample/MyFileWriter.h index 4869fba60..8a3232e47 100644 --- a/src/examples/TimesliceExample/MyFileWriter.h +++ b/src/examples/TimesliceExample/MyFileWriter.h @@ -37,6 +37,7 @@ struct MyFileWriter : public JEventProcessor { void Process(const std::shared_ptr& event) { + std::lock_guard guard(m_mutex); if (event->HasParent(JEventLevel::Timeslice)) { auto& ts = event->GetParent(JEventLevel::Timeslice); @@ -63,7 +64,6 @@ struct MyFileWriter : public JEventProcessor { << LOG_END; } - std::lock_guard guard(m_mutex); m_writer->writeFrame(*(m_evt_frame_in().at(0)), "events"); } From 51417cfefed39e4e10c256b203b985013240f970 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Fri, 19 Apr 2024 12:47:17 -0400 Subject: [PATCH 13/13] Rename JEventLevel::Event => PhysicsEvent --- src/examples/TimesliceExample/MyFileReaderGenerator.h | 2 +- src/examples/TimesliceExample/MyFileWriter.h | 2 +- src/examples/TimesliceExample/MyTimesliceSplitter.h | 2 +- src/libraries/JANA/JFactory.h | 2 +- src/libraries/JANA/JFactorySet.h | 2 +- src/libraries/JANA/Omni/JComponentFwd.h | 2 +- src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h | 4 ++-- src/libraries/JANA/Utils/JEventLevel.h | 8 ++++---- src/libraries/JANA/Utils/JEventPool.h | 2 +- src/programs/unit_tests/MultiLevelTopologyTests.h | 4 ++-- src/programs/unit_tests/UnfoldTests.cc | 10 +++++----- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/examples/TimesliceExample/MyFileReaderGenerator.h b/src/examples/TimesliceExample/MyFileReaderGenerator.h index 454ba78ba..85c3bd7a8 100644 --- a/src/examples/TimesliceExample/MyFileReaderGenerator.h +++ b/src/examples/TimesliceExample/MyFileReaderGenerator.h @@ -16,7 +16,7 @@ class MyFileReaderGenerator : public JEventSourceGenerator { source->SetLevel(JEventLevel::Timeslice); } else { - source->SetLevel(JEventLevel::Event); + source->SetLevel(JEventLevel::PhysicsEvent); } return source; } diff --git a/src/examples/TimesliceExample/MyFileWriter.h b/src/examples/TimesliceExample/MyFileWriter.h index 8a3232e47..c2cca798d 100644 --- a/src/examples/TimesliceExample/MyFileWriter.h +++ b/src/examples/TimesliceExample/MyFileWriter.h @@ -19,7 +19,7 @@ struct MyFileWriter : public JEventProcessor { PodioInput m_evt_clusters_in {this, "clusters"}; // Retrieve the PODIO frame so we can write it directly - Input m_evt_frame_in {this, "", JEventLevel::Event}; + Input m_evt_frame_in {this, "", JEventLevel::PhysicsEvent}; // TODO: Support optional inputs // Input m_ts_frame_in {this, "", JEventLevel::Timeslice}; diff --git a/src/examples/TimesliceExample/MyTimesliceSplitter.h b/src/examples/TimesliceExample/MyTimesliceSplitter.h index 4a867c8b2..34094d6d2 100644 --- a/src/examples/TimesliceExample/MyTimesliceSplitter.h +++ b/src/examples/TimesliceExample/MyTimesliceSplitter.h @@ -18,7 +18,7 @@ struct MyTimesliceSplitter : public JEventUnfolder { MyTimesliceSplitter() { SetTypeName(NAME_OF_THIS); SetParentLevel(JEventLevel::Timeslice); - SetChildLevel(JEventLevel::Event); + SetChildLevel(JEventLevel::PhysicsEvent); } diff --git a/src/libraries/JANA/JFactory.h b/src/libraries/JANA/JFactory.h index af360e4d7..e2cc0a69d 100644 --- a/src/libraries/JANA/JFactory.h +++ b/src/libraries/JANA/JFactory.h @@ -203,7 +203,7 @@ class JFactory { CreationStatus mCreationStatus = CreationStatus::NotCreatedYet; // Common to components - JEventLevel mLevel = JEventLevel::Event; + JEventLevel mLevel = JEventLevel::PhysicsEvent; std::string mPluginName; std::string mFactoryName; mutable std::mutex mMutex; diff --git a/src/libraries/JANA/JFactorySet.h b/src/libraries/JANA/JFactorySet.h index 8b7e290b5..0beb88462 100644 --- a/src/libraries/JANA/JFactorySet.h +++ b/src/libraries/JANA/JFactorySet.h @@ -48,7 +48,7 @@ class JFactorySet : public JResettable std::map, JFactory*> mFactoriesFromString; // {(objname, tag) : factory} std::vector mMultifactories; bool mIsFactoryOwner = true; - JEventLevel mLevel = JEventLevel::Event; + JEventLevel mLevel = JEventLevel::PhysicsEvent; }; diff --git a/src/libraries/JANA/Omni/JComponentFwd.h b/src/libraries/JANA/Omni/JComponentFwd.h index a0b1c3f74..53c8c95de 100644 --- a/src/libraries/JANA/Omni/JComponentFwd.h +++ b/src/libraries/JANA/Omni/JComponentFwd.h @@ -30,7 +30,7 @@ struct JComponent { std::vector m_parameters; std::vector m_services; - JEventLevel m_level = JEventLevel::Event; + JEventLevel m_level = JEventLevel::PhysicsEvent; CallbackStyle m_callback_style = CallbackStyle::Compatibility; std::string m_prefix; std::string m_plugin_name; diff --git a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h index 644b96559..a1051e610 100644 --- a/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h +++ b/src/libraries/JANA/Omni/JOmniFactoryGeneratorT.h @@ -15,7 +15,7 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { struct TypedWiring { std::string tag = ""; - JEventLevel level = JEventLevel::Event; + JEventLevel level = JEventLevel::PhysicsEvent; std::vector input_tags = {}; std::vector input_levels = {}; std::vector output_tags = {}; @@ -24,7 +24,7 @@ class JOmniFactoryGeneratorT : public JFactoryGenerator { struct UntypedWiring { std::string tag = ""; - JEventLevel level = JEventLevel::Event; + JEventLevel level = JEventLevel::PhysicsEvent; std::vector input_tags = {}; std::vector input_levels = {}; std::vector output_tags = {}; diff --git a/src/libraries/JANA/Utils/JEventLevel.h b/src/libraries/JANA/Utils/JEventLevel.h index 27f1b899b..22a10b6c8 100644 --- a/src/libraries/JANA/Utils/JEventLevel.h +++ b/src/libraries/JANA/Utils/JEventLevel.h @@ -5,7 +5,7 @@ #include #include -enum class JEventLevel { Run, Subrun, Timeslice, Block, Event, Subevent, Task, None }; +enum class JEventLevel { Run, Subrun, Timeslice, Block, PhysicsEvent, Subevent, Task, None }; inline std::ostream& operator<<(std::ostream& os, JEventLevel level) { switch (level) { @@ -13,7 +13,7 @@ inline std::ostream& operator<<(std::ostream& os, JEventLevel level) { case JEventLevel::Subrun: os << "Subrun"; break; case JEventLevel::Timeslice: os << "Timeslice"; break; case JEventLevel::Block: os << "Block"; break; - case JEventLevel::Event: os << "Event"; break; + case JEventLevel::PhysicsEvent: os << "PhysicsEvent"; break; case JEventLevel::Subevent: os << "Subevent"; break; case JEventLevel::Task: os << "Task"; break; default: os << "None"; break; @@ -33,8 +33,8 @@ inline JEventLevel next_level(JEventLevel current_level) { case JEventLevel::Run: return JEventLevel::Subrun; case JEventLevel::Subrun: return JEventLevel::Timeslice; case JEventLevel::Timeslice: return JEventLevel::Block; - case JEventLevel::Block: return JEventLevel::Event; - case JEventLevel::Event: return JEventLevel::Subevent; + case JEventLevel::Block: return JEventLevel::PhysicsEvent; + case JEventLevel::PhysicsEvent: return JEventLevel::Subevent; case JEventLevel::Subevent: return JEventLevel::Task; case JEventLevel::Task: return JEventLevel::None; default: return JEventLevel::None; diff --git a/src/libraries/JANA/Utils/JEventPool.h b/src/libraries/JANA/Utils/JEventPool.h index 15873619a..cd9343627 100644 --- a/src/libraries/JANA/Utils/JEventPool.h +++ b/src/libraries/JANA/Utils/JEventPool.h @@ -21,7 +21,7 @@ class JEventPool : public JPool> { size_t pool_size, size_t location_count, bool limit_total_events_in_flight, - JEventLevel level = JEventLevel::Event) + JEventLevel level = JEventLevel::PhysicsEvent) : JPool(pool_size, location_count, limit_total_events_in_flight) , m_component_manager(component_manager) , m_level(level) { diff --git a/src/programs/unit_tests/MultiLevelTopologyTests.h b/src/programs/unit_tests/MultiLevelTopologyTests.h index b36e8b73f..46e86b917 100644 --- a/src/programs/unit_tests/MultiLevelTopologyTests.h +++ b/src/programs/unit_tests/MultiLevelTopologyTests.h @@ -45,7 +45,7 @@ struct MyTimesliceUnfolder : public JEventUnfolder { MyTimesliceUnfolder() { SetParentLevel(JEventLevel::Timeslice); - SetChildLevel(JEventLevel::Event); + SetChildLevel(JEventLevel::PhysicsEvent); } virtual void Init() { @@ -137,7 +137,7 @@ struct MyClusterFactory : public JFactoryT { int process_call_count = 0; MyClusterFactory() { - SetLevel(JEventLevel::Event); + SetLevel(JEventLevel::PhysicsEvent); } void Init() override { diff --git a/src/programs/unit_tests/UnfoldTests.cc b/src/programs/unit_tests/UnfoldTests.cc index fe31c174b..2efa6699e 100644 --- a/src/programs/unit_tests/UnfoldTests.cc +++ b/src/programs/unit_tests/UnfoldTests.cc @@ -19,7 +19,7 @@ struct TestUnfolder : public JEventUnfolder { TestUnfolder() { SetParentLevel(JEventLevel::Timeslice); - SetChildLevel(JEventLevel::Event); + SetChildLevel(JEventLevel::PhysicsEvent); } void Preprocess(const JEvent& parent) const override { @@ -47,7 +47,7 @@ TEST_CASE("UnfoldTests_Basic") { auto jcm = app.GetService(); JEventPool parent_pool {jcm, 5, 1, true, JEventLevel::Timeslice}; // size=5, locations=1, limit_total_events_in_flight=true - JEventPool child_pool {jcm, 5, 1, true, JEventLevel::Event}; + JEventPool child_pool {jcm, 5, 1, true, JEventLevel::PhysicsEvent}; JMailbox parent_queue {3}; // size JMailbox child_queue {3}; @@ -77,7 +77,7 @@ TEST_CASE("UnfoldTests_Basic") { REQUIRE(unfolder.unfolded_parent_levels[0] == JEventLevel::Timeslice); REQUIRE(unfolder.unfolded_child_nrs.size() == 1); REQUIRE(unfolder.unfolded_child_nrs[0] == 117); - REQUIRE(unfolder.unfolded_child_levels[0] == JEventLevel::Event); + REQUIRE(unfolder.unfolded_child_levels[0] == JEventLevel::PhysicsEvent); } @@ -90,7 +90,7 @@ TEST_CASE("FoldArrowTests") { // We only use these to obtain preconfigured JEvents JEventPool parent_pool {jcm, 5, 1, true, JEventLevel::Timeslice}; // size=5, locations=1, limit_total_events_in_flight=true - JEventPool child_pool {jcm, 5, 1, true, JEventLevel::Event}; + JEventPool child_pool {jcm, 5, 1, true, JEventLevel::PhysicsEvent}; parent_pool.init(); child_pool.init(); @@ -100,7 +100,7 @@ TEST_CASE("FoldArrowTests") { JMailbox*> child_out; JMailbox*> parent_out; - JFoldArrow arrow("sut", JEventLevel::Timeslice, JEventLevel::Event, &child_in, &child_out, &parent_out); + JFoldArrow arrow("sut", JEventLevel::Timeslice, JEventLevel::PhysicsEvent, &child_in, &child_out, &parent_out); JArrowMetrics metrics; arrow.initialize();