ATLAS Offline Software
Loading...
Searching...
No Matches
HitsToxAODCopier.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "HitsToxAODCopier.h"
6namespace InDet {
7HitsToxAODCopier::HitsToxAODCopier(const std::string& name,
8 ISvcLocator* pSvcLocator)
9 : AthReentrantAlgorithm(name, pSvcLocator) {}
10
11
13 ATH_CHECK(m_pixelRDOTool.retrieve());
15 ATH_CHECK(m_pixelOutputKey.initialize());
17 ATH_CHECK(m_stripOutputKey.initialize());
18
19 ATH_CHECK(detStore()->retrieve(m_pixelIdHelper, "PixelID"));
20 ATH_CHECK(detStore()->retrieve(m_stripIdHelper, "SCT_ID"));
21
22 return StatusCode::SUCCESS;
23}
24
25StatusCode HitsToxAODCopier::execute(const EventContext& context) const {
26 ATH_CHECK(exportPixel(context));
27 ATH_CHECK(exportStrip(context));
28 return StatusCode::SUCCESS;
29}
30
31StatusCode HitsToxAODCopier::exportPixel(const EventContext& context) const {
34 ATH_CHECK(rdoContainer.isValid());
35
36 auto output = std::make_unique<xAOD::BaseContainer>();
37 auto outputAux = std::make_unique<xAOD::AuxContainerBase>();
38 output->setStore(outputAux.get());
39 static const SG::AuxElement::Accessor<int> col("col");
40 static const SG::AuxElement::Accessor<int> row("row");
41 static const SG::AuxElement::Accessor<int> tot("tot");
42 static const SG::AuxElement::Accessor<int> eta_module("eta_module");
43 static const SG::AuxElement::Accessor<int> phi_module("phi_module");
44 static const SG::AuxElement::Accessor<int> layer_disk("layer_disk");
45 static const SG::AuxElement::Accessor<int> barrel_ec("barrel_ec");
46 static const SG::AuxElement::Accessor<uint64_t> id("detid");
47
48 for (const auto *collection : *rdoContainer) {
49 const InDetDD::SiDetectorElement* element =
50 m_pixelRDOTool->checkCollection(*collection, context);
51 if (element != nullptr) {
52 std::vector<InDet::UnpackedPixelRDO> hits =
53 m_pixelRDOTool->getUnpackedPixelRDOs(*collection, *m_pixelIdHelper,
54 element, context);
55 for (auto hit : hits) {
56 auto* item = new SG::AuxElement();
57 output->push_back(item);
58 col(*item) = hit.COL;
59 row(*item) = hit.ROW;
60 tot(*item) = hit.TOT;
61 eta_module(*item) = m_pixelIdHelper->eta_module(hit.ID);
62 phi_module(*item) = m_pixelIdHelper->phi_module(hit.ID);
63 layer_disk(*item) = m_pixelIdHelper->layer_disk(hit.ID);
64 barrel_ec(*item) = m_pixelIdHelper->barrel_ec(hit.ID);
65 id(*item) = hit.ID.get_compact();
66 }
67 }
68 }
69 auto outputHandle = SG::makeHandle(m_pixelOutputKey, context);
70 ATH_CHECK(outputHandle.record(std::move(output), std::move(outputAux)));
71
72 return StatusCode::SUCCESS;
73}
74
75
76StatusCode HitsToxAODCopier::exportStrip(const EventContext& context) const {
79 ATH_CHECK(rdoContainer.isValid());
80
81 auto output = std::make_unique<xAOD::BaseContainer>();
82 auto outputAux = std::make_unique<xAOD::AuxContainerBase>();
83 output->setStore(outputAux.get());
84 static const SG::AuxElement::Accessor<int> strip("strip");
85 static const SG::AuxElement::Accessor<int> side("side");
86 static const SG::AuxElement::Accessor<int> eta_module("eta_module");
87 static const SG::AuxElement::Accessor<int> phi_module("phi_module");
88 static const SG::AuxElement::Accessor<int> layer_disk("layer_disk");
89 static const SG::AuxElement::Accessor<int> barrel_ec("barrel_ec");
90 static const SG::AuxElement::Accessor<uint64_t> id("detid");
91
92 for ( const auto *collection: *rdoContainer) {
93 if ( collection == nullptr) continue;
94 // const IdentifierHash idHash = rdos->identifyHash();
95 for ( const auto *hit: *collection) {
96 auto* item = new SG::AuxElement();
97 output->push_back(item);
98 strip(*item) = m_stripIdHelper->strip(hit->identify());
99 side(*item) = m_stripIdHelper->side(hit->identify());
100 eta_module(*item) = m_stripIdHelper->eta_module(hit->identify());
101 phi_module(*item) = m_stripIdHelper->phi_module(hit->identify());
102 layer_disk(*item) = m_stripIdHelper->layer_disk(hit->identify());
103 barrel_ec(*item) = m_stripIdHelper->barrel_ec(hit->identify());
104 id(*item) = hit->identify().get_compact();
105 }
106 }
107
108 auto outputHandle = SG::makeHandle(m_stripOutputKey, context);
109 ATH_CHECK(outputHandle.record(std::move(output), std::move(outputAux)));
110 return StatusCode::SUCCESS;
111}
112
113} // namespace InDet
#define ATH_CHECK
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
Class to hold geometrical description of a silicon detector element.
const SCT_ID * m_stripIdHelper
SG::ReadHandleKey< PixelRDO_Container > m_pixelRdoContainerKey
SG::WriteHandleKey< xAOD::BaseContainer > m_stripOutputKey
SG::ReadHandleKey< SCT_RDO_Container > m_stripRdoContainerKey
StatusCode exportStrip(const EventContext &context) const
StatusCode exportPixel(const EventContext &context) const
virtual StatusCode initialize() override
HitsToxAODCopier(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< InDet::PixelRDOTool > m_pixelRDOTool
const PixelID * m_pixelIdHelper
virtual StatusCode execute(const EventContext &context) const override
SG::WriteHandleKey< xAOD::BaseContainer > m_pixelOutputKey
Base class for elements of a container that can have aux data.
Definition AuxElement.h:483
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Primary Vertex Finder.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())