ATLAS Offline Software
Loading...
Searching...
No Matches
ROBDataProviderSvc Class Reference

#include <ROBDataProviderSvc.h>

Inheritance diagram for ROBDataProviderSvc:
Collaboration diagram for ROBDataProviderSvc:

Classes

struct  EventCache

Public Types

using ROBF = OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
 ROB Fragment class.

Public Member Functions

 ROBDataProviderSvc (const std::string &name, ISvcLocator *svcloc)
 Constructor.
virtual StatusCode initialize () override
 initialize the service
virtual void addROBData (const EventContext &context, const std::vector< uint32_t > &robIds, const std::string_view callerName="UNKNOWN") override
 Add ROBFragments to cache for given ROB ids, ROB fragments may be retrieved with DataCollector.
virtual void setNextEvent (const EventContext &context, const std::vector< OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment > &result) override
 Add a given LVL1/LVL2 ROBFragment to cache.
virtual void setNextEvent (const EventContext &context, const RawEvent *re) override
 Add all ROBFragments of a RawEvent to cache.
virtual void getROBData (const EventContext &context, const std::vector< uint32_t > &robIds, VROBFRAG &robFragments, const std::string_view callerName="UNKNOWN") override
 Retrieve ROBFragments for given ROB ids from cache.
virtual const RawEventgetEvent (const EventContext &context) override
 Retrieve the whole event.
virtual void setEventStatus (const EventContext &context, uint32_t status) override
 Store the status for the event.
virtual uint32_t getEventStatus (const EventContext &context) override
 Retrieve the status for the event.
virtual void processCachedROBs (const EventContext &context, const std::function< void(const ROBF *)> &fn) const override
virtual bool isEventComplete (const EventContext &) const override
virtual int collectCompleteEventData (const EventContext &, const std::string_view) override

Protected Types

using ROBMAP = std::map<uint32_t, std::unique_ptr<const ROBF>, std::less<uint32_t>>
 vector of ROBFragment class
using ArrayPairIntType = std::vector<std::pair<int, int>>
 Remaining attributes are for configuration vector of Source ids and status words to be ignored for the ROB map.
using FilterRobMap = std::map<uint32_t, std::vector<uint32_t>>
 map of full ROB Source ids and status words to be ignored for the ROB map
using FilterSubDetMap = std::map<eformat::SubDetector, std::vector<uint32_t>>
 map of Sub Det Source ids and status words to be ignored for the ROB map

Protected Member Functions

bool filterRobWithStatus (const ROBF *rob)
 method to filter ROBs with given Status code

Protected Attributes

SG::SlotSpecificObj< EventCachem_eventsCache
Gaudi::Property< ArrayPairIntTypem_filterRobWithStatus
Gaudi::Property< ArrayPairIntTypem_filterSubDetWithStatus
FilterRobMap m_filterRobMap
FilterSubDetMap m_filterSubDetMap
Gaudi::Property< bool > m_filterEmptyROB {this, "filterEmptyROB", false, "Filter out empty ROB fragments"}
 Filter out empty ROB fragments which are send by the ROS.
bool m_maskL2EFModuleID = false

Static Private Member Functions

static void robmapClear (ROBMAP &toclear)

Detailed Description

Definition at line 38 of file ROBDataProviderSvc.h.

Member Typedef Documentation

◆ ArrayPairIntType

using ROBDataProviderSvc::ArrayPairIntType = std::vector<std::pair<int, int>>
protected

Remaining attributes are for configuration vector of Source ids and status words to be ignored for the ROB map.

Definition at line 96 of file ROBDataProviderSvc.h.

◆ FilterRobMap

using ROBDataProviderSvc::FilterRobMap = std::map<uint32_t, std::vector<uint32_t>>
protected

map of full ROB Source ids and status words to be ignored for the ROB map

Definition at line 103 of file ROBDataProviderSvc.h.

◆ FilterSubDetMap

using ROBDataProviderSvc::FilterSubDetMap = std::map<eformat::SubDetector, std::vector<uint32_t>>
protected

map of Sub Det Source ids and status words to be ignored for the ROB map

Definition at line 106 of file ROBDataProviderSvc.h.

◆ ROBF

ROB Fragment class.

Definition at line 42 of file ROBDataProviderSvc.h.

◆ ROBMAP

using ROBDataProviderSvc::ROBMAP = std::map<uint32_t, std::unique_ptr<const ROBF>, std::less<uint32_t>>
protected

vector of ROBFragment class

map for all the ROB fragments

Definition at line 83 of file ROBDataProviderSvc.h.

Constructor & Destructor Documentation

◆ ROBDataProviderSvc()

ROBDataProviderSvc::ROBDataProviderSvc ( const std::string & name,
ISvcLocator * svcloc )

Constructor.

Definition at line 87 of file ROBDataProviderSvc.cxx.

88 : base_class(name, svcloc) {}

Member Function Documentation

◆ addROBData()

void ROBDataProviderSvc::addROBData ( const EventContext & context,
const std::vector< uint32_t > & robIds,
const std::string_view callerName = "UNKNOWN" )
overridevirtual

Add ROBFragments to cache for given ROB ids, ROB fragments may be retrieved with DataCollector.

  • in offline only check that given ROB ids are in the map, issue an error if not

Definition at line 143 of file ROBDataProviderSvc.cxx.

143 {
144 EventCache* cache = m_eventsCache.get( context );
145
146 // Copy missing ROB ids to vector with pthread allocator
147 ATH_MSG_DEBUG(" ---> Number of ROB Id s requested : " << robIds.size() << ", Caller Name = " << callerName);
148 // for offline running all requested ROBs should be found in cache
149 // if not issue error
150 for (uint32_t id : robIds) {
151 // mask off the module ID for L2 and EF result for Run 1 data
152 if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
153 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_LVL2) ) {
154 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
155 // TB if it is inconsistent we should not continue like this?
156 if ( !m_maskL2EFModuleID ) {
157 ATH_MSG_ERROR("Inconsistent flag for masking L2/EF module IDs");
159 }
160 } else if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
161 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) &&
162 ( m_maskL2EFModuleID ) ) {
163 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
164 }
165 ROBMAP& robmap( cache->robmap );
166 ROBMAP::iterator map_it = robmap.find(id) ;
167 if (map_it != robmap.end()) {
168 ATH_MSG_DEBUG(" ---> Found ROB Id : 0x" << MSG::hex << (*map_it).second->source_id()
169 << MSG::dec << " in cache");
170 } else {
171 ATH_MSG_DEBUG(" ---> ROB Id : 0x" << MSG::hex << id
172 << MSG::dec << " not found in cache for running mode OFFLINE (method addROBData),");
173 ATH_MSG_DEBUG(" Lvl1 id = " << cache->currentLvl1ID);
174 }
175 }
176 return;
177}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
std::map< uint32_t, std::unique_ptr< const ROBF >, std::less< uint32_t > > ROBMAP
vector of ROBFragment class
SG::SlotSpecificObj< EventCache > m_eventsCache
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.

◆ collectCompleteEventData()

virtual int ROBDataProviderSvc::collectCompleteEventData ( const EventContext & ,
const std::string_view  )
inlineoverridevirtual

Definition at line 76 of file ROBDataProviderSvc.h.

76{ return 0; }

◆ filterRobWithStatus()

bool ROBDataProviderSvc::filterRobWithStatus ( const ROBF * rob)
protected

method to filter ROBs with given Status code

  • filter ROB with Sub Detector Id and Status Code

Definition at line 339 of file ROBDataProviderSvc.cxx.

339 {
340 // No filter criteria defined
341 if ((m_filterRobMap.size() == 0) && (m_filterSubDetMap.size() == 0)) {
342 return(false);
343 }
344 // There should be at least one status element if there was an error
345 // in case there are 0 status elements then there was no known error
346 // (see event format document ATL-D-ES-0019 (EDMS))
347 if (rob->nstatus() == 0) {
348 return(false);
349 }
350 // The ROB has at least one status element, access it via an iterator
351 const uint32_t* rob_it_status;
352 rob->status(rob_it_status);
353 // Build the full ROB Sourceidentifier
354 eformat::helper::SourceIdentifier tmpsrc(rob->rob_source_id());
355 // Check if there is a ROB specific filter rule defined for this ROB Id and match the status code
356 FilterRobMap::iterator map_it_rob = m_filterRobMap.find(tmpsrc.code());
357 if (map_it_rob != m_filterRobMap.end()) {
358 for (uint32_t status : map_it_rob->second) {
359 if (*rob_it_status == status) {
360 return(true);
361 }
362 }
363 }
364 // Check if there is a sub detector specific filter rule defined for this ROB Id and match the status code
365 FilterSubDetMap::iterator map_it_subdet = m_filterSubDetMap.find(tmpsrc.subdetector_id());
366 if (map_it_subdet != m_filterSubDetMap.end()) {
367 for (uint32_t status : map_it_subdet->second) {
368 if (*rob_it_status == status) {
369 return(true);
370 }
371 }
372 }
373 return(false);
374}
FilterSubDetMap m_filterSubDetMap
setEventNumber uint32_t

