ATLAS Offline Software
CpmTowerByteStreamAuxCnv.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 // ============================================================================
40 // ============================================================================
41 // xAOD
42 // ============================================================================
46 // ============================================================================
47 // Local
48 // ============================================================================
50 #include "../CpByteStreamV2Tool.h"
51 #include "../ToString.h"
52 // ============================================================================
53 
54 namespace LVL1BS {
56  Converter(storageType(), classID(), svcloc),
57  AthMessaging(svcloc != 0 ? msgSvc() : 0, "CpmTowerByteStreamAuxCnv"),
58  m_name("CpmTowerByteStreamAuxCnv"),
59  m_cpmReadTool("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool")
60 {
61 }
62 
65 }
66 
68 {
70 }
71 
72 // Init method gets all necessary services etc.
73 
75  ATH_MSG_DEBUG("Initializing " << m_name);
76 
78  CHECK(m_cpmReadTool.retrieve());
79 
80  return StatusCode::SUCCESS;
81 }
82 
83 // createObj should create the RDO from bytestream.
85  DataObject*& pObj) {
86  ATH_MSG_DEBUG("createObj() called");
87  // -------------------------------------------------------------------------
88  ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr);
89  CHECK(pBS_Addr != nullptr);
90  // -------------------------------------------------------------------------
91  const std::string nm = *(pBS_Addr->par());
92  ATH_MSG_DEBUG("Creating Objects " << nm);
93 
94  auto aux = new xAOD::CPMTowerAuxContainer;
95  xAOD::CPMTowerContainer cpmCollection;
96  cpmCollection.setStore(aux);
97  // -------------------------------------------------------------------------
98  DataVector<LVL1::CPMTower> cpmTowerVector;
99  StatusCode sc = m_cpmReadTool->convert(nm, &cpmTowerVector);
100  if (sc.isFailure()) {
101  ATH_MSG_ERROR("Failed to create objects");
102  delete aux;
103  return sc;
104  }
105 
106  for (auto ct : cpmTowerVector) {
108  cpmCollection.push_back(item);
109  std::vector<uint8_t> emEnergyVec(ct->emEnergyVec().begin(), ct->emEnergyVec().end());
110  std::vector<uint8_t> hadEnergyVec(ct->hadEnergyVec().begin(), ct->hadEnergyVec().end());
111  std::vector<uint32_t> emErrorVec(ct->emErrorVec().begin(), ct->emErrorVec().end());
112  std::vector<uint32_t> hadErrorVec(ct->hadErrorVec().begin(), ct->hadErrorVec().end());
113 
114  item->initialize(ct->eta(), ct->phi(),
115  emEnergyVec,
116  hadEnergyVec,
117  emErrorVec,
118  hadErrorVec,
119  uint8_t(ct->peak()));
120  }
121 
122  // -------------------------------------------------------------------------
123  //ATH_MSG_VERBOSE(ToString(cpmCollection));
124  ATH_MSG_DEBUG("Number of readed CPM towers: " << aux->size());
125  // -------------------------------------------------------------------------
126  pObj = SG::asStorable(aux);
127  return StatusCode::SUCCESS;
128 }
129 
130 // createRep should create the bytestream from RDOs.
132  IOpaqueAddress*& /*pAddr*/) {
133  return StatusCode::FAILURE;
134 }
135 
136 } // end namespace
LVL1BS::CpmTowerByteStreamAuxCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Create ByteStream from TriggerTowers.
Definition: CpmTowerByteStreamAuxCnv.cxx:131
CpmTowerByteStreamAuxCnv.h
LVL1BS::CpmTowerByteStreamAuxCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Create TriggerTowers from ByteStream.
Definition: CpmTowerByteStreamAuxCnv.cxx:84
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
LVL1BS::CpmTowerByteStreamAuxCnv::classID
static const CLID & classID()
Definition: CpmTowerByteStreamAuxCnv.cxx:63
StorableConversions.h
convert to and from a SG storable
LVL1BS::CpmTowerByteStreamAuxCnv::m_name
std::string m_name
Converter name.
Definition: CpmTowerByteStreamAuxCnv.h:56
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::CPMTowerAuxContainer
CPMTowerAuxContainer_v2 CPMTowerAuxContainer
Define the latest version of the CPMHits auxiliary container.
Definition: CPMTowerAuxContainer.h:14
CPMTowerContainer.h
SG::asStorable
DataObject * asStorable(T *pObject)
Definition: StorableConversions.h:158
xAOD::CPMTower
CPMTower_v2 CPMTower
Define the latest version of the CPMTower class.
Definition: Event/xAOD/xAODTrigL1Calo/xAODTrigL1Calo/CPMTower.h:16
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ClassID_traits::ID
static const CLID & ID()
the CLID of T
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:50
LVL1BS::CpmTowerByteStreamAuxCnv::CpmTowerByteStreamAuxCnv
CpmTowerByteStreamAuxCnv(ISvcLocator *svcloc)
Definition: CpmTowerByteStreamAuxCnv.cxx:55
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
CPMTower.h
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
LVL1BS::CpmTowerByteStreamAuxCnv::storageType
static long storageType()
Definition: CpmTowerByteStreamAuxCnv.cxx:67
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ByteStreamAddress
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
Definition: ByteStreamAddress.h:28
LVL1BS::CpmTowerByteStreamAuxCnv::m_cpmReadTool
ToolHandle< CpByteStreamV2Tool > m_cpmReadTool
Do the main job - retrieve xAOD TriggerTowers from robs.
Definition: CpmTowerByteStreamAuxCnv.h:59
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
ByteStreamAddress.h
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
calibdata.ct
ct
Definition: calibdata.py:418
ByteStreamAddress::storageType
static constexpr long storageType()
Definition: ByteStreamAddress.h:51
Converter
Definition: Converter.h:27
CPMTower.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CMXCPTob.h
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
item
Definition: ItemListSvc.h:43
LVL1BS::CpmTowerByteStreamAuxCnv::initialize
virtual StatusCode initialize()
Definition: CpmTowerByteStreamAuxCnv.cxx:74
CalibCoolCompareRT.nm
nm
Definition: CalibCoolCompareRT.py:110
CPMTowerAuxContainer.h
LVL1BS
Definition: ZdcByteStreamReadV1V2Tool.h:47
CMXCPHits.h
StoreGateSvc.h
IROBDataProviderSvc.h
xAOD::CPMTower_v2
Description of CPMTower_v2.
Definition: CPMTower_v2.h:26