ATLAS Offline Software
Loading...
Searching...
No Matches
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
12
15
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
35
38
39
40StatusCode
42{
43 ATH_CHECK( AthConstConverter::initialize() );
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
56StatusCode
57LArRawChannelContByteStreamCnv::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
97StatusCode
98LArRawChannelContByteStreamCnv::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}
const boost::regex re(r_e)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
macros to associate a CLID to a type
uint32_t CLID
The Class ID type.
static Double_t sc
Helper tool for conversion of raw data classes to/from LArByteStream.
Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Old LArRawChannelContainer
Definition LArTPCnv.cxx:86
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
AthConstConverter(long storage_type, const CLID &class_type, ISvcLocator *svc, const std::string &name)
const std::string & name() const
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Template class for assembling a full atlas raw event from subfragments.
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
ServiceHandle< IROBDataProviderSvc > m_rdpSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Container for LArRawChannel (IDC using LArRawChannelCollection)
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)