2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 // using namespace EventFormat::RawMemory ;
7 #include "GaudiKernel/MsgStream.h"
8 #include "eformat/Status.h"
10 //using namespace OFFLINE_FRAGMENTS_NAMESPACE ;
12 template <class IDMAP>
13 FullEventAssembler<IDMAP>::FullEventAssembler():
14 m_runnum(0),m_lvl1_id(0),
18 m_lvl1_trigger_type(0),
24 template <class IDMAP>
25 FullEventAssembler<IDMAP>::~FullEventAssembler()
32 template <class IDMAP>
33 void FullEventAssembler<IDMAP>::clear()
36 RODMAP::iterator it_rod = m_rodMap.begin();
37 RODMAP::iterator it_rod_end = m_rodMap.end();
38 for(; it_rod!=it_rod_end; ++it_rod)
39 delete it_rod->second;
42 ROBMAP::iterator it_rob = m_robMap.begin();
43 ROBMAP::iterator it_rob_end = m_robMap.end();
44 for(; it_rob!=it_rob_end; ++it_rob)
45 delete it_rob->second;
50 template <class IDMAP>
51 void FullEventAssembler<IDMAP>::fill(RawEventWrite* re, MsgStream& log )
53 m_runnum = re->run_no() ;
54 m_lvl1_id = re->lvl1_id();
55 m_lvl1_trigger_type = re->lvl1_trigger_type();
59 RodToRob(m_rodMap,m_robMap,log);
60 // ROB to FullEventFragment
61 RobToEvt(m_robMap,re,log);
65 template <class IDMAP>
66 typename FullEventAssembler<IDMAP>::RODDATA*
67 FullEventAssembler<IDMAP>::getRodData(uint32_t id)
69 RODMAP::iterator itr = m_rodMap.find(id);
72 if(itr!=m_rodMap.end())
74 theROD = (*itr).second;
78 theROD = new RODDATA();
79 m_rodMap.insert(RODMAP::value_type(id,theROD)) ;
86 template <class IDMAP>
88 FullEventAssembler<IDMAP>::RodToRob(RODMAP& rodMap,
89 ROBMAP& robMap, MsgStream& log )
91 log << MSG::DEBUG << " RodToRob " << endmsg;
93 // loop over all the RODs
94 RODMAP::iterator it_rod = rodMap.begin();
95 RODMAP::iterator it_rod_end = rodMap.end();
96 for(; it_rod!=it_rod_end; ++it_rod)
98 uint32_t rodid = (*it_rod).first;
99 RODDATA* intv = (*it_rod).second;
101 std::ios_base::fmtflags oflags=log.stream().flags();
102 log << MSG::DEBUG << " Rod id = " << MSG::hex << rodid << endmsg;
103 log.flags(oflags); // reset precision after use of hex
105 // make an ROB id from an ROD id.
106 uint32_t robid = m_idmap.getRobID(rodid);
108 // find or make a ROS fragment
109 ROBMAP::iterator itr2 = robMap.find(robid);
110 if(itr2!=robMap.end())
112 oflags=log.stream().flags();
113 log << MSG::ERROR << " More than one RODs in ROB:" << MSG::hex << (*itr2).first << endmsg;
114 log.flags(oflags); // reset precision after use of hex
117 { // Make a new ROBFragment
118 OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment* theROB
119 = new OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment(robid,m_runnum,m_lvl1_id,m_bcid,
120 m_lvl1_trigger_type,m_detEvtType,intv->size(),
121 &(*intv)[0],eformat::STATUS_BACK);
122 theROB->minor_version(m_rob_version);
123 theROB->rod_minor_version(m_rod_version);
124 robMap.insert(ROBMAP::value_type(robid,theROB)) ;
130 template <class IDMAP>
131 void FullEventAssembler<IDMAP>::RobToEvt(ROBMAP& robMap, RawEventWrite* re, MsgStream& log )
133 log << MSG::DEBUG<< " RobToEvt, number of ROBFrag= " << robMap.size() << endmsg;
134 OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment* theROB;
136 ROBMAP::iterator it_rob = robMap.begin();
137 ROBMAP::iterator it_rob_end = robMap.end();
138 for(; it_rob!= it_rob_end;++it_rob)
140 theROB = (*it_rob).second;
141 std::ios_base::fmtflags oflags=log.stream().flags();
142 log << MSG::DEBUG << " RobToEvt: adding ROB " << MSG::hex <<
143 theROB->source_id() << endmsg;
144 log.flags(oflags); // reset precision after use of hex
145 re->append((*it_rob).second);
148 log << MSG::DEBUG << " FullEventFragment is done " << re << endmsg;
152 template <class IDMAP>
153 FullEventAssembler<IDMAP>::RODMAP::const_iterator
154 FullEventAssembler<IDMAP>::begin() const
156 return m_rodMap.begin();
160 template <class IDMAP>
161 FullEventAssembler<IDMAP>::RODMAP::const_iterator
162 FullEventAssembler<IDMAP>::end() const
164 return m_rodMap.end();
168 template <class IDMAP>
169 void FullEventAssembler<IDMAP>::setRodMinorVersion(uint16_t m )
175 template <class IDMAP>
176 void FullEventAssembler<IDMAP>::setRobMinorVersion(uint16_t m )
182 template <class IDMAP>
183 void FullEventAssembler<IDMAP>::setDetEvtType(uint32_t m )
189 template <class IDMAP>
190 void FullEventAssembler<IDMAP>::setLvl1TriggerType(uint8_t m )
192 m_lvl1_trigger_type = m;
196 template <class IDMAP>
197 typename FullEventAssembler<IDMAP>::IDMAP_t& FullEventAssembler<IDMAP>::idMap()