ATLAS Offline Software
CmxCpTobByteStreamAuxCnv.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 // ============================================================================
19 
21 #include "ByteStreamData/ROBData.h"
22 
24 #include "GaudiKernel/DataObject.h"
25 #include "GaudiKernel/IOpaqueAddress.h"
26 #include "GaudiKernel/IRegistry.h"
27 #include "GaudiKernel/ISvcLocator.h"
28 #include "GaudiKernel/StatusCode.h"
29 
32 #include "StoreGate/StoreGateSvc.h"
33 
34 // ============================================================================
35 // TrigT1
36 // ============================================================================
38 // ============================================================================
39 // xAOD
40 // ============================================================================
44 // ============================================================================
45 // Local
46 // ============================================================================
48 #include "../CpByteStreamV2Tool.h"
49 #include "../ToString.h"
50 // ============================================================================
51 
52 namespace LVL1BS {
54  Converter(storageType(), classID(), svcloc),
55  AthMessaging(svcloc != 0 ? msgSvc() : 0, "CmxCpTobByteStreamAuxCnv"),
56  m_name("CmxCpTobByteStreamAuxCnv"),
57  m_readTool("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool")
58 {
59 }
60 
63 }
64 
66 {
68 }
69 
70 // Init method gets all necessary services etc.
71 
73  ATH_MSG_DEBUG("Initializing " << m_name);
74 
76  CHECK(m_readTool.retrieve());
77 
78  return StatusCode::SUCCESS;
79 }
80 
81 // createObj should create the RDO from bytestream.
83  DataObject*& pObj) {
84  ATH_MSG_DEBUG("createObj() called");
85  // -------------------------------------------------------------------------
86  ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr);
87  CHECK(pBS_Addr != nullptr);
88  // -------------------------------------------------------------------------
89  const std::string nm = *(pBS_Addr->par());
90  ATH_MSG_DEBUG("Creating Objects " << nm);
91 
92  auto aux = new xAOD::CMXCPTobAuxContainer;
93  xAOD::CMXCPTobContainer cpmCollection;
94  cpmCollection.setStore(aux);
95  // -------------------------------------------------------------------------
96  DataVector<LVL1::CMXCPTob> cmxCpTobVector;
97  StatusCode sc = m_readTool->convert(nm, &cmxCpTobVector);
98  if (sc.isFailure()) {
99  ATH_MSG_ERROR("Failed to create objects");
100  delete aux;
101  return sc;
102  }
103 
104  for (auto ct : cmxCpTobVector) {
106  cpmCollection.push_back(item);
107  std::vector<uint8_t> energyVec(ct->energyVec().begin(), ct->energyVec().end());
108  std::vector<uint8_t> isolationVec(ct->isolationVec().begin(), ct->isolationVec().end());
109  std::vector<uint32_t> errorVec(ct->errorVec().begin(), ct->errorVec().end());
110  std::vector<uint16_t> presenceMapVec(ct->presenceMapVec().begin(), ct->presenceMapVec().end());
111 
112  item->initialize(ct->crate(), ct->cmx(),
113  ct->cpm(), ct->chip(), ct->location(),
114  energyVec,
115  isolationVec,
116  errorVec,
117  presenceMapVec,
118  ct->peak());
119  }
120 
121  // -------------------------------------------------------------------------
122  //ATH_MSG_VERBOSE(ToString(cpmCollection));
123  ATH_MSG_DEBUG("Number of readed CMXCPTob: " << aux->size());
124  // -------------------------------------------------------------------------
125  pObj = SG::asStorable(aux);
126  return StatusCode::SUCCESS;
127 }
128 
129 // createRep should create the bytestream from RDOs.
131  IOpaqueAddress*& /*pAddr*/) {
132  return StatusCode::FAILURE;
133 }
134 
135 } // end namespace
xAOD::CMXCPTobAuxContainer
CMXCPTobAuxContainer_v1 CMXCPTobAuxContainer
Define the latest version of the CMXCPTob class.
Definition: CMXCPTobAuxContainer.h:17
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::CMXCPTob
CMXCPTob_v1 CMXCPTob
Define the latest version of the CMXCPTob class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CMXCPTob.h:17
xAOD::CMXCPTob_v1
Description of CMXCPTob_v1.
Definition: CMXCPTob_v1.h:27
CMXCPTobContainer.h
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CMXCPTobAuxContainer.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
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
LVL1BS::CmxCpTobByteStreamAuxCnv::storageType
static long storageType()
Definition: CmxCpTobByteStreamAuxCnv.cxx:65
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
LVL1BS::CmxCpTobByteStreamAuxCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Create TriggerTowers from ByteStream.
Definition: CmxCpTobByteStreamAuxCnv.cxx:82
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
CmxCpTobByteStreamAuxCnv.h
LVL1BS::CmxCpTobByteStreamAuxCnv::initialize
virtual StatusCode initialize()
Definition: CmxCpTobByteStreamAuxCnv.cxx:72
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LVL1BS::CmxCpTobByteStreamAuxCnv::CmxCpTobByteStreamAuxCnv
CmxCpTobByteStreamAuxCnv(ISvcLocator *svcloc)
Definition: CmxCpTobByteStreamAuxCnv.cxx:53
ByteStreamAddress.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
calibdata.ct
ct
Definition: calibdata.py:418
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.
CMXCPTob.h
LVL1BS::CmxCpTobByteStreamAuxCnv::m_readTool
ToolHandle< CpByteStreamV2Tool > m_readTool
Do the main job - retrieve xAOD TriggerTowers from robs.
Definition: CmxCpTobByteStreamAuxCnv.h:59
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
LVL1BS::CmxCpTobByteStreamAuxCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Create ByteStream from TriggerTowers.
Definition: CmxCpTobByteStreamAuxCnv.cxx:130
item
Definition: ItemListSvc.h:43
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
LVL1BS
Definition: ZdcModifySlices.h:10
LVL1BS::CmxCpTobByteStreamAuxCnv::classID
static const CLID & classID()
Definition: CmxCpTobByteStreamAuxCnv.cxx:61
StoreGateSvc.h
LVL1BS::CmxCpTobByteStreamAuxCnv::m_name
std::string m_name
Converter name.
Definition: CmxCpTobByteStreamAuxCnv.h:56
IROBDataProviderSvc.h
CMXCPTob.h