18 ISvcLocator *pSvcLocator)
45 return StatusCode::SUCCESS;
53 std::unique_ptr< xAOD::PixelClusterContainer > pixel_cluster_xaod_container = std::make_unique< xAOD::PixelClusterContainer >();
54 std::unique_ptr< xAOD::PixelClusterAuxContainer > pixel_cluster_xaod_aux_container = std::make_unique< xAOD::PixelClusterAuxContainer >();
55 pixel_cluster_xaod_container->setStore( pixel_cluster_xaod_aux_container.get() );
57 std::unique_ptr< xAOD::StripClusterContainer > strip_cluster_xaod_container = std::make_unique< xAOD::StripClusterContainer >();
58 std::unique_ptr< xAOD::StripClusterAuxContainer > strip_cluster_xaod_aux_container = std::make_unique< xAOD::StripClusterAuxContainer >();
59 strip_cluster_xaod_container->setStore( strip_cluster_xaod_aux_container.get() );
67 std::unordered_map<Identifier, std::size_t> mapClusters{};
69 strip_cluster_xaod_container.get(),
72 strip_cluster_xaod_container.get(),
80 ATH_CHECK( pixel_cluster_xaod_handle.
record( std::move(pixel_cluster_xaod_container),
81 std::move(pixel_cluster_xaod_aux_container) ) );
86 ATH_CHECK( strip_cluster_xaod_handle.
record( std::move(strip_cluster_xaod_container),
87 std::move(strip_cluster_xaod_aux_container) ) );
91 return StatusCode::SUCCESS;
97 static const SG::AuxElement::Accessor< ElementLink< ::SpacePointCollection > > linkAcc(
"pixelSpacePointLink");
102 if (not pixelDetEleHandle.
isValid()) {
104 return StatusCode::FAILURE;
106 pixElements = pixelDetEleHandle.
cptr();
112 const ::SpacePointContainer* pixel_container = pixel_handle.
cptr();
116 std::unique_ptr< xAOD::SpacePointAuxContainer > pixel_xaod_aux_container = std::make_unique< xAOD::SpacePointAuxContainer >();
117 pixel_xaod_container->setStore( pixel_xaod_aux_container.get() );
120 for (const ::SpacePointCollection *spc : *pixel_container) {
124 pixel_xaod_container->push_new (nsp, [&
pool](){
return pool.nextElementPtr();});
128 for (const ::SpacePointCollection *spc : *pixel_container) {
137 const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>& clusterList =
sp->clusterList();
139 if (theCluster ==
nullptr) {
143 auto clusterId = clusterList.first->identify();
145 if ( element ==
nullptr ) {
146 ATH_MSG_FATAL(
"Invalid pixel detector element for cluster identifier " << clusterId );
147 return StatusCode::FAILURE;
151 cluster_xaod_container->
push_back(pixelCl);
158 linkAcc(*pixel_sp) = link;
164 ATH_CHECK( pixel_xaod_handle.
record( std::move(pixel_xaod_container), std::move(pixel_xaod_aux_container) ) );
166 return StatusCode::SUCCESS;
171 std::unordered_map<Identifier, std::size_t>& mapClusters)
const
176 if (not stripDetEleHandle.
isValid()) {
178 return StatusCode::FAILURE;
180 stripElements = stripDetEleHandle.
cptr();
183 static const SG::AuxElement::Accessor< ElementLink< ::SpacePointCollection > > linkAcc(
"sctSpacePointLink");
188 const ::SpacePointContainer* strip_container = strip_handle.
cptr();
191 std::unique_ptr< xAOD::SpacePointContainer > strip_xaod_container = std::make_unique< xAOD::SpacePointContainer >();
192 std::unique_ptr< xAOD::SpacePointAuxContainer > strip_xaod_aux_container = std::make_unique< xAOD::SpacePointAuxContainer >();
193 strip_xaod_container->setStore( strip_xaod_aux_container.get() );
195 strip_xaod_container->reserve(strip_container->size());
196 strip_xaod_aux_container->reserve(strip_container->size());
199 for (const ::SpacePointCollection *spc : *strip_container) {
208 const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>& clusterList =
sp->clusterList();
211 if (theCluster1 ==
nullptr or
212 theCluster2 ==
nullptr) {
216 auto clusterId1 = clusterList.first->identify();
217 auto clusterId2 = clusterList.second->identify();
220 if ( element1 ==
nullptr ) {
221 ATH_MSG_FATAL(
"Invalid strip detector element for cluster (1) identifiers " << clusterId1 );
222 return StatusCode::FAILURE;
224 if ( element2 ==
nullptr ) {
225 ATH_MSG_FATAL(
"Invalid strip detector element for cluster (2) identifiers " << clusterId2 );
226 return StatusCode::FAILURE;
229 auto insertEntry = [&mapClusters, cluster_xaod_container](
const auto & clusterId)->
bool{
230 const auto & [p,inserted] = mapClusters.try_emplace(clusterId, cluster_xaod_container->
size());
234 if (insertEntry(clusterId1)){
236 cluster_xaod_container->
push_back(stripCl1);
239 if (insertEntry(clusterId2)) {
241 cluster_xaod_container->
push_back(stripCl2);
247 strip_xaod_container->back()->setMeasurements( {stripCl1, stripCl2} );
252 linkAcc(*strip_xaod_container->back()) = link;
258 ATH_CHECK( strip_xaod_handle.
record( std::move(strip_xaod_container), std::move(strip_xaod_aux_container) ) );
260 return StatusCode::SUCCESS;
266 std::unordered_map<Identifier, std::size_t>& mapClusters)
const
271 if (not stripDetEleHandle.
isValid()) {
273 return StatusCode::FAILURE;
275 stripElements = stripDetEleHandle.
cptr();
281 const ::SpacePointOverlapCollection* strip_overlap_container = strip_overlap_handle.
cptr();
284 std::unique_ptr< xAOD::SpacePointContainer > strip_overlap_xaod_container = std::make_unique< xAOD::SpacePointContainer >();
285 std::unique_ptr< xAOD::SpacePointAuxContainer > strip_overlap_xaod_aux_container = std::make_unique< xAOD::SpacePointAuxContainer >();
286 strip_overlap_xaod_container->setStore( strip_overlap_xaod_aux_container.get() );
288 strip_overlap_xaod_container->reserve(strip_overlap_container->size());
289 strip_overlap_xaod_aux_container->reserve(strip_overlap_container->size());
292 static const SG::AuxElement::Accessor< ElementLink< ::SpacePointOverlapCollection > > stripSpacePointLinkAcc(
"stripOverlapSpacePointLink");
304 const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>& clusterList =
sp->clusterList();
307 if (theCluster1 ==
nullptr or
308 theCluster2 ==
nullptr) [[
unlikely]]{
312 auto clusterId1 = clusterList.first->identify();
313 auto clusterId2 = clusterList.second->identify();
317 if ( element1 ==
nullptr ) {
318 ATH_MSG_FATAL(
"Invalid strip detector element for cluster (1) identifiers " << clusterId1 );
319 return StatusCode::FAILURE;
321 if ( element2 ==
nullptr ) {
322 ATH_MSG_FATAL(
"Invalid strip detector element for cluster (2) identifiers " << clusterId2 );
323 return StatusCode::FAILURE;
326 auto insertEntry = [&mapClusters, cluster_xaod_container](
const auto & clusterId)->
bool{
327 const auto & [p,inserted] = mapClusters.try_emplace(clusterId, cluster_xaod_container->
size());
330 if (insertEntry(clusterId1)) {
332 cluster_xaod_container->
push_back(stripCl1);
335 if (insertEntry(clusterId2)) {
337 cluster_xaod_container->
push_back(stripCl2);
343 strip_overlap_xaod_container->back()->setMeasurements( {stripCl1, stripCl2} );
347 stripSpacePointLinkAcc( *strip_overlap_xaod_container->back() ) = TrkLink;
352 ATH_CHECK( strip_overlap_xaod_handle.
record( std::move(strip_overlap_xaod_container), std::move(strip_overlap_xaod_aux_container) ) );
354 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_FATAL(x,...)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
a typed memory pool that saves time spent allocation small object.
const T * back() const
Access the last element in the collection as an rvalue.
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
ElementLink implementation for ROOT usage.
Class to hold the SiDetectorElement objects to be put in the detector store.
const SiDetectorElement * getDetectorElement(const IdentifierHash &hash) const
Class to hold geometrical description of a silicon detector element.
StatusCode convertPixel(const EventContext &ctx, xAOD::PixelClusterContainer *cluster_xaod_container) const
const PixelID * m_pixelID
virtual StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< xAOD::SpacePointContainer > m_outSpacepointsPixel
SG::ReadHandleKey< ::SpacePointContainer > m_inSpacepointsPixel
virtual StatusCode initialize() override
InDetToXAODSpacePointConversion(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Property< bool > m_processStrip
SG::WriteHandleKey< xAOD::PixelClusterContainer > m_outClustersPixel
Gaudi::Property< bool > m_processPixel
SG::WriteHandleKey< xAOD::SpacePointContainer > m_outSpacepointsOverlap
StatusCode convertStrip(const EventContext &ctx, xAOD::StripClusterContainer *cluster_xaod_container, std::unordered_map< Identifier, std::size_t > &mapClusters) const
Gaudi::Property< bool > m_convertClusters
SG::ReadHandleKey< ::SpacePointContainer > m_inSpacepointsStrip
StatusCode convertStripOverlap(const EventContext &ctx, xAOD::StripClusterContainer *cluster_xaod_container, std::unordered_map< Identifier, std::size_t > &mapClusters) const
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_pixelDetEleCollKey
SG::ReadHandleKey< ::SpacePointOverlapCollection > m_inSpacepointsOverlap
SG::WriteHandleKey< xAOD::StripClusterContainer > m_outClustersStrip
SG::WriteHandleKey< xAOD::SpacePointContainer > m_outSpacepointsStrip
SG::ReadCondHandleKey< InDetDD::SiDetectorElementCollection > m_stripDetEleCollKey
A PixelSpacePoint is created from a PixelCluster.
An SCT_SpacePoint is created from two SCT_Cluster's from two different wafers.
const_pointer_type cptr()
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void setMeasurements(std::vector< const xAOD::UncalibratedMeasurement * > &&value)
Sets the index of the measurements.
@ 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
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
StatusCode convertTrkToXaodPixelSpacePoint(const InDet::PixelSpacePoint &trkSpacePoint, xAOD::SpacePoint &xaodSpacePoint)
StatusCode convertInDetToXaodCluster(const InDet::PixelCluster &indetCluster, const InDetDD::SiDetectorElement &element, xAOD::PixelCluster &xaodCluster)
StatusCode convertTrkToXaodStripSpacePoint(const InDet::SCT_SpacePoint &trkSpacePoint, xAOD::SpacePoint &xaodSpacePoint)
PixelClusterContainer_v1 PixelClusterContainer
Define the version of the pixel cluster container.
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
StripClusterContainer_v1 StripClusterContainer
Define the version of the strip cluster container.
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.