ATLAS Offline Software
LUCID_DigitByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
11 #include "StoreGate/StoreGateSvc.h"
13 
14 #include <cstdint>
15 #include <string>
16 #include <map>
17 
18 typedef std::map<uint32_t, LUCID_RodEncoder> LucidRodEncoder_map;
19 
21  Converter(storageType(), classID(), svcloc),
22  AthMessaging("LUCID_DigitByteStreamCnv"),
23  m_RodBlockVersion (0),
24  m_BCs_per_LVL1ID (1)
25 {
26  m_ByteStreamEventAccess = nullptr;
27  m_StoreGate = nullptr;
28 }
29 
31 
33  ATH_CHECK( service("ByteStreamCnvSvc", m_ByteStreamEventAccess) );
34 
35  return StatusCode::SUCCESS;
36 }
37 
39 
41 }
42 
44 
46 }
47 
48 StatusCode LUCID_DigitByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr) {
49 
50  ATH_MSG_DEBUG(" LUCID_DigitByteStreamCnv::createRep");
51 
53  LUCID_DigitContainer* RDO_container = nullptr;
54 
55  // dynamic cast of the pObj to RDO_container based in clid of pObj
56  if (!SG::fromStorable(pObj, RDO_container)) {
57  ATH_MSG_ERROR("Can not cast to LUCID_DigitContainer");
58  return StatusCode::RECOVERABLE;
59  }
60 
61 // get name of the persistent object (pObj)
62  std::string nm = pObj->registry()->name();
63 
64 // and create a empty generic BytestreamAddress for the specific clid of pObj
65  ByteStreamAddress* addr = new ByteStreamAddress(classID(), nm, "");
66 
67  pAddr = addr;
68 
69  StatusCode sc = fillFEA(RDO_container, re);
70 
71  if (sc.isFailure()){
72  ATH_MSG_ERROR(" Could not convert RawData with to ByteStream ");
73  return StatusCode::RECOVERABLE;
74  }
75 
76  return StatusCode::SUCCESS;
77 }
78 
80 
81  m_fea.clear();
82  // type of RODDATA is std::vector<uint32_t>
84 
86  ATH_MSG_DEBUG("Setting ROD Minor Version Number to: " << m_RodBlockVersion);
87 
88  LucidRodEncoder_map RDOEncoder_map;
89 
90  LUCID_DigitContainer::const_iterator it_cont = RDO_container->begin();
91  LUCID_DigitContainer::const_iterator it_cont_end = RDO_container->end();
93  for( ; it_cont != it_cont_end; ++it_cont) {
94 
95  if ((*it_cont) != nullptr) {
96 
97  uint32_t rodId = getSourceID();
98 
99  RDOEncoder_map[rodId].addDigit((*it_cont),cache);
100  }
101  else ATH_MSG_WARNING(" Digit is empty, skipping digit.");
102  }
103 
104  LucidRodEncoder_map::iterator it_map = RDOEncoder_map.begin();
105  LucidRodEncoder_map::iterator it_map_end = RDOEncoder_map.end();
106 
107  for (; it_map != it_map_end; ++it_map) {
108 
109  // (*it_map) is now a pointer of the type std::pair<const uint32_t, LUCID_RDOEncoder >
110 
111  theROD = m_fea.getRodData((*it_map).first);
112 
113  ((*it_map).second).encode(*theROD, cache, msg());
114 
115  (*theROD).push_back(0); // add status word
116 
117  LUCID_RawData lrd(*theROD);
118 
119  lrd.encodeLumatMapping();
120 
121  *theROD = lrd.getDataBlock();
122  }
123 
124  m_fea.fill(re, msg(MSG::INFO));
125 
126  return StatusCode::SUCCESS;
127 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LUCID_DigitByteStreamCnv::m_fea
FullEventAssembler< SrcIdMap > m_fea
Definition: LUCID_DigitByteStreamCnv.h:58
RawEventWrite
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition: RawEvent.h:39
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
AthCheckMacros.h
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:180
LUCID_DigitContainer
Definition: LUCID_DigitContainer.h:13
initialize
void initialize()
Definition: run_EoverP.cxx:894
LUCID_DigitByteStreamCnv::LUCID_DigitByteStreamCnv
LUCID_DigitByteStreamCnv(ISvcLocator *svcloc)
Definition: LUCID_DigitByteStreamCnv.cxx:20
LucidRodEncoder_map
std::map< uint32_t, LUCID_RodEncoder > LucidRodEncoder_map
Definition: LUCID_DigitByteStreamCnv.cxx:18
LUCID_DigitByteStreamCnv::fillFEA
StatusCode fillFEA(LUCID_DigitContainer *RDO_container, RawEventWrite *re)
Definition: LUCID_DigitByteStreamCnv.cxx:79
LUCID_DigitByteStreamCnv.h
IByteStreamEventAccess.h
LUCID_RawData
Definition: LUCID_RawData.h:40
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
LUCID_DigitByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: LUCID_DigitByteStreamCnv.cxx:30
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LUCID_RawData::encodeLumatMapping
void encodeLumatMapping(void)
Definition: LUCID_RawData.cxx:281
IByteStreamEventAccess::getRawEvent
virtual RawEventWrite * getRawEvent()=0
pure virtual method for accessing RawEventWrite
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
LUCID_RodEncoder::Cache
Definition: LUCID_RodEncoder.h:24
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LUCID_DigitByteStreamCnv::m_ByteStreamEventAccess
IByteStreamEventAccess * m_ByteStreamEventAccess
Definition: LUCID_DigitByteStreamCnv.h:55
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
LUCID_DigitByteStreamCnv::RodBlockVersion
unsigned short RodBlockVersion(void)
Definition: LUCID_DigitByteStreamCnv.h:48
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
LUCID_DigitByteStreamCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr) override
Definition: LUCID_DigitByteStreamCnv.cxx:48
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
FullEventAssembler::clear
void clear()
Clear internal stack.
LUCID_RodEncoder.h
Converter
Definition: Converter.h:27
LUCID_DigitByteStreamCnv::getSourceID
unsigned int getSourceID()
Definition: LUCID_DigitByteStreamCnv.h:51
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
FullEventAssembler::setRodMinorVersion
void setRodMinorVersion(uint16_t m)
change the ROD minor version
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LUCID_RawData::getDataBlock
std::vector< uint32_t > getDataBlock() const
Definition: LUCID_RawData.h:97
LUCID_DigitByteStreamCnv::m_RodBlockVersion
unsigned short m_RodBlockVersion
Definition: LUCID_DigitByteStreamCnv.h:59
re
const boost::regex re(r_e)
LUCID_DigitContainer.h
LUCID_DigitByteStreamCnv::storageType
static long storageType()
Definition: LUCID_DigitByteStreamCnv.cxx:43
LUCID_DigitByteStreamCnv::classID
static const CLID & classID()
Definition: LUCID_DigitByteStreamCnv.cxx:38
python.PerfMonSerializer.encode
def encode(data, use_base64=True)
Definition: PerfMonSerializer.py:375
LUCID_DigitByteStreamCnv::m_StoreGate
StoreGateSvc * m_StoreGate
Definition: LUCID_DigitByteStreamCnv.h:56
StoreGateSvc.h
FullEventAssembler::getRodData
RODDATA * getRodData(uint32_t id)
get a block of ROD data
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
FullEventAssembler::fill
void fill(RawEventWrite *re, MsgStream &log)
Fill the FullEventFragment with all the ROD data stored in this.