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
21#include <unordered_map>
22#include <mutex>
23
24#include "TH1.h"
25#include "TTree.h"
26
36 public:
37
43 TrigCostAnalysis( const std::string& name, ISvcLocator* pSvcLocator );
44
48 virtual ~TrigCostAnalysis() = default;
49
53 virtual StatusCode initialize() final;
54
58 virtual StatusCode start();
59
63 virtual StatusCode execute(const EventContext& ctx) final;
64
68 virtual StatusCode finalize() final;
69
76 TH1* bookGetPointer(TH1* hist, const std::string& tDir = "") const;
77
78 ServiceHandle<ITHistSvc> m_histSvc{ this, "THistSvc", "THistSvc/THistSvc", "Histogramming svc" };
79
80 Gaudi::Property<bool> m_singleTimeRange { this, "UseSingleTimeRange", false,
81 "Use a single time range rather than splitting by LB" };
82
83 Gaudi::Property<std::string> m_singleTimeRangeName { this, "SingleTimeRangeName", "All",
84 "Name for single time range" };
85
86 Gaudi::Property<std::string> m_additionalHashMap { this, "AdditionalHashMap", "TrigCostRootAnalysis/hashes2string_29042021.txt",
87 "Used to load strings corresponding to algorithms which are not explicitly scheduled by chains. To be updated periodically." };
88
89 Gaudi::Property<std::vector<std::string>> m_additionalHashList { this, "AdditionalHashList", {},
90 "Used to load strings corresponding to algorithms which are not explicitly scheduled by chains." };
91
92 Gaudi::Property<size_t> m_TimeRangeLengthLB { this, "TimeRangeLengthLB", 50,
93 "Length of each variable length Time Range in LB" };
94
95 Gaudi::Property<size_t> m_maxTimeRange { this, "MaxTimeRanges", 5,
96 "Maximum number of allowed time ranges" };
97
98 Gaudi::Property<bool> m_doMonitorAlgorithm { this, "DoMonitorAlgs", true,
99 "Monitor individual algorithms by instance name" };
100
101 Gaudi::Property<bool> m_doMonitorAlgorithmClass { this, "DoMonitorAlgClass", true,
102 "Monitor individual algorithms by instance class type name" };
103
104 Gaudi::Property<bool> m_doMonitorGlobal { this, "DoMonitorGlobal", true,
105 "Monitor global event properties" };
106
107 Gaudi::Property<bool> m_doMonitorThreadOccupancy { this, "DoMonitorThreadOccupancy", true,
108 "Monitor algorithm occupancy load of individual threads in an MT execution environment" };
109
110 Gaudi::Property<bool> m_doMonitorChain { this, "DoMonitorChain", true,
111 "Monitor individual chains by instance name" };
112
113 Gaudi::Property<bool> m_doMonitorChainAlgorithm { this, "DoMonitorChainAlgorithm", false,
114 "Monitor algorithms associated with chains by instance name" };
115
116 Gaudi::Property<bool> m_doMonitorSequence { this, "DoMonitorSequence", true,
117 "Monitor individual sequences by name" };
118
119 Gaudi::Property<bool> m_useEBWeights { this, "UseEBWeights", true,
120 "Apply Enhanced Bias weights" };
121
122 Gaudi::Property<size_t> m_maxFullEventDumps { this, "MaxFullEventDumps", 10,
123 "Maximum number of full event summaries which will be dumped" };
124
125 Gaudi::Property<uint64_t> m_fullEventDumpProbability { this, "FullEventDumpProbability", 10,
126 "Save a full record of one in every N events, up to MaxFullEventDumps." };
127
128 Gaudi::Property<float> m_baseEventWeight { this, "BaseEventWeight", true,
129 "Base events weight, other weights may be multiplied on top of this one." };
130
131 Gaudi::Property<std::set<std::string>> m_excludeAlgsFromChain {
132 this, "ExcludeAlgsFromChainTime", {}, "Algorithms to exclude from chain time calculation"};
133
134 SG::ReadHandleKey<xAOD::TrigCompositeContainer> m_costDataKey { this, "CostReadHandleKey", "HLT_TrigCostContainer",
135 "Trigger cost payload container for algorithms" };
136
137 SG::ReadHandleKey<xAOD::TrigCompositeContainer> m_metadataDataKey { this, "CostMetadataWriteHandleKey", "HLT_RuntimeMetadata",
138 "TrigComposite collections with additional cost metadata" };
139
140 SG::ReadHandleKey<TrigConf::HLTMenu> m_HLTMenuKey{this, "HLTTriggerMenu", "DetectorStore+HLTTriggerMenu",
141 "HLT Menu"};
142
143 ToolHandle<IEnhancedBiasWeighter> m_enhancedBiasTool{this, "EnhancedBiasTool", "",
144 "Enhanced bias weighting tool."};
145
146 ToolHandle<TrigCompositeUtils::AlgToChainTool> m_algToChainTool{this, "AlgToChainTool", "",
147 "Tool to retrieve chains for algorithm."};
148
149 private:
150
157 bool checkDoFullEventDump(const EventContext& context, const CostData& costData);
158
166 StatusCode getRange(const EventContext& context, MonitoredRange*& range);
167
172 StatusCode dumpEvent(const EventContext& context) const;
173
178 StatusCode registerMonitors(MonitoredRange* range);
179
185 float getWeight(const EventContext& context);
186
192 uint32_t getOnlineSlot(const xAOD::TrigCompositeContainer* costCollection) const;
193
198 StatusCode checkUpdateMaxView(const size_t max);
199
203 void writeMetadata();
204
205 std::unordered_map<std::string, std::unique_ptr<MonitoredRange> > m_monitoredRanges;
206 std::unordered_map<uint32_t, std::string > m_algTypeMap;
207 std::set<std::string> m_storeIdentifiers;
209
210 mutable std::atomic<size_t> m_fullEventDumps;
211 mutable std::atomic<size_t> m_maxViewsNumber;
213 mutable std::set<std::string> m_hostnames ATLAS_THREAD_SAFE;
214
215};
216
217#endif // TRIGCOSTANALYSIS_TRIGCOSTALYSIS_H
#define max(a, b)
Definition cfImp.cxx:41
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Caches and propagates event data to be used by monitoring algorithms.
Definition CostData.h:26
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
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 StatusCode execute(const EventContext &ctx) final
Monitor event, unless max range limit reached and event outside of all ranges.
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
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
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.
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.