ATLAS Offline Software
JetElementByteStreamAuxCnv.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ============================================================================
6 // Includes
7 // ============================================================================
8 // STD
9 // ============================================================================
10 #include <vector>
11 #include <cstdint>
12 #include <memory>
13 #include <algorithm>
14 // ============================================================================
15 // Athena
16 // ============================================================================
20 
22 #include "ByteStreamData/ROBData.h"
23 
25 #include "GaudiKernel/DataObject.h"
26 #include "GaudiKernel/IOpaqueAddress.h"
27 #include "GaudiKernel/IRegistry.h"
28 #include "GaudiKernel/ISvcLocator.h"
29 #include "GaudiKernel/StatusCode.h"
30 
33 #include "StoreGate/StoreGateSvc.h"
34 
35 // ============================================================================
36 // TrigT1
37 // ============================================================================
39 // ============================================================================
40 // xAOD
41 // ============================================================================
45 // ============================================================================
46 // Local
47 // ============================================================================
49 #include "../JepByteStreamV2Tool.h"
50 #include "../ToString.h"
51 // ============================================================================
52 
53 namespace LVL1BS {
55  Converter(storageType(), classID(), svcloc),
56  AthMessaging(svcloc != 0 ? msgSvc() : 0, "JetElementByteStreamAuxCnv"),
57  m_name("JetElementByteStreamAuxCnv"),
58  m_readTool("LVL1BS::JepByteStreamV2Tool/JepByteStreamV2Tool")
59 {
60 }
61 
64 }
65 
67 {
69 }
70 
71 // Init method gets all necessary services etc.
72 
74  ATH_MSG_DEBUG("Initializing " << m_name);
75 
77  CHECK(m_readTool.retrieve());
78 
79  return StatusCode::SUCCESS;
80 }
81 
82 // createObj should create the RDO from bytestream.
84  DataObject*& pObj) {
85  ATH_MSG_DEBUG("createObj() called");
86  // -------------------------------------------------------------------------
87  ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr);
88  CHECK(pBS_Addr != nullptr);
89  // -------------------------------------------------------------------------
90  const std::string nm = *(pBS_Addr->par());
91  ATH_MSG_DEBUG("Creating Objects " << nm);
92 
93  auto aux = new xAOD::JetElementAuxContainer;
94  xAOD::JetElementContainer container;
95  container.setStore(aux);
96  // -------------------------------------------------------------------------
98  StatusCode sc = m_readTool->convert(nm, &vec);
99  if (sc.isFailure()) {
100  ATH_MSG_ERROR("Failed to create objects");
101  delete aux;
102  return sc;
103  }
104 
105  for (auto source : vec) {
107  container.push_back(item);
108 
109  std::vector<uint16_t> emJetElementETVec(
110  source->emEnergyVec().begin(),
111  source->emEnergyVec().end()
112  );
113 
114  std::vector<uint16_t> hadJetElementETVec(
115  source->hadEnergyVec().begin(),
116  source->hadEnergyVec().end()
117  );
118 
119  std::vector<uint32_t> emJetElementError(
120  source->emErrorVec().begin(),
121  source->emErrorVec().end()
122  );
123 
124  std::vector<uint32_t> hadJetElementError(
125  source->hadErrorVec().begin(),
126  source->hadErrorVec().end()
127  );
128 
129  std::vector<uint32_t> linkErrorVec(
130  source->linkErrorVec().begin(),
131  source->linkErrorVec().end()
132  );
133 
134  item->initialize(
135  source->eta(),
136  source->phi(),
137  source->key(),
138  emJetElementETVec,
139  hadJetElementETVec,
140  emJetElementError,
141  hadJetElementError,
142  linkErrorVec,
143  source->peak()
144  );
145  }
146 
147  // -------------------------------------------------------------------------
148  //ATH_MSG_VERBOSE(ToString(container));
149  ATH_MSG_DEBUG("Number of readed JetElement: " << aux->size());
150  // -------------------------------------------------------------------------
151  pObj = SG::asStorable(aux);
152  return StatusCode::SUCCESS;
153 }
154 
155 // createRep should create the bytestream from RDOs.
157  IOpaqueAddress*& /*pAddr*/) {
158  return StatusCode::FAILURE;
159 }
160 
161 } // end namespace
LVL1BS::JetElementByteStreamAuxCnv::JetElementByteStreamAuxCnv
JetElementByteStreamAuxCnv(ISvcLocator *svcloc)
Definition: JetElementByteStreamAuxCnv.cxx:54
LVL1BS::JetElementByteStreamAuxCnv::storageType
static long storageType()
Definition: JetElementByteStreamAuxCnv.cxx:66
LVL1BS::JetElementByteStreamAuxCnv::initialize
virtual StatusCode initialize()
Definition: JetElementByteStreamAuxCnv.cxx:73
StorableConversions.h
convert to and from a SG storable
ROBData.h
Defines the ROB data entity. The ROB data is an abstract entity that is used to discase the raw event...
initialize
void initialize()
Definition: run_EoverP.cxx:894
xAOD::JetElement_v2
Description of JetElement_v2.
Definition: JetElement_v2.h:26
LVL1BS::JetElementByteStreamAuxCnv::classID
static const CLID & classID()
Definition: JetElementByteStreamAuxCnv.cxx:62
LVL1BS::JetElementByteStreamAuxCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Create ByteStream from TriggerTowers.
Definition: JetElementByteStreamAuxCnv.cxx:156
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
IByteStreamEventAccess.h
JetElementAuxContainer.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
JetElementContainer.h
CxxUtils::vec
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
Definition: vec.h:207
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
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
xAOD::JetElement
JetElement_v2 JetElement
Define the latest version of the JetElement class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/JetElement.h:16
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
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
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
JetElement.h
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
ByteStreamAddress.h
LVL1BS::JetElementByteStreamAuxCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Create TriggerTowers from ByteStream.
Definition: JetElementByteStreamAuxCnv.cxx:83
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
Converter
Definition: Converter.h:27
errorcheck.h
Helpers for checking error return status codes and reporting errors.
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
item
Definition: ItemListSvc.h:43
xAOD::JetElementAuxContainer
JetElementAuxContainer_v2 JetElementAuxContainer
Define the latest version of the JetElement auxiliary container.
Definition: JetElementAuxContainer.h:14
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
LVL1BS::JetElementByteStreamAuxCnv::m_readTool
ToolHandle< JepByteStreamV2Tool > m_readTool
Do the main job - retrieve objects from robs.
Definition: JetElementByteStreamAuxCnv.h:60
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
StoreGateSvc.h
IROBDataProviderSvc.h
JetElementByteStreamAuxCnv.h
JetElement.h
LVL1BS::JetElementByteStreamAuxCnv::m_name
std::string m_name
Converter name.
Definition: JetElementByteStreamAuxCnv.h:57