ATLAS Offline Software
Loading...
Searching...
No Matches
CpReadByteStreamV1V2Cnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6#include <vector>
7#include <stdint.h>
8
11
14
16
17#include "GaudiKernel/DataObject.h"
18#include "GaudiKernel/IOpaqueAddress.h"
19#include "GaudiKernel/IRegistry.h"
20#include "GaudiKernel/ISvcLocator.h"
21#include "GaudiKernel/StatusCode.h"
22
26
28
30#include "CpByteStreamV1Tool.h"
31#include "CpByteStreamV2Tool.h"
32
33namespace LVL1BS {
34
36 : AthConstConverter( storageType(), classID(), svcloc, "CpReadByteStreamV1V2Cnv" ),
37 m_tool1("LVL1BS::CpByteStreamV1Tool/CpByteStreamV1Tool"),
38 m_tool2("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool"),
39 m_robDataProvider("ROBDataProviderSvc", name())
40{
41}
42
46
47// CLID
48
53
58
59// Init method gets all necessary services etc.
60
61
63{
64 ATH_CHECK( Converter::initialize() );
65 ATH_CHECK( m_tool1.retrieve() );
66 ATH_CHECK( m_tool2.retrieve() );
67 ATH_CHECK( m_robDataProvider.retrieve() );
68
69 return StatusCode::SUCCESS;
70}
71
72// createObj should create the RDO from bytestream.
73
74StatusCode CpReadByteStreamV1V2Cnv::createObjConst( IOpaqueAddress* pAddr,
75 DataObject*& pObj ) const
76{
77 ByteStreamAddress* pBS_Addr{};
78 ATH_CHECK( (pBS_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
79
80 const EventContext& ctx = pBS_Addr->getEventContext();
81 const std::string nm = *( pBS_Addr->par() );
82
83 ATH_MSG_DEBUG( " Creating Objects " << nm );
84
85 // get SourceIDs
86 const std::vector<uint32_t>& vID1(m_tool1->sourceIDs());
87 const std::vector<uint32_t>& vID2(m_tool2->sourceIDs());
88
89 // get ROB fragments
91 m_robDataProvider->getROBData(ctx, vID1, robFrags1 );
93 m_robDataProvider->getROBData(ctx, vID2, robFrags2 );
94
95 // size check
96 auto towerCollection = std::make_unique<DataVector<LVL1::CPMTower> >();
97 ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags1.size()
98 << ", " << robFrags2.size() );
99
100 if (robFrags1.size() == 0 && robFrags2.size() == 0) {
101 pObj = SG::asStorable(std::move(towerCollection)) ;
102 return StatusCode::SUCCESS;
103 }
104
105 // Pre-LS1 data
106 if (robFrags1.size() > 0) {
107 ATH_CHECK( m_tool1->convert(nm, robFrags1, towerCollection.get()) );
108 }
109 // Post-LS1 data
110 if (robFrags2.size() > 0) {
111 ATH_CHECK( m_tool2->convert(nm, robFrags2, towerCollection.get()) );
112 }
113
114 pObj = SG::asStorable(std::move(towerCollection));
115
116 return StatusCode::SUCCESS;
117}
118
119} // end namespace
#define ATH_CHECK
Evaluate an expression and check for errors.
#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...
Helpers for checking error return status codes and reporting errors.
An STL vector of pointers that by default owns its pointed-to elements.
uint32_t CLID
The Class ID type.
Defines the ROB data entity. The ROB data is an abstract entity that is used to decouple the raw even...
convert to and from a SG storable
AthConstConverter(long storage_type, const CLID &class_type, ISvcLocator *svc, const std::string &name)
const std::string & name() const
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
const EventContext & getEventContext() const
static constexpr long storageType()
std::vector< const ROBF * > VROBFRAG
ToolHandle< LVL1BS::CpByteStreamV1Tool > m_tool1
Tool that does the actual work pre-LS1.
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create CPM Towers from ByteStream.
virtual StatusCode initialize() override
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for reading bytestream.
ToolHandle< LVL1BS::CpByteStreamV2Tool > m_tool2
Tool that does the actual work post-LS1.
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Default, invalid implementation of ClassID_traits.