ATLAS Offline Software
LArRawChannelContByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
12 #include "ByteStreamData/RawEvent.h"
13 
16 
17 #include "AthenaKernel/CLASS_DEF.h"
18 
19 //STL-Stuff
20 #include <map>
21 #include <iostream>
22 #include <string>
23 
24 
26  AthConstConverter(storageType(), classID(),svcloc,"LArRawChannelContByteStreamCnv"),
27  m_tool("LArRawDataContByteStreamTool"),
28  m_rdpSvc("ROBDataProviderSvc", name()),
29  m_byteStreamEventAccess("ByteStreamCnvSvc", name()),
30  m_byteStreamCnvSvc(nullptr),
31  m_contSize(0)
32 {}
33 
36 }
37 
39 }
40 
41 
44 {
46 
47  if ( m_rdpSvc.retrieve().isFailure()) {
48  ATH_MSG_WARNING( " Can't get ByteStreamInputSvc interface Reading of ByteStream Data not possible. " );
49  }
50 
51  ATH_CHECK( m_byteStreamEventAccess.retrieve() );
53 
54  ATH_CHECK( m_tool.retrieve() );
55 
56  return StatusCode::SUCCESS;
57 }
58 
60 LArRawChannelContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
61 { //Convert RawChannels from ByteStream to StoreGate
62 
63  ByteStreamAddress *pRE_Addr;
64  pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
65  if(!pRE_Addr) {
66  ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
67  return StatusCode::FAILURE;
68  }
69 
70  const RawEvent* re = m_rdpSvc->getEvent();
71  if (!re) {
72  ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
73  return StatusCode::FAILURE;
74  }
75 
76  // create LArRawChannelContainer
77  LArRawChannelContainer* channelContainer = new LArRawChannelContainer() ;
78  if (m_contSize) channelContainer->reserve(m_contSize);
79 
80  StatusCode sc=m_tool->convert(re,channelContainer,CaloGain::CaloGain(0)); //Gain is a dummy variable in this case...
81  if (sc!=StatusCode::SUCCESS) {
82  ATH_MSG_WARNING( "Conversion tool returned an error. LArRawChannelContainer might be empty." );
83  }
84 
85  pObj = SG::asStorable( channelContainer ) ;
86 
87  ATH_MSG_DEBUG( "Created a LArRawChannelContainer of size" << channelContainer->size() );
88 
89  if (!m_contSize) {
90  m_contSize=channelContainer->size();
91  ATH_MSG_DEBUG( "For the following events, we will reserve space for "
92  << m_contSize << " LArRawchannels" );
93  }
94 
95  return StatusCode::SUCCESS;
96 
97 
98 }
99 
100 StatusCode
101 LArRawChannelContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
102 { // convert LArRawChannels in the container into ByteStream
103 
104  // Get Full Event Assembler
107 
108  LArRawChannelContainer* ChannelContainer = nullptr;
109  if (!SG::fromStorable (pObj, ChannelContainer ) || !ChannelContainer) {
110  ATH_MSG_ERROR( " Can not cast to LArRawChannelContainer " );
111  return StatusCode::FAILURE;
112  }
113 
114  const std::string& nm = pObj->registry()->name();
115 
116  if ( pAddr != nullptr ) pAddr->release();
117  pAddr = new ByteStreamAddress(classID(),nm,"");
118  pAddr->addRef();
119 
120  ATH_CHECK( m_tool->WriteLArRawChannels(ChannelContainer,*fea) );
121  return StatusCode::SUCCESS;
122 }
LArRawChannelContByteStreamCnv::m_byteStreamEventAccess
ServiceHandle< IByteStreamEventAccess > m_byteStreamEventAccess
Definition: LArRawChannelContByteStreamCnv.h:51
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:180
initialize
void initialize()
Definition: run_EoverP.cxx:894
LArRawChannelContByteStreamCnv::m_rdpSvc
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
Definition: LArRawChannelContByteStreamCnv.h:50
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
LArRawDataContByteStreamTool.h
Helper tool for conversion of raw data classes to/from LArByteStream.
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
LArRawChannelContByteStreamCnv::m_tool
ToolHandle< BYTESTREAMTOOL > m_tool
Definition: LArRawChannelContByteStreamCnv.h:49
LArRawChannelContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: LArRawChannelContByteStreamCnv.cxx:101
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
LArRawChannelContByteStreamCnv::LArRawChannelContByteStreamCnv
LArRawChannelContByteStreamCnv(ISvcLocator *svcloc)
Definition: LArRawChannelContByteStreamCnv.cxx:25
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
ByteStreamCnvSvc
Gaudi Conversion Service class for ByteStream Persistency.
Definition: ByteStreamCnvSvc.h:34
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArRawChannelContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: LArRawChannelContByteStreamCnv.cxx:43
LArRawChannelContainer
Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old LArRawChannelContainer
Definition: LArTPCnv.cxx:86
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
LArRawChannelContByteStreamCnv.h
LArRawChannelContByteStreamCnv::m_byteStreamCnvSvc
ByteStreamCnvSvc * m_byteStreamCnvSvc
Definition: LArRawChannelContByteStreamCnv.h:52
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
ByteStreamAddress.h
ByteStreamCnvSvc.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
LArRawChannelContByteStreamCnv::~LArRawChannelContByteStreamCnv
virtual ~LArRawChannelContByteStreamCnv()
Definition: LArRawChannelContByteStreamCnv.cxx:38
LArRawChannelContByteStreamCnv::m_contSize
std::atomic< size_t > m_contSize
Definition: LArRawChannelContByteStreamCnv.h:53
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArDigitContainer.h
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
LArRawChannelContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: LArRawChannelContByteStreamCnv.cxx:60
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
re
const boost::regex re(r_e)
ByteStreamCnvSvcBase.h
ByteStreamCnvSvc::getFullEventAssembler
StatusCode getFullEventAssembler(T *&t, const std::string &nm)
Access to FullEventAssembler.
Definition: ByteStreamCnvSvc.h:121
LArRawChannelContByteStreamCnv::classID
static const CLID & classID()
Definition: LArRawChannelContByteStreamCnv.cxx:34
CLASS_DEF.h
macros to associate a CLID to a type
IROBDataProviderSvc.h
LArRawChannelContainer.h
LArRawChannelContainer
Container for LArRawChannel (IDC using LArRawChannelCollection)
Definition: LArRawChannelContainer.h:26