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 
11 
13 #include "ByteStreamData/ROBData.h"
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 
33 namespace 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 
44 {
45 }
46 
47 // CLID
48 
50 {
52 }
53 
55 {
57 }
58 
59 // Init method gets all necessary services etc.
60 
61 
63 {
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 
75  DataObject*& pObj ) const
76 {
77  ByteStreamAddress *pBS_Addr;
78  pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
79  if ( !pBS_Addr ) {
80  ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
81  return StatusCode::FAILURE;
82  }
83 
84  const std::string nm = *( pBS_Addr->par() );
85 
86  ATH_MSG_DEBUG( " Creating Objects " << nm );
87 
88  // get SourceIDs
89  const std::vector<uint32_t>& vID1(m_tool1->sourceIDs());
90  const std::vector<uint32_t>& vID2(m_tool2->sourceIDs());
91 
92  // get ROB fragments
94  m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID1, robFrags1 );
96  m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID2, robFrags2 );
97 
98  // size check
99  auto towerCollection = std::make_unique<DataVector<LVL1::CPMTower> >();
100  ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags1.size()
101  << ", " << robFrags2.size() );
102 
103  if (robFrags1.size() == 0 && robFrags2.size() == 0) {
104  pObj = SG::asStorable(std::move(towerCollection)) ;
105  return StatusCode::SUCCESS;
106  }
107 
108  // Pre-LS1 data
109  if (robFrags1.size() > 0) {
110  ATH_CHECK( m_tool1->convert(nm, robFrags1, towerCollection.get()) );
111  }
112  // Post-LS1 data
113  if (robFrags2.size() > 0) {
114  ATH_CHECK( m_tool2->convert(nm, robFrags2, towerCollection.get()) );
115  }
116 
117  pObj = SG::asStorable(std::move(towerCollection));
118 
119  return StatusCode::SUCCESS;
120 }
121 
122 } // end namespace
LVL1BS::CpReadByteStreamV1V2Cnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create CPM Towers from ByteStream.
Definition: CpReadByteStreamV1V2Cnv.cxx:74
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:35
LVL1BS::CpReadByteStreamV1V2Cnv::storageType
static long storageType()
Definition: CpReadByteStreamV1V2Cnv.cxx:54
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:43
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
LVL1BS::CpReadByteStreamV1V2Cnv::classID
static const CLID & classID()
Definition: CpReadByteStreamV1V2Cnv.cxx:49
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:59
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:27
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:56
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:62
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:54
IROBDataProviderSvc.h
CpByteStreamV2Tool.h