ATLAS Offline Software
Loading...
Searching...
No Matches
HgtdClusterizationAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10namespace ActsTrk {
11
13 ISvcLocator* pSvcLocator)
14 : AthReentrantAlgorithm(name, pSvcLocator)
15 {}
16
18 {
19 ATH_MSG_DEBUG("Initializing " << name() << " ...");
20 ATH_CHECK(m_clusteringTool.retrieve());
21 ATH_CHECK(m_monTool.retrieve(EnableTool{not m_monTool.empty()}));
22
23 ATH_CHECK(m_rdoContainerKey.initialize(not m_use_altiroc_rdo.value()));
25 ATH_CHECK(m_clusterContainerKey.initialize());
26
27 return StatusCode::SUCCESS;
28
29 }
30
32 ATH_MSG_INFO("Clusterization statistics" << std::endl << makeTable(m_stat,
33 std::array<std::string, kNStat>{
34 "RDOs",
35 "Clusters"
36 }).columnWidth(10));
37
38 return StatusCode::SUCCESS;
39 }
40
41 StatusCode HgtdClusterizationAlg::execute(const EventContext& ctx) const
42 {
43 ATH_MSG_DEBUG("Executing " << name() << " ...");
44
45 auto timer = Monitored::Timer<std::chrono::milliseconds>( "TIME_execute" );
46 auto mon = Monitored::Group( m_monTool, timer );
47
49 ATH_CHECK(clusterContainer.record(std::make_unique<xAOD::HGTDClusterContainer>(),
50 std::make_unique<xAOD::HGTDClusterAuxContainer>()));
51
52 unsigned int nRDOs=0;
53 unsigned int nClusters=0;
54 std::vector<IHGTDClusteringTool::ClusterCollection> clusterCollection;
57 if (!rdoContainer.isValid()) {
58 ATH_MSG_ERROR("Failed to retrieve HGTD ALTIROC RDO container");
59 return StatusCode::FAILURE;
60 }
61
62 clusterCollection.reserve(rdoContainer->size());
63 for (const auto rdoCollection : *rdoContainer) {
64 if (rdoCollection->empty()) {
65 continue;
66 }
67 nRDOs+=rdoCollection->size();
68 ATH_CHECK(m_clusteringTool->clusterize(ctx, *rdoCollection, clusterCollection));
69 nClusters += clusterCollection.back().size();
70 }
71
72 } else {
74 if (!rdoContainer.isValid()) {
75 ATH_MSG_ERROR("Failed to retrieve HGTD RDO container");
76 return StatusCode::FAILURE;
77 }
78
79 clusterCollection.reserve(rdoContainer->size());
80 for (const auto rdoCollection : *rdoContainer) {
81 if (rdoCollection->empty()) {
82 continue;
83 }
84 nRDOs+=rdoCollection->size();
85 ATH_CHECK(m_clusteringTool->clusterize(ctx, *rdoCollection, clusterCollection));
86 nClusters += clusterCollection.back().size();
87 }
88 }
89
90 clusterContainer->push_new(nClusters, []() {return new xAOD::HGTDCluster;});
91 std::any cache = m_clusteringTool->createEventDataCache(*clusterContainer,nRDOs);
92
93 std::size_t icluster=0;
94 for (std::size_t icollection=0u; icollection<clusterCollection.size(); ++icollection) {
95 ATH_CHECK( m_clusteringTool->makeClusters(ctx,
96 clusterCollection[icollection],
97 *clusterContainer,
98 icluster,
99 cache));
100 icluster += clusterCollection[icollection].size();
101 }
102 assert( clusterContainer->size() == icluster);
103
104 m_stat[kNRdo] += nRDOs;
105 m_stat[kNClusters] += clusterContainer->size();
106 ATH_MSG_DEBUG("Clusters produced size: "<<clusterContainer->size());
107 return StatusCode::SUCCESS;
108 }
109
110
111}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Header file to be included by clients of the Monitored infrastructure.
TableUtils::StatTable< T > makeTable(const std::array< T, N > &counter, const std::array< std::string, N > &label)
Definition TableUtils.h:543
SG::WriteHandleKey< xAOD::HGTDClusterContainer > m_clusterContainerKey
SG::ReadHandleKey< HGTD_RDO_Container > m_rdoContainerKey
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< HGTD_ALTIROC_RDO_Container > m_altiroc_rdo_rh_key
HgtdClusterizationAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode finalize() override
ToolHandle< IHGTDClusteringTool > m_clusteringTool
virtual StatusCode initialize() override
ToolHandle< GenericMonitoringTool > m_monTool
An algorithm that can be simultaneously executed in multiple threads.
Group of local monitoring quantities and retain correlation when filling histograms
A monitored timer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
HGTDCluster_v1 HGTDCluster
Define the version of the pixel cluster class.
Definition HGTDCluster.h:13