ATLAS Offline Software
Loading...
Searching...
No Matches
PadClusterizationAlg.cxx
Go to the documentation of this file.
1
8
10
14
15namespace HGTD {
16
18 ISvcLocator* pSvcLocator)
19 : AthReentrantAlgorithm(name, pSvcLocator) {}
20
22
24 ATH_CHECK(m_prd_wh_key.initialize());
26 ATH_CHECK(m_rdo_rh_key.initialize(not m_use_altiroc_rdo.value()));
27
28 ATH_CHECK(detStore()->retrieve(m_hgtd_idhelper, "HGTD_ID"));
29 ATH_CHECK(m_monTool.retrieve(EnableTool{not m_monTool.empty()}));
30
31 return StatusCode::SUCCESS;
32}
33
34StatusCode PadClusterizationAlg::execute(const EventContext& ctx) const {
35 auto timer = Monitored::Timer<std::chrono::milliseconds>( "TIME_execute" );
36 auto mon = Monitored::Group( m_monTool, timer );
37
38 // register the PRD container in storegate
39 SG::WriteHandle<HGTD_ClusterContainer> prd_container_handle(
40 m_prd_wh_key, ctx);
41
43 prd_container_handle.record(std::make_unique<HGTD_ClusterContainer>(
44 m_hgtd_idhelper->wafer_hash_max())));
45
46 HGTD_ClusterContainer* locp_prd_container = prd_container_handle.ptr();
47
48 std::unique_ptr<DataPool<HGTD_Cluster>> dataItemsPool = nullptr;
49
50 if (m_use_altiroc_rdo.value()){
51 // retrieve the RDOs
52
54 const HGTD_ALTIROC_RDO_Container* rdo_container = rdo_container_handle.cptr();
55
56 if (not rdo_container) {
57 //assume this is fast digi input and ignore
58 return StatusCode::SUCCESS;
59 }
60
61 const bool hasExternalCache = rdo_container->hasExternalCache();
62 if (!hasExternalCache) {
63 dataItemsPool = std::make_unique<DataPool<HGTD_Cluster>>(ctx);
64 dataItemsPool->reserve(10000); // Some large default size
65 }
66
67 // Transform the RDOs collection by collection
68 for (const auto rdo_collection : *rdo_container) {
69 if (rdo_collection->empty()) {
70 continue;
71 }
72
73 std::unique_ptr<HGTD_ClusterCollection> prd_collection =
74 m_clusterization_tool->clusterize(*rdo_collection,dataItemsPool.get());
75
76 // can happen if some channels are masked, not really relevant currently
77 if (prd_collection->empty()) {
78 continue;
79 }
80 const IdentifierHash identifyHash{prd_collection->identifyHash()};
81 if (locp_prd_container
82 ->addCollection(prd_collection.release(),identifyHash)
83 .isFailure()) {
84 ATH_MSG_WARNING("Could not add ClusterCollection to container!");
85 }
86 } // END LOOP over container
87
88 } else {
89 // retrieve the RDOs
90 SG::ReadHandle<HGTD_RDO_Container> rdo_container_handle(m_rdo_rh_key, ctx);
91 const HGTD_RDO_Container* rdo_container = rdo_container_handle.cptr();
92
93 if (not rdo_container) {
94 //assume this is fast digi input and ignore
95 return StatusCode::SUCCESS;
96 }
97
98 const bool hasExternalCache = rdo_container->hasExternalCache();
99 if (!hasExternalCache) {
100 dataItemsPool = std::make_unique<DataPool<HGTD_Cluster>>(ctx);
101 dataItemsPool->reserve(10000); // Some large default size
102 }
103
104
105 // Transform the RDOs collection by collection
106 for (const auto rdo_collection : *rdo_container) {
107 if (rdo_collection->empty()) {
108 continue;
109 }
110
111 std::unique_ptr<HGTD_ClusterCollection> prd_collection =
112 m_clusterization_tool->clusterize(*rdo_collection,dataItemsPool.get());
113
114 // can happen if some channels are masked, not really relevant currently
115 if (prd_collection->empty()) {
116 continue;
117 }
118 const IdentifierHash identifyHash{prd_collection->identifyHash()};
119 if (locp_prd_container
120 ->addCollection(prd_collection.release(),identifyHash)
121 .isFailure()) {
122 ATH_MSG_WARNING("Could not add ClusterCollection to container!");
123 }
124 } // END LOOP over container
125 }
126
127 return StatusCode::SUCCESS;
128}
129
130} // namespace HGTD
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Trk::PrepRawDataContainer< HGTD_ClusterCollection > HGTD_ClusterContainer
Header file to be included by clients of the Monitored infrastructure.
Handle class for recording to StoreGate.
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
SG::WriteHandleKey< HGTD_ClusterContainer > m_prd_wh_key
SG::ReadHandleKey< HGTD_RDO_Container > m_rdo_rh_key
virtual StatusCode initialize() override final
virtual StatusCode execute(const EventContext &ctx) const override final
PadClusterizationAlg(const std::string &name, ISvcLocator *pSvcLocator)
ToolHandle< IHGTD_PadClusterizationTool > m_clusterization_tool
SG::ReadHandleKey< HGTD_ALTIROC_RDO_Container > m_altiroc_rdo_rh_key
ToolHandle< GenericMonitoringTool > m_monTool
virtual bool hasExternalCache() const override final
This is a "hash" representation of an Identifier.
Group of local monitoring quantities and retain correlation when filling histograms
A monitored timer.
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.