ATLAS Offline Software
Loading...
Searching...
No Matches
TrigCostAnalysis.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGCOSTANALYSIS_TRIGCOSTALYSIS_H
6#define TRIGCOSTANALYSIS_TRIGCOSTALYSIS_H 1
7
13
15
16#include "Gaudi/Parsers/Factory.h"
17#include "GaudiKernel/ITHistSvc.h"
18
19#include "MonitoredRange.h"
20#include "CostROSData.h"
21
22#include <unordered_map>
23#include <mutex>
24
25#include "TH1.h"
26#include "TTree.h"
27
37 public:
38
44 TrigCostAnalysis( const std::string& name, ISvcLocator* pSvcLocator );
45
49 virtual ~TrigCostAnalysis() = default;
50
54 virtual StatusCode initialize() final;
55
59 virtual StatusCode start();
60
64 virtual StatusCode execute() final;
65
69 virtual StatusCode finalize() final;
70
77 TH1* bookGetPointer(TH1* hist, const std::string& tDir = "") const;
78
79 ServiceHandle<ITHistSvc> m_histSvc{ this, "THistSvc", "THistSvc/THistSvc", "Histogramming svc" };
80
81 Gaudi::Property<bool> m_singleTimeRange { this, "UseSingleTimeRange", false,
82 "Use a single time range rather than splitting by LB" };
83
84 Gaudi::Property<std::string> m_singleTimeRangeName { this, "SingleTimeRangeName", "All",
85 "Name for single time range" };
86
87 Gaudi::Property<std::string> m_additionalHashMap { this, "AdditionalHashMap", "TrigCostRootAnalysis/hashes2string_29042021.txt",
88 "Used to load strings corresponding to algorithms which are not explicitly scheduled by chains. To be updated periodically." };
89
90 Gaudi::Property<std::vector<std::string>> m_additionalHashList { this, "AdditionalHashList", {},
91 "Used to load strings corresponding to algorithms which are not explicitly scheduled by chains." };
92
93 Gaudi::Property<size_t> m_TimeRangeLengthLB { this, "TimeRangeLengthLB", 50,
94 "Length of each variable length Time Range in LB" };
95
96 Gaudi::Property<size_t> m_maxTimeRange { this, "MaxTimeRanges", 5,
97 "Maximum number of allowed time ranges" };
98
99 Gaudi::Property<bool> m_doMonitorAlgorithm { this, "DoMonitorAlgs", true,
100 "Monitor individual algorithms by instance name" };
101
102 Gaudi::Property<bool> m_doMonitorAlgorithmClass { this, "DoMonitorAlgClass", true,
103 "Monitor individual algorithms by instance class type name" };
104
105 Gaudi::Property<bool> m_doMonitorGlobal { this, "DoMonitorGlobal", true,
106 "Monitor global event properties" };
107
108 Gaudi::Property<bool> m_doMonitorThreadOccupancy { this, "DoMonitorThreadOccupancy", true,
109 "Monitor algorithm occupancy load of individual threads in an MT execution environment" };
110
111 Gaudi::Property<bool> m_doMonitorROS { this, "DoMonitorROS", true,
112 "Monitor Read-Out System" };
113
114 Gaudi::Property<bool> m_doMonitorChain { this, "DoMonitorChain", true,
115 "Monitor individual chains by instance name" };
116
117 Gaudi::Property<bool> m_doMonitorChainAlgorithm { this, "DoMonitorChainAlgorithm", false,
118 "Monitor algorithms associated with chains by instance name" };
119
120 Gaudi::Property<bool> m_doMonitorSequence { this, "DoMonitorSequence", true,
121 "Monitor individual sequences by name" };
122
123 Gaudi::Property<bool> m_useEBWeights { this, "UseEBWeights", true,
124 "Apply Enhanced Bias weights" };
125
126 Gaudi::Property<size_t> m_maxFullEventDumps { this, "MaxFullEventDumps", 10,
127 "Maximum number of full event summaries which will be dumped" };
128
129 Gaudi::Property<uint64_t> m_fullEventDumpProbability { this, "FullEventDumpProbability", 10,
130 "Save a full record of one in every N events, up to MaxFullEventDumps." };
131
132 Gaudi::Property<float> m_baseEventWeight { this, "BaseEventWeight", true,
133 "Base events weight, other weights may be multiplied on top of this one." };
134
135 Gaudi::Property<std::map<std::string, std::vector<uint32_t>>> m_rosToRob {
136 this, "ROSToROBMap", {}, "ROS to ROB mapping" };
137
138 Gaudi::Property<std::set<std::string>> m_excludeAlgsFromChain {
139 this, "ExcludeAlgsFromChainTime", {}, "Algorithms to exclude from chain time calculation"};
140
141 SG::ReadHandleKey<xAOD::TrigCompositeContainer> m_costDataKey { this, "CostReadHandleKey", "HLT_TrigCostContainer",
142 "Trigger cost payload container for algorithms" };
143
144 SG::ReadHandleKey<xAOD::TrigCompositeContainer> m_rosDataKey { this, "CostROSReadHandleKey", "HLT_TrigCostROSContainer",
145 "Trigger ROS cost payload container for algorithms" };
146
147 SG::ReadHandleKey<xAOD::TrigCompositeContainer> m_metadataDataKey { this, "CostMetadataWriteHandleKey", "HLT_RuntimeMetadata",
148 "TrigComposite collections with additional cost metadata" };
149
150 SG::ReadHandleKey<TrigConf::HLTMenu> m_HLTMenuKey{this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu",
151 "HLT Menu"};
152
153 ToolHandle<IEnhancedBiasWeighter> m_enhancedBiasTool{this, "EnhancedBiasTool", "",
154 "Enhanced bias weighting tool."};
155
156 ToolHandle<TrigCompositeUtils::AlgToChainTool> m_algToChainTool{this, "AlgToChainTool", "",
157 "Tool to retrieve chains for algorithm."};
158
159 private:
160
167 bool checkDoFullEventDump(const EventContext& context, const CostData& costData);
168
176 StatusCode getRange(const EventContext& context, MonitoredRange*& range);
177
182 StatusCode dumpEvent(const EventContext& context) const;
183
188 StatusCode registerMonitors(MonitoredRange* range);
189
195 float getWeight(const EventContext& context);
196
202 uint32_t getOnlineSlot(const xAOD::TrigCompositeContainer* costCollection) const;
203
208 StatusCode checkUpdateMaxView(const size_t max);
209
213 void writeMetadata();
214
215 std::unordered_map<std::string, std::unique_ptr<MonitoredRange> > m_monitoredRanges;
216 std::unordered_map<uint32_t, std::string > m_algTypeMap;
217 std::set<std::string> m_storeIdentifiers;
219
220 mutable std::atomic<size_t> m_fullEventDumps;
221 mutable std::atomic<size_t> m_maxViewsNumber;
223 mutable std::set<std::string> m_hostnames ATLAS_THREAD_SAFE;
224
226};
227
228#endif // TRIGCOSTANALYSIS_TRIGCOSTALYSIS_H
#define max(a, b)
Definition cfImp.cxx:41
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Caches and propagates event data to be used by monitoring algorithms.
Definition CostData.h:26
Caches and propagates event data to be used by monitoring algorithms.
Definition CostROSData.h:24
Container which represents a time range and holds a collection of Monitors which monitor this range.
Property holding a SG store/key/clid from which a ReadHandle is made.
Gaudi::Property< bool > m_useEBWeights
uint32_t getOnlineSlot(const xAOD::TrigCompositeContainer *costCollection) const
Return the slot used to process the event online.
std::unordered_map< std::string, std::unique_ptr< MonitoredRange > > m_monitoredRanges
Owned storage of Ranges.
Gaudi::Property< bool > m_singleTimeRange
Gaudi::Property< std::set< std::string > > m_excludeAlgsFromChain
Gaudi::Property< std::vector< std::string > > m_additionalHashList
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_metadataDataKey
Gaudi::Property< bool > m_doMonitorAlgorithm
Gaudi::Property< bool > m_doMonitorChainAlgorithm
Gaudi::Property< bool > m_doMonitorROS
virtual StatusCode finalize() final
Currently a noop for this algorithm.
Gaudi::Property< float > m_baseEventWeight
TH1 * bookGetPointer(TH1 *hist, const std::string &tDir="") const
Public method forwarded to this class' AthHistogramAlgorithm::bookGetPointer base.
ServiceHandle< ITHistSvc > m_histSvc
Gaudi::Property< bool > m_doMonitorSequence
std::atomic< size_t > m_maxViewsNumber
What is the maximum number of View instances we've so far cached string hashes to cover?
virtual StatusCode start()
Retrieve menu handle.
virtual ~TrigCostAnalysis()=default
Default destructor.
void writeMetadata()
Write to outpute tree (if any) the metadata needed downstream.
std::set< std::string > m_hostnames ATLAS_THREAD_SAFE
Save unique hostnames for the run.
ToolHandle< IEnhancedBiasWeighter > m_enhancedBiasTool
Gaudi::Property< size_t > m_maxFullEventDumps
Gaudi::Property< std::string > m_additionalHashMap
Gaudi::Property< std::map< std::string, std::vector< uint32_t > > > m_rosToRob
std::mutex m_addHostnameMutex
Mutex to update set below.
StatusCode getRange(const EventContext &context, MonitoredRange *&range)
Return or construct and return a Range for the Context.
std::unordered_map< uint32_t, std::string > m_algTypeMap
Cache of algorithm's type, read from configuration data.
Gaudi::Property< size_t > m_maxTimeRange
Gaudi::Property< bool > m_doMonitorThreadOccupancy
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_rosDataKey
virtual StatusCode execute() final
Monitor event, unless max range limit reached and event outside of all ranges.
StatusCode registerMonitors(MonitoredRange *range)
Populate a newly minted Range object with all configured Monitors.
Gaudi::Property< bool > m_doMonitorGlobal
Gaudi::Property< size_t > m_TimeRangeLengthLB
StatusCode checkUpdateMaxView(const size_t max)
High watermark for pre-cached string hashes for the SLOT category.
virtual StatusCode initialize() final
Retrieve tools and initialise read handles.
CostROSData m_costROSData
Cached CostROSData class with details needed for ROS monitoring.
SG::ReadHandleKey< xAOD::TrigCompositeContainer > m_costDataKey
TTree * m_metadataTree
Used to write out some metadata needed by post-processing (e.g.
TrigCostAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
Construct TrigCostAnalysis.
SG::ReadHandleKey< TrigConf::HLTMenu > m_HLTMenuKey
ToolHandle< TrigCompositeUtils::AlgToChainTool > m_algToChainTool
std::set< std::string > m_storeIdentifiers
Identifiers of object stores, needed to cache STORE string-hash values.
Gaudi::Property< bool > m_doMonitorChain
StatusCode dumpEvent(const EventContext &context) const
Dump event algorithm execution data in ASCII format.
Gaudi::Property< bool > m_doMonitorAlgorithmClass
Gaudi::Property< uint64_t > m_fullEventDumpProbability
std::atomic< size_t > m_fullEventDumps
Counter to keep track of how many events have been full-dumped.
Gaudi::Property< std::string > m_singleTimeRangeName
float getWeight(const EventContext &context)
Compute global event weight to correct for online prescales.
bool checkDoFullEventDump(const EventContext &context, const CostData &costData)
Check if event dumping should be performed for the current event.
STL namespace.
TrigCompositeContainer_v1 TrigCompositeContainer
Declare the latest version of the container.