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 // ============================================================================
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 // ============================================================================
41 // ============================================================================
42 // xAOD
43 // ============================================================================
47 // ============================================================================
48 // Local
49 // ============================================================================
51 #include "../CpByteStreamV2Tool.h"
52 #include "../ToString.h"
53 // ============================================================================
54 
55 namespace LVL1BS {
57  Converter(storageType(), classID(), svcloc),
58  AthMessaging(svcloc != 0 ? msgSvc() : 0, "CpmTowerByteStreamAuxCnv"),
59  m_name("CpmTowerByteStreamAuxCnv"),
60  m_cpmReadTool("LVL1BS::CpByteStreamV2Tool/CpByteStreamV2Tool")
61 {
62 }
63 
66 }
67 
69 {
71 }
72 
73 // Init method gets all necessary services etc.
74 
76  ATH_MSG_DEBUG("Initializing " << m_name);
77 
79  CHECK(m_cpmReadTool.retrieve());
80 
81  return StatusCode::SUCCESS;
82 }
83 
84 // createObj should create the RDO from bytestream.
86  DataObject*& pObj) {
87  ATH_MSG_DEBUG("createObj() called");
88  // -------------------------------------------------------------------------
89  ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr);
90  CHECK(pBS_Addr != nullptr);
91  // -------------------------------------------------------------------------
92  const std::string nm = *(pBS_Addr->par());
93  ATH_MSG_DEBUG("Creating Objects " << nm);
94 
95  auto aux = new xAOD::CPMTowerAuxContainer;
96  xAOD::CPMTowerContainer cpmCollection;
97  cpmCollection.setStore(aux);
98  // -------------------------------------------------------------------------
99  DataVector<LVL1::CPMTower> cpmTowerVector;
100  StatusCode sc = m_cpmReadTool->convert(nm, &cpmTowerVector);
101  if (sc.isFailure()) {
102  ATH_MSG_ERROR("Failed to create objects");
103  delete aux;
104  return sc;
105  }
106 
107  for (auto ct : cpmTowerVector) {
109  cpmCollection.push_back(item);
110  std::vector<uint8_t> emEnergyVec(ct->emEnergyVec().begin(), ct->emEnergyVec().end());
111  std::vector<uint8_t> hadEnergyVec(ct->hadEnergyVec().begin(), ct->hadEnergyVec().end());
112  std::vector<uint32_t> emErrorVec(ct->emErrorVec().begin(), ct->emErrorVec().end());
113  std::vector<uint32_t> hadErrorVec(ct->hadErrorVec().begin(), ct->hadErrorVec().end());
114 
115  item->initialize(ct->eta(), ct->phi(),
116  emEnergyVec,
117  hadEnergyVec,
118  emErrorVec,
119  hadErrorVec,
120  uint8_t(ct->peak()));
121  }
122 
123  // -------------------------------------------------------------------------
124  //ATH_MSG_VERBOSE(ToString(cpmCollection));
125  ATH_MSG_DEBUG("Number of readed CPM towers: " << aux->size());
126  // -------------------------------------------------------------------------
127  pObj = SG::asStorable(aux);
128  return StatusCode::SUCCESS;
129 }
130 
131 // createRep should create the bytestream from RDOs.
133  IOpaqueAddress*& /*pAddr*/) {
134  return StatusCode::FAILURE;
135 }
136 
137 } // end namespace
LVL1BS::CpmTowerByteStreamAuxCnv::createRep
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Create ByteStream from TriggerTowers.
Definition: CpmTowerByteStreamAuxCnv.cxx:132
CpmTowerByteStreamAuxCnv.h
LVL1BS::CpmTowerByteStreamAuxCnv::createObj
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Create TriggerTowers from ByteStream.
Definition: CpmTowerByteStreamAuxCnv.cxx:85
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
LVL1BS::CpmTowerByteStreamAuxCnv::classID
static const CLID & classID()
Definition: CpmTowerByteStreamAuxCnv.cxx:64
StorableConversions.h
convert to and from a SG storable
LVL1BS::CpmTowerByteStreamAuxCnv::m_name
std::string m_name
Converter name.
Definition: CpmTowerByteStreamAuxCnv.h:57
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
IByteStreamEventAccess.h
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:56
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:68
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:60
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:75
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