ATLAS Offline Software
Loading...
Searching...
No Matches
SinglePadClusterTool.cxx
Go to the documentation of this file.
1
10
12
14
15namespace HGTD {
16
18 const std::string& name,
19 const IInterface* parent)
20 : base_class(type, name, parent) {}
21
23
24 ATH_CHECK(AlgTool::initialize());
25
26 ATH_CHECK(m_cluster_maker.retrieve());
27
28 ATH_CHECK(detStore()->retrieve(m_hgtd_det_mgr, "HGTD"));
29
30 ATH_CHECK(m_hgtd_tdc_calib_tool.retrieve(EnableTool{m_use_altiroc_rdo.value()}));
31
32 return StatusCode::SUCCESS;
33}
34
35std::unique_ptr<HGTD_ClusterCollection>
37 DataPool<HGTD_Cluster>* dataItemsPool) const {
38
39 Identifier identifier = rdo_coll.identify();
40 IdentifierHash id_hash = rdo_coll.identifierHash();
41
42 std::unique_ptr<HGTD_ClusterCollection> cluster_collection =
43 std::make_unique<HGTD_ClusterCollection>(id_hash);
44
45 if(dataItemsPool){
46 cluster_collection->clear(SG::VIEW_ELEMENTS);
47 }
48
49 cluster_collection->setIdentifier(identifier);
50 cluster_collection->reserve(rdo_coll.size());
51
52 const InDetDD::HGTD_DetectorElement* element =
53 m_hgtd_det_mgr->getDetectorElement(identifier);
54
55 for (const auto *const rdo : rdo_coll) {
56
57 Identifier rdo_id = rdo->identify();
58 ATH_MSG_DEBUG("Using RDO: " << rdo_id);
59
60 // get the local position from the detector design
61 InDetDD::SiCellId si_cell_id = element->cellIdFromIdentifier(rdo_id);
62 const InDetDD::HGTD_ModuleDesign& det_design = element->design();
64 det_design.localPositionOfCell(si_cell_id);
65 Amg::Vector2D loc_pos(si_pos.xPhi(), si_pos.xEta());
66 ATH_MSG_DEBUG("Local position: x=" << loc_pos.x() << " y=" << loc_pos.y());
67
68 // a cluster consists only of the pad itself
69 std::vector<Identifier> rdo_list = {rdo_id};
70
71 // From SiWidth header:
72 // Constructor with parameters: <col, row> in units of RDOs (so should be
73 // int),
74 // <phiR width in mm, Z width in mm>
75 // NOTE: without a clustering of the pads, the width of each "cluster" is 1
76 // in col and row direction
77 int col_width = 1;
78 int row_width = 1;
79 //FIXME there is a bug in the detector design! should not be hardcoded here
80 // double eta_width = det_design.etaPitch();
81 // double phi_width = det_design.phiPitch();
82 double eta_width = 1.3;
83 double phi_width = 1.3;
84 ATH_MSG_DEBUG("eta_width=" << eta_width << " phi_width=" << phi_width);
85
86 InDet::SiWidth si_width(Amg::Vector2D(col_width, row_width),
87 Amg::Vector2D(phi_width, eta_width));
88
89 // retrieve the time of arrival
90 float time_of_arrival = rdo->getTOA();
91
92 // this would hold the vector of all cluster components. Only size 1 if RDO
93 // gets transformed to cluster directly
94 std::vector<int> time_over_threshold = {static_cast<int>(rdo->getTOT())};
95
96 HGTD_Cluster* cluster = nullptr;
97 if (dataItemsPool) {
98 // data Item pool owns the element. The collection
99 // is view. Just move assign to it.
100 cluster = dataItemsPool->nextElementPtr();
101 } else {
102 // collection will own the element release
103 cluster = new HGTD_Cluster();
104 }
105 (*cluster) = m_cluster_maker->createCluster(
106 rdo_id,
107 loc_pos,
108 std::move(rdo_list),
109 si_width,
110 element,
111 time_of_arrival,
112 std::move(time_over_threshold));
113
114 cluster->setHashAndIndex(cluster_collection->identifyHash(),
115 cluster_collection->size());
116
117 cluster_collection->push_back(cluster);
118 }
119 return cluster_collection;
120}
121
122std::unique_ptr<HGTD_ClusterCollection>
124 DataPool<HGTD_Cluster>* dataItemsPool) const {
125
126 Identifier identifier = rdo_coll.identify();
127 IdentifierHash id_hash = rdo_coll.identifierHash();
128
129 std::unique_ptr<HGTD_ClusterCollection> cluster_collection =
130 std::make_unique<HGTD_ClusterCollection>(id_hash);
131
132 if(dataItemsPool){
133 cluster_collection->clear(SG::VIEW_ELEMENTS);
134 }
135
136 cluster_collection->setIdentifier(identifier);
137 cluster_collection->reserve(rdo_coll.size());
138
139 const InDetDD::HGTD_DetectorElement* element =
140 m_hgtd_det_mgr->getDetectorElement(identifier);
141
142 for (const auto *const rdo : rdo_coll) {
143
144 Identifier rdo_id = rdo->identify();
145 ATH_MSG_DEBUG("Using RDO: " << rdo_id);
146
147 // get the local position from the detector design
148 InDetDD::SiCellId si_cell_id = element->cellIdFromIdentifier(rdo_id);
149 const InDetDD::HGTD_ModuleDesign& det_design = element->design();
151 det_design.localPositionOfCell(si_cell_id);
152 Amg::Vector2D loc_pos(si_pos.xPhi(), si_pos.xEta());
153 ATH_MSG_DEBUG("Local position: x=" << loc_pos.x() << " y=" << loc_pos.y());
154
155 // a cluster consists only of the pad itself
156 std::vector<Identifier> rdo_list = {rdo_id};
157
158 // From SiWidth header:
159 // Constructor with parameters: <col, row> in units of RDOs (so should be
160 // int),
161 // <phiR width in mm, Z width in mm>
162 // NOTE: without a clustering of the pads, the width of each "cluster" is 1
163 // in col and row direction
164 int col_width = 1;
165 int row_width = 1;
166 //FIXME there is a bug in the detector design! should not be hardcoded here
167 // double eta_width = det_design.etaPitch();
168 // double phi_width = det_design.phiPitch();
169 double eta_width = 1.3;
170 double phi_width = 1.3;
171 ATH_MSG_DEBUG("eta_width=" << eta_width << " phi_width=" << phi_width);
172
173 InDet::SiWidth si_width(Amg::Vector2D(col_width, row_width),
174 Amg::Vector2D(phi_width, eta_width));
175
176 // Invoke the TOA TDC Calibration tool to retrieve the time of arrival
177 float time_of_arrival = m_hgtd_tdc_calib_tool->TOA2Time(element,rdo->getToA());
178
179 ATH_MSG_DEBUG("Recovered Time of Arrival: " << time_of_arrival);
180
181 // this would hold the vector of all cluster components. Only size 1 if RDO
182 // gets transformed to cluster directly
183 std::vector<int> time_over_threshold = {static_cast<int>(rdo->getToT())};
184
185 HGTD_Cluster* cluster = nullptr;
186 if (dataItemsPool) {
187 // data Item pool owns the element. The collection
188 // is view. Just move assign to it.
189 cluster = dataItemsPool->nextElementPtr();
190 } else {
191 // collection will own the element release
192 cluster = new HGTD_Cluster();
193 }
194 (*cluster) = m_cluster_maker->createCluster(
195 rdo_id,
196 loc_pos,
197 std::move(rdo_list),
198 si_width,
199 element,
200 time_of_arrival,
201 std::move(time_over_threshold));
202
203 cluster->setHashAndIndex(cluster_collection->identifyHash(),
204 cluster_collection->size());
205
206 cluster_collection->push_back(cluster);
207 }
208 return cluster_collection;
209}
210
211} // namespace HGTD
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration.
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
size_type size() const noexcept
Returns the number of elements in the collection.
const HGTD_DetectorManager * m_hgtd_det_mgr
ToolHandle< HGTD_TdcCalibrationTool > m_hgtd_tdc_calib_tool
virtual std::unique_ptr< HGTD_ClusterCollection > clusterize(const HGTD_RDO_Collection &rdo_coll, DataPool< HGTD_Cluster > *dataItemsPool) const override final
virtual StatusCode initialize() override final
SinglePadClusterTool(const std::string &type, const std::string &name, const IInterface *parent)
ToolHandle< HGTD_ClusterMakerTool > m_cluster_maker
const Identifier & identify() const
const IdentifierHash & identifierHash() const
const Identifier & identify() const
const IdentifierHash & identifierHash() const
This is a "hash" representation of an Identifier.
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:
Class used to describe the design of a module (diode segmentation and readout scheme)
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:
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
Eigen::Matrix< double, 2, 1 > Vector2D
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts