ATLAS Offline Software
Loading...
Searching...
No Matches
ActsMaterialConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3def MaterialTrackRecorderCfg(configFlags, name="ActsTrk::UserActionSvc.MaterialTrackRecorderTool", **kwargs):
4 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 acc = ComponentAccumulator()
7 acc.setPrivateTools(CompFactory.ActsTrk.MaterialTrackRecorderTool(name, **kwargs))
8 return acc
9
10
11def MaterialTrackRecorderUserActionSvcCfg(configFlags, name="ActsTrk::MaterialTrackRecorderUserActionSvc", **kwargs):
12 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
13 from AthenaConfiguration.ComponentFactory import CompFactory
14
15 acc = ComponentAccumulator()
16
17 #Setting up the CA for the MaterialStepRecorder
18 actionAcc = ComponentAccumulator()
19 actions = []
20 actions += [actionAcc.popToolsAndMerge(MaterialTrackRecorderCfg(configFlags))]
21 actionAcc.setPrivateTools(actions)
22 MaterialTrackRecorderAction = acc.popToolsAndMerge(actionAcc)
23
24 #Retrieving the default action list
25 from G4AtlasServices.G4AtlasUserActionConfig import getDefaultActions
26 defaultActions = acc.popToolsAndMerge(getDefaultActions(configFlags))
27
28 #Adding material recorder action to defaults
29 actionList = (defaultActions + MaterialTrackRecorderAction)
30
31 kwargs.setdefault("UserActionTools",actionList)
32 acc.addService(CompFactory.G4UA.UserActionSvc(name,**kwargs), primary = True)
33
34 return acc
35
36def MaterialTrackWriterCfg(configFlags,
37 name="MaterialTrackWriter",
38 FileName="material-tracks.root",
39 OutStream="ACTSMATERIALWRITER",
40 **kwargs) :
41 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
42 from AthenaConfiguration.ComponentFactory import CompFactory
43 acc = ComponentAccumulator()
44 kwargs.setdefault("OutStream", OutStream)
45 kwargs.setdefault("useTrackingGeometry", True)
46
47 from MuonConfig.MuonConfigUtils import setupHistSvcCfg
48 acc.merge(setupHistSvcCfg(configFlags, outFile = FileName, outStream=kwargs["OutStream"]))
49
50 acc.addEventAlgo(CompFactory.ActsTrk.MaterialTrackWriter(name, **kwargs), primary = True)
51
52 return acc
53
54def MaterialTrackReaderCfg(configFlags, name="MaterialTrackReader", **kwargs) :
55 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
56 from AthenaConfiguration.ComponentFactory import CompFactory
57 acc = ComponentAccumulator()
58
59 acc.addEventAlgo(CompFactory.ActsTrk.MaterialTrackReader(name, **kwargs), primary = True)
60
61 return acc
62
63def RootMaterialWriterToolCfg(configFlags, name="RootMaterialWriterTool", **kwargs):
64 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
65 from AthenaConfiguration.ComponentFactory import CompFactory
66 acc = ComponentAccumulator()
67 acc.setPrivateTools(CompFactory.ActsTrk.RootMaterialWriterTool(name, **kwargs))
68 return acc
69
70def JsonMaterialWriterToolCfg(configFlags, name="JsonMaterialWriterTool", **kwargs):
71 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
72 from AthenaConfiguration.ComponentFactory import CompFactory
73 acc = ComponentAccumulator()
74 acc.setPrivateTools(CompFactory.ActsTrk.JsonMaterialWriterTool(name, **kwargs))
75 return acc
76
77def MaterialDumperToolCfg(configFlags, name="MaterialDumperTool", **kwargs):
78 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
79 from AthenaConfiguration.ComponentFactory import CompFactory
80 acc = ComponentAccumulator()
81 acc.setPrivateTools(CompFactory.ActsTrk.MaterialDumperTool(name, **kwargs))
82 return acc
83
84def MaterialMappingCfg(configFlags,
85 name="MaterialMapping",
86 StoreTracks=False,
87 StoreSurfInfo=False,
88 WriteJsonMaterialMap=True,
89 WriteRootMaterialMap=False,
90 OutputMappedMaterialTracks="OuputMappedMaterialTracks",
91 OutputUnmappedMaterialTracks="OutputUnmappedMaterialTracks",
92 **kwargs) :
93
94 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
95 from AthenaConfiguration.ComponentFactory import CompFactory
96 acc = ComponentAccumulator()
97
98 # Need geometry
99 from ActsConfig.ActsGeometryConfig import ActsTrackingGeometrySvcCfg
100 acc.merge( ActsTrackingGeometrySvcCfg(configFlags))
101 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
102 acc.merge(AtlasFieldCacheCondAlgCfg(configFlags))
103 from ActsAlignmentAlgs.AlignmentAlgsConfig import ActsGeometryContextAlgCfg
104 acc.merge(ActsGeometryContextAlgCfg(configFlags))
105
106 mapwriters = []
107 if WriteRootMaterialMap:
108 mapwriters += [acc.popToolsAndMerge(RootMaterialWriterToolCfg(configFlags))]
109 if WriteJsonMaterialMap:
110 mapwriters += [acc.popToolsAndMerge(JsonMaterialWriterToolCfg(configFlags))]
111 # The mapped maps are dumped by the material dumper, which owns the writers
112 kwargs.setdefault("MaterialDumper", acc.popToolsAndMerge(MaterialDumperToolCfg(configFlags, MaterialMapWriters=mapwriters)))
113
114 kwargs.setdefault("MappedMaterialTrackCollectionKey", OutputMappedMaterialTracks)
115 kwargs.setdefault("UnmappedMaterialTrackCollectionKey", OutputUnmappedMaterialTracks)
116
117 acc.addEventAlgo(CompFactory.ActsTrk.MaterialMapping(name, **kwargs), primary = True)
118
119 if StoreTracks:
120 from ActsConfig.ActsMaterialConfig import MaterialTrackWriterCfg
121 acc.merge(MaterialTrackWriterCfg(configFlags,
122 name="MappedMaterialTrackWriter",
123 FileName="material-tracks-mapped.root",
124 OutStream="ACTSMAPPEDMATERIALWRITER",
125 StoreSurface=StoreSurfInfo,
126 MaterialTrackCollectionKey=OutputMappedMaterialTracks))
127 acc.merge(MaterialTrackWriterCfg(configFlags,
128 name="UnmappedMaterialTrackWriter",
129 FileName="material-tracks-unmapped.root",
130 OutStream="ACTSUNMAPPEDMATERIALWRITER",
131 StoreSurface=StoreSurfInfo,
132 MaterialTrackCollectionKey=OutputUnmappedMaterialTracks))
133
134 return acc
135
136
137def MaterialJsonDumpCfg(configFlags,
138 name="MaterialJsonDump",
139 FileName="material-maps",
140 **kwargs) :
141 """Dump the material assigned to the tracking geometry (e.g. loaded from a
142 Root material map by the ITkMaterialDecoratorTool) with the Json material
143 writer. FileName is the output base name, without extension."""
144 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
145 from AthenaConfiguration.ComponentFactory import CompFactory
146 acc = ComponentAccumulator()
147
148 # Need geometry
149 from ActsConfig.ActsGeometryConfig import ActsTrackingGeometrySvcCfg
150 acc.merge( ActsTrackingGeometrySvcCfg(configFlags))
151 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
152 acc.merge(AtlasFieldCacheCondAlgCfg(configFlags))
153 from ActsAlignmentAlgs.AlignmentAlgsConfig import ActsGeometryContextAlgCfg
154 acc.merge(ActsGeometryContextAlgCfg(configFlags))
155
156 # Same dumper as the material mapping, here with only the Json writer
157 mapwriters = [acc.popToolsAndMerge(JsonMaterialWriterToolCfg(configFlags, FileName=FileName))]
158 kwargs.setdefault("MaterialDumper", acc.popToolsAndMerge(MaterialDumperToolCfg(configFlags, MaterialMapWriters=mapwriters)))
159
160 acc.addEventAlgo(CompFactory.ActsTrk.MaterialJsonDumpAlg(name, **kwargs), primary = True)
161
162 return acc
163
164
165def MaterialValidationCfg(configFlags,
166 StoreTracks=True,
167 OutputMaterialTracks="OutputMaterialTracks",
168 name="MaterialValidation", **kwargs) :
169 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
170 from AthenaConfiguration.ComponentFactory import CompFactory
171 acc = ComponentAccumulator()
172
173 # Need geometry
174 from ActsConfig.ActsGeometryConfig import ActsTrackingGeometrySvcCfg
175 acc.merge( ActsTrackingGeometrySvcCfg(configFlags))
176 from MagFieldServices.MagFieldServicesConfig import AtlasFieldCacheCondAlgCfg
177 acc.merge(AtlasFieldCacheCondAlgCfg(configFlags))
178 from ActsAlignmentAlgs.AlignmentAlgsConfig import ActsGeometryContextAlgCfg
179 acc.merge(ActsGeometryContextAlgCfg(configFlags))
180
181 kwargs.setdefault("MaterialTrackCollectionKey", OutputMaterialTracks)
182
183 acc.addEventAlgo(CompFactory.ActsTrk.MaterialValidation(name, **kwargs), primary = True)
184 if StoreTracks:
185 from ActsConfig.ActsMaterialConfig import MaterialTrackWriterCfg
186 acc.merge(MaterialTrackWriterCfg(configFlags,
187 FileName="material-tracks-validation.root",
188 MaterialTrackCollectionKey=OutputMaterialTracks))
189
190
191 return acc
192
MaterialTrackRecorderUserActionSvcCfg(configFlags, name="ActsTrk::MaterialTrackRecorderUserActionSvc", **kwargs)
MaterialTrackWriterCfg(configFlags, name="MaterialTrackWriter", FileName="material-tracks.root", OutStream="ACTSMATERIALWRITER", **kwargs)
JsonMaterialWriterToolCfg(configFlags, name="JsonMaterialWriterTool", **kwargs)
MaterialTrackReaderCfg(configFlags, name="MaterialTrackReader", **kwargs)
MaterialDumperToolCfg(configFlags, name="MaterialDumperTool", **kwargs)
RootMaterialWriterToolCfg(configFlags, name="RootMaterialWriterTool", **kwargs)
MaterialValidationCfg(configFlags, StoreTracks=True, OutputMaterialTracks="OutputMaterialTracks", name="MaterialValidation", **kwargs)
MaterialMappingCfg(configFlags, name="MaterialMapping", StoreTracks=False, StoreSurfInfo=False, WriteJsonMaterialMap=True, WriteRootMaterialMap=False, OutputMappedMaterialTracks="OuputMappedMaterialTracks", OutputUnmappedMaterialTracks="OutputUnmappedMaterialTracks", **kwargs)
MaterialJsonDumpCfg(configFlags, name="MaterialJsonDump", FileName="material-maps", **kwargs)
MaterialTrackRecorderCfg(configFlags, name="ActsTrk::UserActionSvc.MaterialTrackRecorderTool", **kwargs)