ATLAS Offline Software
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
6 
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 
38 class HltROBDataProviderSvc : public extends<AthService, IROBDataProviderSvc> {
39 public:
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 
82 private:
83  /*--------------+
84  * Event cache |
85  *--------------+
86  */
88  typedef tbb::concurrent_unordered_map<uint32_t, ROBF> ROBMAP;
89 
91  struct EventCache {
92  ~EventCache();
93  const RawEvent* event = 0;
97  bool isEventComplete = false;
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
HltROBDataProviderSvc::finalize
virtual StatusCode finalize() override
Definition: HltROBDataProviderSvc.cxx:192
HltROBDataProviderSvc::setNextEvent
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...
Definition: HltROBDataProviderSvc.cxx:239
HltROBDataProviderSvc::getEventStatus
virtual uint32_t getEventStatus(const EventContext &) override
Retrieve the status for the event.
Definition: HltROBDataProviderSvc.cxx:451
robmonitor::ROBDataStruct
A structure with data about ROB properties.
Definition: ROBDataMonitor.h:39
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
robmonitor::ROBHistory
ROBHistory
A structure with data about ROB properties.
Definition: ROBDataMonitor.h:26
HltROBDataProviderSvc::getROBData
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.
Definition: HltROBDataProviderSvc.cxx:304
HltROBDataProviderSvc::m_eventsCache
SG::SlotSpecificObj< EventCache > m_eventsCache
An event cache for each slot.
Definition: HltROBDataProviderSvc.h:104
HltROBDataProviderSvc::m_filterSubDetMap
FilterSubDetMap m_filterSubDetMap
Definition: HltROBDataProviderSvc.h:122
HltROBDataProviderSvc::m_prefetchAllROBsfromROS
Gaudi::Property< bool > m_prefetchAllROBsfromROS
Definition: HltROBDataProviderSvc.h:141
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
HltROBDataProviderSvc::EventCache
struct which provides the event cache for each slot
Definition: HltROBDataProviderSvc.h:91
HltROBDataProviderSvc::EventCache::~EventCache
~EventCache()
Definition: HltROBDataProviderSvc.cxx:714
HltROBDataProviderSvc::m_filterEmptyROB
Gaudi::Property< bool > m_filterEmptyROB
Filter out empty ROB fragments which are send by the ROS.
Definition: HltROBDataProviderSvc.h:125
ROBDataMonitor.h
HltROBDataProviderSvc::robmap_getRobData
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
Definition: HltROBDataProviderSvc.cxx:426
ROBF
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment ROBF
Definition: ByteStreamMergeOutputSvc.cxx:16
HltROBDataProviderSvc::EventCache::robmap
ROBMAP robmap
Definition: HltROBDataProviderSvc.h:98
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
HltROBDataProviderSvc::processCachedROBs
virtual void processCachedROBs(const EventContext &, const std::function< void(const ROBF *)> &) const override
Apply a function to all ROBs in the cache.
Definition: HltROBDataProviderSvc.cxx:458
HltROBDataProviderSvc::initialize
virtual StatusCode initialize() override
Definition: HltROBDataProviderSvc.cxx:30
eformat::ROBFragment
Definition: L1CaloBsDecoderUtil.h:12
HltROBDataProviderSvc::ArrayPairIntType
std::vector< std::pair< int, int > > ArrayPairIntType
vector of Source ids and status words to be ignored for the ROB map
Definition: HltROBDataProviderSvc.h:111
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
HltROBDataProviderSvc::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Monitoring tool.
Definition: HltROBDataProviderSvc.h:205
ITrigCostSvc.h
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
HltROBDataProviderSvc::eventCache_clear
void eventCache_clear(EventCache *)
method to clear an event cache in a slot input: pointer to cache
Definition: HltROBDataProviderSvc.cxx:585
HltROBDataProviderSvc::m_maskL2EFModuleID
bool m_maskL2EFModuleID
For Run 1 the module ID for the Lvl2/EF result contained the machine ID and needed to be filtered out...
Definition: HltROBDataProviderSvc.h:130
HltROBDataProviderSvc::m_prefetchSubDetROS
Gaudi::Property< std::vector< uint8_t > > m_prefetchSubDetROS
Definition: HltROBDataProviderSvc.h:149
HltROBDataProviderSvc::EventCache::eventStatus
uint32_t eventStatus
Definition: HltROBDataProviderSvc.h:96
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
HltROBDataProviderSvc::m_readROBfromOKS
Gaudi::Property< bool > m_readROBfromOKS
Definition: HltROBDataProviderSvc.h:133
HltROBDataProviderSvc
ROBDataProvider service for retrieving and serving ROB data in HLT online.
Definition: HltROBDataProviderSvc.h:38
HltROBDataProviderSvc::m_filterRobMap
FilterRobMap m_filterRobMap
Definition: HltROBDataProviderSvc.h:119
HltROBDataProviderSvc::m_filterSubDetWithStatus
Gaudi::Property< ArrayPairIntType > m_filterSubDetWithStatus
Definition: HltROBDataProviderSvc.h:114
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
HltROBDataProviderSvc::m_doCostMonitoring
Gaudi::Property< bool > m_doCostMonitoring
Definition: HltROBDataProviderSvc.h:154
HltROBDataProviderSvc::setEventStatus
virtual void setEventStatus(const EventContext &, uint32_t) override
Store the status for the event.
Definition: HltROBDataProviderSvc.cxx:444
HltROBDataProviderSvc::m_trigCostSvcHandle
ServiceHandle< ITrigCostSvc > m_trigCostSvcHandle
Definition: HltROBDataProviderSvc.h:157
HltROBDataProviderSvc::ROBF
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF
ROB Fragment class.
Definition: HltROBDataProviderSvc.h:41
HltROBDataProviderSvc::eventCache_addRobData
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...
Definition: HltROBDataProviderSvc.cxx:651
HltROBDataProviderSvc::addROBData
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.
Definition: HltROBDataProviderSvc.cxx:201
HltROBDataProviderSvc::EventCache::globalEventNumber
uint64_t globalEventNumber
Definition: HltROBDataProviderSvc.h:95
HltROBDataProviderSvc::HltROBDataProviderSvc
HltROBDataProviderSvc(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HltROBDataProviderSvc.cxx:25
HltROBDataProviderSvc::isEventComplete
virtual bool isEventComplete(const EventContext &) const override
Flag to check if all event data have been retrieved.
Definition: HltROBDataProviderSvc.cxx:468
HltROBDataProviderSvc::collectCompleteEventData
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...
Definition: HltROBDataProviderSvc.cxx:475
HltROBDataProviderSvc::EventCache::eventCache_mtx
std::mutex eventCache_mtx
mutex for ROB cache updates
Definition: HltROBDataProviderSvc.h:100
AthService.h
HltROBDataProviderSvc::ROBMAP
tbb::concurrent_unordered_map< uint32_t, ROBF > ROBMAP
map for all the ROB fragments
Definition: HltROBDataProviderSvc.h:88
SlotSpecificObj.h
Maintain a set of objects, one per slot.
HltROBDataProviderSvc::FilterSubDetMap
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
Definition: HltROBDataProviderSvc.h:121
HltROBDataProviderSvc::getEvent
virtual const RawEvent * getEvent(const EventContext &) override
Retrieve the full event fragment.
Definition: HltROBDataProviderSvc.cxx:437
HltROBDataProviderSvc::FilterRobMap
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
Definition: HltROBDataProviderSvc.h:118
HltROBDataProviderSvc::m_enabledROBs
Gaudi::Property< std::vector< uint32_t > > m_enabledROBs
Definition: HltROBDataProviderSvc.h:137
HltROBDataProviderSvc::m_filterRobWithStatus
Gaudi::Property< ArrayPairIntType > m_filterRobWithStatus
Definition: HltROBDataProviderSvc.h:112
HltROBDataProviderSvc::EventCache::isEventComplete
bool isEventComplete
Definition: HltROBDataProviderSvc.h:97
HltROBDataProviderSvc::EventCache::currentLvl1ID
uint32_t currentLvl1ID
Definition: HltROBDataProviderSvc.h:94
HltROBDataProviderSvc::m_prefetchWholeROSList
std::vector< uint32_t > m_prefetchWholeROSList
Definition: HltROBDataProviderSvc.h:152
IROBDataProviderSvc.h
HltROBDataProviderSvc::robmap_filterRobWithStatus
bool robmap_filterRobWithStatus(const ROBF *)
method to filter ROBs with given Status code
Definition: HltROBDataProviderSvc.cxx:534
ServiceHandle< ITrigCostSvc >
HltROBDataProviderSvc::eventCache_checkRobListToCache
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...
Definition: HltROBDataProviderSvc.cxx:596