ATLAS Offline Software
TileL2ContByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Gaudi includes
6 #include "GaudiKernel/MsgStream.h"
7 #include "GaudiKernel/StatusCode.h"
8 #include "GaudiKernel/DataObject.h"
9 #include "GaudiKernel/IRegistry.h"
10 #include "GaudiKernel/IToolSvc.h"
11 
12 // Athena includes
14 
19 #include "ByteStreamData/RawEvent.h"
20 
22 #include "AthenaKernel/CLASS_DEF.h"
23 
24 // Tile includes
30 
31 
32 #include <string>
33 
34 
36 {
37  this->reserve(256);
38  for(int i = 0; i < 256; ++i) {
39  int collId = decoder.hashFunc()->identifier(i);
40  this->push_back (std::make_unique<TileL2> (collId));
41  }
42 }
43 
44 
53 {
54  for (TileL2* elt : *this) {
55  elt->clear();
56  }
57 }
58 
59 
61  : AthConstConverter(storageType(), classID(), svcloc, "TileL2ContByteStreamCnv")
62  , m_tool("TileL2ContByteStreamTool")
63  , m_byteStreamEventAccess("ByteStreamCnvSvc", name())
64  , m_byteStreamCnvSvc(0)
65  , m_storeGate("StoreGateSvc", name())
66  , m_robSvc("ROBDataProviderSvc", name())
67  , m_decoder("TileROD_Decoder")
68  , m_hid2re(0)
69 {
70 }
71 
73 
75 
77 
79 
80  ATH_MSG_DEBUG(" initialize ");
81 
82  // Get ByteStreamCnvSvc
83  ATH_CHECK( m_byteStreamEventAccess.retrieve() );
85 
86  // retrieve Tool
87  ATH_CHECK( m_decoder.retrieve() );
88  m_hid2re = m_decoder->getHid2re();
89 
90  ATH_CHECK( m_tool.retrieve() );
91 
92  ATH_CHECK( m_robSvc.retrieve() );
93 
94  ATH_CHECK( m_storeGate.retrieve() );
95 
96  return StatusCode::SUCCESS ;
97 }
98 
99 
100 StatusCode TileL2ContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
101 {
102  ATH_MSG_DEBUG( " Executing createObj method" );
103 
104  ByteStreamAddress* pRE_Addr;
105  pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
106  if(!pRE_Addr) {
107  ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
108  return StatusCode::FAILURE;
109  }
110 
111  const RawEvent* re = m_robSvc->getEvent();
112  if (!re) {
113  ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
114  return StatusCode::FAILURE;
115  }
116 
117  TileL2Container* cont = m_queue.get (*m_decoder);
118 
119  if (!m_decoder->convert(re, cont).isSuccess()) {
120  ATH_MSG_WARNING( "Conversion tool returned an error. TileL2Container might be empty." );
121  }
122 
123  pObj = SG::asStorable( cont ) ;
124 
125  return StatusCode::SUCCESS;
126 }
127 
128 StatusCode TileL2ContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
129 {
130  // convert TileL2s in the container into ByteStream
131 
132  ATH_MSG_DEBUG( " Executing createRep method" );
133 
134  // get Full Event Assembler
136  std::string key("Tile");
137 
139 
140  // create TileL2Container
141  TileL2Container* l2cont(0);
142  SG::fromStorable(pObj, l2cont);
143  if(!l2cont){
144  ATH_MSG_ERROR( " Can not cast to TileL2Container " );
145  return StatusCode::FAILURE;
146  }
147 
148  std::string name = pObj->registry()->name();
149  ByteStreamAddress* addr = new ByteStreamAddress(classID(), name, "");
150 
151  pAddr = addr;
152 
153  // call TileL2ContByteStreamTool
154  ATH_CHECK( m_tool->convert(l2cont, fea) );
155 
156  return StatusCode::SUCCESS;
157 }
158 
159 
161 {
162  return Converter::finalize();
163 }
DataVector< TELEMENT >::reserve
void reserve(size_type n)
Attempt to preallocate enough memory for a specified number of elements.
TileL2ContByteStreamCnv::m_tool
ToolHandle< BYTESTREAMTOOL > m_tool
Definition: TileL2ContByteStreamCnv.h:86
TileROD_Decoder
Decodes the different TileCal ROD subfragment types in bytestream data and fills TileDigitsContainer,...
Definition: TileROD_Decoder.h:119
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:53
TileL2ContByteStreamCnv::storageType
static long storageType()
Definition: TileL2ContByteStreamCnv.cxx:74
TileL2ContByteStreamCnv::m_robSvc
ServiceHandle< IROBDataProviderSvc > m_robSvc
Pointer to IROBDataProviderSvc.
Definition: TileL2ContByteStreamCnv.h:95
FullEventAssembler
Template class for assembling a full atlas raw event from subfragments.
Definition: FullEventAssembler.h:40
TileL2ContByteStreamCnv::initialize
virtual StatusCode initialize() override
Definition: TileL2ContByteStreamCnv.cxx:76
python.LArCondContChannels.decoder
decoder
def channelSelection(self, channelList, groupType): if groupType == self.SingleGroup: pass elif group...
Definition: LArCondContChannels.py:618
SG::fromStorable
bool fromStorable(DataObject *pDObj, T *&pTrans, bool quiet=false, IRegisterTransient *irt=0, bool isConst=true)
Definition: StorableConversions.h:180
TileL2ContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: TileL2ContByteStreamCnv.cxx:128
initialize
void initialize()
Definition: run_EoverP.cxx:894
RawEvent
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition: RawEvent.h:37
TileL2ContByteStreamCnv::m_hid2re
const TileHid2RESrcID * m_hid2re
Pointer to TileHid2RESrcID.
Definition: TileL2ContByteStreamCnv.h:101
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
TileL2Builder.h
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
TileL2ContByteStreamCnv::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Pointer to StoreGateSvc.
Definition: TileL2ContByteStreamCnv.h:92
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileL2ContByteStreamCnv::classID
static const CLID & classID()
Definition: TileL2ContByteStreamCnv.cxx:72
lumiFormat.i
int i
Definition: lumiFormat.py:92
TileROD_Decoder.h
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
TileL2ContByteStreamCnv::createObjConst
virtual StatusCode createObjConst(IOpaqueAddress *pAddr, DataObject *&pObj) const override
Create the transient representation of an object.
Definition: TileL2ContByteStreamCnv.cxx:100
TileL2ContByteStreamCnv::TileL2ContByteStreamCnv
TileL2ContByteStreamCnv(ISvcLocator *svcloc)
Definition: TileL2ContByteStreamCnv.cxx:60
TileL2ContByteStreamCnv::m_decoder
ToolHandle< TileROD_Decoder > m_decoder
Pointer to TileROD_Decoder.
Definition: TileL2ContByteStreamCnv.h:98
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileL2::clear
void clear()
Clear all vectors in TileL2.
Definition: TileL2.cxx:104
TileL2ContByteStreamTool.h
ByteStreamAddress.h
ByteStreamCnvSvc.h
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
TileL2ContByteStreamCnv.h
TileHid2RESrcID.h
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DataVector< TELEMENT >::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StoreClearedIncident.h
Incident sent after a store is cleared.
TileRecyclableL2Container::TileRecyclableL2Container
TileRecyclableL2Container(const TileROD_Decoder &decoder)
Definition: TileL2ContByteStreamCnv.cxx:35
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TileL2ContByteStreamCnv::finalize
virtual StatusCode finalize() override
Definition: TileL2ContByteStreamCnv.cxx:160
re
const boost::regex re(r_e)
ByteStreamCnvSvcBase.h
TileRecyclableL2Container::recycle
void recycle()
Recycle this object for use in another event.
Definition: TileL2ContByteStreamCnv.cxx:52
ByteStreamCnvSvc::getFullEventAssembler
StatusCode getFullEventAssembler(T *&t, const std::string &nm)
Access to FullEventAssembler.
Definition: ByteStreamCnvSvc.h:121
TileL2ContByteStreamCnv::m_byteStreamEventAccess
ServiceHandle< IByteStreamEventAccess > m_byteStreamEventAccess
Definition: TileL2ContByteStreamCnv.h:88
TileContainer
Definition: TileContainer.h:38
CLASS_DEF.h
macros to associate a CLID to a type
TileL2
Class to store TileMuId and Et quantities computed at the TileCal ROD DSPs.
Definition: TileL2.h:33
IROBDataProviderSvc.h
TileL2ContByteStreamCnv::m_byteStreamCnvSvc
ByteStreamCnvSvc * m_byteStreamCnvSvc
Definition: TileL2ContByteStreamCnv.h:89
AthConstConverter::name
std::string name() const
Definition: AthConstConverter.h:67
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37