ATLAS Offline Software
L1TopoByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 // Gaudi/Athena include(s):
7 #include "GaudiKernel/IRegistry.h"
8 
11 #include "ByteStreamData/ROBData.h"
12 
14 
15 // Trigger include(s):
17 #include "L1TopoRDO/Helpers.h"
18 
19 // Local include(s):
20 #include "L1TopoByteStreamCnv.h"
21 #include "L1TopoSrcIdMap.h"
22 
29  : AthConstConverter(storageType(), classID(), svcloc, "L1TopoByteStreamCnv"),
30  m_tool("L1TopoByteStreamTool"),
31  m_srcIdMap(0),
32  m_robDataProvider("ROBDataProviderSvc", "L1TopoByteStreamCnv"),
33  m_ByteStreamEventAccess("ByteStreamCnvSvc", "L1TopoByteStreamCnv") {}
34 
40  if (m_srcIdMap) {
41  delete m_srcIdMap;
42  m_srcIdMap = 0;
43  }
44 }
45 
52 }
53 
56 }
57 
62  //
63  // Initialise the base class:
64  //
66  if (sc.isFailure()) {
67  return sc;
68  }
69 
70  ATH_MSG_DEBUG("L1TopoByteStreamCnv in initialize() ");
71 
72  //
73  // Get ByteStreamCnvSvc:
74  //
75  sc = m_ByteStreamEventAccess.retrieve();
76  if (sc.isFailure()) {
77  ATH_MSG_FATAL("Can't get ByteStreamEventAccess interface");
78  return sc;
79  } else {
80  ATH_MSG_DEBUG("Connected to ByteStreamEventAccess interface");
81  }
82 
83  //
84  // Get L1TopoByteStreamTool:
85  //
86  sc = m_tool.retrieve();
87  if (sc.isFailure()) {
88  ATH_MSG_FATAL("Can't get L1TopoByteStreamTool");
89  return sc;
90  } else {
91  ATH_MSG_DEBUG("Connected to L1TopoByteStreamTool");
92  }
93 
94  //
95  // Get ROBDataProvider:
96  //
97  sc = m_robDataProvider.retrieve();
98  if (sc.isFailure()) {
99  ATH_MSG_WARNING("Can't get ROBDataProviderSvc");
100  // return is disabled for Write BS which does not requre ROBDataProviderSvc
101  } else {
102  ATH_MSG_DEBUG("Connected to ROBDataProviderSvc");
103  }
104 
105  //
106  // Create L1TopoSrcIdMap:
107  //
108  m_srcIdMap = new L1TopoSrcIdMap();
109 
110  return StatusCode::SUCCESS;
111 }
112 
119  DataObject*& pObj) const {
120  ATH_MSG_DEBUG("createObj() called");
121  // -------------------------------------------------------------------------
122  ByteStreamAddress* pBS_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
123  CHECK(pBS_Addr != nullptr);
124  // -------------------------------------------------------------------------
125  const std::string nm = *(pBS_Addr->par());
126  ATH_MSG_DEBUG("Creating Objects " << nm);
127 
128  // Create an empty collection. This is a DataVector<L1TopoRDO> which is like a
129  // vector of pointers to L1TopoRDO and it owns the L1TopoRDOs from a memory
130  // cleanup point of view
132  StatusCode sc = m_tool->convert(nm, result);
133  if (sc.isFailure()) {
134  return sc;
135  }
136  ATH_MSG_DEBUG("Converted " << result->size() << " ROBs");
137  pObj = SG::asStorable(result);
138 
139  return StatusCode::SUCCESS;
140 }
141 
148  IOpaqueAddress*& pAddr) const {
149  ATH_MSG_DEBUG("createRep() called");
150 
151  RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
152 
154  if (!SG::fromStorable(pObj, result)) {
155  ATH_MSG_ERROR(" Cannot cast to L1TopoRDOCollection");
156  return StatusCode::FAILURE;
157  } else {
158  ATH_MSG_DEBUG(" Found " << result->size() << " L1TopoRDOs to convert to ROBs");
159  }
160 
161  ByteStreamAddress* addr =
162  new ByteStreamAddress(classID(), pObj->registry()->name(), "");
163 
164  pAddr = addr;
165 
166  // Convert to ByteStream
168  it != result->end(); ++it) {
169  StatusCode sc = m_tool->convert(*it, re);
170  if (sc.isFailure()) {
171  ATH_MSG_ERROR(" Failed to create ROB for L1TopoRDO: " << **it);
172  return sc;
173  }
174  }
175  return StatusCode::SUCCESS;
176 }
L1TopoByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const
Function creating the L1TopoRDOCollection object from a L1Topo ROB fragment.
Definition: L1TopoByteStreamCnv.cxx:118
RawEventWrite
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition: RawEvent.h:39
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
get_generator_info.result
result
Definition: get_generator_info.py:21
L1TopoByteStreamCnv::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service used when reading the BS data.
Definition: L1TopoByteStreamCnv.h:74
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:180
StorableConversions.h
convert to and from a SG storable
ROBData.h
Defines the ROB data entity. The ROB data is an abstract entity that is used to discase the raw event...
L1TopoSrcIdMap
This class provides conversion between Lower level Source ID to higher level source ID for L1Topo Byt...
Definition: L1TopoSrcIdMap.h:17
initialize
void initialize()
Definition: run_EoverP.cxx:894
skel.it
it
Definition: skel.GENtoEVGEN.py:423
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
L1TopoByteStreamCnv::m_srcIdMap
L1TopoSrcIdMap * m_srcIdMap
Object storing the various IDs of the CTP fragment.
Definition: L1TopoByteStreamCnv.h:71
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
L1TopoByteStreamCnv.h
L1TopoByteStreamCnv::L1TopoByteStreamCnv
L1TopoByteStreamCnv(ISvcLocator *svcloc)
Standard constructor.
Definition: L1TopoByteStreamCnv.cxx:28
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
L1TopoByteStreamCnv::classID
static const CLID & classID()
Function needed by the framework.
Definition: L1TopoByteStreamCnv.cxx:50
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RawEvent.h
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
L1TopoRDOCollection.h
L1TopoByteStreamCnv::m_tool
ToolHandle< L1TopoByteStreamTool > m_tool
Tool doing the actual conversion.
Definition: L1TopoByteStreamCnv.h:68
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
L1TopoByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const
Function creating the L1Topo ROB fragment from a L1TopoRDOCollection object.
Definition: L1TopoByteStreamCnv.cxx:147
L1TopoByteStreamCnv::initialize
virtual StatusCode initialize()
Function connecting to all the needed services/tools.
Definition: L1TopoByteStreamCnv.cxx:61
L1TopoRDOCollection
Container of L1TopoRDOs (standard Athena boilerplate)
Definition: L1TopoRDOCollection.h:13
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
L1TopoByteStreamCnv::~L1TopoByteStreamCnv
~L1TopoByteStreamCnv()
Standard destructor.
Definition: L1TopoByteStreamCnv.cxx:39
L1TopoByteStreamCnv::storageType
static long storageType()
Function needed by the framework.
Definition: L1TopoByteStreamCnv.cxx:54
L1TopoByteStreamCnv::m_ByteStreamEventAccess
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service used when writing the BS data.
Definition: L1TopoByteStreamCnv.h:76
Helpers.h
L1TopoSrcIdMap.h