ATLAS Offline Software
Loading...
Searching...
No Matches
CpmTowerByteStreamAuxCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
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
33
34// ============================================================================
35// TrigT1
36// ============================================================================
40// ============================================================================
41// xAOD
42// ============================================================================
46// ============================================================================
47// Local
48// ============================================================================
51#include "../ToString.h"
52// ============================================================================
53
54namespace 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
66
71
72// Init method gets all necessary services etc.
73
75 ATH_MSG_DEBUG("Initializing " << m_name);
76
77 CHECK(Converter::initialize());
78 CHECK(m_cpmReadTool.retrieve());
79
80 return StatusCode::SUCCESS;
81}
82
83// createObj should create the RDO from bytestream.
84StatusCode CpmTowerByteStreamAuxCnv::createObj(IOpaqueAddress* pAddr,
85 DataObject*& pObj) {
86 ATH_MSG_DEBUG("createObj() called");
87 // -------------------------------------------------------------------------
88 ByteStreamAddress *pBS_Addr = dynamic_cast<ByteStreamAddress *>(pAddr);
89 if (not pBS_Addr) return StatusCode::FAILURE;
90 // -------------------------------------------------------------------------
91 const EventContext& ctx = pBS_Addr->getEventContext();
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(ctx, 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) {
108 xAOD::CPMTower* item = new xAOD::CPMTower();
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.
132StatusCode CpmTowerByteStreamAuxCnv::createRep(DataObject* /*pObj*/,
133 IOpaqueAddress*& /*pAddr*/) {
134 return StatusCode::FAILURE;
135}
136
137} // end namespace
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
uint32_t CLID
The Class ID type.
static Double_t sc
Defines the ROB data entity. The ROB data is an abstract entity that is used to decouple the raw even...
convert to and from a SG storable
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
IOpaqueAddress for ByteStreamCnvSvc, with ROB ids.
const EventContext & getEventContext() const
static constexpr long storageType()
Derived DataVector<T>.
Definition DataVector.h:795
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ToolHandle< CpByteStreamV2Tool > m_cpmReadTool
Do the main job - retrieve xAOD TriggerTowers from robs.
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr)
Create ByteStream from TriggerTowers.
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj)
Create TriggerTowers from ByteStream.
virtual void initialize(const float eta, const float phi)
initialize
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
CPMTowerContainer_v2 CPMTowerContainer
Define the latest version of the CPMHits container.
CPMTowerAuxContainer_v2 CPMTowerAuxContainer
Define the latest version of the CPMHits auxiliary container.
CPMTower_v2 CPMTower
Define the latest version of the CPMTower class.