ATLAS Offline Software
CpReadByteStreamV1V2Cnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #include <vector>
7 #include <stdint.h>
8 
12 
14 #include "ByteStreamData/ROBData.h"
15 
17 
18 #include "GaudiKernel/DataObject.h"
19 #include "GaudiKernel/IOpaqueAddress.h"
20 #include "GaudiKernel/IRegistry.h"
21 #include "GaudiKernel/ISvcLocator.h"
22 #include "GaudiKernel/StatusCode.h"
23 
27 
29 
31 #include "CpByteStreamV1Tool.h"
32 #include "CpByteStreamV2Tool.h"
33 
34 namespace LVL1BS {
35 
37  : AthConstConverter( storageType(), classID(), svcloc, "CpReadByteStreamV1V2Cnv" ),
38  m_tool1("LVL1BS::CpByteStreamV1Tool/CpByteStreamV1Tool"),
39  m_tool2("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool"),
40  m_robDataProvider("ROBDataProviderSvc", name())
41 {
42 }
43 
45 {
46 }
47 
48 // CLID
49 
51 {
53 }
54 
56 {
58 }
59 
60 // Init method gets all necessary services etc.
61 
62 
64 {
66  ATH_CHECK( m_tool1.retrieve() );
67  ATH_CHECK( m_tool2.retrieve() );
68  ATH_CHECK( m_robDataProvider.retrieve() );
69 
70  return StatusCode::SUCCESS;
71 }
72 
73 // createObj should create the RDO from bytestream.
74 
76  DataObject*& pObj ) const
77 {
78  ByteStreamAddress *pBS_Addr;
79  pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
80  if ( !pBS_Addr ) {
81  ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
82  return StatusCode::FAILURE;
83  }
84 
85  const std::string nm = *( pBS_Addr->par() );
86 
87  ATH_MSG_DEBUG( " Creating Objects " << nm );
88 
89  // get SourceIDs
90  const std::vector<uint32_t>& vID1(m_tool1->sourceIDs());
91  const std::vector<uint32_t>& vID2(m_tool2->sourceIDs());
92 
93  // get ROB fragments
95  m_robDataProvider->getROBData( vID1, robFrags1 );
97  m_robDataProvider->getROBData( vID2, robFrags2 );
98 
99  // size check
100  auto towerCollection = std::make_unique<DataVector<LVL1::CPMTower> >();
101  ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags1.size()
102  << ", " << robFrags2.size() );
103 
104  if (robFrags1.size() == 0 && robFrags2.size() == 0) {
105  pObj = SG::asStorable(std::move(towerCollection)) ;
106  return StatusCode::SUCCESS;
107  }
108 
109  // Pre-LS1 data
110  if (robFrags1.size() > 0) {
111  ATH_CHECK( m_tool1->convert(nm, robFrags1, towerCollection.get()) );
112  }
113  // Post-LS1 data
114  if (robFrags2.size() > 0) {
115  ATH_CHECK( m_tool2->convert(nm, robFrags2, towerCollection.get()) );
116  }
117 
118  pObj = SG::asStorable(std::move(towerCollection));
119 
120  return StatusCode::SUCCESS;
121 }
122 
123 } // end namespace
LVL1BS::CpReadByteStreamV1V2Cnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create CPM Towers from ByteStream.
Definition: CpReadByteStreamV1V2Cnv.cxx:75
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
StorableConversions.h
convert to and from a SG storable
LVL1BS::CpReadByteStreamV1V2Cnv::CpReadByteStreamV1V2Cnv
CpReadByteStreamV1V2Cnv(ISvcLocator *svcloc)
Definition: CpReadByteStreamV1V2Cnv.cxx:36
LVL1BS::CpReadByteStreamV1V2Cnv::storageType
static long storageType()
Definition: CpReadByteStreamV1V2Cnv.cxx:55
ROBData.h
Defines the ROB data entity. The ROB data is an abstract entity that is used to discase the raw event...
initialize
void initialize()
Definition: run_EoverP.cxx:894
LVL1BS::CpReadByteStreamV1V2Cnv::~CpReadByteStreamV1V2Cnv
virtual ~CpReadByteStreamV1V2Cnv()
Definition: CpReadByteStreamV1V2Cnv.cxx:44
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
IByteStreamEventAccess.h
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
LVL1BS::CpReadByteStreamV1V2Cnv::classID
static const CLID & classID()
Definition: CpReadByteStreamV1V2Cnv.cxx:50
CpReadByteStreamV1V2Cnv.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
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
LVL1BS::CpReadByteStreamV1V2Cnv::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for reading bytestream.
Definition: CpReadByteStreamV1V2Cnv.h:60
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
CpByteStreamV1Tool.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IROBDataProviderSvc::VROBFRAG
std::vector< const ROBF * > VROBFRAG
Definition: IROBDataProviderSvc.h:29
ByteStreamAddress.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
LVL1BS::CpReadByteStreamV1V2Cnv::m_tool2
ToolHandle< LVL1BS::CpByteStreamV2Tool > m_tool2
Tool that does the actual work post-LS1.
Definition: CpReadByteStreamV1V2Cnv.h:57
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CPMTower.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
LVL1BS::CpReadByteStreamV1V2Cnv::initialize
virtual StatusCode initialize() override
Definition: CpReadByteStreamV1V2Cnv.cxx:63
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
LVL1BS::CpReadByteStreamV1V2Cnv::m_tool1
ToolHandle< LVL1BS::CpByteStreamV1Tool > m_tool1
Tool that does the actual work pre-LS1.
Definition: CpReadByteStreamV1V2Cnv.h:55
IROBDataProviderSvc.h
CpByteStreamV2Tool.h