ATLAS Offline Software
TrigSignatureMoni.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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 <TH2.h>
12 
14 #include "GaudiKernel/IIncidentListener.h"
15 #include "GaudiKernel/ITHistSvc.h"
16 #include "GaudiKernel/LockedHandle.h"
20 #include "DecisionCollectorTool.h"
21 #include "TrigConfData/HLTMenu.h"
22 #include "TrigConfData/L1Menu.h"
24 
25 #include "TimeDivider.h"
28 
29 // Forward declarations
30 class IIncidentSvc;
31 
36 class TrigSignatureMoni : public extends<AthReentrantAlgorithm, IIncidentListener>
37 {
38  public:
39 
40  TrigSignatureMoni( const std::string& name, ISvcLocator* pSvcLocator );
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
50  class RateHistogram {
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<Athena::AlgorithmTimer>& 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;
87  std::unique_ptr<Athena::AlgorithmTimer> 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  std::map<unsigned int, int> m_chainIDToBinMap;
115  std::map<std::string, int> m_nameToBinMap;
116  std::map<std::string, int> m_sequenceToBinMap;
117  std::map<unsigned int, std::set<std::string>> m_chainIDToBunchMap;
118  std::map<std::string, TrigCompositeUtils::DecisionIDContainer> m_groupToChainMap;
119  std::map<std::string, TrigCompositeUtils::DecisionIDContainer> m_streamToChainMap;
120  std::map<std::string, TrigCompositeUtils::DecisionIDContainer> m_expressChainMap;
121 
122 
123  // Returns number of chains + groups + sequencers based on the menu handle
125 
126  // Returns number of chains + groups + sequencers based of size of m_chainIDToBinMap
127  int nBinsX() const;
128 
129  // Returns number of chains based on the menu handle
131 
132  // Returns number of BCIDs to monitor
133  int nBCIDs() const;
134 
135  // Returns number of sequences
136  int nSequenceBins() const;
137 
138  // Returns number of steps
139  int nSteps() const;
140 
141  // Returns number of base steps: in, after ps, out steps
142  int nBaseSteps() const;
143 
144 
145  // Init different types of histograms
146  StatusCode initHist(LockedHandle<TH2>&, SG::ReadHandle<TrigConf::HLTMenu>&, bool = true);
147  StatusCode initSeqHist(LockedHandle<TH2>&, std::set<std::string>&);
148 
149  // Fill different types of histograms
150  StatusCode fillDecisionCount(const std::vector<TrigCompositeUtils::DecisionID>& , int) const;
153  StatusCode fillHistogram(const TrigCompositeUtils::DecisionIDContainer&, int, LockedHandle<TH2>&) const;
154  StatusCode fillSequences(const std::set<std::string>&) const;
155  StatusCode fillStreamsAndGroups(const std::map<std::string, TrigCompositeUtils::DecisionIDContainer>&, const TrigCompositeUtils::DecisionIDContainer&) const;
156 };
157 
158 #endif //> !TRIGSTEERMONITOR_TRIGSIGNATUREMONI_H
TrigSignatureMoni::RateHistogram::m_timer
std::unique_ptr< Athena::AlgorithmTimer > m_timer
Definition: TrigSignatureMoni.h:87
TrigSignatureMoni::TrigSignatureMoni
TrigSignatureMoni(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigSignatureMoni.cxx:13
TrigSignatureMoni::m_groupToChainMap
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_groupToChainMap
Group name to chain objects map.
Definition: TrigSignatureMoni.h:118
TimeDivider.h
TrigSignatureMoni::RateHistogram::getTimer
std::unique_ptr< Athena::AlgorithmTimer > & getTimer()
Definition: TrigSignatureMoni.cxx:522
TrigSignatureMoni::nBCIDs
int nBCIDs() const
TrigSignatureMoni::RateHistogram::ATLAS_NOT_CONST_THREAD_SAFE
LockedHandle< TH2 > &getBuffer ATLAS_NOT_CONST_THREAD_SAFE() const
TrigSignatureMoni::RateHistogram::ATLAS_THREAD_SAFE
LockedHandle< TH2 > m_histogram ATLAS_THREAD_SAFE
Definition: TrigSignatureMoni.h:85
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
TrigSignatureMoni::m_streamToChainMap
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_streamToChainMap
Stream name to chain objects map, excluding express.
Definition: TrigSignatureMoni.h:119
TrigSignatureMoni::RateHistogram::ATLAS_NOT_CONST_THREAD_SAFE
LockedHandle< TH2 > &getHistogram ATLAS_NOT_CONST_THREAD_SAFE() const
TrigSignatureMoni::m_HLTMenuKey
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
Definition: TrigSignatureMoni.h:94
TrigSignatureMoni::RateHistogram::m_duration
unsigned int m_duration
Definition: TrigSignatureMoni.h:89
TrigSignatureMoni::m_L1MenuKey
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
Definition: TrigSignatureMoni.h:95
TrigSignatureMoni::start
virtual StatusCode start() override
Definition: TrigSignatureMoni.cxx:32
TrigSignatureMoni::fillRate
StatusCode fillRate(const TrigCompositeUtils::DecisionIDContainer &, int) const
Definition: TrigSignatureMoni.cxx:228
TrigSignatureMoni::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition: TrigSignatureMoni.h:98
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
TrigSignatureMoni::initialize
virtual StatusCode initialize() override
Definition: TrigSignatureMoni.cxx:17
TrigSignatureMoni::initSeqHist
StatusCode initSeqHist(LockedHandle< TH2 > &, std::set< std::string > &)
Definition: TrigSignatureMoni.cxx:480
TrigSignatureMoni::fillSequences
StatusCode fillSequences(const std::set< std::string > &) const
Definition: TrigSignatureMoni.cxx:252
x
#define x
TrigSignatureMoni::m_sequenceToBinMap
std::map< std::string, int > m_sequenceToBinMap
Sequence to bin map for sequence histogram.
Definition: TrigSignatureMoni.h:116
TrigSignatureMoni::initHist
StatusCode initHist(LockedHandle< TH2 > &, SG::ReadHandle< TrigConf::HLTMenu > &, bool=true)
Definition: TrigSignatureMoni.cxx:431
TrigSignatureMoni::m_expressChainMap
std::map< std::string, TrigCompositeUtils::DecisionIDContainer > m_expressChainMap
Stream name to chain objects map, including only express.
Definition: TrigSignatureMoni.h:120
TrigSignatureMoni::fillStreamsAndGroups
StatusCode fillStreamsAndGroups(const std::map< std::string, TrigCompositeUtils::DecisionIDContainer > &, const TrigCompositeUtils::DecisionIDContainer &) const
Definition: TrigSignatureMoni.cxx:260
TrigSignatureMoni::nChains
int nChains(SG::ReadHandle< TrigConf::HLTMenu > &) const
Definition: TrigSignatureMoni.cxx:415
TrigSignatureMoni::RateHistogram::startTimer
void startTimer(unsigned int duration, unsigned int intervals)
Definition: TrigSignatureMoni.cxx:530
TrigCompositeUtils.h
TrigSignatureMoni::nSequenceBins
int nSequenceBins() const
Definition: TrigSignatureMoni.cxx:419
AlgorithmTimer.h
Efficient realtime timers.
TrigSignatureMoni::fillHistogram
StatusCode fillHistogram(const TrigCompositeUtils::DecisionIDContainer &, int, LockedHandle< TH2 > &) const
Definition: TrigSignatureMoni.cxx:216
TrigSignatureMoni::RateHistogram::ATLAS_THREAD_SAFE
LockedHandle< TH2 > m_bufferHistogram ATLAS_THREAD_SAFE
Definition: TrigSignatureMoni.h:84
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TrigSignatureMoni::RateHistogram::~RateHistogram
~RateHistogram()
Definition: TrigSignatureMoni.cxx:498
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
TrigSignatureMoni::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Definition: TrigSignatureMoni.h:97
TrigSignatureMoni::ATLAS_THREAD_SAFE
LockedHandle< TH2 > m_passHistogram ATLAS_THREAD_SAFE
Definition: TrigSignatureMoni.h:109
TrigSignatureMoni::m_chainIDToBunchMap
std::map< unsigned int, std::set< std::string > > m_chainIDToBunchMap
Chain ID to bunchgroup name map.
Definition: TrigSignatureMoni.h:117
TrigSignatureMoni::fillDecisionCount
StatusCode fillDecisionCount(const std::vector< TrigCompositeUtils::DecisionID > &, int) const
Definition: TrigSignatureMoni.cxx:236
TrigSignatureMoni::RateHistogram::init
StatusCode init(const std::string &histoName, const std::string &histoTitle, const int x, const int y, const std::string &registerPath, const ServiceHandle< ITHistSvc > &histSvc)
Definition: TrigSignatureMoni.cxx:502
TrigSignatureMoni::m_sequenceHistogram
RateHistogram m_sequenceHistogram
Definition: TrigSignatureMoni.h:112
TrigSignatureMoni::nSteps
int nSteps() const
Definition: TrigSignatureMoni.cxx:423
PixelAthHitMonAlgCfg.duration
duration
Definition: PixelAthHitMonAlgCfg.py:152
TrigSignatureMoni::m_decisionCollectorTools
ToolHandleArray< DecisionCollectorTool > m_decisionCollectorTools
Definition: TrigSignatureMoni.h:105
TrigSignatureMoni::RateHistogram::callback
void callback()
Definition: TrigSignatureMoni.cxx:554
AthReentrantAlgorithm.h
TrigSignatureMoni::RateHistogram::m_timeDivider
std::unique_ptr< TimeDivider > m_timeDivider
Definition: TrigSignatureMoni.h:88
TrigSignatureMoni::m_chainIDToBinMap
std::map< unsigned int, int > m_chainIDToBinMap
Chain id to histogram bin map.
Definition: TrigSignatureMoni.h:114
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigSignatureMoni::m_featureCollectorTools
ToolHandleArray< DecisionCollectorTool > m_featureCollectorTools
Definition: TrigSignatureMoni.h:106
TrigSignatureMoni::m_intervals
Gaudi::Property< unsigned int > m_intervals
Definition: TrigSignatureMoni.h:103
TrigSignatureMoni::nBinsX
int nBinsX() const
Definition: TrigSignatureMoni.cxx:411
TrigSignatureMoni::handle
virtual void handle(const Incident &incident) override
Definition: TrigSignatureMoni.cxx:277
EventInfo.h
TrigSignatureMoni::m_nameToBinMap
std::map< std::string, int > m_nameToBinMap
Sequence/group/bunchgroup name to bin map.
Definition: TrigSignatureMoni.h:115
TrigSignatureMoni::RateHistogram::m_mutex
std::mutex m_mutex
Definition: TrigSignatureMoni.h:86
TrigSignatureMoni
Definition: TrigSignatureMoni.h:37
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
y
#define y
TrigSignatureMoni::stop
virtual StatusCode stop() override
Definition: TrigSignatureMoni.cxx:123
TrigSignatureMoni::m_finalDecisionKey
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_finalDecisionKey
Definition: TrigSignatureMoni.h:93
DecisionCollectorTool.h
TrigSignatureMoni::ATLAS_THREAD_SAFE
LockedHandle< TH2 > m_countHistogram ATLAS_THREAD_SAFE
Definition: TrigSignatureMoni.h:110
TrigComposite_v1.h
TrigSignatureMoni::RateHistogram::fill
void fill(const double x, const double y) const
Definition: TrigSignatureMoni.cxx:526
TrigSignatureMoni::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigSignatureMoni.cxx:298
TrigSignatureMoni::RateHistogram
Definition: TrigSignatureMoni.h:50
TrigSignatureMoni::nBaseSteps
int nBaseSteps() const
Definition: TrigSignatureMoni.cxx:427
TrigSignatureMoni::RateHistogram::RateHistogram
RateHistogram()=default
HLTMenu.h
TrigSignatureMoni::RateHistogram::updatePublished
void updatePublished(unsigned int duration) const
Definition: TrigSignatureMoni.cxx:547
TrigSignatureMoni::fillPassEvents
StatusCode fillPassEvents(const TrigCompositeUtils::DecisionIDContainer &, int) const
Definition: TrigSignatureMoni.cxx:232
L1Menu.h
TrigSignatureMoni::m_duration
Gaudi::Property< unsigned int > m_duration
Definition: TrigSignatureMoni.h:102
checker_macros.h
Define macros for attributes used to control the static checker.
DataStructure.h
TrigSignatureMoni::RateHistogram::stopTimer
void stopTimer()
Definition: TrigSignatureMoni.cxx:536
TrigSignatureMoni::m_bookingPath
Gaudi::Property< std::string > m_bookingPath
Definition: TrigSignatureMoni.h:99
TrigSignatureMoni::m_l1DecisionsKey
SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > m_l1DecisionsKey
Definition: TrigSignatureMoni.h:92
TrigSignatureMoni::m_rateHistogram
RateHistogram m_rateHistogram
Definition: TrigSignatureMoni.h:111
ServiceHandle< ITHistSvc >