ATLAS Offline Software
TileL2ContByteStreamCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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_byteStreamCnvSvc("ByteStreamCnvSvc", name())
64  , m_storeGate("StoreGateSvc", name())
65  , m_robSvc("ROBDataProviderSvc", name())
66  , m_decoder("TileROD_Decoder")
67  , m_hid2re(0)
68 {
69 }
70 
72 
74 
76 
78 
79  ATH_MSG_DEBUG(" initialize ");
80 
81  // Get ByteStreamCnvSvc
82  ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
83 
84  // retrieve Tool
85  ATH_CHECK( m_decoder.retrieve() );
86  m_hid2re = m_decoder->getHid2re();
87 
88  ATH_CHECK( m_tool.retrieve() );
89 
90  ATH_CHECK( m_robSvc.retrieve() );
91 
92  ATH_CHECK( m_storeGate.retrieve() );
93 
94  return StatusCode::SUCCESS ;
95 }
96 
97 
98 StatusCode TileL2ContByteStreamCnv::createObjConst(IOpaqueAddress* pAddr, DataObject*& pObj) const
99 {
100  ATH_MSG_DEBUG( " Executing createObj method" );
101 
102  ByteStreamAddress* pRE_Addr;
103  pRE_Addr = dynamic_cast<ByteStreamAddress*>(pAddr);
104  if(!pRE_Addr) {
105  ATH_MSG_ERROR( " Can not cast to ByteStreamAddress " );
106  return StatusCode::FAILURE;
107  }
108 
109  const RawEvent* re = m_robSvc->getEvent(Gaudi::Hive::currentContext());
110  if (!re) {
111  ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
112  return StatusCode::FAILURE;
113  }
114 
115  TileL2Container* cont = m_queue.get (*m_decoder);
116 
117  if (!m_decoder->convert(re, cont).isSuccess()) {
118  ATH_MSG_WARNING( "Conversion tool returned an error. TileL2Container might be empty." );
119  }
120 
121  pObj = SG::asStorable( cont ) ;
122 
123  return StatusCode::SUCCESS;
124 }
125 
126 StatusCode TileL2ContByteStreamCnv::createRepConst(DataObject* pObj, IOpaqueAddress*& pAddr) const
127 {
128  // convert TileL2s in the container into ByteStream
129 
130  ATH_MSG_DEBUG( " Executing createRep method" );
131 
132  // get Full Event Assembler
134  std::string key("Tile");
135 
136  ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler(fea, key) );
137 
138  // create TileL2Container
139  TileL2Container* l2cont(0);
140  SG::fromStorable(pObj, l2cont);
141  if(!l2cont){
142  ATH_MSG_ERROR( " Can not cast to TileL2Container " );
143  return StatusCode::FAILURE;
144  }
145 
146  std::string name = pObj->registry()->name();
147  ByteStreamAddress* addr = new ByteStreamAddress(classID(), name, "");
148 
149  pAddr = addr;
150 
151  // call TileL2ContByteStreamTool
152  ATH_CHECK( m_tool->convert(l2cont, fea) );
153 
154  return StatusCode::SUCCESS;
155 }
156 
157 
159 {
160  return Converter::finalize();
161 }
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:50
TileL2ContByteStreamCnv::storageType
static long storageType()
Definition: TileL2ContByteStreamCnv.cxx:73
TileL2ContByteStreamCnv::m_robSvc
ServiceHandle< IROBDataProviderSvc > m_robSvc
Pointer to IROBDataProviderSvc.
Definition: TileL2ContByteStreamCnv.h:94
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:75
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:167
TileL2ContByteStreamCnv::createRepConst
virtual StatusCode createRepConst(DataObject *pObj, IOpaqueAddress *&pAddr) const override
Convert the transient object to the requested representation.
Definition: TileL2ContByteStreamCnv.cxx:126
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:100
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
AthConstConverter
Gaudi converter base class with const interfaces.
Definition: AthConstConverter.h:33
TileL2Builder.h
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
TileL2ContByteStreamCnv::m_byteStreamCnvSvc
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: TileL2ContByteStreamCnv.h:88
TileL2ContByteStreamCnv::m_storeGate
ServiceHandle< StoreGateSvc > m_storeGate
Pointer to StoreGateSvc.
Definition: TileL2ContByteStreamCnv.h:91
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TileL2ContByteStreamCnv::classID
static const CLID & classID()
Definition: TileL2ContByteStreamCnv.cxx:71
lumiFormat.i
int i
Definition: lumiFormat.py:85
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:98
TileL2ContByteStreamCnv::TileL2ContByteStreamCnv
TileL2ContByteStreamCnv(ISvcLocator *svcloc)
Definition: TileL2ContByteStreamCnv.cxx:60
TileL2ContByteStreamCnv::m_decoder
ToolHandle< TileROD_Decoder > m_decoder
Pointer to TileROD_Decoder.
Definition: TileL2ContByteStreamCnv.h:97
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
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:228
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AthConstConverter::name
const std::string & name() const
Definition: AthConstConverter.h:67
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:158
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
IByteStreamCnvSvc.h
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
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37