ATLAS Offline Software
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 
10 #include "StoreGate/StoreGateSvc.h"
12 
13 #include <cstdint>
14 #include <string>
15 #include <map>
16 
17 typedef std::map<uint32_t, LUCID_RodEncoder> LucidRodEncoder_map;
18 
20  Converter(storageType(), classID(), svcloc),
21  AthMessaging("LUCID_DigitByteStreamCnv"),
22  m_ByteStreamEventAccess("ByteStreamCnvSvc", "LUCID_DigitByteStreamCnv"),
23  m_RodBlockVersion (0),
24  m_BCs_per_LVL1ID (1)
25 {
26 
27 }
28 
30 
32  ATH_CHECK( m_ByteStreamEventAccess.retrieve() );
33 
34  return StatusCode::SUCCESS;
35 }
36 
38 
40 }
41 
43 
45 }
46 
47 StatusCode LUCID_DigitByteStreamCnv::createRep(DataObject* pObj, IOpaqueAddress*& pAddr) {
48 
49  ATH_MSG_DEBUG(" LUCID_DigitByteStreamCnv::createRep");
50 
51  RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
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 
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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LUCID_DigitByteStreamCnv::m_fea
FullEventAssembler< SrcIdMap > m_fea
Definition: LUCID_DigitByteStreamCnv.h:54
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:167
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:19
LUCID_DigitByteStreamCnv::m_ByteStreamEventAccess
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Definition: LUCID_DigitByteStreamCnv.h:52
LucidRodEncoder_map
std::map< uint32_t, LUCID_RodEncoder > LucidRodEncoder_map
Definition: LUCID_DigitByteStreamCnv.cxx:17
LUCID_DigitByteStreamCnv::fillFEA
StatusCode fillFEA(LUCID_DigitContainer *RDO_container, RawEventWrite *re)
Definition: LUCID_DigitByteStreamCnv.cxx:78
LUCID_DigitByteStreamCnv.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:29
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LUCID_RawData::encodeLumatMapping
void encodeLumatMapping(void)
Definition: LUCID_RawData.cxx:281
AtlasMcWeight::encode
number_type encode(double weight)
Definition: AtlasMcWeight.cxx:65
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
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:45
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:47
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:48
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:55
re
const boost::regex re(r_e)
LUCID_DigitContainer.h
LUCID_DigitByteStreamCnv::storageType
static long storageType()
Definition: LUCID_DigitByteStreamCnv.cxx:42
LUCID_DigitByteStreamCnv::classID
static const CLID & classID()
Definition: LUCID_DigitByteStreamCnv.cxx:37
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.