2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5 #include "GaudiKernel/MsgStream.h"
6 #include "eformat/Status.h"
11 template <class IDMAP>
12 FullEventAssembler<IDMAP>::FullEventAssembler():
18 m_lvl1_trigger_type(0),
24 template <class IDMAP>
25 FullEventAssembler<IDMAP>::~FullEventAssembler()
31 template <class IDMAP>
32 void FullEventAssembler<IDMAP>::clear()
35 for(const auto& [id, rod] : m_rodMap) delete rod;
38 for(const auto& [id, rob] : m_robMap) delete rob;
43 template <class IDMAP>
44 void FullEventAssembler<IDMAP>::fill(RawEventWrite* re, MsgStream& log )
46 m_runnum = re->run_no() ;
47 m_lvl1_id = re->lvl1_id();
48 m_lvl1_trigger_type = re->lvl1_trigger_type();
52 RodToRob(m_rodMap,m_robMap,log);
53 // ROB to FullEventFragment
54 RobToEvt(m_robMap,re,log);
58 template <class IDMAP>
59 typename FullEventAssembler<IDMAP>::RODDATA*
60 FullEventAssembler<IDMAP>::getRodData(uint32_t id)
62 if (auto itr = m_rodMap.find(id); itr != m_rodMap.end()) {
66 auto* theROD = new RODDATA();
67 m_rodMap.emplace(id, theROD);
72 template <class IDMAP>
74 FullEventAssembler<IDMAP>::RodToRob(RODMAP& rodMap,
75 ROBMAP& robMap, MsgStream& log ) const
77 // loop over all the RODs
78 for(const auto& [rodid, rod] : rodMap)
80 if(log.level() <= MSG::DEBUG)
81 log << MSG::DEBUG << " Rod id = " << std::format("{:x}", rodid) << endmsg;
83 // make an ROB id from an ROD id.
84 const uint32_t robid = m_idmap.getRobID(rodid);
86 // find or make a ROS fragment
87 if (robMap.contains(robid))
89 log << MSG::ERROR << " More than one ROD in ROB:" << std::format("{:x}", robid) << endmsg;
92 { // Make a new ROBFragment
93 auto theROB = new OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment(robid,m_runnum,m_lvl1_id,m_bcid,
94 m_lvl1_trigger_type,m_detEvtType,rod->size(),
95 &(*rod)[0],eformat::STATUS_BACK);
96 theROB->minor_version(m_rob_version);
97 theROB->rod_minor_version(m_rod_version);
98 robMap.emplace(robid, theROB);
104 template <class IDMAP>
105 void FullEventAssembler<IDMAP>::RobToEvt(ROBMAP& robMap, RawEventWrite* re, MsgStream& log ) const
107 const bool debug = log.level() <= MSG::DEBUG;
108 if(debug) log << MSG::DEBUG << " RobToEvt, number of ROBFrag= " << robMap.size() << endmsg;
110 for(const auto& [robid, theROB] : robMap)
112 if(debug) log << MSG::DEBUG << " RobToEvt: adding ROB "
113 << std::format("{:x}", theROB->source_id()) << endmsg;
117 if(debug) log << MSG::DEBUG << " FullEventFragment is done " << re << endmsg;
121 template <class IDMAP>
122 FullEventAssembler<IDMAP>::RODMAP::const_iterator
123 FullEventAssembler<IDMAP>::begin() const
125 return m_rodMap.begin();
129 template <class IDMAP>
130 FullEventAssembler<IDMAP>::RODMAP::const_iterator
131 FullEventAssembler<IDMAP>::end() const
133 return m_rodMap.end();
137 template <class IDMAP>
138 void FullEventAssembler<IDMAP>::setRodMinorVersion(uint16_t m )
144 template <class IDMAP>
145 void FullEventAssembler<IDMAP>::setRobMinorVersion(uint16_t m )
151 template <class IDMAP>
152 void FullEventAssembler<IDMAP>::setDetEvtType(uint32_t m )
158 template <class IDMAP>
159 void FullEventAssembler<IDMAP>::setLvl1TriggerType(uint8_t m )
161 m_lvl1_trigger_type = m;
165 template <class IDMAP>
166 typename FullEventAssembler<IDMAP>::IDMAP_t& FullEventAssembler<IDMAP>::idMap()