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

◆ 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 348 of file ROBDataProviderSvc.cxx.

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

◆ getEvent()

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

Retrieve the whole event.

Definition at line 320 of file ROBDataProviderSvc.cxx.

320 {
321
322 return m_eventsCache.get( context )->event;
323}

◆ getEventStatus()

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

Retrieve the status for the event.

Definition at line 333 of file ROBDataProviderSvc.cxx.

333 {
334 return m_eventsCache.get( context )->eventStatus;
335}

◆ 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 276 of file ROBDataProviderSvc.cxx.

277 {
278 EventCache* cache = m_eventsCache.get( context );
279
280 for (uint32_t id : ids) {
281 // mask off the module ID for L2 and EF result for Run 1 data
282 if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
283 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_LVL2) ) {
284 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
285 if (!m_maskL2EFModuleID) {
286 ATH_MSG_ERROR("Inconsistent flag for masking L2/EF module IDs");
288 }
289 } else if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
290 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) &&
292 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
293 }
294 ROBMAP::iterator map_it = cache->robmap.find(id);
295 if (map_it != cache->robmap.end()) {
296 v.push_back((*map_it).second.get());
297 } else {
298 ATH_MSG_DEBUG("Failed to find ROB for id 0x" << MSG::hex << id << MSG::dec << ", Caller Name = " << callerName);
299#ifndef NDEBUG
300 int nrob = 0;
301 ATH_MSG_VERBOSE(" --- Dump of ROB cache ids --- total size = " << cache->robmap.size());
302 for (const auto& p : cache->robmap) {
303 ++nrob;
304 ATH_MSG_VERBOSE(" # = " << nrob << " id = 0x" << MSG::hex << p.second->source_id() << MSG::dec);
305 }
306#endif
307 }
308 }
309 return;
310}
#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)
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 337 of file ROBDataProviderSvc.cxx.

338 {
339 for ( const auto& el : m_eventsCache.get( context )->robmap ) {
340 fn( el.second.get() );
341 }
342}

◆ robmapClear()

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

Definition at line 313 of file ROBDataProviderSvc.cxx.

313 {
314 for (auto& it : toclear) {
315 it.second.reset();
316 }
317 toclear.clear();
318}

◆ 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 328 of file ROBDataProviderSvc.cxx.

328 {
329 m_eventsCache.get(context)->eventStatus = status;
330}
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 // get all the ROBFragments
216 constexpr size_t MAX_ROBFRAGMENTS = 4096;
217 std::vector<OFFLINE_FRAGMENTS_NAMESPACE::PointerType> robF(MAX_ROBFRAGMENTS);
219 re->start(rePointer);
220 size_t robcount = re->children(robF.data(), MAX_ROBFRAGMENTS);
221 if (robcount == MAX_ROBFRAGMENTS) {
222 ATH_MSG_ERROR("ROB buffer overflow");
223 }
224 // loop over all ROBs
225 for (size_t irob = 0; irob < robcount; irob++) {
226 // add to the map
227 //const ROBF* rob = new ROBF(robF[irob]);
228 std::unique_ptr<const ROBF> rob=std::make_unique<const ROBF>(robF[irob]);
229 uint32_t id = rob->source_id();
230 // mask off the module ID for L2 and EF result for Run 1 data
231 if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
232 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_LVL2) ) {
233 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
234 if (!m_maskL2EFModuleID) {
235 ATH_MSG_ERROR("Inconsistent flag for masking L2/EF module IDs");
237 }
238 } else if ( (eformat::helper::SourceIdentifier(id).module_id() != 0) &&
239 (eformat::helper::SourceIdentifier(id).subdetector_id() == eformat::TDAQ_EVENT_FILTER) &&
241 id = eformat::helper::SourceIdentifier(eformat::helper::SourceIdentifier(id).subdetector_id(),0).code();
242 }
243 if (filterRobWithStatus(rob.get())) {
244 if (rob->nstatus() > 0) {
245 const uint32_t* it_status;
246 rob->status(it_status);
247 eformat::helper::Status tmpstatus(*it_status);
248 ATH_MSG_DEBUG(" ---> ROB Id = 0x" << MSG::hex << id << std::setfill('0')
249 << " with Generic Status Code = 0x" << std::setw(4) << tmpstatus.generic()
250 << " and Specific Status Code = 0x" << std::setw(4) << tmpstatus.specific() << MSG::dec
251 << " removed for L1 Id = " << cache->currentLvl1ID);
252 }
253 rob.reset();
254 } else if ((rob->rod_ndata() == 0) && (m_filterEmptyROB.value())) {
255 ATH_MSG_DEBUG( " ---> Empty ROB Id = 0x" << MSG::hex << id << MSG::dec
256 << " removed for L1 Id = " << cache->currentLvl1ID);
257 rob.reset();
258 } else {
259 ROBMAP::const_iterator it = cache->robmap.find(id);
260 if (it != cache->robmap.end()) {
261 ATH_MSG_WARNING(" ROBDataProviderSvc:: Duplicate ROBID 0x" << MSG::hex << id
262 << " found. " << MSG::dec << " Overwriting the previous one ");
263 }
264 cache->robmap[id]=std::move(rob);
265
266 }
267 }
268 ATH_MSG_DEBUG(" ---> setNextEvent offline for " << name() );
269 ATH_MSG_DEBUG(" current LVL1 id = " << cache->currentLvl1ID );
270 ATH_MSG_DEBUG(" size of ROB cache = " << cache->robmap.size() );
271 return;
272}
const boost::regex re(r_e)
#define ATH_MSG_WARNING(x)
static const size_t MAX_ROBFRAGMENTS
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: