ATLAS Offline Software
Loading...
Searching...
No Matches
HgtdClusteringTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
8
9namespace ActsTrk {
10
12 const std::string& name,
13 const IInterface* parent)
14 : base_class(type, name, parent)
15 {}
16
18 {
19 ATH_MSG_INFO("Initializing HgtdClusteringTool...");
20
21 ATH_CHECK(detStore()->retrieve(m_hgtd_det_mgr, "HGTD"));
22 ATH_CHECK(m_hgtd_tdc_calib_tool.retrieve(EnableTool{m_use_altiroc_rdo.value()}));
23
24 return StatusCode::SUCCESS;
25 }
26
27 std::any HgtdClusteringTool::createEventDataCache(xAOD::HGTDClusterContainer& cont, std::size_t nClusterRDOs) const {
28 return HgtdAuxDataCache(cont,nClusterRDOs);
29 }
30
31 StatusCode HgtdClusteringTool::clusterize(const EventContext&,
32 const RawDataCollection& RDOs,
33 std::vector<ClusterCollection>& collection) const
34 {
35 ATH_MSG_DEBUG("Clustering hits...");
36 collection.emplace_back();
37 ClusterCollection &clusters=collection.back();
38 clusters.reserve(RDOs.size());
39 for (std::size_t i(0), n(RDOs.size()); i < n; ++i) {
40 const auto* rdo = RDOs[i];
41 Identifier rdo_id = rdo->identify();
42 clusters.emplace_back();
43 clusters.back().ids.push_back(rdo_id.get_compact());
44 clusters.back().times.push_back(rdo->getTOA());
45 clusters.back().tots.push_back(rdo->getTOT());
46 }
47 return StatusCode::SUCCESS;
48 }
49
50 StatusCode HgtdClusteringTool::makeClusters(const EventContext& ctx,
51 const ClusterCollection& clusters,
53 size_t& icluster,
54 std::any& cache) const
55 {
56 HgtdAuxDataCache* auxDataCache = std::any_cast<HgtdAuxDataCache> (&cache);
57 if (!auxDataCache) throw std::bad_any_cast();
58 assert( icluster+clusters.size() <= container.size() );
59 for (std::size_t i(0); i<clusters.size(); ++i) {
60 const HgtdClusteringTool::Cluster& cluster = clusters[i];
61 assert(icluster+i == container[icluster+i]->index());
62 ATH_CHECK(makeCluster(ctx, cluster, *container[icluster+i],auxDataCache));
63 }
64
65 return StatusCode::SUCCESS;
66 }
67
68 StatusCode HgtdClusteringTool::makeCluster(const EventContext& /*ctx*/,
69 const typename HgtdClusteringTool::Cluster &cluster,
70 xAOD::HGTDCluster& xaodcluster,
71 HgtdAuxDataCache* auxDataCache) const
72 {
73 unsigned int icluster=xaodcluster.index();
74 unsigned int n_rdos = auxDataCache->rdoList.getBeginIndex(icluster);
75 assert(icluster==0 || n_rdos == auxDataCache->totList.getBeginIndex(icluster));
76 assert( n_rdos+cluster.ids.size() <= auxDataCache->rdoList.nObjects() );
77 assert( cluster.tots.size() == cluster.ids.size());
78 assert( cluster.times.size() == cluster.ids.size());
79 assert( cluster.ids.size() == 1);
80 for (size_t rdo_i = 0; rdo_i < cluster.ids.size(); ++rdo_i) {
81 Identifier rdo_id( cluster.ids[rdo_i]);
82 // @TODO get detector element only once by caller aka. makeClusters
83 const InDetDD::HGTD_DetectorElement* element = m_hgtd_det_mgr->getDetectorElement(rdo_id);
84
85 InDetDD::SiCellId si_cell_id = element->cellIdFromIdentifier(rdo_id);
86
87 InDetDD::SiLocalPosition si_pos = element->design().localPositionOfCell(si_cell_id);
88
89
90 Eigen::Matrix<float, 3, 1> loc_pos(si_pos.xPhi(), si_pos.xEta(),cluster.times[rdo_i]);
91 Eigen::Matrix<float, 3, 3> cov_matrix= Eigen::Matrix<float, 3, 3>::Zero();
92
93 float xWidth = 1.3;
94 float yWidth = 1.3;
95 cov_matrix(0,0) = xWidth * xWidth / 12; // i.e. Cov XX
96 cov_matrix(1,1) = yWidth * yWidth / 12; // i.e. Cov YY
97 float time_of_arrival_err = 0.035;
98 cov_matrix(2,2) = time_of_arrival_err * time_of_arrival_err; // i.e. Cov TT
99
100 auxDataCache->rdoList.setValue(n_rdos,rdo_id.get_compact());
101 auxDataCache->totList.setValue(n_rdos,cluster.tots[rdo_i]);
102 ++n_rdos;
103 // this will set the position and covariance to the last and only RDO
104 IdentifierHash id_hash = element->identifyHash();
105 xaodcluster.setMeasurement<3>(id_hash,loc_pos,cov_matrix);
106 }
107
108
109 // Fill
110 xaodcluster.setIdentifier(cluster.ids.front());
111 auxDataCache->rdoList.updateEndIndex(icluster,n_rdos);
112 auxDataCache->totList.updateEndIndex(icluster,n_rdos);
113
114 return StatusCode::SUCCESS;
115 }
116
117 StatusCode HgtdClusteringTool::clusterize(const EventContext&,
118 const HGTD_ALTIROC_RDO_Collection& RDOs,
119 std::vector<ClusterCollection>& collection) const
120 {
121 ATH_MSG_DEBUG("Clustering hits...");
122 collection.emplace_back();
123 ClusterCollection &clusters=collection.back();
124 clusters.reserve(RDOs.size());
125
126 for (std::size_t i(0), n(RDOs.size()); i < n; ++i) {
127 const auto* rdo = RDOs[i];
128 Identifier rdo_id = rdo->identify();
129 clusters.emplace_back();
130 clusters.back().ids.push_back(rdo_id.get_compact());
131 const InDetDD::HGTD_DetectorElement* element = m_hgtd_det_mgr->getDetectorElement(rdo_id);
132 clusters.back().times.push_back(m_hgtd_tdc_calib_tool->TOA2Time(element, rdo->getToA()));
133 ATH_MSG_DEBUG("Recovered Time of Arrival: " << m_hgtd_tdc_calib_tool->TOA2Time(element, rdo->getToA()));
134 clusters.back().tots.push_back(rdo->getToT());
135 }
136 return StatusCode::SUCCESS;
137 }
138
139} // namespace
140
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Define structures for fast filling of xAOD objects.
const HGTD_DetectorManager * m_hgtd_det_mgr
ToolHandle< HGTD_TdcCalibrationTool > m_hgtd_tdc_calib_tool
IHGTDClusteringTool::Cluster Cluster
virtual StatusCode clusterize(const EventContext &ctx, const RawDataCollection &RDOs, std::vector< ClusterCollection > &collection) const override
StatusCode makeCluster(const EventContext &, const typename HgtdClusteringTool::Cluster &cluster, xAOD::HGTDCluster &xaodcluster, HgtdAuxDataCache *cache) const
virtual std::any createEventDataCache(xAOD::HGTDClusterContainer &cont, std::size_t nClusterRDOs) const override
virtual StatusCode makeClusters(const EventContext &ctx, const ClusterCollection &clusters, xAOD::HGTDClusterContainer &container, size_t &icluster, std::any &cache) const override
virtual StatusCode initialize() override
IHGTDClusteringTool::ClusterCollection ClusterCollection
HgtdClusteringTool(const std::string &type, const std::string &name, const IInterface *parent)
size_type size() const noexcept
Returns the number of elements in the collection.
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
Class to hold geometrical description of an HGTD detector element.
SiCellId cellIdFromIdentifier(const Identifier &identifier) const override final
SiCellId from Identifier.
const HGTD_ModuleDesign & design() const override final
access to the local description:
virtual SiLocalPosition localPositionOfCell(const SiCellId &cellId) const
readout or diode id -> position.
Identifier for the strip or pixel cell.
Definition SiCellId.h:29
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
double xPhi() const
position along phi direction:
double xEta() const
position along eta direction:
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
void setIdentifier(const DetectorIdentType measId)
Sets the full Identifier of the measurement.
void updateEndIndex(unsigned int obj_i, unsigned int elm_i)
unsigned int getBeginIndex(unsigned int obj_i) const
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition index.py:1
HGTDClusterContainer_v1 HGTDClusterContainer
Define the version of the HGTD cluster container.
HGTDCluster_v1 HGTDCluster
Define the version of the pixel cluster class.
Definition HGTDCluster.h:13
xAOD::xAODInDetMeasurement::Utilities::JaggedVecEltCache< int > totList
xAOD::xAODInDetMeasurement::Utilities::JaggedVecEltCache< Identifier::value_type > rdoList
std::vector< Identifier::value_type > ids