ATLAS Offline Software
Loading...
Searching...
No Matches
HltROBDataProviderSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef TRIGSERVICES_HLTROBDATAPROVIDERSVC_H
5#define TRIGSERVICES_HLTROBDATAPROVIDERSVC_H
11
12// Package includes
15#include "eformat/SourceIdentifier.h"
16
17// Framework includes
23
24// STL includes
25#include <string>
26#include <string_view>
27#include <vector>
28#include <map>
29#include <mutex>
30
31// TBB includes
32#include "tbb/concurrent_unordered_map.h"
33
38class HltROBDataProviderSvc : public extends<AthService, IROBDataProviderSvc> {
39public:
42
43 HltROBDataProviderSvc(const std::string& name, ISvcLocator* pSvcLocator);
44
45 virtual StatusCode initialize() override;
46 virtual StatusCode finalize() override;
47
49 virtual void addROBData(const EventContext& /*context*/, const std::vector<uint32_t>& /*robIds*/,
50 const std::string_view callerName="UNKNOWN") override;
51
53 virtual void setNextEvent(const EventContext& /*context*/, const std::vector<ROBF>& /*result*/) override;
54
56 virtual void setNextEvent(const EventContext& /*context*/, const RawEvent* /*re*/) override;
57
59 virtual void getROBData(const EventContext& /*context*/,
60 const std::vector<uint32_t>& /*robIds*/, std::vector<const ROBF*>& /*robFragments*/,
61 const std::string_view callerName="UNKNOWN") override;
62
64 virtual const RawEvent* getEvent(const EventContext& /*context*/) override;
65
67 virtual void setEventStatus(const EventContext& /*context*/, uint32_t /*status*/) override;
68
70 virtual uint32_t getEventStatus(const EventContext& /*context*/) override;
71
73 virtual void processCachedROBs(const EventContext& /*context*/, const std::function< void(const ROBF* )>& /*fn*/) const override;
74
76 virtual bool isEventComplete(const EventContext& /*context*/) const override;
77
79 virtual int collectCompleteEventData(const EventContext& /*context*/,
80 const std::string_view callerName="UNKNOWN") override;
81
82private:
83 /*--------------+
84 * Event cache |
85 *--------------+
86 */
88 typedef tbb::concurrent_unordered_map<uint32_t, ROBF> ROBMAP;
89
91 struct EventCache {
93 const RawEvent* event = 0;
94 uint32_t currentLvl1ID = 0;
95 uint64_t globalEventNumber = 0;
96 uint32_t eventStatus = 0;
97 bool isEventComplete = false;
100 std::mutex eventCache_mtx;
101 };
102
105
106 /*------------------------------+
107 * Attributes for configuration |
108 *------------------------------+
109 */
111 typedef std::vector< std::pair<int, int> > ArrayPairIntType;
112 Gaudi::Property< ArrayPairIntType > m_filterRobWithStatus{
113 this, "filterRobWithStatus", {} , "List of ROBs with status code to remove"};
114 Gaudi::Property< ArrayPairIntType > m_filterSubDetWithStatus{
115 this, "filterSubDetWithStatus", {} , "List of SubDets with status code to remove"};
116
118 typedef std::map<uint32_t, std::vector<uint32_t> > FilterRobMap;
121 typedef std::map<eformat::SubDetector, std::vector<uint32_t> > FilterSubDetMap;
123
125 Gaudi::Property<bool> m_filterEmptyROB{
126 this, "filterEmptyROB", false , "Filter out empty ROB fragments"};
127
130 bool m_maskL2EFModuleID = false;
131
132 // read enabled ROBs from OKS when possible
133 Gaudi::Property<bool> m_readROBfromOKS{
134 this, "readROBfromOKS", true , "Read enabled ROBs from OKS"};
135
136 // list of all enabled ROBs which can be retrieved
137 Gaudi::Property< std::vector<uint32_t> > m_enabledROBs{
138 this, "enabledROBs", {} , "Enabled ROBs for retrieval"};
139
140 // prefetch all ROBs from a ROS if ROB data from this ROS are requested
141 Gaudi::Property<bool> m_prefetchAllROBsfromROS{
142 this, "prefetchAllROBsfromROS", false , "When ROBs from a ROS are requested then prefetch all ROBs in this ROS"};
143 // list of sub-detector ids for which all ROBs in their ROSes are prefetched
144 // list empty or sub-det ID = 0x0 --> all ROSes will use complete prefetching
145 // For sub-detector specific prefetching sub-detector IDs or sub-detector groups should be specified.
146 // Both types of identifiers can be mixed,
147 // e.g. [ 0x4, 0x5, 0x13, 0x14 ] means prefetching is used for all LAR and TILE ROSes and
148 // for the ROSes of PIXEL_B_LAYER and PIXEL_IBL
149 Gaudi::Property< std::vector<uint8_t> > m_prefetchSubDetROS{
150 this, "prefetchSubDetROS", {} , "List of sub-detectors for which whole ROS prefetching is used"};
151 // internal array, which holds list of ROBs for whole ROS prefetching
152 std::vector<uint32_t> m_prefetchWholeROSList ;
153
154 Gaudi::Property<bool> m_doCostMonitoring{
155 this, "doCostMonitoring", false, "Enables start-of-event cost monitoring behavior."};
156
158 this, "TrigCostSvc", "TrigCostSvc", "The trigger cost service" };
159
160 /*------------------------+
161 * Methods acting on ROBs |
162 *------------------------+
163 */
165 bool robmap_filterRobWithStatus(const ROBF*);
166
173
174 /*------------------------------+
175 * Methods acting on EventCache |
176 *------------------------------+
177 */
181 void eventCache_clear(EventCache*);
182
191 void eventCache_checkRobListToCache(EventCache*, const std::vector<uint32_t>&,
192 std::vector<const ROBF*>&, std::vector<uint32_t>&,
193 std::optional<std::reference_wrapper<std::set<uint32_t>>> robIds_disabled = std::nullopt);
194
201 void eventCache_addRobData(EventCache*, std::vector<ROBF>&&,
202 std::optional<std::reference_wrapper<std::set<uint32_t>>> robIds_ignored = std::nullopt) ;
203
205 ToolHandle<GenericMonitoringTool> m_monTool{this, "MonTool", "", "Monitoring tool"};
206};
207
208#endif // TRIGSERVICES_HLTROBDATAPROVIDERSVC_H
Maintain a set of objects, one per slot.
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
Header file to be included by clients of the Monitored infrastructure.
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
std::vector< uint32_t > m_prefetchWholeROSList
virtual uint32_t getEventStatus(const EventContext &) override
Retrieve the status for the event.
virtual void setEventStatus(const EventContext &, uint32_t) override
Store the status for the event.
virtual void setNextEvent(const EventContext &, const std::vector< ROBF > &) override
Start a new event with a set of ROB fragments, e.g. from LVL1 result, in online and add the fragments...
Gaudi::Property< std::vector< uint32_t > > m_enabledROBs
ServiceHandle< ITrigCostSvc > m_trigCostSvcHandle
HltROBDataProviderSvc(const std::string &name, ISvcLocator *pSvcLocator)
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF
ROB Fragment class.
robmonitor::ROBDataStruct robmap_getRobData(const ROBF &, robmonitor::ROBHistory)
method to get ROB fragment from ROBF input: context ROB fragment to be parsed ROB history status
void eventCache_clear(EventCache *)
method to clear an event cache in a slot input: pointer to cache
Gaudi::Property< ArrayPairIntType > m_filterRobWithStatus
bool robmap_filterRobWithStatus(const ROBF *)
method to filter ROBs with given Status code
void eventCache_checkRobListToCache(EventCache *, const std::vector< uint32_t > &, std::vector< const ROBF * > &, std::vector< uint32_t > &, std::optional< std::reference_wrapper< std::set< uint32_t > > > robIds_disabled=std::nullopt)
method to compare a list of ROB Ids to the ones in an event cache in a slot input: pointer to cache v...
virtual void addROBData(const EventContext &, const std::vector< uint32_t > &, const std::string_view callerName="UNKNOWN") override
Signal ROB fragments which should be considered for prefetching in online running.
virtual void getROBData(const EventContext &, const std::vector< uint32_t > &, std::vector< const ROBF * > &, const std::string_view callerName="UNKNOWN") override
Retrieve ROB fragments for given ROB ids from the ROB cache.
virtual StatusCode finalize() override
Gaudi::Property< bool > m_prefetchAllROBsfromROS
virtual StatusCode initialize() override
void eventCache_addRobData(EventCache *, std::vector< ROBF > &&, std::optional< std::reference_wrapper< std::set< uint32_t > > > robIds_ignored=std::nullopt)
method to add ROB fragments to an event cache in a slot input: pointer to cache vector of ROB fragmen...
virtual int collectCompleteEventData(const EventContext &, const std::string_view callerName="UNKNOWN") override
retrieve in online running all ROBs for the event from the readout system. Only those ROBs are retrie...
Gaudi::Property< ArrayPairIntType > m_filterSubDetWithStatus
std::map< uint32_t, std::vector< uint32_t > > FilterRobMap
map of full ROB Source ids and status words to be ignored for the ROB map
tbb::concurrent_unordered_map< uint32_t, ROBF > ROBMAP
map for all the ROB fragments
virtual bool isEventComplete(const EventContext &) const override
Flag to check if all event data have been retrieved.
virtual void processCachedROBs(const EventContext &, const std::function< void(const ROBF *)> &) const override
Apply a function to all ROBs in the cache.
ToolHandle< GenericMonitoringTool > m_monTool
Monitoring tool.
std::vector< std::pair< int, int > > ArrayPairIntType
vector of Source ids and status words to be ignored for the ROB map
virtual const RawEvent * getEvent(const EventContext &) override
Retrieve the full event fragment.
Gaudi::Property< std::vector< uint8_t > > m_prefetchSubDetROS
SG::SlotSpecificObj< EventCache > m_eventsCache
An event cache for each slot.
Gaudi::Property< bool > m_filterEmptyROB
Filter out empty ROB fragments which are send by the ROS.
Gaudi::Property< bool > m_readROBfromOKS
Gaudi::Property< bool > m_doCostMonitoring
std::map< eformat::SubDetector, std::vector< uint32_t > > FilterSubDetMap
map of Sub Det Source ids and status words to be ignored for the ROB map
bool m_maskL2EFModuleID
For Run 1 the module ID for the Lvl2/EF result contained the machine ID and needed to be filtered out...
Maintain a set of objects, one per slot.
A structure with data about ROB properties.
eformat::ROBFragment< PointerType > ROBFragment
Definition RawEvent.h:27
ROBHistory
A structure with data about ROB properties.
struct which provides the event cache for each slot
std::mutex eventCache_mtx
mutex for ROB cache updates