ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
Acts
ActsGeometry
src
ActsVolumeIdToDetectorElementCollectionMappingAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
#include "
ActsVolumeIdToDetectorElementCollectionMappingAlg.h
"
5
6
// ATHENA
7
#include "
AthenaKernel/IOVInfiniteRange.h
"
8
9
#include "
StoreGate/WriteCondHandle.h
"
10
11
#include "
ActsGeometry/ActsDetectorElement.h
"
12
#include "Acts/Geometry/TrackingGeometry.hpp"
13
14
namespace
ActsTrk
{
15
ActsVolumeIdToDetectorElementCollectionMappingAlg::ActsVolumeIdToDetectorElementCollectionMappingAlg
(
const
std::string& name, ISvcLocator* pSvcLocator) :
16
AthCondAlgorithm
(name, pSvcLocator) {}
17
18
ActsVolumeIdToDetectorElementCollectionMappingAlg::~ActsVolumeIdToDetectorElementCollectionMappingAlg
() =
default
;
19
20
StatusCode
ActsVolumeIdToDetectorElementCollectionMappingAlg::initialize
() {
21
ATH_CHECK
(
m_volumeIdToDetectorElementCollMapKey
.initialize());
22
ATH_CHECK
(
m_detEleCollKeys
.initialize());
23
ATH_CHECK
(
m_trackingGeometrySvc
.retrieve());
24
return
StatusCode::SUCCESS;
25
}
26
27
StatusCode
ActsVolumeIdToDetectorElementCollectionMappingAlg::execute
(
const
EventContext& ctx)
const
{
28
SG::WriteCondHandle<ActsTrk::ActsVolumeIdToDetectorElementCollectionMap>
29
volumeIdTodetectorElementCollMap{
m_volumeIdToDetectorElementCollMapKey
, ctx};
30
if
(volumeIdTodetectorElementCollMap.
isValid
()) {
31
return
StatusCode::SUCCESS;
32
}
33
34
volumeIdTodetectorElementCollMap.
addDependency
(
IOVInfiniteRange::infiniteTime
());
35
36
const
Acts::TrackingGeometry *acts_tracking_geometry=
m_trackingGeometrySvc
->trackingGeometry().get();
37
ATH_CHECK
( acts_tracking_geometry !=
nullptr
);
38
39
std::unique_ptr<ActsTrk::ActsVolumeIdToDetectorElementCollectionMap>
40
volume_id_to_detector_element_collection_map = std::make_unique<ActsTrk::ActsVolumeIdToDetectorElementCollectionMap>();
41
42
43
std::unordered_map<unsigned long long, unsigned int> detector_element_to_volume_id;
44
createDetectorElementToVolumeIdMap
(*acts_tracking_geometry,
45
detector_element_to_volume_id);
46
47
for
(
const
SG::ReadCondHandleKey<InDetDD::SiDetectorElementCollection>
&det_ele_col_key :
m_detEleCollKeys
) {
48
SG::ReadCondHandle<InDetDD::SiDetectorElementCollection>
det_ele_col(det_ele_col_key,ctx);
49
ATH_CHECK
(det_ele_col.
isValid
());
50
volumeIdTodetectorElementCollMap.
addDependency
(det_ele_col);
51
for
(
const
InDetDD::SiDetectorElement
*det_ele : *(det_ele_col.
cptr
())) {
52
unsigned
int
vol_id = detector_element_to_volume_id.at(det_ele->identify().get_compact());
53
volume_id_to_detector_element_collection_map->registerCollection(vol_id, det_ele_col.
cptr
());
54
}
55
}
56
if
(
msgLvl
(MSG::DEBUG)) {
57
unsigned
int
vol_i=0;
58
for
(
unsigned
char
col_i : volume_id_to_detector_element_collection_map->collecionMap()) {
59
if
(col_i>0) {
60
ATH_MSG_DEBUG
(
"Mapping "
<< vol_i <<
" -> "
<<
static_cast<
unsigned
int
>
(col_i)
61
<<
" : "
<<
static_cast<
const
void
*
>
(volume_id_to_detector_element_collection_map->collection(vol_i)));
62
}
63
++vol_i;
64
}
65
}
66
67
ATH_CHECK
( volumeIdTodetectorElementCollMap.
record
( std::move(volume_id_to_detector_element_collection_map) ) );
68
69
return
StatusCode::SUCCESS;
70
}
71
72
void
73
ActsVolumeIdToDetectorElementCollectionMappingAlg::createDetectorElementToVolumeIdMap
(
const
Acts::TrackingGeometry &acts_tracking_geometry,
74
std::unordered_map<
unsigned
long
long
,
75
unsigned
int
> &detector_element_to_volume_id)
76
const
77
{
78
struct
Counter {
unsigned
int
n_detector_elements{0};
79
unsigned
int
n_missing_detector_elements{0};
80
unsigned
int
n_wrong_type{0}; };
81
Counter counter {0u,0u,0u};
82
acts_tracking_geometry.visitSurfaces([&counter, &detector_element_to_volume_id](
const
Acts::Surface *surface_ptr) {
83
const
auto
* acts_detector_element =
getActsDetectorElement
(surface_ptr);
84
if
(acts_detector_element) {
85
const
auto
*trk_detector_element =
dynamic_cast<
const
Trk::TrkDetElementBase
*
>
(acts_detector_element->upstreamDetectorElement());
86
if
(trk_detector_element !=
nullptr
) {
87
detector_element_to_volume_id.insert( std::make_pair( trk_detector_element->identify().get_compact(), surface_ptr->geometryId().volume()));
88
}
else
{
89
++counter.n_wrong_type;
90
}
91
++counter.n_detector_elements;
92
}
else
{
93
++counter.n_missing_detector_elements;
94
}
95
},
true
/*sensitive surfaces*/
);
96
97
ATH_MSG_DEBUG
(
"Surfaces without associated detector elements "
<< counter.n_missing_detector_elements
98
<<
" (with "
<< counter.n_detector_elements <<
")"
);
99
if
(counter.n_detector_elements==0) {
100
ATH_MSG_ERROR
(
"No surface with associated detector element"
);
101
}
102
if
(counter.n_wrong_type>0) {
103
ATH_MSG_WARNING
(
"Surfaces associated to detector elements not of type Trk::TrkDetElementBase :"
<< counter.n_wrong_type);
104
}
105
}
106
107
}
ActsDetectorElement.h
getActsDetectorElement
const ActsDetectorElement * getActsDetectorElement(const Acts::Surface &surf)
Attempts to retrieve the ActsDetectorElement associated to the passed ActsSurface.
Definition
ActsDetectorElement.cxx:53
ActsVolumeIdToDetectorElementCollectionMappingAlg.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
IOVInfiniteRange.h
WriteCondHandle.h
ActsTrk::ActsVolumeIdToDetectorElementCollectionMappingAlg::createDetectorElementToVolumeIdMap
void createDetectorElementToVolumeIdMap(const Acts::TrackingGeometry &acts_tracking_geometry, std::unordered_map< unsigned long long, unsigned int > &detector_element_to_volume_id) const
Definition
ActsVolumeIdToDetectorElementCollectionMappingAlg.cxx:73
ActsTrk::ActsVolumeIdToDetectorElementCollectionMappingAlg::m_detEleCollKeys
SG::ReadCondHandleKeyArray< InDetDD::SiDetectorElementCollection > m_detEleCollKeys
Definition
ActsVolumeIdToDetectorElementCollectionMappingAlg.h:33
ActsTrk::ActsVolumeIdToDetectorElementCollectionMappingAlg::execute
StatusCode execute(const EventContext &ctx) const override
Definition
ActsVolumeIdToDetectorElementCollectionMappingAlg.cxx:27
ActsTrk::ActsVolumeIdToDetectorElementCollectionMappingAlg::m_trackingGeometrySvc
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
Definition
ActsVolumeIdToDetectorElementCollectionMappingAlg.h:30
ActsTrk::ActsVolumeIdToDetectorElementCollectionMappingAlg::~ActsVolumeIdToDetectorElementCollectionMappingAlg
virtual ~ActsVolumeIdToDetectorElementCollectionMappingAlg()
ActsTrk::ActsVolumeIdToDetectorElementCollectionMappingAlg::ActsVolumeIdToDetectorElementCollectionMappingAlg
ActsVolumeIdToDetectorElementCollectionMappingAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
ActsVolumeIdToDetectorElementCollectionMappingAlg.cxx:15
ActsTrk::ActsVolumeIdToDetectorElementCollectionMappingAlg::initialize
StatusCode initialize() override
Definition
ActsVolumeIdToDetectorElementCollectionMappingAlg.cxx:20
ActsTrk::ActsVolumeIdToDetectorElementCollectionMappingAlg::m_volumeIdToDetectorElementCollMapKey
SG::WriteCondHandleKey< ActsTrk::ActsVolumeIdToDetectorElementCollectionMap > m_volumeIdToDetectorElementCollMapKey
Definition
ActsVolumeIdToDetectorElementCollectionMappingAlg.h:36
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
AthCondAlgorithm
Base class for conditions algorithms.
Definition
AthCondAlgorithm.h:22
IOVInfiniteRange::infiniteTime
static EventIDRange infiniteTime()
Produces an EventIDRange that is inifinite in Time and invalid in RunLumi.
Definition
IOVInfiniteRange.h:47
InDetDD::SiDetectorElement
Class to hold geometrical description of a silicon detector element.
Definition
SiDetectorElement.h:109
SG::ReadCondHandleKey
Definition
ReadCondHandleKey.h:21
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition
ReadCondHandle.h:67
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition
WriteCondHandle.h:279
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
SG::WriteCondHandle::isValid
bool isValid() const
Definition
WriteCondHandle.h:252
Trk::TrkDetElementBase
This is the base class for all tracking detector elements with read-out relevant information.
Definition
TrkDetElementBase.h:52
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition
MdtCalibInput.h:31
Generated on
for ATLAS Offline Software by
1.17.0