From f7f0fccfc1fb3bbca01487b2723f7c4a910b87d8 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 15 May 2020 14:38:47 +0200 Subject: [PATCH 1/5] Get line names from configuration --- Rec/Allen/src/RunAllen.cpp | 20 ++++++++++++++++++++ Rec/Allen/src/RunAllen.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/Rec/Allen/src/RunAllen.cpp b/Rec/Allen/src/RunAllen.cpp index a535a3b5c4c..c554131b6a1 100644 --- a/Rec/Allen/src/RunAllen.cpp +++ b/Rec/Allen/src/RunAllen.cpp @@ -92,6 +92,9 @@ StatusCode RunAllen::initialize() std::string conf_file = resolveEnvVars(m_json); ConfigurationReader configuration_reader(conf_file); + // Get HLT1 selection names + m_line_names = configuration_reader.params()["configured_lines"]; + // Initialize stream const bool print_memory_usage = false; const uint start_event_offset = 0; @@ -163,6 +166,23 @@ std::tuple RunAllen::operator()( if (m_filter_hlt1.value()) { filter = buffer->host_passing_event_list[0]; } + + // Get line decisions from DecReports + // First two words contain the TCK and taskID, then one word per HLT1 line + uint32_t dec_mask = HltDecReport::decReportMasks::decisionMask; + for (uint i = 0; i < buffer->host_number_of_hlt1_lines; i++) { + const uint32_t line_report = buffer->host_dec_reports[2+i]; + const bool dec = line_report & dec_mask; + const auto it = m_line_names.find(std::to_string(i)); + if (it == m_line_names.end()) { + std::cout << "ERROR: did not find line name for " << i << std::endl; + continue; + } + if (i == 10) { + m_trackMVA_counter.buffer() += int(dec); + } + } + if (msgLevel(MSG::DEBUG)) debug() << "Event selected by Allen: " << uint(filter) << endmsg; return std::make_tuple(filter, *buffer); } diff --git a/Rec/Allen/src/RunAllen.h b/Rec/Allen/src/RunAllen.h index 7d6a0b786e7..f4abc1abfd6 100644 --- a/Rec/Allen/src/RunAllen.h +++ b/Rec/Allen/src/RunAllen.h @@ -64,6 +64,7 @@ private: LHCb::RawBank::UT, LHCb::RawBank::FTCluster, LHCb::RawBank::Muon}; + std::map m_line_names; const uint m_number_of_streams = 1; const uint m_number_of_repetitions = 1; const bool m_cpu_offload = true; @@ -84,6 +85,9 @@ private: // If set to false, events are only filtered by the GEC // If set to true, events are filtered based on an OR of the Allen selection lines Gaudi::Property m_filter_hlt1 {this, "FilterHLT1", false}; + + // Counters for HLT1 selection rates +mutable Gaudi::Accumulators::BinomialCounter<> m_trackMVA_counter{this, "TrackMVA rate"}; }; #endif -- GitLab From ab973aa167875d0d4f96d697af6c1f795eeaa197 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 15 May 2020 15:34:26 +0200 Subject: [PATCH 2/5] Populate one BinomialCounter per HLT1 line --- Rec/Allen/src/RunAllen.cpp | 22 +++++++++++----------- Rec/Allen/src/RunAllen.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Rec/Allen/src/RunAllen.cpp b/Rec/Allen/src/RunAllen.cpp index c554131b6a1..477789676ea 100644 --- a/Rec/Allen/src/RunAllen.cpp +++ b/Rec/Allen/src/RunAllen.cpp @@ -92,9 +92,6 @@ StatusCode RunAllen::initialize() std::string conf_file = resolveEnvVars(m_json); ConfigurationReader configuration_reader(conf_file); - // Get HLT1 selection names - m_line_names = configuration_reader.params()["configured_lines"]; - // Initialize stream const bool print_memory_usage = false; const uint start_event_offset = 0; @@ -122,6 +119,15 @@ StatusCode RunAllen::initialize() new TESProvider( number_of_slices, events_per_slice, n_events)); + // Get HLT1 selection names from configuration and initialize rate counters + m_line_names = configuration_reader.params()["configured_lines"]; + m_hlt1_line_rates.reserve(m_stream_wrapper->number_of_hlt1_lines); + for (uint i = 0; i < m_stream_wrapper->number_of_hlt1_lines; ++i) { + const auto it = m_line_names.find(std::to_string(i)); + const std::string name = "Hlt1" + it->second + "Decision"; + m_hlt1_line_rates.emplace_back( this, "Selected by " + name ); + } + // Set verbosity level logger::setVerbosity(6 - this->msgLevel()); @@ -173,14 +179,8 @@ std::tuple RunAllen::operator()( for (uint i = 0; i < buffer->host_number_of_hlt1_lines; i++) { const uint32_t line_report = buffer->host_dec_reports[2+i]; const bool dec = line_report & dec_mask; - const auto it = m_line_names.find(std::to_string(i)); - if (it == m_line_names.end()) { - std::cout << "ERROR: did not find line name for " << i << std::endl; - continue; - } - if (i == 10) { - m_trackMVA_counter.buffer() += int(dec); - } + const auto it = m_line_names.find(std::to_string(i)); + m_hlt1_line_rates[i].buffer() += int(dec); } if (msgLevel(MSG::DEBUG)) debug() << "Event selected by Allen: " << uint(filter) << endmsg; diff --git a/Rec/Allen/src/RunAllen.h b/Rec/Allen/src/RunAllen.h index f4abc1abfd6..630a4d17e7c 100644 --- a/Rec/Allen/src/RunAllen.h +++ b/Rec/Allen/src/RunAllen.h @@ -87,7 +87,7 @@ private: Gaudi::Property m_filter_hlt1 {this, "FilterHLT1", false}; // Counters for HLT1 selection rates -mutable Gaudi::Accumulators::BinomialCounter<> m_trackMVA_counter{this, "TrackMVA rate"}; + mutable std::vector> m_hlt1_line_rates{}; }; #endif -- GitLab From d23c1c2efc7cf125a97368a34fc298538c78d42a Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Fri, 15 May 2020 17:53:02 +0200 Subject: [PATCH 3/5] add LHCb::HltDecReports as output to RunAllen --- Rec/Allen/CMakeLists.txt | 2 +- Rec/Allen/src/AllenDecReportsToTES.cpp | 2 +- Rec/Allen/src/RunAllen.cpp | 14 ++++++++++---- Rec/Allen/src/RunAllen.h | 5 +++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Rec/Allen/CMakeLists.txt b/Rec/Allen/CMakeLists.txt index 66c1efde852..a906d3084c3 100644 --- a/Rec/Allen/CMakeLists.txt +++ b/Rec/Allen/CMakeLists.txt @@ -100,7 +100,7 @@ gaudi_add_module(AllenWrapper INCLUDE_DIRS Online/OnlineKernel LINK_LIBRARIES AllenLib DAQEventLib DAQKernelLib GaudiAlgLib PrKernel VPDetLib UTDetLib UTKernelLib - FTDetLib) + FTDetLib HltEvent) if(CMAKE_BUILD_TYPE STREQUAL Debug) target_compile_definitions(AllenWrapper PRIVATE ALLEN_DEBUG) endif() diff --git a/Rec/Allen/src/AllenDecReportsToTES.cpp b/Rec/Allen/src/AllenDecReportsToTES.cpp index cd34ca2584f..67152e7243c 100644 --- a/Rec/Allen/src/AllenDecReportsToTES.cpp +++ b/Rec/Allen/src/AllenDecReportsToTES.cpp @@ -27,7 +27,7 @@ AllenDecReportsToTES::AllenDecReportsToTES(const std::string& name, ISvcLocator* // Inputs {KeyValue {"AllenOutput", "Allen/Out/HostBuffers"}}, // Outputs - {KeyValue {"OutputDecReports", "Allen/Out/DecReports"}}) + {KeyValue {"OutputDecReports", "Allen/Out/RawDecReports"}}) {} StatusCode AllenDecReportsToTES::initialize() diff --git a/Rec/Allen/src/RunAllen.cpp b/Rec/Allen/src/RunAllen.cpp index 477789676ea..3669d2b7427 100644 --- a/Rec/Allen/src/RunAllen.cpp +++ b/Rec/Allen/src/RunAllen.cpp @@ -40,7 +40,8 @@ RunAllen::RunAllen(const std::string& name, ISvcLocator* pSvcLocator) : // Inputs {KeyValue {"AllenRawInput", "Allen/Raw/Input"}, KeyValue {"ODINLocation", LHCb::ODINLocation::Default}}, // Outputs - {KeyValue {"AllenOutput", "Allen/Out/HostBuffers"}}) + {KeyValue {"AllenOutput", "Allen/Out/HostBuffers"}, + KeyValue {"DecReportsLocation", "Allen/Out/DecReports"}}) {} StatusCode RunAllen::initialize() @@ -136,7 +137,7 @@ StatusCode RunAllen::initialize() /** Calls Allen for one event */ -std::tuple RunAllen::operator()( +std::tuple RunAllen::operator()( const std::array, LHCb::RawBank::LastType>& allen_banks, const LHCb::ODIN&) const { @@ -175,16 +176,21 @@ std::tuple RunAllen::operator()( // Get line decisions from DecReports // First two words contain the TCK and taskID, then one word per HLT1 line + LHCb::HltDecReports reports{}; + reports.reserve(buffer->host_number_of_hlt1_lines); uint32_t dec_mask = HltDecReport::decReportMasks::decisionMask; - for (uint i = 0; i < buffer->host_number_of_hlt1_lines; i++) { + for (int i = 0; i < buffer->host_number_of_hlt1_lines; i++) { const uint32_t line_report = buffer->host_dec_reports[2+i]; const bool dec = line_report & dec_mask; const auto it = m_line_names.find(std::to_string(i)); + const std::string name = it->second; m_hlt1_line_rates[i].buffer() += int(dec); + reports.insert(name, {dec, 0, 0, 0, i} ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); + } if (msgLevel(MSG::DEBUG)) debug() << "Event selected by Allen: " << uint(filter) << endmsg; - return std::make_tuple(filter, *buffer); + return std::make_tuple(filter, *buffer, reports); } StatusCode RunAllen::finalize() diff --git a/Rec/Allen/src/RunAllen.h b/Rec/Allen/src/RunAllen.h index 630a4d17e7c..b8feb23d37b 100644 --- a/Rec/Allen/src/RunAllen.h +++ b/Rec/Allen/src/RunAllen.h @@ -19,6 +19,7 @@ #include #include #include +#include // Rec includes #include "Event/Track.h" @@ -39,7 +40,7 @@ #include "Logger.h" #include "TESProvider.h" -class RunAllen final : public Gaudi::Functional::MultiTransformerFilter( +class RunAllen final : public Gaudi::Functional::MultiTransformerFilter( const std::array, LHCb::RawBank::LastType>& allen_banks, const LHCb::ODIN& odin)> { public: @@ -50,7 +51,7 @@ public: StatusCode initialize() override; /// Algorithm execution - std::tuple operator()( + std::tuple operator()( const std::array, LHCb::RawBank::LastType>& allen_banks, const LHCb::ODIN& odin) const override; -- GitLab From 9bc60cd9081c07b673691b8b6fc72decc6c8d724 Mon Sep 17 00:00:00 2001 From: Dorothea vom Bruch Date: Wed, 20 May 2020 10:40:59 +0200 Subject: [PATCH 4/5] index lines in DecReports from 1 --- Rec/Allen/src/RunAllen.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Rec/Allen/src/RunAllen.cpp b/Rec/Allen/src/RunAllen.cpp index 3669d2b7427..13e40a9e1a2 100644 --- a/Rec/Allen/src/RunAllen.cpp +++ b/Rec/Allen/src/RunAllen.cpp @@ -185,10 +185,12 @@ std::tuple RunAllen::operator()( const auto it = m_line_names.find(std::to_string(i)); const std::string name = it->second; m_hlt1_line_rates[i].buffer() += int(dec); - reports.insert(name, {dec, 0, 0, 0, i} ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); + // Note: the line index in a DecReport cannot be zero -> start at 1 + const int dec_rep_index = i+1; + verbose() << "Adding Allen line " << dec_rep_index << " with name " << name << " to HltDecReport with decision " << int(dec) << endmsg; - } - + reports.insert(name, {dec, 0, 0, 0, dec_rep_index} ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); + } if (msgLevel(MSG::DEBUG)) debug() << "Event selected by Allen: " << uint(filter) << endmsg; return std::make_tuple(filter, *buffer, reports); } -- GitLab From 08096a03c085ae3793fa0803894ccda8dbb5fe06 Mon Sep 17 00:00:00 2001 From: Gitlab CI Date: Wed, 20 May 2020 08:42:44 +0000 Subject: [PATCH 5/5] Fixed formatting patch generated by https://gitlab.cern.ch/lhcb/Allen/-/jobs/8454742 --- Rec/Allen/src/RunAllen.cpp | 26 +++++++++++++------------- Rec/Allen/src/RunAllen.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Rec/Allen/src/RunAllen.cpp b/Rec/Allen/src/RunAllen.cpp index 13e40a9e1a2..05b3b48aa2c 100644 --- a/Rec/Allen/src/RunAllen.cpp +++ b/Rec/Allen/src/RunAllen.cpp @@ -40,8 +40,7 @@ RunAllen::RunAllen(const std::string& name, ISvcLocator* pSvcLocator) : // Inputs {KeyValue {"AllenRawInput", "Allen/Raw/Input"}, KeyValue {"ODINLocation", LHCb::ODINLocation::Default}}, // Outputs - {KeyValue {"AllenOutput", "Allen/Out/HostBuffers"}, - KeyValue {"DecReportsLocation", "Allen/Out/DecReports"}}) + {KeyValue {"AllenOutput", "Allen/Out/HostBuffers"}, KeyValue {"DecReportsLocation", "Allen/Out/DecReports"}}) {} StatusCode RunAllen::initialize() @@ -124,9 +123,9 @@ StatusCode RunAllen::initialize() m_line_names = configuration_reader.params()["configured_lines"]; m_hlt1_line_rates.reserve(m_stream_wrapper->number_of_hlt1_lines); for (uint i = 0; i < m_stream_wrapper->number_of_hlt1_lines; ++i) { - const auto it = m_line_names.find(std::to_string(i)); + const auto it = m_line_names.find(std::to_string(i)); const std::string name = "Hlt1" + it->second + "Decision"; - m_hlt1_line_rates.emplace_back( this, "Selected by " + name ); + m_hlt1_line_rates.emplace_back(this, "Selected by " + name); } // Set verbosity level @@ -176,20 +175,21 @@ std::tuple RunAllen::operator()( // Get line decisions from DecReports // First two words contain the TCK and taskID, then one word per HLT1 line - LHCb::HltDecReports reports{}; + LHCb::HltDecReports reports {}; reports.reserve(buffer->host_number_of_hlt1_lines); - uint32_t dec_mask = HltDecReport::decReportMasks::decisionMask; + uint32_t dec_mask = HltDecReport::decReportMasks::decisionMask; for (int i = 0; i < buffer->host_number_of_hlt1_lines; i++) { - const uint32_t line_report = buffer->host_dec_reports[2+i]; + const uint32_t line_report = buffer->host_dec_reports[2 + i]; const bool dec = line_report & dec_mask; - const auto it = m_line_names.find(std::to_string(i)); - const std::string name = it->second; + const auto it = m_line_names.find(std::to_string(i)); + const std::string name = it->second; m_hlt1_line_rates[i].buffer() += int(dec); - // Note: the line index in a DecReport cannot be zero -> start at 1 - const int dec_rep_index = i+1; - verbose() << "Adding Allen line " << dec_rep_index << " with name " << name << " to HltDecReport with decision " << int(dec) << endmsg; + // Note: the line index in a DecReport cannot be zero -> start at 1 + const int dec_rep_index = i + 1; + verbose() << "Adding Allen line " << dec_rep_index << " with name " << name << " to HltDecReport with decision " + << int(dec) << endmsg; - reports.insert(name, {dec, 0, 0, 0, dec_rep_index} ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ ); + reports.insert(name, {dec, 0, 0, 0, dec_rep_index}).ignore(/* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */); } if (msgLevel(MSG::DEBUG)) debug() << "Event selected by Allen: " << uint(filter) << endmsg; return std::make_tuple(filter, *buffer, reports); diff --git a/Rec/Allen/src/RunAllen.h b/Rec/Allen/src/RunAllen.h index b8feb23d37b..9c13fc2d147 100644 --- a/Rec/Allen/src/RunAllen.h +++ b/Rec/Allen/src/RunAllen.h @@ -88,7 +88,7 @@ private: Gaudi::Property m_filter_hlt1 {this, "FilterHLT1", false}; // Counters for HLT1 selection rates - mutable std::vector> m_hlt1_line_rates{}; + mutable std::vector> m_hlt1_line_rates {}; }; #endif -- GitLab