◆ getEvent()

const RawEvent * ROBDataProviderSvc::getEvent ( const EventContext & context)
overridevirtual

Retrieve the whole event.

Definition at line 311 of file ROBDataProviderSvc.cxx.

311 {
312
313 return m_eventsCache.get( context )->event;
314}

◆ getEventStatus()

uint32_t ROBDataProviderSvc::getEventStatus ( const EventContext & context)
overridevirtual

Retrieve the status for the event.

Definition at line 324 of file ROBDataProviderSvc.cxx.

324 {
325 return m_eventsCache.get( context )->eventStatus;
326}

◆ getROBData()

void ROBDataProviderSvc::getROBData ( const EventContext & context,
const std::vector< uint32_t > & robIds,
VROBFRAG & robFragments,
const std::string_view callerName = "UNKNOWN" )
overridevirtual

Retrieve ROBFragments for given ROB ids from cache.

return ROBData for ROBID

Definition at line 267 of file ROBDataProviderSvc.cxx.

268 {
269 EventCache* cache = m_eventsCache.get( context );
270
271 for (uint32_t id : ids) {
272 // mask off the module ID for L2 and EF result for Run 1 data
273 if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
274 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_LVL2) ) {
275 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
276 if (!m_maskL2EFModuleID) {
277 ATH_MSG_ERROR("Inconsistent flag for masking L2/EF module IDs");
279 }
280 } else if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
281 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) &&
283 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
284 }
285 ROBMAP::iterator map_it = cache->robmap.find(id);
286 if (map_it != cache->robmap.end()) {
287 v.push_back((*map_it).second.get());
288 } else {
289 ATH_MSG_DEBUG("Failed to find ROB for id 0x" << MSG::hex << id << MSG::dec << ", Caller Name = " << callerName);
290#ifndef NDEBUG
291 int nrob = 0;
292 ATH_MSG_VERBOSE(" --- Dump of ROB cache ids --- total size = " << cache->robmap.size());
293 for (const auto& p : cache->robmap) {
294 ++nrob;
295 ATH_MSG_VERBOSE(" # = " << nrob << " id = 0x" << MSG::hex << p.second->source_id() << MSG::dec);
296 }
297#endif
298 }
299 }
300 return;
301}
#define ATH_MSG_VERBOSE(x)

◆ initialize()

StatusCode ROBDataProviderSvc::initialize ( )
overridevirtual

initialize the service

Definition at line 92 of file ROBDataProviderSvc.cxx.

92 {
93 ATH_MSG_INFO("Initializing");
94 m_eventsCache = SG::SlotSpecificObj<EventCache>( SG::getNSlots() );
95
96 for (unsigned int i = 0; i < m_filterRobWithStatus.value().size(); i++) {
97 eformat::helper::SourceIdentifier tmpsrc(m_filterRobWithStatus.value()[i].first);
98 if (tmpsrc.human_detector() != "UNKNOWN") {
99 m_filterRobMap[tmpsrc.code()].push_back(m_filterRobWithStatus.value()[i].second);
100 }
101 }
102 for (unsigned int i = 0; i < m_filterSubDetWithStatus.value().size(); i++) {
103 eformat::helper::SourceIdentifier tmpsrc((eformat::SubDetector)m_filterSubDetWithStatus.value()[i].first, 0);
104 if (tmpsrc.human_detector() != "UNKNOWN") {
105 m_filterSubDetMap[tmpsrc.subdetector_id()].push_back(m_filterSubDetWithStatus.value()[i].second);
106 }
107 }
108 ATH_MSG_INFO(" ---> Filter out empty ROB fragments = " << m_filterEmptyROB);
109 ATH_MSG_INFO(" ---> Filter out specific ROBs by Status Code: # ROBs = " << m_filterRobMap.size());
110 for (const auto& p : m_filterRobMap) {
111 eformat::helper::SourceIdentifier tmpsrc(p.first);
112 ATH_MSG_INFO(" RobId=0x" << MSG::hex << p.first << " -> in Sub Det = " << tmpsrc.human_detector());
113 for (uint32_t status : p.second) {
114 eformat::helper::Status tmpstatus(status);
115 ATH_MSG_INFO(" Status Code=0x"
116 << MSG::hex << std::setfill( '0' ) << std::setw(8) << tmpstatus.code()
117 << " Generic Part=0x" << std::setw(4) << tmpstatus.generic()
118 << " Specific Part=0x" << std::setw(4) << tmpstatus.specific());
119 }
120 }
121
122 ATH_MSG_INFO(" ---> Filter out Sub Detector ROBs by Status Code: # Sub Detectors = " << m_filterSubDetMap.size());
123 for (const auto& p : m_filterSubDetMap) {
124 eformat::helper::SourceIdentifier tmpsrc(p.first, 0);
125 ATH_MSG_INFO(" SubDetId=0x" << MSG::hex << p.first << " -> " << tmpsrc.human_detector());
126 for (uint32_t status : p.second) {
127 eformat::helper::Status tmpstatus(status);
128 ATH_MSG_INFO(" Status Code=0x"
129 << MSG::hex << std::setfill( '0' ) << std::setw(8) << tmpstatus.code()
130 << " Generic Part=0x" << std::setw(4) << tmpstatus.generic()
131 << " Specific Part=0x" << std::setw(4) << tmpstatus.specific());
132 }
133 }
134 return(StatusCode::SUCCESS);
135}
#define ATH_MSG_INFO(x)
size_t size() const
Number of registered mappings.
Gaudi::Property< ArrayPairIntType > m_filterSubDetWithStatus
Gaudi::Property< ArrayPairIntType > m_filterRobWithStatus
Gaudi::Property< bool > m_filterEmptyROB
Filter out empty ROB fragments which are send by the ROS.
size_t getNSlots()
Return the number of event slots.

