ATLAS Offline Software
Loading...
Searching...
No Matches
FullEventAssembler.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "GaudiKernel/MsgStream.h"
6#include "eformat/Status.h"
7
8#include <format>
9
10
11template <class IDMAP>
12FullEventAssembler<IDMAP>::FullEventAssembler():
13 m_runnum(0),
14 m_lvl1_id(0),
15 m_rod_version(0),
16 m_rob_version(0),
17 m_detEvtType(0),
18 m_lvl1_trigger_type(0),
19 m_bcid(0)
20{
21}
22
23
24template <class IDMAP>
25FullEventAssembler<IDMAP>::~FullEventAssembler()
26{
27 clear();
28}
29
30
31template <class IDMAP>
32void FullEventAssembler<IDMAP>::clear()
33{
34 // clear stack
35 for(const auto& [id, rod] : m_rodMap) delete rod;
36 m_rodMap.clear();
37
38 for(const auto& [id, rob] : m_robMap) delete rob;
39 m_robMap.clear();
40}
41
42
43template <class IDMAP>
44void FullEventAssembler<IDMAP>::fill(RawEventWrite* re, MsgStream& log )
45{
46 m_runnum = re->run_no() ;
47 m_lvl1_id = re->lvl1_id();
48 m_lvl1_trigger_type = re->lvl1_trigger_type();
49 m_bcid = re->bc_id();
50
51 // ROD to ROB
52 RodToRob(m_rodMap,m_robMap,log);
53 // ROB to FullEventFragment
54 RobToEvt(m_robMap,re,log);
55}
56
57
58template <class IDMAP>
59typename FullEventAssembler<IDMAP>::RODDATA*
60FullEventAssembler<IDMAP>::getRodData(uint32_t id)
61{
62 if (auto itr = m_rodMap.find(id); itr != m_rodMap.end()) {
63 return itr->second;
64 }
65
66 auto* theROD = new RODDATA();
67 m_rodMap.emplace(id, theROD);
68 return theROD;
69}
70
71
72template <class IDMAP>
73void
74FullEventAssembler<IDMAP>::RodToRob(RODMAP& rodMap,
75 ROBMAP& robMap, MsgStream& log ) const
76{
77 // loop over all the RODs
78 for(const auto& [rodid, rod] : rodMap)
79 {
80 if(log.level() <= MSG::DEBUG)
81 log << MSG::DEBUG << " Rod id = " << std::format("{:x}", rodid) << endmsg;
82
83 // make an ROB id from an ROD id.
84 const uint32_t robid = m_idmap.getRobID(rodid);
85
86 // find or make a ROS fragment
87 if (robMap.contains(robid))
88 {
89 log << MSG::ERROR << " More than one ROD in ROB:" << std::format("{:x}", robid) << endmsg;
90 }
91 else
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);
99 }
100 }
101}
102
103
104template <class IDMAP>
105void FullEventAssembler<IDMAP>::RobToEvt(ROBMAP& robMap, RawEventWrite* re, MsgStream& log ) const
106{
107 const bool debug = log.level() <= MSG::DEBUG;
108 if(debug) log << MSG::DEBUG << " RobToEvt, number of ROBFrag= " << robMap.size() << endmsg;
109
110 for(const auto& [robid, theROB] : robMap)
111 {
112 if(debug) log << MSG::DEBUG << " RobToEvt: adding ROB "
113 << std::format("{:x}", theROB->source_id()) << endmsg;
114 re->append(theROB);
115 }
116
117 if(debug) log << MSG::DEBUG << " FullEventFragment is done " << re << endmsg;
118}
119
120
121template <class IDMAP>
122FullEventAssembler<IDMAP>::RODMAP::const_iterator
123FullEventAssembler<IDMAP>::begin() const
124{
125 return m_rodMap.begin();
126}
127
128
129template <class IDMAP>
130FullEventAssembler<IDMAP>::RODMAP::const_iterator
131FullEventAssembler<IDMAP>::end() const
132{
133 return m_rodMap.end();
134}
135
136
137template <class IDMAP>
138void FullEventAssembler<IDMAP>::setRodMinorVersion(uint16_t m )
139{
140 m_rod_version = m;
141}
142
143
144template <class IDMAP>
145void FullEventAssembler<IDMAP>::setRobMinorVersion(uint16_t m )
146{
147 m_rob_version = m;
148}
149
150
151template <class IDMAP>
152void FullEventAssembler<IDMAP>::setDetEvtType(uint32_t m )
153{
154 m_detEvtType = m;
155}
156
157
158template <class IDMAP>
159void FullEventAssembler<IDMAP>::setLvl1TriggerType(uint8_t m )
160{
161 m_lvl1_trigger_type = m;
162}
163
164
165template <class IDMAP>
166typename FullEventAssembler<IDMAP>::IDMAP_t& FullEventAssembler<IDMAP>::idMap()
167{
168 return m_idmap ;
169}
170