Skip to content
Snippets Groups Projects
Commit 2bb7accf authored by Rosen Matev's avatar Rosen Matev :sunny:
Browse files

Monitor DecReports and scheduler state in separate algs

parent 4edb7837
No related branches found
No related tags found
1 merge request!3154Add algorithms for monitoring HltDecReports and the Scheduler state
......@@ -19,6 +19,7 @@ gaudi_add_module(HLTScheduler
src/ConfigurableDummy.cpp
src/ControlFlowNode.cpp
src/ExecutionReportsWriter.cpp
src/ExecutionReportsMonitor.cpp
src/HLTControlFlowMgr.cpp
LINK
Python::Python
......
......@@ -29,39 +29,28 @@ a1.CFD = True
a2 = ConfigurableDummy("A2")
a2.inpKeys = ['/Event/a1']
a2.outKeys = ['/Event/a2']
a2.CFD = True
a2.CFD = False
a3 = ConfigurableDummy("A3")
a3.inpKeys = ['/Event/a1']
a3.outKeys = ['/Event/a3']
a3.CFD = True
a3.CFD = False
a4 = ConfigurableDummy("A4")
a4.inpKeys = ['/Event/a3']
a4.outKeys = ['/Event/a4']
a4.CFD = False
a4.CFD = True
a5 = ConfigurableDummy("A5")
a5.inpKeys = ['/Event/a1']
a5.outKeys = ['/Event/a5']
a5.CFD = False
from Configurables import HltANNSvc
HltANNSvc().Hlt1SelectionID = {
'A1Decision': 1,
'A2Decision': 2,
'A3Decision': 3,
'A4Decision': 4,
'A5Decision': 5
}
a5.CFD = True
exerep = ExecutionReportsWriter(
"ExecReportsWriter",
OutputLevel=DEBUG,
PrintFreq=1,
DecReportsLocation="/Event/DecReports",
Persist=["A1", "A2", "A3", "A4", "A5"],
ANNSvcKey="Hlt1SelectionID")
DecReportsLocation="/Event/DecReports")
whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
......@@ -87,10 +76,3 @@ app = ApplicationMgr(
TopAlg=[a1, a2, a3, a4, a5, exerep])
HiveDataBrokerSvc().DataProducers = app.TopAlg
from Configurables import HistogramPersistencySvc
HistogramPersistencySvc(OutputFile="histograms.root")
app.HistogramPersistency = "ROOT"
from Configurables import Gaudi__Histograming__Sink__Root as RootHistoSink
ApplicationMgr().ExtSvc += [RootHistoSink()]
/*****************************************************************************\
* (c) Copyright 2019-2022 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Gaudi/Accumulators/Histogram.h"
#include "GaudiKernel/EventContext.h"
#include "GaudiKernel/StatusCode.h"
#include "Kernel/EventContextExt.h"
#include "Kernel/ISchedulerConfiguration.h"
#include "LHCbAlgs/Consumer.h"
#include <map>
#include <string>
#include <vector>
class ExecutionReportsMonitor final : public LHCb::Algorithm::Consumer<void( EventContext const& )> {
public:
ExecutionReportsMonitor( const std::string& name, ISvcLocator* pSvcLocator ) : Consumer{name, pSvcLocator} {}
StatusCode start() override;
void operator()( EventContext const& evtCtx ) const override;
private:
ServiceHandle<LHCb::Interfaces::ISchedulerConfiguration> m_scheduler{this, "Scheduler", "HLTControlFlowMgr"};
mutable std::optional<Gaudi::Accumulators::Histogram<1, Gaudi::Accumulators::atomicity::full, unsigned int>>
m_execCount;
mutable std::optional<Gaudi::Accumulators::Histogram<1, Gaudi::Accumulators::atomicity::full, unsigned int>>
m_passCount;
mutable std::optional<Gaudi::Accumulators::ProfileHistogram<1, Gaudi::Accumulators::atomicity::full, unsigned int>>
m_passFraction;
std::map<std::string, int> m_name_indices;
};
DECLARE_COMPONENT( ExecutionReportsMonitor )
StatusCode ExecutionReportsMonitor::start() {
return Consumer::start().andThen( [&]() {
m_name_indices = m_scheduler->getNodeNamesWithIndices();
std::vector<std::string> labels;
labels.reserve( m_name_indices.size() );
for ( const auto& [decision_name, index] : m_name_indices ) { labels.push_back( decision_name ); }
auto size = static_cast<unsigned int>( labels.size() );
Gaudi::Accumulators::Axis<decltype( m_execCount )::value_type::AxisArithmeticType> axis{size, 0, size, "", labels};
m_execCount.emplace( this, "exec_count", "Number of times a node was executed", axis );
m_passCount.emplace( this, "pass_count", "Number of times a node passed", axis );
m_passFraction.emplace( this, "pass_frac", "Fraction of times a node passed", axis );
return StatusCode::SUCCESS;
} );
}
void ExecutionReportsMonitor::operator()( EventContext const& evtCtx ) const {
auto const& lhcbExt = evtCtx.getExtension<LHCb::EventContextExtension>();
auto const& state = lhcbExt.getSchedulerExtension<LHCb::Interfaces::ISchedulerConfiguration::State>();
for ( const auto& [i, item] : LHCb::range::enumerate( m_name_indices ) ) {
const auto& [name, index] = item;
const auto& node = state.node( index );
bool executed = node.executionCtr == 0;
bool passed = executed && node.passed; // Attention! node.passed is true when the node hasn't been executed
m_execCount.value()[i] += executed;
if ( executed ) {
m_passCount.value()[i] += passed;
m_passFraction.value()[i] += passed;
}
}
}
......@@ -11,7 +11,6 @@
#include "Event/HltDecReports.h"
#include "LHCbAlgs/Transformer.h"
#include "Gaudi/Accumulators/Histogram.h"
#include "GaudiKernel/EventContext.h"
#include "GaudiKernel/StatusCode.h"
#include "Kernel/EventContextExt.h"
......@@ -48,9 +47,6 @@ private:
/// number assigned by the HltAnnSvc
std::map<std::string, std::pair<int, IANNSvc::minor_mapped_type>> m_name_indices{};
using hist_t = Gaudi::Accumulators::WeightedHistogram<1, Gaudi::Accumulators::atomicity::full, std::size_t>;
mutable std::optional<hist_t> m_histo_PositiveLineDecisions;
Gaudi::Property<int> m_printFreq{this, "PrintFreq", 1000, "Print Frequency for states"};
Gaudi::Property<std::vector<std::string>> m_line_names{this, "Persist", {}, "Specify the nodes to be written to TES"};
Gaudi::Property<std::string> m_ann_key{this, "ANNSvcKey", "", "Key from the ANN service to query."};
......@@ -90,11 +86,6 @@ StatusCode ExecutionReportsWriter::start() {
m_name_indices[decision_name] = {std::get<1>( *node_idx ), std::get<1>( *ann_idx )};
}
Gaudi::Accumulators::Axis<std::size_t> lineDecisions{static_cast<unsigned int>( m_name_indices.size() ), 0,
m_name_indices.size()};
m_histo_PositiveLineDecisions.emplace( this, "m_histo_PositiveLineDecisions", "m_histo_PositiveLineDecisions",
lineDecisions );
return sc;
}
......@@ -112,9 +103,5 @@ LHCb::HltDecReports ExecutionReportsWriter::operator()( EventContext const& evtC
const auto& [node_idx, ann_idx] = idx;
reports.insert( decision_name, {state.node( node_idx ).passed, 0, 0, 0, ann_idx} ).ignore();
}
for ( const auto& [i, item] : LHCb::range::enumerate( m_name_indices ) ) {
const auto& [node_idx, ann_idx] = std::get<1>( item );
m_histo_PositiveLineDecisions.value()[i] += state.node( node_idx ).passed;
}
return reports; // write down something better?
}
......@@ -39,6 +39,7 @@ gaudi_add_library(HltDAQLib
gaudi_add_module(HltDAQ
SOURCES
src/component/HltDecReportsDecoder.cpp
src/component/HltDecReportsMonitor.cpp
src/component/HltDecReportsWriter.cpp
src/component/HltDiffHltDecReports.cpp
src/component/HltLumiWriter.cpp
......
/*****************************************************************************\
* (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration *
* *
* This software is distributed under the terms of the GNU General Public *
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
* *
* In applying this licence, CERN does not waive the privileges and immunities *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
\*****************************************************************************/
#include "Event/HltDecReports.h"
#include "LHCbAlgs/Consumer.h"
#include "Gaudi/Accumulators/Histogram.h"
#include "GaudiKernel/EventContext.h"
#include "GaudiKernel/StatusCode.h"
#include "Kernel/EventContextExt.h"
#include "Kernel/IANNSvc.h"
#include <string>
#include <type_traits>
#include <vector>
class HltDecReportsMonitor final : public LHCb::Algorithm::Consumer<void( const LHCb::HltDecReports& )> {
public:
HltDecReportsMonitor( const std::string& name, ISvcLocator* pSvcLocator )
: Consumer{name, pSvcLocator, {"Input", ""}} {}
void operator()( const LHCb::HltDecReports& ) const override;
private:
mutable std::optional<Gaudi::Accumulators::WeightedHistogram<1, Gaudi::Accumulators::atomicity::full, unsigned int>>
m_decCount;
mutable std::optional<Gaudi::Accumulators::ProfileHistogram<1, Gaudi::Accumulators::atomicity::full, unsigned int>>
m_decAcceptFraction;
mutable std::mutex m_lock;
mutable std::vector<std::string> m_decNames;
};
DECLARE_COMPONENT( HltDecReportsMonitor )
void HltDecReportsMonitor::operator()( const LHCb::HltDecReports& reports ) const {
auto lock = std::scoped_lock{m_lock};
if ( m_decCount.has_value() ) {
bool identical_structure = true;
if ( reports.size() != m_decNames.size() ) {
identical_structure = false;
} else {
for ( const auto& [dr, name] : Gaudi::Functional::details::zip::range( reports, m_decNames ) ) {
if ( dr.first != name ) {
identical_structure = false;
break;
}
}
}
if ( !identical_structure ) {
warning() << "Got different HltDecReports structure, resetting histogram." << endmsg;
m_decCount.reset();
m_decAcceptFraction.reset();
}
}
if ( !m_decCount.has_value() ) {
m_decNames = reports.decisionNames();
auto size = static_cast<unsigned int>( reports.size() );
Gaudi::Accumulators::Axis<decltype( m_decCount )::value_type::AxisArithmeticType> axis{size, 0, size, "",
m_decNames};
m_decCount.emplace( this, "pass_count", "Number of positive decisions", axis );
m_decAcceptFraction.emplace( this, "pass_frac", "Accept fraction per decision", axis );
}
for ( const auto& [i, dr] : LHCb::range::enumerate( reports.decReports() ) ) {
m_decCount.value()[i] += dr.second.decision();
m_decAcceptFraction.value()[i] += dr.second.decision();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment