ATLAS Offline Software
Loading...
Searching...
No Matches
LArRawChannelContByteStreamCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 ATH_CHECK( (pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr)) != nullptr );
62
63 const EventContext& ctx = pRE_Addr->getEventContext();
64 const RawEvent* re = m_rdpSvc->getEvent(ctx);
65 if (!re) {
66 ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
67 return StatusCode::FAILURE;
68 }
69
70 // create LArRawChannelContainer
71 LArRawChannelContainer* channelContainer = new LArRawChannelContainer() ;
72 if (m_contSize) channelContainer->reserve(m_contSize);
73
74 StatusCode sc=m_tool->convert(re,channelContainer,CaloGain::CaloGain(0)); //Gain is a dummy variable in this case...
75 if (sc!=StatusCode::SUCCESS) {
76 ATH_MSG_WARNING( "Conversion tool returned an error. LArRawChannelContainer might be empty." );
77 }
78
79 pObj = SG::asStorable( channelContainer ) ;
80
81 ATH_MSG_DEBUG( "Created a LArRawChannelContainer of size" << channelContainer->size() );
82
83 if (!m_contSize) {
84 m_contSize=channelContainer->size();
85 ATH_MSG_DEBUG( "For the following events, we will reserve space for "
86 << m_contSize << " LArRawchannels" );
87 }
88
89 return StatusCode::SUCCESS;
90
91
92}
93
94StatusCode
95LArRawChannelContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
96{ // convert LArRawChannels in the container into ByteStream
97
98 // Get Full Event Assembler
100 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea,"LAr") );
101
102 LArRawChannelContainer* ChannelContainer = nullptr;
103 if (!SG::fromStorable (pObj, ChannelContainer ) || !ChannelContainer) {
104 ATH_MSG_ERROR( " Can not cast to LArRawChannelContainer " );
105 return StatusCode::FAILURE;
106 }
107
108 const std::string& nm = pObj->registry()->name();
109
110 if ( pAddr != nullptr ) pAddr->release();
111 pAddr = new ByteStreamAddress(classID(),nm,"");
112 pAddr->addRef();
113
114 ATH_CHECK( m_tool->WriteLArRawChannels(ChannelContainer,*fea) );
115 return StatusCode::SUCCESS;
116}
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.
const EventContext & getEventContext() const
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)