42{
43
44 SG::ReadHandle<traccc::edm::measurement_collection::buffer>
47
49 traccc::edm::measurement_collection::host meas_host{
m_hostMR->mr()};
50 (*copy)(*measurements, meas_host)->wait();
51 ATH_MSG_DEBUG(
"Copied " << meas_host.size() <<
" measurements.");
52
53
54 int n_pixels = 0;
55 int n_strips = 0;
56 for (std::size_t i = 0;
i < meas_host.size(); ++
i) {
57 if (meas_host[i].dimensions() == 2u) ++n_pixels;
58 else ++n_strips;
59 }
60
61
62 DataPool<xAOD::PixelCluster> pixel_pool(ctx);
63 DataPool<xAOD::StripCluster> strip_pool(ctx);
64
65 auto pixel_cont = std::make_unique<xAOD::PixelClusterContainer>(
67 auto pixel_aux = std::make_unique<xAOD::PixelClusterAuxContainer>();
68 auto strip_cont = std::make_unique<xAOD::StripClusterContainer>(
70 auto strip_aux = std::make_unique<xAOD::StripClusterAuxContainer>();
71
72 pixel_pool.reserve(n_pixels);
73 strip_pool.reserve(n_strips);
74
75 pixel_cont->push_new(n_pixels,
76 [&pixel_pool]() { return pixel_pool.nextElementPtr(); });
77 strip_cont->push_new(n_strips,
78 [&strip_pool]() { return strip_pool.nextElementPtr(); });
79
80 pixel_aux->resize(pixel_cont->size());
81 strip_aux->resize(strip_cont->size());
82
83 pixel_cont->setStore(pixel_aux.get());
84 strip_cont->setStore(strip_aux.get());
85
86
87 auto pixItr = pixel_cont->begin();
88 auto stripItr = strip_cont->begin();
89
90 size_t pixel_idx = 0;
91 size_t strip_idx = 0;
92
93 for (std::size_t i = 0;
i < meas_host.size(); ++
i) {
94 const auto& meas = meas_host[
i];
95 const uint64_t detrayId = meas.surface_link().value();
97
98 if (meas.dimensions() == 2u) {
99
101
102 const IdentifierHash pixHash =
m_pixelID->wafer_hash(athenaId);
103 const InDetDD::SiDetectorElement* pDE =
105
107 meas.local_position()[1]);
109
110 Eigen::Matrix<float, 2, 1> localPosition(localPos.x(), localPos.y());
111 Eigen::Matrix<float, 2, 2> localCovariance =
112 Eigen::Matrix<float, 2, 2>::Zero();
113 localCovariance(0, 0) = meas.local_variance()[0];
114 localCovariance(1, 1) = meas.local_variance()[1];
115
116 const Identifier hitId(athenaId.
get_compact() + pixel_idx + strip_idx);
117
118 xaod_pcl->
setMeasurement<2>(pixHash, localPosition, localCovariance);
120 Eigen::Matrix<float, 3, 1>(gp.x(), gp.y(), gp.z());
123
124 ++pixel_idx;
125
126 } else {
127
129
130 const IdentifierHash stripHash =
m_stripID->wafer_hash(athenaId);
131 const InDetDD::SiDetectorElement* pDE =
133
134 Eigen::Matrix<float, 1, 1> localPosition = Eigen::Matrix<float, 1, 1>::Zero();
135 Eigen::Matrix<float, 1, 1> localCovariance = Eigen::Matrix<float, 1, 1>::Zero();
136
138 localPosition(0, 0) = meas.local_position()[0];
139 localCovariance(0, 0) = meas.local_variance()[0];
140 } else {
141 localPosition(0, 0) = meas.local_position()[1];
142 localCovariance(0, 0) = meas.local_variance()[1];
143 }
144
145 const Identifier hitId(athenaId.
get_compact() + pixel_idx + strip_idx);
146
147 xaod_scl->
setMeasurement<1>(stripHash, localPosition, localCovariance);
150 ++strip_idx;
151 }
152 }
153
154 ATH_MSG_DEBUG(
"Converted " << pixel_idx <<
" pixel clusters, "
155 << strip_idx << " strip clusters");
156
160
161
162 SG::WriteHandle<xAOD::PixelClusterContainer> pixelHandle{
m_outputPixelKey, ctx};
163 ATH_CHECK(pixelHandle.
record(std::move(pixel_cont), std::move(pixel_aux)));
164
165 SG::WriteHandle<xAOD::StripClusterContainer> stripHandle{
m_outputStripKey, ctx};
166 ATH_CHECK(stripHandle.
record(std::move(strip_cont), std::move(strip_aux)));
167
168 return StatusCode::SUCCESS;
169}
#define ATH_CHECK
Evaluate an expression and check for errors.
SG::ReadHandleKey< traccc::edm::measurement_collection::buffer > m_inputMeasKey
SG::WriteHandleKey< xAOD::StripClusterContainer > m_outputStripKey
std::atomic< int > m_nMeas
ToolHandle< AthDevice::IMemoryResourceTool > m_hostMR
std::atomic< int > m_nPix
const PixelID * m_pixelID
const std::unordered_map< uint64_t, Identifier > * m_detrayToAthena
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_outputPixelKey
ToolHandle< AthDevice::ICopyTool > m_copy
const InDetDD::SCT_DetectorManager * m_stripManager
const InDetDD::PixelDetectorManager * m_pixelManager
std::atomic< int > m_nStrip
value_type get_compact() const
Get the compact id.
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
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.
ConstVectorMap< 3 > globalPosition() const
Returns the global position of the pixel cluster.
void setWidthInEta(float widthInEta)
Sets the width of the cluster in eta (y) direction.
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
void setIdentifierHash(const DetectorIDHashType idHash)
Sets the IdentifierHash of the measurement (corresponds to the detector element IdentifierHash).
void setIdentifier(const DetectorIdentType measId)
Sets the full Identifier of the measurement.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
@ ALWAYS_TRACK_INDICES
Always track indices, regardless of the setting of the ownership policy.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.