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