ATLAS Offline Software
ZdcByteStreamLucrodData.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 #include "eformat/SourceIdentifier.h"
10 
12 
13 ZdcByteStreamLucrodData::ZdcByteStreamLucrodData(const std::string& name, ISvcLocator* pSvcLocator):
14  AthAlgorithm (name , pSvcLocator),
15  m_robDataProvider("ROBDataProviderSvc", name),
16  m_ZdcLucrodDecoder(eformat::FORWARD_ZDC)
17  {
18  }
19 
21 
22  ATH_MSG_DEBUG("ZdcByteStreamLucrodData::initialize");
23 
24  StatusCode sc = m_robDataProvider.retrieve();
25 
26  if (sc.isFailure()) ATH_MSG_WARNING(" Could not retrieve ROBDataProviderSvc ");
27  else ATH_MSG_DEBUG (" Retrieved service ROBDataProviderSvc ");
28 
30 
31  return StatusCode::SUCCESS;
32 }
33 
35 
36  ATH_MSG_DEBUG(" ZdcByteStreamLucrodData::execute ");
37 
39 
40  std::vector<const ROBFragment*> listOfRobf;
41  std::vector<unsigned int> ROBIDs;
42 
43  // Set up the list of LUCROD ROBIDs
44  //
45  // High word of source ID indicates the ZDC (0x83)
46  // Low word numbers the modules: 0-5 for the 6 LUCRODs in Run 3
47  //
48  const unsigned int RODSourceIdShifted = eformat::FORWARD_ZDC << 16;
49 
50  for (unsigned int lucrodModuleNum = 0; lucrodModuleNum < 6; lucrodModuleNum++) {
51  ROBIDs.push_back(RODSourceIdShifted + lucrodModuleNum);
52  }
53 
54  ATH_MSG_DEBUG("ZdcByteStreamLucrodData::execute::getROBDATA");
55  m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), ROBIDs, listOfRobf);
56 
57  auto zdcLucrodDataContainer = std::make_unique<ZdcLucrodDataContainer>();
58 
59  ATH_MSG_DEBUG("ZdcByteStreamLucrodData::execute::filleContainer");
60  StatusCode sc = fillContainer(listOfRobf,zdcLucrodDataContainer.get());
61 
62  if (sc.isFailure()) ATH_MSG_WARNING(" fillContainer failed ");
63  else ATH_MSG_DEBUG (" fillContainer success ");
64 
65  ATH_MSG_DEBUG("ZdcByteStreamLucrodData::execute::record m_ZdcLucrodDataContainerKey");
66 
67  sc = h_write.record(std::move(zdcLucrodDataContainer));
68 
69  ATH_MSG_DEBUG("ZdcByteStreamLucrodData::execute::record testing...");
70 
71  if (sc.isFailure()) ATH_MSG_WARNING(" Could not record ZdcLucrodDataContainer in StoreGate ");
72  else ATH_MSG_DEBUG (" ZdcLucrodDataContainer is recorded in StoreGate ");
73 
74  return StatusCode::SUCCESS;
75 }
76 
77 StatusCode ZdcByteStreamLucrodData::fillContainer(std::vector<const ROBFragment*> listOfRobf, ZdcLucrodDataContainer* zdcLucrodDataContainer) {
78 
79  ATH_MSG_DEBUG(" ZdcByteStreamLucrodData::fillContainer ");
80 
81  size_t nFragments = listOfRobf.size();
82 
83  ATH_MSG_DEBUG(" Number of ROB fragments: " << nFragments);
84 
85  if (!nFragments) return StatusCode::SUCCESS;
86 
87  std::vector<const ROBFragment*>::const_iterator rob_it = listOfRobf.begin();
88  std::vector<const ROBFragment*>::const_iterator rob_end = listOfRobf.end();
89 
90  for (; rob_it != rob_end; ++rob_it) {
91 
92  // *** important: we need to use [rod] source id here ***
93  //
94  uint32_t robid = (*rob_it)->rod_source_id();
95 
96  ATH_MSG_DEBUG(" ROB Fragment with ID: 0x" << std::hex << robid << std::dec);
97 
98  uint32_t lucrodID = robid & 0x7;
99 
100  ZdcLucrodData* zld = new ZdcLucrodData(lucrodID);
101 
102  StatusCode sc = m_ZdcLucrodDecoder.decode(&**rob_it, zld);
103 
104  if (sc.isFailure()) ATH_MSG_WARNING(" Conversion from ByteStream to ZdcLucrodData failed ");
105  else zdcLucrodDataContainer->push_back(zld);
106  }
107 
108  for (auto zld : *zdcLucrodDataContainer) {zld->str();}
109 
110  if (zdcLucrodDataContainer->size() == nFragments)
111  return StatusCode::SUCCESS;
112  else
113  return StatusCode::FAILURE;
114 
115 }
116 
118 
119  ATH_MSG_DEBUG(" ZdcByteStreamLucrodData::finalize ");
120 
121  return StatusCode::SUCCESS;
122 }
eformat
Definition: L1CaloBsDecoderUtil.h:11
ZdcByteStreamLucrodData::initialize
StatusCode initialize()
Definition: ZdcByteStreamLucrodData.cxx:20
ZdcLucrodData::str
std::string str() const
Definition: ZdcLucrodData.h:84
ZdcLucrodDataContainer.h
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ZdcLucrodDataContainer
Definition: ZdcLucrodDataContainer.h:12
ZdcByteStreamLucrodData::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Definition: ZdcByteStreamLucrodData.h:40
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ZdcByteStreamLucrodData::ZdcByteStreamLucrodData
ZdcByteStreamLucrodData(const std::string &name, ISvcLocator *pSvcLocator)
Definition: ZdcByteStreamLucrodData.cxx:13
ZdcByteStreamLucrodData::m_ZdcLucrodDecoder
ZdcLucrodDecoder m_ZdcLucrodDecoder
Definition: ZdcByteStreamLucrodData.h:43
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
ZdcLucrodDecoder::decode
StatusCode decode(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment *robFragment, ZdcLucrodData *zld)
Definition: ZdcLucrodDecoder.cxx:10
ZdcByteStreamLucrodData::execute
StatusCode execute()
Definition: ZdcByteStreamLucrodData.cxx:34
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ZdcByteStreamLucrodData.h
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
ZdcByteStreamLucrodData::fillContainer
StatusCode fillContainer(std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * >, ZdcLucrodDataContainer *zdcLucrodDataContainer)
Definition: ZdcByteStreamLucrodData.cxx:77
AthAlgorithm
Definition: AthAlgorithm.h:47
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment
eformat::ROBFragment< PointerType > ROBFragment
Definition: RawEvent.h:27
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
ZdcLucrodData.h
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ZdcLucrodData
Definition: ZdcLucrodData.h:20
ZdcByteStreamLucrodData::m_ZdcLucrodDataContainerKey
SG::WriteHandleKey< ZdcLucrodDataContainer > m_ZdcLucrodDataContainerKey
Definition: ZdcByteStreamLucrodData.h:42
ZdcByteStreamLucrodData::finalize
StatusCode finalize()
Definition: ZdcByteStreamLucrodData.cxx:117