◆ isEventComplete()

virtual bool ROBDataProviderSvc::isEventComplete ( const EventContext & ) const
inlineoverridevirtual

Definition at line 75 of file ROBDataProviderSvc.h.

75{ return true; }

◆ processCachedROBs()

void ROBDataProviderSvc::processCachedROBs ( const EventContext & context,
const std::function< void(const ROBF *)> & fn ) const
overridevirtual

Definition at line 328 of file ROBDataProviderSvc.cxx.

329 {
330 for ( const auto& el : m_eventsCache.get( context )->robmap ) {
331 fn( el.second.get() );
332 }
333}

◆ robmapClear()

void ROBDataProviderSvc::robmapClear ( ROBMAP & toclear)
staticprivate
  • clear ROB map

Definition at line 304 of file ROBDataProviderSvc.cxx.

304 {
305 for (auto& it : toclear) {
306 it.second.reset();
307 }
308 toclear.clear();
309}

◆ setEventStatus()

void ROBDataProviderSvc::setEventStatus ( const EventContext & context,
uint32_t status )
overridevirtual

Store the status for the event.

Set the status for the event.

Definition at line 319 of file ROBDataProviderSvc.cxx.

319 {
320 m_eventsCache.get(context)->eventStatus = status;
321}
status
Definition merge.py:16

◆ setNextEvent() [1/2]

void ROBDataProviderSvc::setNextEvent ( const EventContext & context,
const RawEvent * re )
overridevirtual

Add all ROBFragments of a RawEvent to cache.

  • add a new Raw event
  • rebuild the map

Definition at line 204 of file ROBDataProviderSvc.cxx.

204 {
205 EventCache* cache = m_eventsCache.get( context );
206
207 cache->event=re;
208 // clear the old map
209 robmapClear( cache->robmap );
210 // set the LVL1 id
211 cache->currentLvl1ID = re->lvl1_id();
212 // set flag for masking L2/EF module ID, this is only necessary for the separate L2 and EF systems from Run 1
213 m_maskL2EFModuleID = (re->nlvl2_trigger_info() != 0);
214
215 // loop over all ROBs
216 auto iter = re->child_iter();
218 // add to the map
219 auto rob = std::make_unique<const ROBF>(fp);
220 uint32_t id = rob->source_id();
221 // mask off the module ID for L2 and EF result for Run 1 data
222 if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
223 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_LVL2) ) {
224 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
225 if (!m_maskL2EFModuleID) {
226 ATH_MSG_ERROR("Inconsistent flag for masking L2/EF module IDs");
228 }
229 } else if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
230 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) &&
232 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
233 }
234 if (filterRobWithStatus(rob.get())) {
235 if (rob->nstatus() > 0) {
236 const uint32_t* it_status;
237 rob->status(it_status);
238 eformat::helper::Status tmpstatus(*it_status);
239 ATH_MSG_DEBUG(" ---> ROB Id = 0x" << MSG::hex << id << std::setfill('0')
240 << " with Generic Status Code = 0x" << std::setw(4) << tmpstatus.generic()
241 << " and Specific Status Code = 0x" << std::setw(4) << tmpstatus.specific() << MSG::dec
242 << " removed for L1 Id = " << cache->currentLvl1ID);
243 }
244 rob.reset();
245 } else if ((rob->rod_ndata() == 0) && (m_filterEmptyROB.value())) {
246 ATH_MSG_DEBUG( " ---> Empty ROB Id = 0x" << MSG::hex << id << MSG::dec
247 << " removed for L1 Id = " << cache->currentLvl1ID);
248 rob.reset();
249 } else {
250 ROBMAP::const_iterator it = cache->robmap.find(id);
251 if (it != cache->robmap.end()) {
252 ATH_MSG_WARNING(" ROBDataProviderSvc:: Duplicate ROBID 0x" << MSG::hex << id
253 << " found. " << MSG::dec << " Overwriting the previous one ");
254 }
255 cache->robmap[id]=std::move(rob);
256
257 }
258 }
259 ATH_MSG_DEBUG(" ---> setNextEvent offline for " << name() );
260 ATH_MSG_DEBUG(" current LVL1 id = " << cache->currentLvl1ID );
261 ATH_MSG_DEBUG(" size of ROB cache = " << cache->robmap.size() );
262 return;
263}
const boost::regex re(r_e)
#define ATH_MSG_WARNING(x)
static void robmapClear(ROBMAP &toclear)
bool filterRobWithStatus(const ROBF *rob)
method to filter ROBs with given Status code
const DataType * PointerType
Definition RawEvent.h:25

