2   Copyright (C) 2002-2024 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   RODDATA* theROD = nullptr;
 
   64   RODMAP::const_iterator itr = m_rodMap.find(id);
 
   65   if(itr!=m_rodMap.end())
 
   71       theROD = new RODDATA();      
 
   72       m_rodMap.emplace(id, theROD);
 
   79 template <class IDMAP> 
 
   81 FullEventAssembler<IDMAP>::RodToRob(RODMAP& rodMap,
 
   82                                     ROBMAP& robMap,  MsgStream& log ) const
 
   84   // loop over all the RODs
 
   85   for(const auto& [rodid, rod] : rodMap)
 
   87       if(log.level() <= MSG::DEBUG)
 
   88           log << MSG::DEBUG << " Rod id = " << std::format("{:x}", rodid) << endmsg;
 
   90       // make an ROB id from an ROD id. 
 
   91       const uint32_t robid = m_idmap.getRobID(rodid);
 
   93       // find or make a ROS fragment
 
   94       ROBMAP::const_iterator itr = robMap.find(robid);
 
   97           log << MSG::ERROR << " More than one ROD in ROB:" << std::format("{:x}", itr->first) << endmsg;
 
  100         { // Make a new ROBFragment 
 
  101           auto theROB = new OFFLINE_FRAGMENTS_NAMESPACE_WRITE::ROBFragment(robid,m_runnum,m_lvl1_id,m_bcid,
 
  102                                                                            m_lvl1_trigger_type,m_detEvtType,rod->size(),
 
  103                                                                            &(*rod)[0],eformat::STATUS_BACK);
 
  104           theROB->minor_version(m_rob_version);
 
  105           theROB->rod_minor_version(m_rod_version);
 
  106           robMap.emplace(robid, theROB);
 
  112 template <class IDMAP> 
 
  113 void FullEventAssembler<IDMAP>::RobToEvt(ROBMAP& robMap, RawEventWrite* re, MsgStream& log ) const
 
  115   const bool debug = log.level() <= MSG::DEBUG;
 
  116   if(debug) log << MSG::DEBUG << " RobToEvt, number of ROBFrag= " << robMap.size() << endmsg;
 
  118   for(const auto& [robid, theROB] : robMap)
 
  120       if(debug) log << MSG::DEBUG << " RobToEvt: adding ROB "
 
  121                     << std::format("{:x}", theROB->source_id()) << endmsg;
 
  125   if(debug) log << MSG::DEBUG << " FullEventFragment is done " << re << endmsg;
 
  129 template <class IDMAP> 
 
  130 FullEventAssembler<IDMAP>::RODMAP::const_iterator 
 
  131 FullEventAssembler<IDMAP>::begin() const 
 
  133   return  m_rodMap.begin();
 
  137 template <class IDMAP> 
 
  138 FullEventAssembler<IDMAP>::RODMAP::const_iterator 
 
  139 FullEventAssembler<IDMAP>::end() const 
 
  141   return  m_rodMap.end();
 
  145 template <class IDMAP> 
 
  146 void FullEventAssembler<IDMAP>::setRodMinorVersion(uint16_t m )
 
  152 template <class IDMAP> 
 
  153 void FullEventAssembler<IDMAP>::setRobMinorVersion(uint16_t m )
 
  159 template <class IDMAP> 
 
  160 void FullEventAssembler<IDMAP>::setDetEvtType(uint32_t m )
 
  166 template <class IDMAP> 
 
  167 void FullEventAssembler<IDMAP>::setLvl1TriggerType(uint8_t m )
 
  169   m_lvl1_trigger_type = m;
 
  173 template <class IDMAP> 
 
  174 typename FullEventAssembler<IDMAP>::IDMAP_t& FullEventAssembler<IDMAP>::idMap()