Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LArRawChannelContByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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_byteStreamCnvSvc("ByteStreamCnvSvc", name()),
30  m_contSize(0)
31 {}
32 
35 }
36 
38 }
39 
40 
43 {
45 
46  if ( m_rdpSvc.retrieve().isFailure()) {
47  ATH_MSG_WARNING( " Can't get ByteStreamInputSvc interface Reading of ByteStream Data not possible. " );
48  }
49 
50  ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
51 
52  ATH_CHECK( m_tool.retrieve() );
53 
54  return StatusCode::SUCCESS;
55 }
56 
58 LArRawChannelContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
59 { //Convert RawChannels from ByteStream to StoreGate
60 
61  ByteStreamAddress *pRE_Addr;
62  pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
63  if(!pRE_Addr) {
64  ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
65  return StatusCode::FAILURE;
66  }
67 
68  const RawEvent* re = m_rdpSvc->getEvent(Gaudi::Hive::currentContext());
69  if (!re) {
70  ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
71  return StatusCode::FAILURE;
72  }
73 
74  // create LArRawChannelContainer
75  LArRawChannelContainer* channelContainer = new LArRawChannelContainer() ;
76  if (m_contSize) channelContainer->reserve(m_contSize);
77 
78  StatusCode sc=m_tool->convert(re,channelContainer,CaloGain::CaloGain(0)); //Gain is a dummy variable in this case...
79  if (sc!=StatusCode::SUCCESS) {
80  ATH_MSG_WARNING( "Conversion tool returned an error. LArRawChannelContainer might be empty." );
81  }
82 
83  pObj = SG::asStorable( channelContainer ) ;
84 
85  ATH_MSG_DEBUG( "Created a LArRawChannelContainer of size" << channelContainer->size() );
86 
87  if (!m_contSize) {
88  m_contSize=channelContainer->size();
89  ATH_MSG_DEBUG( "For the following events, we will reserve space for "
90  << m_contSize << " LArRawchannels" );
91  }
92 
93  return StatusCode::SUCCESS;
94 
95 
96 }
97 
99 LArRawChannelContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
100 { // convert LArRawChannels in the container into ByteStream
101 
102  // Get Full Event Assembler
104  ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea,"LAr") );
105 
106  LArRawChannelContainer* ChannelContainer = nullptr;
107  if (!SG::fromStorable (pObj, ChannelContainer ) || !ChannelContainer) {
108  ATH_MSG_ERROR( " Can not cast to LArRawChannelContainer " );
109  return StatusCode::FAILURE;
110  }
111 
112  const std::string& nm = pObj->registry()->name();
113 
114  if ( pAddr != nullptr ) pAddr->release();
115  pAddr = new ByteStreamAddress(classID(),nm,"");
116  pAddr->addRef();
117 
118  ATH_CHECK( m_tool->WriteLArRawChannels(ChannelContainer,*fea) );
119  return StatusCode::SUCCESS;
120 }
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:99
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
SG::asStorable
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Definition: DataObjectSharedPtr.h:65
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArRawChannelContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: LArRawChannelContByteStreamCnv.cxx:42
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:37
LArRawChannelContByteStreamCnv::m_contSize
std::atomic< size_t > m_contSize
Definition: LArRawChannelContByteStreamCnv.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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:58
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
LArRawChannelContByteStreamCnv::classID
static const CLID & classID()
Definition: LArRawChannelContByteStreamCnv.cxx:33
IByteStreamCnvSvc.h
CLASS_DEF.h
macros to associate a CLID to a type
IROBDataProviderSvc.h
LArRawChannelContainer.h
LArRawChannelContByteStreamCnv::m_byteStreamCnvSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: LArRawChannelContByteStreamCnv.h:50
LArRawChannelContainer
Container for LArRawChannel (IDC using LArRawChannelCollection)
Definition: LArRawChannelContainer.h:26