ATLAS Offline Software
RecMuCTPIByteStreamCnv.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/MsgStream.h"
10 
12 
13 // Trigger include(s):
15 
16 // Local include(s):
17 #include "RecMuCTPIByteStreamCnv.h"
18 
24  : Converter( storageType(), classID(), svcloc ),
25  m_tool( "RecMuCTPIByteStreamTool" ),
26  m_robDataProvider( "ROBDataProviderSvc", "RecMuCTPIByteStreamCnv" ) {
27 
28 }
29 
35 
37 
38 }
39 
42 }
43 
48 
49  //
50  // Initialise the base class:
51  //
53 
54  MsgStream log( msgSvc(), "RecMuCTPIByteStreamCnv" );
55  log << MSG::DEBUG << "RecMuCTPIByteStreamCnv in initialize()" << endmsg;
56 
57  //
58  // Get RecMuCTPIByteStreamTool:
59  //
60  ATH_CHECK( m_tool.retrieve() );
61  log << MSG::DEBUG << "Connected to RecMuCTPIByteStreamTool" << endmsg;
62 
63  //
64  // Get ROBDataProvider:
65  //
66  ATH_CHECK( m_robDataProvider.retrieve() );
67  log << MSG::DEBUG << "Connected to ROBDataProviderSvc" << endmsg;
68 
69  return StatusCode::SUCCESS;
70 }
71 
77 StatusCode RecMuCTPIByteStreamCnv::createObj( IOpaqueAddress* pAddr, DataObject*& pObj ) {
78 
79  MsgStream log( msgSvc(), "RecMuCTPIByteStreamCnv" );
80  log << MSG::DEBUG << "executing createObj()" << endmsg;
81 
82  ByteStreamAddress *pBS_Addr;
83  pBS_Addr = dynamic_cast< ByteStreamAddress* >( pAddr );
84  if ( !pBS_Addr ) {
85  log << MSG::ERROR << " Cannot cast to ByteStreamAddress " << endmsg ;
86  return StatusCode::FAILURE;
87  }
88 
89  log << MSG::DEBUG << " Creating Objects " << *( pBS_Addr->par() ) << endmsg;
90 
91  // get SourceID
92  const uint32_t robId = m_srcIdMap.getRobID( m_srcIdMap.getRodID() );
93 
94  std::vector< uint32_t > vID;
95  vID.push_back( robId );
96 
97  // get ROB fragment
99  m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags );
100 
101  // size check
102  if ( robFrags.size() == 0 ) {
103  // This is a hack - in early data the rob id of the MuCTPI was
104  // wrong, i.e. 0x76000b
105  uint32_t newRobId = robId;
106  newRobId |= 0x00000b;
107  vID[0] = ( newRobId );
108  m_robDataProvider->getROBData(Gaudi::Hive::currentContext(), vID, robFrags );
109  // size check
110  if ( robFrags.size() != 1 ) {
111  log << MSG::WARNING << " Number of ROB fragments for source ROB ID " << MSG::hex << newRobId << " (ROD ID "
112  << m_srcIdMap.getRodID() << MSG::dec << ") is " << robFrags.size() << endmsg;
113  MuCTPI_RIO * result = new MuCTPI_RIO;
114  pObj = SG::asStorable( result ) ;
115  return StatusCode::SUCCESS;
116  }
117  }
118 
119  IROBDataProviderSvc::VROBFRAG::const_iterator it = robFrags.begin();
121  // Convert to Object
122  ATH_CHECK( m_tool->convert( ROBData( *it ).getROBFragment(), result ) );
123  pObj = SG::asStorable( result ) ;
124 
125  return StatusCode::SUCCESS;
126 }
MuCTPISrcIdMap::getRobID
uint32_t getRobID(uint32_t rod_id) const
Make a ROB Source ID from a ROD source ID.
Definition: MuCTPISrcIdMap.cxx:17
RecMuCTPIByteStreamCnv::m_srcIdMap
MuCTPISrcIdMap m_srcIdMap
Object storing the various IDs of the MuCTPI fragment.
Definition: RecMuCTPIByteStreamCnv.h:59
RecMuCTPIByteStreamCnv::classID
static const CLID & classID()
Function needed by the framework.
Definition: RecMuCTPIByteStreamCnv.cxx:34
RecMuCTPIByteStreamCnv::m_tool
ToolHandle< RecMuCTPIByteStreamTool > m_tool
Tool doing the actual conversion.
Definition: RecMuCTPIByteStreamCnv.h:56
MuCTPISrcIdMap::getRodID
uint32_t getRodID() const
get a ROD Source ID
Definition: MuCTPISrcIdMap.cxx:12
get_generator_info.result
result
Definition: get_generator_info.py:21
ROBData_T::getROBFragment
const ROBFragment * getROBFragment() const
Return the ROBFragment.
Definition: ROBData.h:184
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
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
ROBData_T
templete data class to wrap ROB fragment for accessing ROD data
Definition: ROBData.h:46
skel.it
it
Definition: skel.GENtoEVGEN.py:396
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
MuCTPI_RIO
Reconstruction Input Object of the MuCTPI hardware and simulation.
Definition: MuCTPI_RIO.h:43
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
RecMuCTPIByteStreamCnv::initialize
virtual StatusCode initialize() override
Function connecting to all the needed services/tools.
Definition: RecMuCTPIByteStreamCnv.cxx:47
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
MuCTPI_RIO.h
RecMuCTPIByteStreamCnv::m_robDataProvider
ServiceHandle< IROBDataProviderSvc > m_robDataProvider
Service used when reading the BS data.
Definition: RecMuCTPIByteStreamCnv.h:62
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
RecMuCTPIByteStreamCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Function creating the MuCTPI_RIO object from a MuCTPI ROB fragment.
Definition: RecMuCTPIByteStreamCnv.cxx:77
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
RecMuCTPIByteStreamCnv::storageType
static long storageType()
Function needed by the framework.
Definition: RecMuCTPIByteStreamCnv.cxx:40
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
RecMuCTPIByteStreamCnv::RecMuCTPIByteStreamCnv
RecMuCTPIByteStreamCnv(ISvcLocator *svcloc)
Standard constructor.
Definition: RecMuCTPIByteStreamCnv.cxx:23
Converter
Definition: Converter.h:27
DEBUG
#define DEBUG
Definition: page_access.h:11
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
RecMuCTPIByteStreamCnv.h