ATLAS Offline Software
PpmByteStreamV1Cnv.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 
30 #include "PpmByteStreamV1Cnv.h"
31 #include "PpmByteStreamV1Tool.h"
32 
33 namespace LVL1BS {
34 
36  : AthConstConverter( storageType(), classID(), svcloc, "PpmByteStreamV1Cnv" ),
37  m_tool("LVL1BS::PpmByteStreamV1Tool/PpmByteStreamV1Tool"),
38  m_robDataProvider("ROBDataProviderSvc", name()),
39  m_ByteStreamEventAccess("ByteStreamCnvSvc", 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_ByteStreamEventAccess.retrieve() );
66  ATH_CHECK( m_tool.retrieve() );
67 
68  // Get ROBDataProvider
69  StatusCode sc = m_robDataProvider.retrieve();
70  if ( sc.isFailure() ) {
71  ATH_MSG_WARNING( "Failed to retrieve service " << m_robDataProvider );
72  // return is disabled for Write BS which does not require ROBDataProviderSvc
73  // return sc ;
74  }
75  return StatusCode::SUCCESS;
76 }
77 
78 // createObj should create the RDO from bytestream.
79 
81  DataObject*& pObj ) const
82 {
83  ByteStreamAddress *pBS_Addr;
84  pBS_Addr = dynamic_cast<ByteStreamAddress *>( pAddr );
85  if ( !pBS_Addr ) {
86  ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
87  return StatusCode::FAILURE;
88  }
89 
90  const std::string nm = *( pBS_Addr->par() );
91 
92  ATH_MSG_DEBUG( " Creating Objects " << nm );
93 
94  // get SourceIDs
95  const std::vector<uint32_t>& vID(m_tool->sourceIDs(nm));
96 
97  // get ROB fragments
99  m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags );
100 
101  // size check
102  auto ttCollection = std::make_unique<DataVector<LVL1::TriggerTower> >(SG::VIEW_ELEMENTS);
103  ATH_MSG_DEBUG( " Number of ROB fragments is " << robFrags.size() );
104 
105  if (robFrags.size() == 0) {
106  pObj = SG::asStorable(std::move(ttCollection)) ;
107  return StatusCode::SUCCESS;
108  }
109 
110  ATH_CHECK( m_tool->convert(nm, robFrags, ttCollection.get()) );
111 
112  pObj = SG::asStorable(std::move(ttCollection));
113 
114  return StatusCode::SUCCESS;
115 }
116 
117 // createRep should create the bytestream from RDOs.
118 
120  IOpaqueAddress*& pAddr ) const
121 {
122  RawEventWrite* re = m_ByteStreamEventAccess->getRawEvent();
123 
124  DataVector<LVL1::TriggerTower>* ttCollection = 0;
125  if( !SG::fromStorable( pObj, ttCollection ) ) {
126  ATH_MSG_ERROR( " Cannot cast to DataVector<TriggerTower>" );
127  return StatusCode::FAILURE;
128  }
129 
130  const std::string nm = pObj->registry()->name();
131 
132  ByteStreamAddress* addr = new ByteStreamAddress( classID(), nm, "" );
133 
134  pAddr = addr;
135 
136  // Convert to ByteStream
137  return m_tool->convert( ttCollection, re );
138 }
139 
140 } // end namespace
LVL1BS::PpmByteStreamV1Cnv::initialize
virtual StatusCode initialize() override
Definition: PpmByteStreamV1Cnv.cxx:62
RawEventWrite
OFFLINE_FRAGMENTS_NAMESPACE_WRITE::FullEventFragment RawEventWrite
data type for writing raw event
Definition: RawEvent.h:39
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
LVL1BS::PpmByteStreamV1Cnv::PpmByteStreamV1Cnv
PpmByteStreamV1Cnv(ISvcLocator *svcloc)
Definition: PpmByteStreamV1Cnv.cxx:35
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
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...
initialize
void initialize()
Definition: run_EoverP.cxx:894
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
IByteStreamEventAccess.h
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1BS::PpmByteStreamV1Cnv::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service for reading bytestream.
Definition: PpmByteStreamV1Cnv.h:57
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
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
LVL1BS::PpmByteStreamV1Cnv::~PpmByteStreamV1Cnv
virtual ~PpmByteStreamV1Cnv()
Definition: PpmByteStreamV1Cnv.cxx:43
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LVL1BS::PpmByteStreamV1Cnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create TriggerTowers from ByteStream.
Definition: PpmByteStreamV1Cnv.cxx:80
IROBDataProviderSvc::VROBFRAG
std::vector< const ROBF * > VROBFRAG
Definition: IROBDataProviderSvc.h:27
ByteStreamAddress.h
DataVector< LVL1::TriggerTower >
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LVL1BS::PpmByteStreamV1Cnv::m_tool
ToolHandle< LVL1BS::PpmByteStreamV1Tool > m_tool
Tool that does the actual work.
Definition: PpmByteStreamV1Cnv.h:54
errorcheck.h
Helpers for checking error return status codes and reporting errors.
LVL1BS::PpmByteStreamV1Cnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Create ByteStream from TriggerTowers.
Definition: PpmByteStreamV1Cnv.cxx:119
LVL1BS::PpmByteStreamV1Cnv::m_ByteStreamEventAccess
ServiceHandle< IByteStreamEventAccess > m_ByteStreamEventAccess
Service for writing bytestream.
Definition: PpmByteStreamV1Cnv.h:59
PpmByteStreamV1Cnv.h
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
LVL1BS::PpmByteStreamV1Cnv::classID
static const CLID & classID()
Definition: PpmByteStreamV1Cnv.cxx:49
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
PpmByteStreamV1Tool.h
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
TriggerTower.h
IROBDataProviderSvc.h
LVL1BS::PpmByteStreamV1Cnv::storageType
static long storageType()
Definition: PpmByteStreamV1Cnv.cxx:54