ATLAS Offline Software
Loading...
Searching...
No Matches
TrigSignatureMoni.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef TRIGSTEERMONITOR_TRIGSIGNATUREMONI_H
5#define TRIGSTEERMONITOR_TRIGSIGNATUREMONI_H 1
6
7#include <string>
8#include <mutex>
9#include <memory>
10#include <vector>
11#include <map>
12#include <unordered_map>
13
14#include <TH2.h>
15
17#include "TimeDivider.h"
18
20#include "GaudiKernel/IIncidentListener.h"
21#include "GaudiKernel/ITHistSvc.h"
22#include "GaudiKernel/LockedHandle.h"
23#include "Gaudi/Utils/PeriodicAction.h"
26#include "TrigConfData/L1Menu.h"
27
29
30// Forward declarations
31class IIncidentSvc;
32
37class TrigSignatureMoni : public extends<AthReentrantAlgorithm, IIncidentListener>
38{
39 public:
40 using base_class::base_class;
41
42 virtual StatusCode initialize() override;
43 virtual StatusCode start() override;
44 virtual StatusCode execute( const EventContext& context ) const override;
45 virtual StatusCode stop() override;
46 virtual void handle( const Incident& incident ) override;
47
48 private:
49 // Class representing asynchronously published histograms
51 public:
52 RateHistogram() = default;
54
55 // Initialize rate histogram and create buffer
56 StatusCode init( const std::string& histoName, const std::string& histoTitle,
57 const int x, const int y, const std::string& registerPath, const ServiceHandle<ITHistSvc>& histSvc );
58
59 // Get the histogram
60 LockedHandle<TH2>& getHistogram ATLAS_NOT_CONST_THREAD_SAFE () const;
61
62 // Get the histogram buffer
63 LockedHandle<TH2>& getBuffer ATLAS_NOT_CONST_THREAD_SAFE () const;
64
65 // Get rate histogram timer pointer
66 std::unique_ptr<Gaudi::Utils::PeriodicAction>& getTimer();
67
68 // Start the histogram timer with given duration and intervals
69 void startTimer(unsigned int duration, unsigned int intervals);
70
71 // Stop the histogram timer
72 void stopTimer();
73
74 // Fill the histogram with given bins x, y
75 void fill(const double x, const double y) const;
76
77 private:
78 // Update the histogram with values from the buffer
79 void updatePublished(unsigned int duration) const;
80
81 // Callback to check if interval's duration passed and histogram should be published
82 void callback();
83
84 mutable LockedHandle<TH2> m_bufferHistogram ATLAS_THREAD_SAFE;
85 mutable LockedHandle<TH2> m_histogram ATLAS_THREAD_SAFE;
86 std::mutex m_mutex;
87 std::unique_ptr<Gaudi::Utils::PeriodicAction> m_timer;
88 std::unique_ptr<TimeDivider> m_timeDivider;
89 unsigned int m_duration{0};
90 };
91
92 SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> m_l1DecisionsKey{ this, "L1Decisions", "HLTSeedingSummary", "Chains activated after the L1" };
93 SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer> m_finalDecisionKey{ this, "FinalDecisionKey", "HLTNav_Summary", "Final stage of all decisions" };
94 SG::ReadHandleKey<TrigConf::HLTMenu> m_HLTMenuKey{ this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu", "HLT Menu" };
95 SG::ReadHandleKey<TrigConf::L1Menu> m_L1MenuKey{ this, "L1TriggerMenu", "DetectorStore+L1TriggerMenu", "L1 Menu" };
96
97 ServiceHandle<IIncidentSvc> m_incidentSvc{ this, "IncidentSvc", "IncidentSvc", "Incident service"};
98 ServiceHandle<ITHistSvc> m_histSvc{ this, "THistSvc", "THistSvc/THistSvc", "Histogramming svc" };
99 Gaudi::Property<std::string> m_bookingPath{ this, "HistPath", "/EXPERT/HLTFramework", "Booking path for the histogram"};
100
101 // Necessary for asynchronous calling callback function
102 Gaudi::Property<unsigned int> m_duration {this, "RateIntegrationDuration", 10, "Integration time for the rate histogram in seconds"};
103 Gaudi::Property<unsigned int> m_intervals {this, "RateIntegrationIntervals", 6, "Number of the rate histogram publications"};
104
105 ToolHandleArray<DecisionCollectorTool> m_decisionCollectorTools{ this, "DecisionCollectorTools", {}, "Tools that collect decisions (yes/no) for steps" };
106 ToolHandleArray<DecisionCollectorTool> m_featureCollectorTools{ this, "FeatureCollectorTools", {}, "Tools that collect decision counts for specific features for steps" };
107
108 // Histograms
109 mutable LockedHandle<TH2> m_passHistogram ATLAS_THREAD_SAFE;
110 mutable LockedHandle<TH2> m_countHistogram ATLAS_THREAD_SAFE;
113
114 // Unordered maps for fast lookup
115 std::unordered_map<unsigned int, int> m_chainIDToBinMap;
116 std::unordered_map<std::string, int> m_nameToBinMap;
117 std::unordered_map<std::string, int> m_sequenceToBinMap;
118
119 // Regular maps for ordered iteration
120 std::map<std::string, TrigCompositeUtils::DecisionIDContainer> m_groupToChainMap;
121 std::map<std::string, TrigCompositeUtils::DecisionIDContainer> m_streamToChainMap;
122 std::map<std::string, TrigCompositeUtils::DecisionIDContainer> m_expressChainMap;
123
124 // Returns number of chains + groups + sequencers based on the menu handle
126
127 // Returns number of chains + groups + sequencers based of size of m_chainIDToBinMap
128 int nBinsX() const;
129
130 // Returns number of chains based on the menu handle
132
133 // Returns number of steps
134 int nSteps() const;
135
136 // Init different types of histograms
137 StatusCode initHist(LockedHandle<TH2>&, SG::ReadHandle<TrigConf::HLTMenu>&, bool = true);
138 StatusCode initSeqHist(LockedHandle<TH2>&, std::set<std::string>&);
139
140 // Fill different types of histograms
141 StatusCode fillDecisionCount(const std::vector<TrigCompositeUtils::DecisionID>& , int) const;
142 StatusCode fillPassEvents(const TrigCompositeUtils::DecisionIDContainer&, int) const;
143 StatusCode fillRate(const TrigCompositeUtils::DecisionIDContainer&, int) const;
144 StatusCode fillHistogram(const TrigCompositeUtils::DecisionIDContainer&, int, LockedHandle<TH2>&) const;
145 StatusCode fillSequences(const std::set<std::string>&) const;
146 StatusCode fillStreamsAndGroups(const std::map<std::string, TrigCompositeUtils::DecisionIDContainer>&, const TrigCompositeUtils::DecisionIDContainer&, int) const;
147};
148
149#endif //> !TRIGSTEERMONITOR_TRIGSIGNATUREMONI_H
#define y
#define x
Define macros for attributes used to control the static checker.
Property holding a SG store/key/clid from which a ReadHandle is made.
LockedHandle< TH2 > &getBuffer ATLAS_NOT_CONST_THREAD_SAFE() const
void updatePublished(unsigned int duration) const
std::unique_ptr< Gaudi::Utils::PeriodicAction > m_timer
LockedHandle< TH2 > m_bufferHistogram ATLAS_THREAD_SAFE
void startTimer(unsigned int duration, unsigned int intervals)
void fill(const double x, const double y) const
LockedHandle< TH2 > &getHistogram ATLAS_NOT_CONST_THREAD_SAFE() const
StatusCode init(const std::string &histoName, const std::string &histoTitle, const int x, const int y, const std::string &registerPath, const ServiceHandle< ITHistSvc > &histSvc)
std::unique_ptr< Gaudi::Utils::PeriodicAction > & getTimer()
std::unique_ptr< TimeDivider > m_timeDivider
std::unordered_map< std::string, int > m_sequenceToBinMap
Sequence to bin map for sequence histogram.
int nChains(SG::ReadHandle< TrigConf::HLTMenu > &) const
StatusCode initHist(LockedHandle< TH2 > &, SG::ReadHandle< TrigConf::HLTMenu > &, bool=true)
Gaudi::Property< unsigned int > m_intervals
StatusCode fillPassEvents(const TrigCompositeUtils::DecisionIDContainer &, int) const
Gaudi::Property< unsigned int > m_duration
StatusCode initSeqHist(LockedHandle< TH2 > &, std::set< std::string > &)
virtual StatusCode start() override
StatusCode fillRate(const TrigCompositeUtils::DecisionIDContainer &, int) const
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_streamToChainMap
Stream name to chain objects map, excluding express.
virtual StatusCode initialize() override
StatusCode fillDecisionCount(const std::vector< TrigCompositeUtils::DecisionID > &, int) const
virtual StatusCode execute(const EventContext &context) const override
RateHistogram m_sequenceHistogram
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_l1DecisionsKey
ServiceHandle< ITHistSvc > m_histSvc
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_expressChainMap
Stream name to chain objects map, including only express.
StatusCode fillHistogram(const TrigCompositeUtils::DecisionIDContainer &, int, LockedHandle< TH2 > &) const
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_groupToChainMap
Group name to chain objects map.
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
StatusCode fillSequences(const std::set< std::string > &) const
LockedHandle< TH2 > m_passHistogram ATLAS_THREAD_SAFE
ServiceHandle< IIncidentSvc > m_incidentSvc
RateHistogram m_rateHistogram
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_finalDecisionKey
Gaudi::Property< std::string > m_bookingPath
std::unordered_map< std::string, int > m_nameToBinMap
Sequence/group/bunchgroup name to bin map.
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
StatusCode fillStreamsAndGroups(const std::map< std::string, TrigCompositeUtils::DecisionIDContainer > &, const TrigCompositeUtils::DecisionIDContainer &, int) const
virtual StatusCode stop() override
virtual void handle(const Incident &incident) override
ToolHandleArray< DecisionCollectorTool > m_decisionCollectorTools
ToolHandleArray< DecisionCollectorTool > m_featureCollectorTools
std::unordered_map< unsigned int, int > m_chainIDToBinMap
Chain id to histogram bin map.
std::set< DecisionID > DecisionIDContainer