ATLAS Offline Software
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"
6 namespace InDet {
8  ISvcLocator* pSvcLocator)
9  : AthReentrantAlgorithm(name, pSvcLocator) {}
10 
11 
13  ATH_CHECK(m_pixelRDOTool.retrieve());
15  ATH_CHECK(m_pixelOutputKey.initialize());
16  ATH_CHECK(m_stripRdoContainerKey.initialize());
17  ATH_CHECK(m_stripOutputKey.initialize());
18 
21 
22  return StatusCode::SUCCESS;
23 }
24 
25 StatusCode HitsToxAODCopier::execute(const EventContext& context) const {
26  ATH_CHECK(exportPixel(context));
27  ATH_CHECK(exportStrip(context));
28  return StatusCode::SUCCESS;
29 }
30 
31 StatusCode 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 
76 StatusCode 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
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
InDet::HitsToxAODCopier::m_stripIdHelper
const SCT_ID * m_stripIdHelper
Definition: HitsToxAODCopier.h:50
query_example.row
row
Definition: query_example.py:24
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::HitsToxAODCopier::m_stripOutputKey
SG::WriteHandleKey< xAOD::BaseContainer > m_stripOutputKey
Definition: HitsToxAODCopier.h:46
InDet::HitsToxAODCopier::initialize
virtual StatusCode initialize() override
Definition: HitsToxAODCopier.cxx:12
HitsToxAODCopier.h
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
InDet::HitsToxAODCopier::exportStrip
StatusCode exportStrip(const EventContext &context) const
Definition: HitsToxAODCopier.cxx:76
InDet::HitsToxAODCopier::m_pixelOutputKey
SG::WriteHandleKey< xAOD::BaseContainer > m_pixelOutputKey
Definition: HitsToxAODCopier.h:43
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
InDet::HitsToxAODCopier::m_pixelIdHelper
const PixelID * m_pixelIdHelper
Definition: HitsToxAODCopier.h:49
TRT::Hit::side
@ side
Definition: HitInfo.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::HitsToxAODCopier::HitsToxAODCopier
HitsToxAODCopier(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HitsToxAODCopier.cxx:7
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
InDet::HitsToxAODCopier::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: HitsToxAODCopier.cxx:25
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
merge.output
output
Definition: merge.py:17
PixelID::layer_disk
int layer_disk(const Identifier &id) const
Definition: PixelID.h:626
PixelID::eta_module
int eta_module(const Identifier &id) const
Definition: PixelID.h:651
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:227
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
item
Definition: ItemListSvc.h:43
InDet::HitsToxAODCopier::m_pixelRdoContainerKey
SG::ReadHandleKey< PixelRDO_Container > m_pixelRdoContainerKey
Definition: HitsToxAODCopier.h:38
query_example.col
col
Definition: query_example.py:7
SCT_ID::strip
int strip(const Identifier &id) const
Definition: SCT_ID.h:764
InDet::HitsToxAODCopier::exportPixel
StatusCode exportPixel(const EventContext &context) const
Definition: HitsToxAODCopier.cxx:31
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
InDet::HitsToxAODCopier::m_stripRdoContainerKey
SG::ReadHandleKey< SCT_RDO_Container > m_stripRdoContainerKey
Definition: HitsToxAODCopier.h:40
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
InDet::HitsToxAODCopier::m_pixelRDOTool
ToolHandle< InDet::PixelRDOTool > m_pixelRDOTool
Definition: HitsToxAODCopier.h:36