ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
Acts
ActsConfig
python
ActsCollectionsConfig.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3
from
AthenaConfiguration.ComponentAccumulator
import
ComponentAccumulator
4
from
AthenaConfiguration.ComponentFactory
import
CompFactory
5
6
class
TrackBackends
:
7
# Allowed types
8
types = (
'xAOD::TrackSummaryContainer'
,
9
'xAOD::TrackStateContainer'
,
10
'xAOD::TrackParametersContainer'
,
11
'xAOD::TrackJacobianContainer'
,
12
'xAOD::TrackMeasurementContainer'
,
13
'xAOD::TrackSurfaceContainer'
)
14
# Allowed post-fixes
15
postFixes = (
'TrackSummary'
,
16
'TrackStates'
,
17
'TrackParameters'
,
18
'TrackJacobians'
,
19
'TrackMeasurements'
,
20
'TrackStateSurfaces'
,
21
'TrackSurfaces'
)
22
23
def
__init__
(self) -> None:
24
self.
collections
= dict()
25
for
el
in
TrackBackends.postFixes:
26
self.
collections
[el] =
None
27
28
def
__str__
(self) -> str:
29
message =
"[ "
30
for
el
in
TrackBackends.postFixes:
31
message += f
"{el}={self.collections[el]} "
32
message +=
"]"
33
return
message
34
35
@staticmethod
36
def
extractPrefix
(*, collection: str) -> str:
37
assert
isinstance(collection, str)
38
for
el
in
TrackBackends.postFixes:
39
if
collection.endswith(el):
40
return
collection.replace(el,
""
)
41
# If not in allowed post fixes we raise Exception
42
raise
Exception(f
"Collection {collection} is a NOT KNOWN ACTS track backend, prefix could not be deduced"
)
43
44
def
isValid
(self) -> bool:
45
for
(key, value)
in
self.
collections
.items():
46
if
value
is
None
:
47
return
False
48
return
True
49
50
def
addCollection
(self,
51
*,
52
collection: str) ->
None
:
53
assert
isinstance(collection, str)
54
for
el
in
TrackBackends.postFixes:
55
if
collection.endswith(el):
56
if
self.
collections
[el]
is
not
None
:
57
raise
Exception(f
"Trying to add collection '{collection}', but this backend is already recorded"
)
58
self.
collections
[el] = collection
59
return
60
# If not in allowed post fixes we raise Exception
61
raise
Exception(f
"Collection {collection} is a NOT KNOWN ACTS track backend"
)
62
63
def
ActsTrackReaderAlgCfg
(flags,
64
prefix: str) -> ComponentAccumulator:
65
assert
isinstance(prefix, str)
66
"""
67
Setup algorithm that reads xAOD track backends and produced TrackContainer
68
name - the collections prefix, for consistency it also is the prefix of the output container name
69
"""
70
acc = ComponentAccumulator()
71
from
ActsConfig.ActsGeometryConfig
import
ActsTrackingGeometrySvcCfg
72
acc.merge(ActsTrackingGeometrySvcCfg(flags))
73
from
ActsAlignmentAlgs.AlignmentAlgsConfig
import
ActsGeometryContextAlgCfg
74
acc.merge(ActsGeometryContextAlgCfg(flags))
75
from
MagFieldServices.MagFieldServicesConfig
import
AtlasFieldCacheCondAlgCfg
76
acc.merge(AtlasFieldCacheCondAlgCfg(flags))
77
acc.addEventAlgo(CompFactory.ActsTrk.TrackContainerReader(f
"{prefix}TrackContainerReaderAlg"
,
78
TrackContainer=prefix+
"Tracks"
))
79
return
acc
80
81
def
ActsPoolReadCfg
(flags) -> ComponentAccumulator:
82
acc = ComponentAccumulator()
83
84
# Reader for InDet objects (i.e. xAOD SpacePoints and Measurements)
85
from
InDetConfig.InDetPoolReadConfig
import
InDetPoolReadCfg
86
acc.merge(InDetPoolReadCfg(flags))
87
88
StoredTracks = dict()
89
typedCollections = flags.Input.TypedCollections
90
91
for
typedCollection
in
typedCollections:
92
[colType, colName] = typedCollection.split(
'#'
)
93
94
# Track Backend Collections
95
if
colType
in
TrackBackends.types:
96
prefix = TrackBackends.extractPrefix(collection=colName)
97
StoredTracks[prefix] = StoredTracks.get(prefix,
TrackBackends
())
98
StoredTracks[prefix].addCollection(collection=colName)
99
continue
100
101
for
(key, backends)
in
StoredTracks.items():
102
if
not
backends.isValid():
103
raise
Exception(f
'Track backends with prefix {key} are not consistent. Be sure all the backends have been properly persistified in the file: {backends}'
)
104
105
acc.merge(
ActsTrackReaderAlgCfg
(flags, key))
106
107
return
acc
108
109
if
__name__ ==
"__main__"
:
110
# test reading
111
from
AthenaConfiguration.AllConfigFlags
import
initConfigFlags
112
from
AthenaPoolCnvSvc.PoolReadConfig
import
PoolReadCfg
113
flags = initConfigFlags()
114
flags.fillFromArgs()
115
flags.lock()
116
117
from
AthenaConfiguration.MainServicesConfig
import
MainServicesCfg
118
cfg = MainServicesCfg(flags)
119
cfg.merge(PoolReadCfg(flags))
120
cfg.merge(
ActsPoolReadCfg
(flags))
121
122
status = cfg.run()
123
if
status.isFailure():
124
import
sys
125
sys.exit(
"Execution failed"
)
isValid
bool isValid() const
Test to see if the link can be dereferenced.
ActsCollectionsConfig.TrackBackends
Definition
ActsCollectionsConfig.py:6
ActsCollectionsConfig.TrackBackends.collections
collections
Definition
ActsCollectionsConfig.py:24
ActsCollectionsConfig.TrackBackends.extractPrefix
str extractPrefix(*, str collection)
Definition
ActsCollectionsConfig.py:36
ActsCollectionsConfig.TrackBackends.__str__
str __str__(self)
Definition
ActsCollectionsConfig.py:28
ActsCollectionsConfig.TrackBackends.addCollection
None addCollection(self, *, str collection)
Definition
ActsCollectionsConfig.py:52
ActsCollectionsConfig.TrackBackends.__init__
None __init__(self)
Definition
ActsCollectionsConfig.py:23
ActsCollectionsConfig.ActsTrackReaderAlgCfg
ComponentAccumulator ActsTrackReaderAlgCfg(flags, str prefix)
Definition
ActsCollectionsConfig.py:64
ActsCollectionsConfig.ActsPoolReadCfg
ComponentAccumulator ActsPoolReadCfg(flags)
Definition
ActsCollectionsConfig.py:81
Generated on
for ATLAS Offline Software by
1.17.0