◆ setNextEvent() [2/2]

void ROBDataProviderSvc::setNextEvent ( const EventContext & context,
const std::vector< OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment > & result )
overridevirtual

Add a given LVL1/LVL2 ROBFragment to cache.

  • this is the online method to add the LVL1/LVL2 result
  • this version of ROBDataProviderSvc does not support it
  • this version is for offline use only

Definition at line 182 of file ROBDataProviderSvc.cxx.

182 {
183 // clear the old map
184 // TB honestly, why do any action if this is FATAL mistake
185 // robmapClear( m_eventsCache.get(context)->robmap );
186
187 // This method should never be used by offline
188 ATH_MSG_FATAL(" +-----------------------------------------------------------------+ ");
189 ATH_MSG_FATAL(" | The method ROBDataProviderSvc::setNextEvent(const ROBF* result) | ");
190 ATH_MSG_FATAL(" | is not implemented for this version of ROBDataProviderSvc | ");
191 ATH_MSG_FATAL(" | Use the version from the HLT repository if you need it. | ");
192 ATH_MSG_FATAL(" +-----------------------------------------------------------------+ ");
193 ATH_MSG_FATAL(" ---> The " << result.size() << " ROB fragments in the call will not be used.");
194 return;
195}
#define ATH_MSG_FATAL(x)

Member Data Documentation

◆ m_eventsCache

SG::SlotSpecificObj<EventCache> ROBDataProviderSvc::m_eventsCache
protected

Definition at line 92 of file ROBDataProviderSvc.h.

◆ m_filterEmptyROB

Gaudi::Property<bool> ROBDataProviderSvc::m_filterEmptyROB {this, "filterEmptyROB", false, "Filter out empty ROB fragments"}
protected

Filter out empty ROB fragments which are send by the ROS.

Definition at line 112 of file ROBDataProviderSvc.h.

112{this, "filterEmptyROB", false, "Filter out empty ROB fragments"};

◆ m_filterRobMap

FilterRobMap ROBDataProviderSvc::m_filterRobMap
protected

Definition at line 104 of file ROBDataProviderSvc.h.

◆ m_filterRobWithStatus

Gaudi::Property<ArrayPairIntType> ROBDataProviderSvc::m_filterRobWithStatus
protected
Initial value:
{
this, "filterRobWithStatus", {}, "ROB IDs and status words to filter (full ROB SourceID)"}

Definition at line 97 of file ROBDataProviderSvc.h.

97 {
98 this, "filterRobWithStatus", {}, "ROB IDs and status words to filter (full ROB SourceID)"};

◆ m_filterSubDetMap

FilterSubDetMap ROBDataProviderSvc::m_filterSubDetMap
protected

Definition at line 107 of file ROBDataProviderSvc.h.

◆ m_filterSubDetWithStatus

Gaudi::Property<ArrayPairIntType> ROBDataProviderSvc::m_filterSubDetWithStatus
protected
Initial value:
{
this, "filterSubDetWithStatus", {}, "Sub-detector IDs and status words to filter"}

Definition at line 99 of file ROBDataProviderSvc.h.

99 {
100 this, "filterSubDetWithStatus", {}, "Sub-detector IDs and status words to filter"};

◆ m_maskL2EFModuleID

bool ROBDataProviderSvc::m_maskL2EFModuleID = false
protected

Definition at line 113 of file ROBDataProviderSvc.h.


The documentation for this class was generated from the following files: