5#ifndef TRIGCOSTMONITOR_TRIGCOSTSVC_H
6#define TRIGCOSTMONITOR_TRIGCOSTSVC_H
13#include "GaudiKernel/ToolHandle.h"
36class TrigCostSvc :
public extends <AthService, ITrigCostSvc> {
44 TrigCostSvc(
const std::string& name, ISvcLocator* pSvcLocator);
59 virtual StatusCode
finalize()
override;
67 virtual StatusCode
startEvent(
const EventContext& context,
const bool enableMonitoring =
true)
override;
75 virtual StatusCode
processAlg(
const EventContext& context,
const std::string& caller,
const AuditType
type)
override;
89 virtual bool isMonitoredEvent(
const EventContext& context,
const bool includeMultiSlot =
true)
const override;
110 virtual StatusCode
discardEvent(
const EventContext& context)
override;
129 StatusCode
checkSlot(
const EventContext& context)
const;
136 int32_t
getROIID(
const EventContext& context);
143 static size_t hash(
const std::thread::id& thread);
144 static bool equal(
const std::thread::id&
x,
const std::thread::id&
y);
155 tbb::concurrent_hash_map<std::thread::id, AlgorithmIdentifier, ThreadHashCompare>
m_threadToAlgMap;
161 Gaudi::Property<bool>
m_monitorAllEvents{
this,
"MonitorAllEvents",
false,
"Monitor every HLT event, e.g. for offline validation."};
162 Gaudi::Property<bool>
m_enableMultiSlot{
this,
"EnableMultiSlot",
false,
"Monitored events in the MasterSlot collect data from events running in other slots."};
163 Gaudi::Property<bool>
m_saveHashes{
this,
"SaveHashes",
false,
"Store a copy of the hash dictionary for easier debugging"};
164 Gaudi::Property<size_t>
m_masterSlot{
this,
"MasterSlot", 0,
"The slot responsible for saving MultiSlot data"};
165 Gaudi::Property<std::string>
m_costSupervisorAlgName{
this,
"CostSupervisorAlgName",
"TrigCostSupervisorAlg",
"The name of cost monitoring supervising algorithm, starting at the begining of the event"};
166 Gaudi::Property<std::string>
m_costFinalizeAlgName{
this,
"CostFinalizeAlgName",
"TrigCostFinalizeAlg",
"The name of cost monitoring finalize algorithm, starting at the end of the event"};
DataVector adapter that acts like it holds const pointers.
Handle class for recording to StoreGate.
Thread safe and multi-slot hash-map to cache PAYLOAD objects/primitives during event execution.
virtual StatusCode processAlg(const EventContext &context, const std::string &caller, const AuditType type) override
Implementation of ITrigCostSvc::processAlg.
Gaudi::Property< bool > m_monitorAllEvents
Gaudi::Property< bool > m_saveHashes
Gaudi::Property< std::string > m_costFinalizeAlgName
std::mutex m_globalMutex
Used to protect all-slot modifications.
TrigCostDataStore< AlgorithmPayload > m_algStartInfo
Thread-safe store of algorithm start payload.
StatusCode checkSlot(const EventContext &context) const
Sanity check that the job is respecting the number of slots which were declared at config time.
TrigCostDataStore< TrigTimeStamp > m_algStopTime
Thread-safe store of algorithm stop times.
Gaudi::Property< bool > m_enableMultiSlot
virtual StatusCode initialize() override
Initialise, create enough storage to store m_eventSlots.
size_t m_eventSlots
Number of concurrent processing slots.
virtual ~TrigCostSvc()
Destructor.
std::unique_ptr< std::shared_mutex[] > m_slotMutex
Used to control and protect whole-table operations.
virtual StatusCode monitorROS(const EventContext &context, robmonitor::ROBDataMonitorStruct payload) override
Implementation of ITrigCostSvc::monitorROS.
virtual bool isMonitoredEvent(const EventContext &context, const bool includeMultiSlot=true) const override
std::unique_ptr< std::atomic< bool >[] > m_eventMonitored
Used to cache if the event in a given slot is being monitored.
virtual StatusCode endEvent(const EventContext &context, SG::WriteHandle< xAOD::TrigCompositeContainer > &costOutputHandle, SG::WriteHandle< xAOD::TrigCompositeContainer > &rosOutputHandle) override
Implementation of ITrigCostSvc::endEvent.
int32_t getROIID(const EventContext &context)
@breif Internal function to return a RoI from an extended event context context
virtual StatusCode discardEvent(const EventContext &context) override
Discard a cost monitored event.
Gaudi::Property< std::string > m_costSupervisorAlgName
TrigCostDataStore< std::vector< robmonitor::ROBDataMonitorStruct > > m_rosData
Thread-safe store of ROS data.
TrigCostSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard ATLAS Service constructor.
Gaudi::Property< size_t > m_masterSlot
virtual StatusCode finalize() override
Finalize, act on m_saveHashes.
virtual StatusCode generateTimeoutReport(const EventContext &context, std::string &report) override
StatusCode monitor(const EventContext &context, const AlgorithmIdentifier &ai, const TrigTimeStamp &now, const AuditType type)
Internal call to save monitoring data for a given AlgorithmIdentifier.
size_t m_threadCounter
Count how many unique thread ID we have seen.
tbb::concurrent_hash_map< std::thread::id, AlgorithmIdentifier, ThreadHashCompare > m_threadToAlgMap
Keeps track of what is running right now in each thread.
std::unordered_map< uint32_t, uint32_t > m_threadToCounterMap
Map thread's hash ID to a counting numeral.
virtual StatusCode startEvent(const EventContext &context, const bool enableMonitoring=true) override
Implementation of ITrigCostSvc::startEvent.
utility class to measure time duration in AthenaMT The pattern when it is useful: AlgA tags the begin...
The structure which is used to monitor the ROB data request in L2 It is created for every addROBData ...
Small structure to hold an algorithm's name and store, plus some details on its EventView.
Static hash and equal members as required by tbb::concurrent_hash_map.
static bool equal(const std::thread::id &x, const std::thread::id &y)
static size_t hash(const std::thread::id &thread)