ATLAS Offline Software
Loading...
Searching...
No Matches
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
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 CHECK(pBS_Addr != nullptr);
90 // -------------------------------------------------------------------------
91 const std::string nm = *(pBS_Addr->par());
92 ATH_MSG_DEBUG("Creating Objects " << nm);
93
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) {
107 xAOD::CPMTower* item = new xAOD::CPMTower();
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.
131StatusCode CpmTowerByteStreamAuxCnv::createRep(DataObject* /*pObj*/,
132 IOpaqueAddress*& /*pAddr*/) {
133 return StatusCode::FAILURE;
134}
135
136} // 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.
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.
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.