diff --git a/.gitignore b/.gitignore index e7ce99f16..b755f3128 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,5 @@ src/examples/PodioExample/src/* src/examples/PodioExample/podio_generated_files.cmake podio_build/ + +everything_build/ diff --git a/src/libraries/JANA/CLI/JSignalHandler.cc b/src/libraries/JANA/CLI/JSignalHandler.cc index 3f8c5cce7..61a5032fc 100644 --- a/src/libraries/JANA/CLI/JSignalHandler.cc +++ b/src/libraries/JANA/CLI/JSignalHandler.cc @@ -62,7 +62,7 @@ std::string produce_overall_report() { // Include detailed report from JApplication auto t = time(nullptr); ss << "JANA status report: " << ctime(&t) << std::endl; - ss << g_app->GetComponentSummary() << std::endl; + ss << g_app->GetComponentSummaryTable() << std::endl; // Include backtraces from each individual thread if( typeid(std::thread::native_handle_type) == typeid(pthread_t) ){ diff --git a/src/libraries/JANA/CMakeLists.txt b/src/libraries/JANA/CMakeLists.txt index 45fb77e13..751fa57b7 100644 --- a/src/libraries/JANA/CMakeLists.txt +++ b/src/libraries/JANA/CMakeLists.txt @@ -64,8 +64,7 @@ set(JANA2_SOURCES Services/JServiceLocator.h Services/JEventGroupTracker.h - Status/JComponentSummary.h - Status/JComponentSummary.cc + Omni/JComponentSummary.cc Streaming/JDiscreteJoin.h Streaming/JEventBuilder.h diff --git a/src/libraries/JANA/JApplication.cc b/src/libraries/JANA/JApplication.cc index 9dd5d4e53..4d593e7fe 100644 --- a/src/libraries/JANA/JApplication.cc +++ b/src/libraries/JANA/JApplication.cc @@ -185,7 +185,7 @@ void JApplication::Run(bool wait_until_finished) { // Print summary of all config parameters (if any aren't default) m_params->PrintParameters(false); - LOG_INFO(m_logger) << GetComponentSummary() << LOG_END; + LOG_INFO(m_logger) << GetComponentSummaryTable() << LOG_END; LOG_INFO(m_logger) << "Starting processing with " << m_desired_nthreads << " threads requested..." << LOG_END; m_processing_controller->run(m_desired_nthreads); @@ -324,9 +324,9 @@ int JApplication::GetExitCode() { return m_exit_code; } -JComponentSummary JApplication::GetComponentSummary() { +JComponentSummaryTable JApplication::GetComponentSummaryTable() { /// Returns a data object describing all components currently running - return m_component_manager->get_component_summary(); + return m_component_manager->get_component_summary_table(); } // Performance/status monitoring diff --git a/src/libraries/JANA/JApplicationFwd.h b/src/libraries/JANA/JApplicationFwd.h index 678d7fc3d..762eb9559 100644 --- a/src/libraries/JANA/JApplicationFwd.h +++ b/src/libraries/JANA/JApplicationFwd.h @@ -25,7 +25,7 @@ class JParameterManager; class JApplication; extern JApplication* japp; -#include +#include #include #include @@ -98,7 +98,7 @@ class JApplication { float GetIntegratedRate(); float GetInstantaneousRate(); - JComponentSummary GetComponentSummary(); + JComponentSummaryTable GetComponentSummaryTable(); // Parameter config diff --git a/src/libraries/JANA/JFactorySet.cc b/src/libraries/JANA/JFactorySet.cc index bea444441..2818a4c76 100644 --- a/src/libraries/JANA/JFactorySet.cc +++ b/src/libraries/JANA/JFactorySet.cc @@ -223,22 +223,22 @@ void JFactorySet::Release() { /// Summarize() fills in component summaries for each JFactory in the set. /// that this JFactorySet contains. The data is extracted from the JFactory itself. -void JFactorySet::Summarize(JComponentSummary& summary) const { +void JFactorySet::Summarize(JComponentSummaryTable& summaries) const { for (auto& pair : mFactories) { - JComponentSummary::Component c; + JComponentSummary c; c.level = pair.second->GetLevel(); c.component_type = JComponentSummary::ComponentType::JFactory; - c.class_name = pair.second->GetFactoryName(); + c.type_name = pair.second->GetFactoryName(); c.instance_name = pair.second->GetTag().empty() ? pair.second->GetObjectName() : pair.second->GetObjectName() + ":" + pair.second->GetTag(); c.plugin_name = pair.second->GetPluginName(); - JComponentSummary::Collection output; + JCollectionSummary output; output.collection_name = pair.second->GetTag(); - output.class_name = pair.second->GetObjectName(); + output.type_name = pair.second->GetObjectName(); c.outputs.push_back(output); - summary.components.push_back(c); + summaries.components.push_back(c); } } diff --git a/src/libraries/JANA/JFactorySet.h b/src/libraries/JANA/JFactorySet.h index f356470ca..d30bf6205 100644 --- a/src/libraries/JANA/JFactorySet.h +++ b/src/libraries/JANA/JFactorySet.h @@ -37,7 +37,7 @@ class JFactorySet : public JResettable std::vector GetAllFactories() const; template std::vector*> GetAllFactories() const; - void Summarize(JComponentSummary&) const; + void Summarize(JComponentSummaryTable&) const; JEventLevel GetLevel() const { return mLevel; } void SetLevel(JEventLevel level) { mLevel = level; } diff --git a/src/libraries/JANA/Status/JComponentSummary.cc b/src/libraries/JANA/Omni/JComponentSummary.cc similarity index 79% rename from src/libraries/JANA/Status/JComponentSummary.cc rename to src/libraries/JANA/Omni/JComponentSummary.cc index 72b31adb1..501fc666d 100644 --- a/src/libraries/JANA/Status/JComponentSummary.cc +++ b/src/libraries/JANA/Omni/JComponentSummary.cc @@ -8,7 +8,7 @@ #include "JComponentSummary.h" -std::ostream& operator<<(std::ostream& os, JComponentSummary const& cs) { +std::ostream& operator<<(std::ostream& os, JComponentSummaryTable const& cs) { os << "Component Summary" << std::endl << std::endl; @@ -27,8 +27,8 @@ std::ostream& operator<<(std::ostream& os, JComponentSummary const& cs) { factoryTable.AddColumn("Class"); factoryTable.AddColumn("Instance"); factoryTable.AddColumn("Direction"); - factoryTable.AddColumn("Collection name"); factoryTable.AddColumn("Collection type"); + factoryTable.AddColumn("Collection name"); for (const auto& component : cs.components) { @@ -44,17 +44,17 @@ std::ostream& operator<<(std::ostream& os, JComponentSummary const& cs) { } if (component.component_type == JComponentSummary::ComponentType::JFactory) { - factoryTable | component.plugin_name | component.level | base | component.class_name | component.instance_name; - for (const JComponentSummary::Collection& in: component.inputs) { - factoryTable | "Input" | in.collection_name | in.class_name; + factoryTable | component.plugin_name | component.level | base | component.type_name | component.instance_name; + for (const JCollectionSummary& in: component.inputs) { + factoryTable | "Input" | in.type_name | in.collection_name; } - for (const JComponentSummary::Collection& out: component.outputs) { - factoryTable | "Output" | out.collection_name | out.class_name; + for (const JCollectionSummary& out: component.outputs) { + factoryTable | "Output" | out.type_name | out.collection_name; } } else { - table | component.plugin_name | component.level | base | component.class_name | component.instance_name; + table | component.plugin_name | component.level | base | component.type_name | component.instance_name; } } diff --git a/src/libraries/JANA/Omni/JComponentSummary.h b/src/libraries/JANA/Omni/JComponentSummary.h new file mode 100644 index 000000000..4acd47329 --- /dev/null +++ b/src/libraries/JANA/Omni/JComponentSummary.h @@ -0,0 +1,41 @@ + +// Copyright 2020, Jefferson Science Associates, LLC. +// Subject to the terms in the LICENSE file found in the top-level directory. + + +#ifndef JANA2_JCOMPONENTSUMMARY_H +#define JANA2_JCOMPONENTSUMMARY_H + +#include +#include +#include + + +struct JCollectionSummary { + std::string collection_name; + std::string collection_tag; + std::string type_name; + std::string base_name; +}; + +struct JComponentSummary { + enum class ComponentType {JEventSource, JFactory, JEventProcessor, JEventUnfolder, JEventFolder, JService}; + + ComponentType component_type; + JEventLevel level; + std::string type_name; + std::string instance_name; + std::string plugin_name; + std::vector inputs; + std::vector outputs; +}; + +struct JComponentSummaryTable { + std::vector components; +}; + +std::ostream& operator<<(std::ostream& os, JComponentSummaryTable const& cs); + + + +#endif //JANA2_JCOMPONENTSUMMARY_H diff --git a/src/libraries/JANA/Services/JComponentManager.cc b/src/libraries/JANA/Services/JComponentManager.cc index 19f542380..9f8283587 100644 --- a/src/libraries/JANA/Services/JComponentManager.cc +++ b/src/libraries/JANA/Services/JComponentManager.cc @@ -210,15 +210,15 @@ std::vector& JComponentManager::get_unfolders() { return m_unfolders; } -JComponentSummary JComponentManager::get_component_summary() { - JComponentSummary result; +JComponentSummaryTable JComponentManager::get_component_summary_table() { + JComponentSummaryTable result; // Event sources for (auto * src : m_evt_srces) { - JComponentSummary::Component c; + JComponentSummary c; c.component_type = JComponentSummary::ComponentType::JEventSource; c.level = src->GetLevel(); - c.class_name = src->GetTypeName(); + c.type_name = src->GetTypeName(); c.instance_name = src->GetName(); // Instance name will eventually be "Source", "PhysicsEventSource", "Source:2", depending on circumstances c.plugin_name = src->GetPluginName(); @@ -227,20 +227,20 @@ JComponentSummary JComponentManager::get_component_summary() { // Event processors for (auto * evt_proc : m_evt_procs) { - JComponentSummary::Component c; + JComponentSummary c; c.component_type = JComponentSummary::ComponentType::JEventProcessor; c.level = evt_proc->GetLevel(); - c.class_name = evt_proc->GetTypeName(); + c.type_name = evt_proc->GetTypeName(); c.instance_name = evt_proc->GetPrefix(); result.components.push_back(c); } // Event unfolders for (auto * unfolder : m_unfolders) { - JComponentSummary::Component c; + JComponentSummary c; c.component_type = JComponentSummary::ComponentType::JEventUnfolder; c.level = unfolder->GetLevel(); - c.class_name = unfolder->GetTypeName(); + c.type_name = unfolder->GetTypeName(); c.instance_name = unfolder->GetPrefix(); result.components.push_back(c); } diff --git a/src/libraries/JANA/Services/JComponentManager.h b/src/libraries/JANA/Services/JComponentManager.h index ac00f2e48..02adcd49e 100644 --- a/src/libraries/JANA/Services/JComponentManager.h +++ b/src/libraries/JANA/Services/JComponentManager.h @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -36,7 +36,7 @@ class JComponentManager : public JService { JEventSourceGenerator* resolve_user_event_source_generator() const; JEventSourceGenerator* resolve_event_source(std::string source_name) const; - JComponentSummary get_component_summary(); + JComponentSummaryTable get_component_summary_table(); // Unsafe access into our own repository of components std::vector& get_evt_src_gens(); diff --git a/src/libraries/JANA/Status/JComponentSummary.h b/src/libraries/JANA/Status/JComponentSummary.h deleted file mode 100644 index f71b0464f..000000000 --- a/src/libraries/JANA/Status/JComponentSummary.h +++ /dev/null @@ -1,42 +0,0 @@ - -// Copyright 2020, Jefferson Science Associates, LLC. -// Subject to the terms in the LICENSE file found in the top-level directory. - - -#ifndef JANA2_JCOMPONENTSUMMARY_H -#define JANA2_JCOMPONENTSUMMARY_H - -#include -#include -#include - - -struct JComponentSummary { - - enum class ComponentType {JEventSource, JFactory, JEventProcessor, JEventUnfolder, JEventFolder, JService}; - - struct Collection { - std::string collection_base; - std::string collection_name; - std::string collection_tag; - std::string class_name; - }; - - struct Component { - ComponentType component_type; - JEventLevel level; - std::string class_name; - std::string instance_name; - std::string plugin_name; - std::vector inputs; - std::vector outputs; - }; - - std::vector components; -}; - -std::ostream& operator<<(std::ostream& os, JComponentSummary const& cs); - - - -#endif //JANA2_JCOMPONENTSUMMARY_H diff --git a/src/plugins/janacontrol/src/JControlEventProcessor.cc b/src/plugins/janacontrol/src/JControlEventProcessor.cc index 067c99386..03a9575f9 100644 --- a/src/plugins/janacontrol/src/JControlEventProcessor.cc +++ b/src/plugins/janacontrol/src/JControlEventProcessor.cc @@ -82,7 +82,7 @@ void JControlEventProcessor::NextEvent(void){ // Get count of objects already created for the current event // for each type of factory. //------------------------------------------------------------- -void JControlEventProcessor::GetObjectStatus( std::map &factory_object_counts ){ +void JControlEventProcessor::GetObjectStatus( std::map &factory_object_counts ){ // bombproof against getting called with no active JEvent if(_jevent.get() == nullptr ) return; @@ -93,8 +93,8 @@ void JControlEventProcessor::GetObjectStatus( std::mapGetAllFactories(); for( auto fac : factories ){ - JComponentSummary::Collection fac_info; - fac_info.class_name = fac->GetObjectName(); + JCollectionSummary fac_info; + fac_info.type_name = fac->GetObjectName(); fac_info.collection_name = fac->GetTag(); fac_info.collection_tag = fac->GetTag(); if( fac ) factory_object_counts[fac_info] = fac->GetNumObjects(); diff --git a/src/plugins/janacontrol/src/JControlEventProcessor.h b/src/plugins/janacontrol/src/JControlEventProcessor.h index 7b9eb0004..39c4da9bc 100644 --- a/src/plugins/janacontrol/src/JControlEventProcessor.h +++ b/src/plugins/janacontrol/src/JControlEventProcessor.h @@ -47,7 +47,7 @@ class JControlEventProcessor : public JEventProcessor { auto GetLastFetchResult(void){return _fetch_object_summaries;} auto GetLastFetchMetadata(void){return _fetch_metadata;} void NextEvent(void); - void GetObjectStatus( std::map &factory_object_counts ); + void GetObjectStatus( std::map &factory_object_counts ); void GetObjects(const std::string &factory_name, const std::string &factory_tag, const std::string &object_name, std::map &objects); uint32_t GetRunNumber(void); uint64_t GetEventNumber(void); @@ -63,12 +63,12 @@ class JControlEventProcessor : public JEventProcessor { std::shared_ptr jstringification; }; -// Compare function to allow JFactorySummary to be used as keys in std::map +// Compare function to allow JCollectionSummary to be used as keys in std::map // ( used in argument to JControlEventProcessor::GetObjectStatus() ) -inline bool operator<(const JFactorySummary& lhs, const JFactorySummary& rhs){ - if( lhs.class_name != rhs.class_name ) return lhs.class_name < rhs.class_name; +inline bool operator<(const JCollectionSummary& lhs, const JCollectionSummary& rhs){ + if( lhs.type_name != rhs.type_name ) return lhs.type_name < rhs.type_name; if( lhs.collection_name != rhs.collection_name ) return lhs.collection_name < rhs.collection_name; - return lhs.collection_base < rhs.collection_base; + return lhs.base_name < rhs.base_name; } #endif // _JControlEventProcessor_h_ diff --git a/src/plugins/janacontrol/src/JControlZMQ.cc b/src/plugins/janacontrol/src/JControlZMQ.cc index a641c7d83..89550fcd6 100644 --- a/src/plugins/janacontrol/src/JControlZMQ.cc +++ b/src/plugins/janacontrol/src/JControlZMQ.cc @@ -599,19 +599,23 @@ std::string JControlZMQ::GetJANAFactoryListJSON() JSONADD( ss,"PID" , _pid ); ss << ",\n" << R"("factories":[)"; - auto component_summary = _japp->GetComponentSummary(); + auto component_summary_table = _japp->GetComponentSummaryTable(); bool is_first = true; - for( auto fac_summary : component_summary.factories ){ - - int indent_level = 2; - if( !is_first ) ss << ","; - is_first = false; - ss << "\n" + string(indent_level*2, ' ') + "{\n"; - JSONADD( ss, "plugin_name" , fac_summary.plugin_name, indent_level, true ); - JSONADD( ss, "factory_name" , fac_summary.factory_name, indent_level ); - JSONADD( ss, "factory_tag" , fac_summary.factory_tag, indent_level ); - JSONADD( ss,"object_name" , fac_summary.object_name, indent_level ); - ss << "\n" + string(indent_level*2, ' ') + "}"; + for( auto& component_summary : component_summary_table.components ){ + if (component_summary.component_type != JComponentSummary::ComponentType::JFactory) { + continue; + } + for( auto& fac_summary : component_summary.outputs ){ + int indent_level = 2; + if( !is_first ) ss << ","; + is_first = false; + ss << "\n" + string(indent_level*2, ' ') + "{\n"; + JSONADD( ss, "plugin_name" , component_summary.plugin_name, indent_level, true ); + JSONADD( ss, "factory_name", component_summary.type_name, indent_level ); + JSONADD( ss, "factory_tag" , fac_summary.collection_name, indent_level ); + JSONADD( ss, "object_name" , fac_summary.type_name, indent_level ); + ss << "\n" + string(indent_level*2, ' ') + "}"; + } } ss << "\n ]\n"; @@ -630,7 +634,7 @@ std::string JControlZMQ::GetJANAObjectListJSON(){ /// already produced for this event. // Get list of factories and number of objects they've created this event already - std::map factory_object_counts; + std::map factory_object_counts; _jproc->GetObjectStatus( factory_object_counts ); // Create JSON string @@ -645,23 +649,27 @@ std::string JControlZMQ::GetJANAObjectListJSON(){ JSONADD( ss,"event_number" , _jproc->GetEventNumber() ); ss << ",\n" << R"("factories":[)"; - auto component_summary = _japp->GetComponentSummary(); + auto component_summary_table = _japp->GetComponentSummaryTable(); bool is_first = true; - for( auto pfac_summary : factory_object_counts ){ - - auto &fac_summary = pfac_summary.first; - auto &Nobjects = pfac_summary.second; - - int indent_level = 2; - if( !is_first ) ss << ","; - is_first = false; - ss << "\n" + string(indent_level*2, ' ') + "{\n"; - JSONADD( ss, "plugin_name" , fac_summary.plugin_name, indent_level, true ); - JSONADD( ss, "factory_name" , fac_summary.factory_name, indent_level ); - JSONADD( ss, "factory_tag" , fac_summary.factory_tag, indent_level ); - JSONADD( ss,"object_name" , fac_summary.object_name, indent_level ); - JSONADD( ss,"nobjects" , Nobjects, indent_level ); - ss << "\n" + string(indent_level*2, ' ') + "}"; + + for (auto& component_summary : component_summary_table.components) { + if (component_summary.component_type != JComponentSummary::ComponentType::JFactory) { + continue; + } + for (auto& collection_summary : component_summary.outputs) { + auto& Nobjects = factory_object_counts[collection_summary]; + + int indent_level = 2; + if( !is_first ) ss << ","; + is_first = false; + ss << "\n" + string(indent_level*2, ' ') + "{\n"; + JSONADD( ss, "plugin_name" , component_summary.plugin_name, indent_level, true ); + JSONADD( ss, "factory_name" , component_summary.type_name, indent_level ); + JSONADD( ss, "factory_tag" , collection_summary.collection_name, indent_level ); + JSONADD( ss,"object_name" , collection_summary.type_name, indent_level ); + JSONADD( ss,"nobjects" , Nobjects, indent_level ); + ss << "\n" + string(indent_level*2, ' ') + "}"; + } } ss << "\n ]\n";