ATLAS Offline Software
Loading...
Searching...
No Matches
LUCID_DigitByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
12
13#include <cstdint>
14#include <string>
15#include <map>
16
17typedef std::map<uint32_t, LUCID_RodEncoder> LucidRodEncoder_map;
18
20 Converter(storageType(), classID(), svcloc),
21 AthMessaging("LUCID_DigitByteStreamCnv"),
22 m_ByteStreamEventAccess("ByteStreamCnvSvc", "LUCID_DigitByteStreamCnv"),
25{
26
27}
28
30
31 ATH_CHECK( Converter::initialize() );
33
34 return StatusCode::SUCCESS;
35}
36
41
46
47StatusCode LUCID_DigitByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr) {
48
49 ATH_MSG_DEBUG(" LUCID_DigitByteStreamCnv::createRep");
50
52 LUCID_DigitContainer* RDO_container = nullptr;
53
54 // dynamic cast of the pObj to RDO_container based in clid of pObj
55 if (!SG::fromStorable(pObj, RDO_container)) {
56 ATH_MSG_ERROR("Can not cast to LUCID_DigitContainer");
57 return StatusCode::RECOVERABLE;
58 }
59
60// get name of the persistent object (pObj)
61 std::string nm = pObj->registry()->name();
62
63// and create a empty generic BytestreamAddress for the specific clid of pObj
64 ByteStreamAddress* addr = new ByteStreamAddress(classID(), nm, "");
65
66 pAddr = addr;
67
68 StatusCode sc = fillFEA(RDO_container, re);
69
70 if (sc.isFailure()){
71 ATH_MSG_ERROR(" Could not convert RawData with to ByteStream ");
72 return StatusCode::RECOVERABLE;
73 }
74
75 return StatusCode::SUCCESS;
76}
77
79
80 m_fea.clear();
81 // type of RODDATA is std::vector<uint32_t>
83
84 m_fea.setRodMinorVersion(RodBlockVersion());
85 ATH_MSG_DEBUG("Setting ROD Minor Version Number to: " << m_RodBlockVersion);
86
87 LucidRodEncoder_map RDOEncoder_map;
88
89 LUCID_DigitContainer::const_iterator it_cont = RDO_container->begin();
90 LUCID_DigitContainer::const_iterator it_cont_end = RDO_container->end();
92 for( ; it_cont != it_cont_end; ++it_cont) {
93
94 if ((*it_cont) != nullptr) {
95
96 uint32_t rodId = getSourceID();
97
98 RDOEncoder_map[rodId].addDigit((*it_cont),cache);
99 }
100 else ATH_MSG_WARNING(" Digit is empty, skipping digit.");
101 }
102
103 LucidRodEncoder_map::iterator it_map = RDOEncoder_map.begin();
104 LucidRodEncoder_map::iterator it_map_end = RDOEncoder_map.end();
105
106 for (; it_map != it_map_end; ++it_map) {
107
108 // (*it_map) is now a pointer of the type std::pair<const uint32_t, LUCID_RDOEncoder >
109
110 theROD = m_fea.getRodData((*it_map).first);
111
112 ((*it_map).second).encode(*theROD, cache, msg());
113
114 (*theROD).push_back(0); // add status word
115
116 LUCID_RawData lrd(*theROD);
117
118 lrd.encodeLumatMapping();
119
120 *theROD = lrd.getDataBlock();
121 }
122
123 m_fea.fill(re, msg(MSG::INFO));
124
125 return StatusCode::SUCCESS;
126}
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
uint32_t CLID
The Class ID type.
static Double_t sc
std::map< uint32_t, LUCID_RodEncoder > LucidRodEncoder_map
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition RawEvent.h:39
MsgStream & msg() const
The standard message stream.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
static constexpr long storageType()
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
std::vector< uint32_t > RODDATA
ROD data as a vector of unsigned int.
virtual StatusCode initialize() override
FullEventAssembler< SrcIdMap > m_fea
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
LUCID_DigitByteStreamCnv(ISvcLocator *svcloc)
StatusCode fillFEA(LUCID_DigitContainer *RDO_container, RawEventWrite *re)
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr) override
unsigned short RodBlockVersion(void)
void encodeLumatMapping(void)
std::vector< uint32_t > getDataBlock() const
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)