ATLAS Offline Software
Loading...
Searching...
No Matches
MuonSegmentFindingConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3# This file configures the Muon segment finding. It is based on a few files in the old configuration system:
4# Tools, which are configured here:
5
6
7# Core
8from AthenaConfiguration.ComponentFactory import CompFactory
9from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
10from AthenaConfiguration.Enums import BeamType, Format
11
12#Local
13from TrkConfig.TrkGlobalChi2FitterConfig import MCTBFitterCfg, MCTBSLFitterCfg, MCTBSLFitterMaterialFromTrackCfg
14from MuonConfig.MuonRecToolsConfig import MuonAmbiProcessorCfg, MuonTrackCleanerCfg, MuonEDMPrinterToolCfg
15from MuonConfig.MuonCondAlgConfig import MuonStationIntersectCondAlgCfg
16from TrkConfig.AtlasExtrapolatorConfig import MuonStraightLineExtrapolatorCfg
17from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MdtCalibWindowNumber
18
19
20def MuonCombinePatternToolCfg(flags, name="MuonCombinePatternTool",**kwargs):
21 result = ComponentAccumulator()
22 kwargs.setdefault("UseTightAssociation",flags.Beam.Type is BeamType.Collisions)
23 kwargs.setdefault("UseCosmics", flags.Beam.Type is not BeamType.Collisions )
24 the_tool = CompFactory.MuonCombinePatternTool(name,**kwargs)
25 result.setPrivateTools(the_tool)
26 return result
27
28def MuonHoughPatternToolCfg(flags, name = "MuonHoughPatternTool",**kwargs):
29 result = ComponentAccumulator()
30 if flags.Beam.Type is not BeamType.Collisions:
31 kwargs.setdefault("UseCosmics", True)
32 kwargs.setdefault("NumberOfMaximaPerIterations", 1)
33 the_tool = CompFactory.MuonHoughPatternTool(name,**kwargs)
34 result.setPrivateTools(the_tool)
35 return result
36def MuonHoughPatternFinderToolCfg(flags, name = "MuonHoughPatternFinderTool", **kwargs):
37 result = ComponentAccumulator()
38 if flags.Beam.Type is BeamType.Collisions:
39 kwargs.setdefault("MDT_TDC_cut", False)
40 kwargs.setdefault("RecordAll",False)
41 kwargs.setdefault("muonHoughPatternTool", result.popToolsAndMerge(MuonHoughPatternToolCfg(flags)) )
42 kwargs.setdefault("muonCombinePatternTool", result.popToolsAndMerge(MuonCombinePatternToolCfg(flags)) )
43 kwargs.setdefault("DoSummary", flags.Muon.printSummary)
44 the_tool = CompFactory.Muon.MuonHoughPatternFinderTool(name,**kwargs)
45 result.setPrivateTools(the_tool)
46 return result
47
48def MdtMathSegmentFinderCfg(flags,name="MdtMathSegmentFinder", **kwargs):
49 # beamType = getattr(extraFlags,"beamType", beamFlags.beamType())
50 # enableCurvedSegmentFinding = getattr(extraFlags,"enableCurvedSegmentFinding", muonStandaloneFlags.enableCurvedSegmentFinding())
51 result = ComponentAccumulator()
52
53 doSegmentT0Fit = kwargs.pop('doSegmentT0Fit', flags.Muon.doSegmentT0Fit)
54
55 kwargs.setdefault("FinderDebugLevel", 0) # This is just to avoid that the tool seems unconfigured. Real fix is to use default name.
56
57 if doSegmentT0Fit and not (flags.Muon.MuonTrigger and flags.Beam.Type in [BeamType.SingleBeam, BeamType.Cosmics]):
58 kwargs.setdefault("AssociationRoadWidth", 3.)
59 kwargs.setdefault("MDTAssocationPullcut", 3.)
60 kwargs.setdefault("RecoverMdtOutliers", False)
61 kwargs.setdefault("DCFitProvider", result.popToolsAndMerge(MdtSegmentT0FitterCfg(flags) ) )
62
63 if flags.Beam.Type in [BeamType.SingleBeam, BeamType.Cosmics] or flags.Input.isMC is False:
64 kwargs.setdefault("AssociationRoadWidth", 2.)
65 kwargs.setdefault("MDTAssocationPullcut", 4.)
66 kwargs.setdefault("RecoverMdtOutliers", True )
67
68
69 if flags.Muon.enableCurvedSegmentFinding:
70 kwargs.setdefault("DoCurvedSegmentFinder",True)
71 result.setPrivateTools(CompFactory.Muon.MdtMathSegmentFinder(name=name,**kwargs))
72 return result
73
74def MuonSegmentFittingToolCfg(flags, name = "MuonSegmentFittingTool", **kwargs):
75 from TrkConfig.TrkExRungeKuttaPropagatorConfig import RungeKuttaPropagatorCfg
76 result = RungeKuttaPropagatorCfg(flags, name='AtlasRungeKuttaPropagator')
77 kwargs.setdefault("SLPropagator",
78 result.popPrivateTools())
79 kwargs.setdefault("SLFitter",
80 result.popToolsAndMerge(MCTBSLFitterCfg(flags)))
81 kwargs.setdefault("CurvedFitter",
82 result.popToolsAndMerge(MCTBFitterCfg(flags)))
83 kwargs.setdefault("TrackCleaner", result.popToolsAndMerge(MuonTrackCleanerCfg(flags)))
84
85 result.setPrivateTools(CompFactory.Muon.MuonSegmentFittingTool(name,**kwargs))
86 return result
87
88def MdtSegmentT0FitterCfg(flags, name="MdtSegmentT0Fitter", **kwargs):
89 result = ComponentAccumulator()
90 kwargs.setdefault("FloatSegDirection", flags.Beam.Type is BeamType.Cosmics)
91 result.setPrivateTools(CompFactory.TrkDriftCircleMath.MdtSegmentT0Fitter(name, **kwargs))
92 return result
93
95 name='DCMathSegmentMaker',
96 doSegmentT0Fit=False,
97 **kwargs):
98
99 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MdtDriftCircleOnTrackCreatorCfg, TriggerChamberClusterOnTrackCreatorCfg, MdtCalibToolForRotsCfg
100 from MuonCombinedConfig.MuonCombinedRecToolsConfig import MuonSegmentSelectionToolCfg
101
102 # This in general is a pretty problematic piece of code. It seems to have a lot of potential issues, because it has loads of mutables / subtools etc
103 # https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonSegmentMakers/MuonSegmentMakerTools/DCMathSegmentMaker/src/DCMathSegmentMaker.h
104 # ToolHandle<IMdtDriftCircleOnTrackCreator> m_mdtCreator; //<! mdt rio ontrack creator
105 # ToolHandle<IMdtDriftCircleOnTrackCreator> m_mdtCreatorT0; //<! mdt rio ontrack creator
106 # ToolHandle<IMuonClusterOnTrackCreator> m_clusterCreator; //<! cluster rio ontrack creator
107 # ToolHandle<IMuonCompetingClustersOnTrackCreator> m_compClusterCreator; //<! competing clusters rio ontrack creator
108 # ToolHandle<MuonEDMPrinterTool> m_printer; //<! printer helper tool
109 # ServiceHandle<IMuonEDMHelperSvc> m_edmHelperSvc; //<! printer helper tool
110 # ToolHandle<IMdtSegmentFinder> m_segmentFinder; //<! segment finder tool MdtSegmentFinder
111 # ToolHandle<IMuonSegmentFittingTool> m_segmentFitter; //<! segment fitting tool
112 # ToolHandle<IMuonSegmentSelectionTool> m_segmentSelectionTool; //<! segment selection tool
113 # ToolHandle<IDCSLFitProvider> m_dcslFitProvider;
114
115 result=ComponentAccumulator()
116 # Won't explicitly configure MuonIdHelperSvc
117 from MuonConfig.MuonRecToolsConfig import MuonEDMHelperSvcCfg
118 kwargs.setdefault("edmHelper", result.getPrimaryAndMerge(MuonEDMHelperSvcCfg(flags)))
119 kwargs.setdefault("RefitSegment", True)
120 kwargs.setdefault("AssumePointingPhi", flags.Beam.Type is not BeamType.Cosmics)
121 kwargs.setdefault("OutputFittedT0", True)
122
123 kwargs.setdefault("DCFitProvider", result.popToolsAndMerge(MdtSegmentT0FitterCfg(flags)))
124 #kwargs.setdefault("CurvedErrorScaling", False)
125 kwargs.setdefault("UsePreciseError", True)
126 kwargs.setdefault("SinAngleCut", 0.4)
127
128 doSegmentT0Fit = doSegmentT0Fit or flags.Beam.Type in [BeamType.SingleBeam, BeamType.Cosmics]
129 if flags.Beam.Type in [BeamType.SingleBeam, BeamType.Cosmics]:
130 kwargs.setdefault("SinAngleCut", 0.9)
131 kwargs.setdefault("AddUnassociatedPhiHits", True)
132 kwargs.setdefault("RecoverBadRpcCabling", True)
133 kwargs.setdefault("CurvedErrorScaling", False)
134 elif not flags.Input.isMC: # collisions real data
135 kwargs.setdefault("AddUnassociatedPhiHits", True)
136 kwargs.setdefault("RecoverBadRpcCabling", True)
137
138 if flags.Muon.updateSegmentSecondCoordinate:
139 kwargs.setdefault("UpdatePhiUsingPhiHits",True)
140
141 if flags.Muon.enableCurvedSegmentFinding:
142 kwargs.setdefault("CurvedErrorScaling", False)
143 kwargs.setdefault("PreciseErrorScale", 1)
144 kwargs.setdefault("UsePreciseError", True)
145
146 # Now stuff that wasn't explicitly configured before.
147
148 result.merge(MuonStationIntersectCondAlgCfg(flags))
149
150 kwargs.setdefault("MdtCreator", result.getPrimaryAndMerge(MdtDriftCircleOnTrackCreatorCfg(flags)))
151 # Set MdtCreatorT0 below
152 kwargs.setdefault("MuonCompetingClustersCreator", result.getPrimaryAndMerge(TriggerChamberClusterOnTrackCreatorCfg(flags)))
153 edm_printer = result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags) ) # Needed again below
154 kwargs.setdefault("EDMPrinter", edm_printer )
155 if doSegmentT0Fit:
156 mdt_dcot_CA = MdtDriftCircleOnTrackCreatorCfg(flags,
157 name="MdtDriftCircleOnTrackCreatorAdjustableT0",
158 TimingMode=3,
159 CalibrationTool = result.popToolsAndMerge(MdtCalibToolForRotsCfg(flags,
160 DoTofCorrection=True,
161 TimeWindowSetting=MdtCalibWindowNumber('Collision_data'))))
162 kwargs.setdefault("MdtCreatorT0", result.getPrimaryAndMerge(mdt_dcot_CA))
163 kwargs.setdefault("MdtSegmentFinder", result.getPrimaryAndMerge(MdtMathSegmentFinderCfg(flags, name='MdtMathT0FitSegmentFinder', doSegmentT0Fit=True)))
164 else:
165 kwargs.setdefault("MdtCreatorT0", "")
166 kwargs.setdefault("MdtSegmentFinder", result.getPrimaryAndMerge(MdtMathSegmentFinderCfg(flags)) )
167
168 kwargs.setdefault("SegmentFitter", result.getPrimaryAndMerge(MuonSegmentFittingToolCfg(flags, name="MuonSegmentFittingTool")))
169
170 kwargs.setdefault("SegmentSelector", result.popToolsAndMerge(MuonSegmentSelectionToolCfg(flags)))
171
172 dc_segment_maker = CompFactory.Muon.DCMathSegmentMaker(name=name, **kwargs)
173 result.setPrivateTools(dc_segment_maker)
174 return result
175
176
177def CscAlignmentTool(flags, **kwargs):
178
179 CscAlignmentTool=CompFactory.CscAlignmentTool
180 etaposAlignConsts = [ # 1st, 2nd, 3rd, 4th layer
181 0.0, -0.0902347, -0.0984321, -0.141175, #sector -16
182 0.0, -0.166412, -0.150399, -0.18592, #sector -15
183 0.0, -0.0544449, 0.101448, -0.0433321, #sector -14
184 0.0, -0.047769, -0.156247, -0.0854826, #sector -13
185 0.0, -0.0970101, -0.227578, -0.301079, #sector -12
186 0.0, -0.152912, -0.365218, -0.314042, #sector -11
187 0.0, 0.0338696, -0.264766, -0.224567, #sector -10
188 0.0, -0.107372, -0.16099, -0.13508, #sector -9
189 0.0, -0.0663979, -0.0312645, -0.130711, #sector -8
190 0.0, -0.249974, -0.269372, -0.353648, #sector -7
191 0.0, -0.194175, 0.0238348, -0.188433, #sector -6
192 0.0, 0.0977346, 0.0492461, 0.150434, #sector -5
193 0.0, 0.0444637, -0.0871214, -0.0627541, #sector -4
194 0.0, 0.0347245, -0.0226186, -0.0826478, #sector -3
195 0.0, -0.00408879, -0.0638005, -0.206868, #sector -2
196 0.0, 0.0331328, 0.0402103, 0.118611, #sector -1
197 0.0, -0.0634537, -0.0516743, 0.0045364, #sector 1
198 0.0, -0.0957718, -0.235246, -0.439811, #sector 2
199 0.0, -0.163504, -0.0129115, 0.00140143, #sector 3
200 0.0, -0.182903, -0.0503858, -0.207799, #sector 4
201 0.0, -0.0970927, 0, 0.124744, #sector 5
202 0.0, -0.0169602, -0.0527447, 0.0319154, #sector 6
203 0.0, -0.176499, -0.196542, -0.0846979, #sector 7
204 0.0, 0.0589994, 0.0131431, 0.0461769, #sector 8
205 0.0, -0.0237507, -0.0307316, 0.144429, #sector 9
206 0.0, -0.0144483, -0.0328234, -0.00553684, #sector 10
207 0.0, 0.113188, -0.176182, 0.0635706, #sector 11
208 0.0, -0.109776, -0.727705, -0.756824, #sector 12
209 0.0, -0.0553061, -0.056162, -0.0336955, #sector 13
210 0.0, -0.070077, -0.127203, -0.140082, #sector 14
211 0.0, -0.0844368, -0.0735331, -0.016667, #sector 15
212 0.0, 0.0426443, -0.153659, -0.129711, #sector 16
213 ]
214
215 phiposAlignConsts = [ # 1st, 2nd, 3rd, 4th layer
216 0.0, 0.0, 0.0, 0.0, #-16
217 0.0, 0.0, 0.0, 0.0,
218 0.0, 0.0, 0.0, 0.0, #-14
219 0.0, 0.0, 0.0, 0.0,
220 0.0, 0.0, 0.0, 0.0, #-12
221 0.0, 0.0, 0.0, 0.0,
222 0.0, 0.0, 0.0, 0.0, #-10
223 0.0, 0.0, 0.0, 0.0,
224 0.0, 0.0, 0.0, 0.0, #-8
225 0.0, 0.0, 0.0, 0.0,
226 0.0, 0.0, 0.0, 0.0, #-6
227 0.0, 0.0, 0.0, 0.0,
228 0.0, 0.0, 0.0, 0.0, #-4
229 0.0, 0.0, 0.0, 0.0,
230 0.0, 0.0, 0.0, 0.0, #-2
231 0.0, 0.0, 0.0, 0.0, #-1
232 0.0, 0.0, 0.0, 0.0, # sector =1 and above...
233 0.0, 0.0, 0.0, 0.0, #2
234 0.0, 0.0, 0.0, 0.0, #3
235 0.0, 0.0, 0.0, 0.0, #4
236 0.0, 0.0, 0.0, 0.0,
237 0.0, 0.0, 0.0, 0.0, #6
238 0.0, 0.0, 0.0, 0.0,
239 0.0, 0.0, 0.0, 0.0, #8
240 0.0, 0.0, 0.0, 0.0,
241 0.0, 0.0, 0.0, 0.0, #10
242 0.0, 0.0, 0.0, 0.0,
243 0.0, 0.0, 0.0, 0.0, #12
244 0.0, 0.0, 0.0, 0.0,
245 0.0, 0.0, 0.0, 0.0, #14
246 0.0, 0.0, 0.0, 0.0,
247 0.0, 0.0, 0.0, 0.0 #16
248 ]
249 kwargs.setdefault("phiposAlignConsts", phiposAlignConsts)
250 kwargs.setdefault("etaposAlignConsts", etaposAlignConsts)
251 kwargs.setdefault("useAlignment", flags.Input.isMC is False and flags.Muon.Align.UseILines is False )
252
253 return CscAlignmentTool(**kwargs)
254
255
256def QratCscClusterFitterCfg(flags, **kwargs):
257 # This is based on https://gitlab.cern.ch/atlas/athena/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecExample/python/CscTools.py#L151
258 QratCscClusterFitter=CompFactory.QratCscClusterFitter
259 result=ComponentAccumulator()
260 qratcor_css_eta = [
261 0.000000, 0.000000, 0.000000, 0.000000, 0.0699381, 0.178291, 0.271303, 0.345611,
262 0.400738, 0.452451, 0.493772, 0.526792, 0.553845, 0.580111, 0.603337, 0.624749,
263 0.646065, 0.663924, 0.681897, 0.701345, 0.716067, 0.730324, 0.743168, 0.760598,
264 0.773341, 0.786406, 0.798358, 0.811339, 0.820949, 0.832676, 0.843917, 0.85412,
265 0.863914, 0.873229, 0.88251, 0.892856, 0.903296, 0.910067, 0.917892, 0.928028,
266 0.93461, 0.943679, 0.951617, 0.958326, 0.964428, 0.97341, 0.978204, 0.987075,
267 0.994789, 1.000000
268 ]
269 qratcor_csl_eta = [
270 0.000000, 0.000000, 0.000000, 0.000000, 0.0290177, 0.0834867, 0.188683, 0.269967,
271 0.334887, 0.393036, 0.440317, 0.481884, 0.51725, 0.545107, 0.56959, 0.592327,
272 0.614087, 0.635344, 0.655252, 0.672766, 0.690929, 0.707293, 0.722742, 0.738323,
273 0.753562, 0.76749, 0.780983, 0.79354, 0.806521, 0.818085, 0.829987, 0.841443,
274 0.853723, 0.863393, 0.87431, 0.883139, 0.892962, 0.902803, 0.911276, 0.921417,
275 0.929387, 0.938106, 0.947072, 0.954406, 0.961692, 0.97055, 0.978517, 0.985133,
276 0.992257, 1.000000
277 ]
278 kwargs.setdefault("qratcor_csl_eta",qratcor_csl_eta)
279 kwargs.setdefault("qratcor_css_eta",qratcor_css_eta)
280 csc_align_tool = CscAlignmentTool(flags)
281 kwargs.setdefault("CscAlignmentTool", csc_align_tool )
282 result.setPrivateTools(QratCscClusterFitter(**kwargs))
283
284 return result
285
286def CalibCscStripFitterCfg(flags, name = "CalibCscStripFitter",**kwargs):
287 CalibCscStripFitter=CompFactory.CalibCscStripFitter
288 from MuonConfig.MuonCalibrationConfig import CscCalibToolCfg
289 result = CscCalibToolCfg(flags)
290 kwargs.setdefault("cscCalibTool", result.popPrivateTools() )
291 result.setPrivateTools(CalibCscStripFitter(name=name,**kwargs))
292 return result
293
294def CscClusterUtilToolCfg(flags, name='CscClusterUtilTool', **kwargs):
295 CscClusterUtilTool=CompFactory.CscClusterUtilTool
296
297 result = CalibCscStripFitterCfg(flags)
298 kwargs.setdefault("strip_fitter", result.popPrivateTools() )
299
300 acc = QratCscClusterFitterCfg(flags)
301 kwargs.setdefault("precision_fitter", acc.popPrivateTools() )
302 result.setPrivateTools(CscClusterUtilTool(name=name, **kwargs))
303 result.merge(acc)
304 return result
305
306def CscSegmentUtilToolCfg(flags, name='CscSegmentUtilTool', **kwargs):
307 CscSegmentUtilTool=CompFactory.CscSegmentUtilTool
308 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import CscClusterOnTrackCreatorCfg
309
310 result=CscClusterOnTrackCreatorCfg(flags)
311 csc_cluster_creator = result.popPrivateTools()
312 kwargs.setdefault("rot_creator", csc_cluster_creator )
313
314 result.setPrivateTools(CscSegmentUtilTool( name=name, **kwargs))
315 return result
316
317def Csc2dSegmentMakerCfg(flags, name= "Csc2dSegmentMaker", **kwargs):
318 Csc2dSegmentMaker=CompFactory.Csc2dSegmentMaker
319 result=ComponentAccumulator()
320 if 'segmentTool' not in kwargs:
321 acc = CscSegmentUtilToolCfg(flags)
322 csc_segment_util_tool = acc.getPrimary()
323 result.addPublicTool(csc_segment_util_tool)
324 kwargs.setdefault('segmentTool', csc_segment_util_tool)
325 result.merge(acc)
326
327 kwargs.setdefault("printerTool", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags) ))
328
329 csc_segment_maker = Csc2dSegmentMaker(name=name, **kwargs)
330 result.setPrivateTools(csc_segment_maker)
331
332 return result
333
334
335def Csc4dSegmentMakerCfg(flags, name= "Csc4dSegmentMaker", **kwargs):
336 result=CscSegmentUtilToolCfg(flags)
337 kwargs.setdefault("segmentTool", result.getPrimary() )
338 kwargs.setdefault("Printer", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags)) )
339 result.setPrivateTools(CompFactory.Csc4dSegmentMaker(name=name, **kwargs))
340 return result
341
342def MuonNSWSegmentFinderToolCfg(flags, name='MuonNSWSegmentFinderTool', **kwargs):
343
344 from MuonConfig.MuonRecToolsConfig import MuonTrackToSegmentToolCfg
345 from TrkConfig.TrkTrackSummaryToolConfig import MuonTrackSummaryToolCfg
346 result=ComponentAccumulator()
347 kwargs.setdefault("IPConstraint", flags.Beam.Type is BeamType.Collisions)
348 kwargs.setdefault('SegmentAmbiguityTool', result.popToolsAndMerge( MuonAmbiProcessorCfg(flags) ) )
349 kwargs.setdefault('SLFitter', result.popToolsAndMerge( MCTBSLFitterMaterialFromTrackCfg(flags) ) )
350 kwargs.setdefault("TrackToSegmentTool", result.popToolsAndMerge( MuonTrackToSegmentToolCfg(flags) ) )
351 kwargs.setdefault("Printer", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags)) )
352 if flags.Beam.Type is not BeamType.Collisions:
353 kwargs.setdefault("MmOccupancyBinWidth", 2048)
354
355 kwargs.setdefault('TrackCleaner', result.popToolsAndMerge( MuonTrackCleanerCfg(flags, name='MuonTrackCleaner_seg',seg=True) ) )
356 kwargs.setdefault('TrackSummaryTool', result.popToolsAndMerge( MuonTrackSummaryToolCfg(flags, name='MuonTrackSummary') ) )
357
358 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg
359 kwargs.setdefault("MuonClusterCreator", result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)) )
360
361 result.setPrivateTools(CompFactory.Muon.MuonNSWSegmentFinderTool(name,**kwargs))
362 return result
363
364def MuonPRDSelectionToolCfg( flags, name="MuonPRDSelectionTool", **kwargs):
365 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg, MdtDriftCircleOnTrackCreatorCfg
366 # Won't explicitly configure MuonIdHelperSvc
367 result = ComponentAccumulator()
368 kwargs.setdefault("MdtDriftCircleOnTrackCreator", result.popToolsAndMerge(MdtDriftCircleOnTrackCreatorCfg(flags)))
369 kwargs.setdefault("MuonClusterOnTrackCreator", result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)))
370 # Won't explicitly configure MuonRecoValidationTool (but it would need configuration if used)
371 the_tool = CompFactory.Muon.MuonPRDSelectionTool(name, **kwargs)
372 result.setPrivateTools(the_tool)
373 return result
374
375
376def MuonLayerHoughToolCfg(flags, name = "MuonLayerHoughTool" , **kwargs):
377 result = ComponentAccumulator()
378 layer_hough_tool = CompFactory.Muon.MuonLayerHoughTool(name, **kwargs)
379 result.setPrivateTools(layer_hough_tool)
380 return result
381
382def MuonLayerHoughAlgCfg(flags, name = "MuonLayerHoughAlg", **kwargs):
383 result = ComponentAccumulator()
384
385 if not flags.Detector.EnableMDT:
386 kwargs.setdefault("MdtPrepDataContainer", "")
387 if not flags.Detector.EnableRPC:
388 kwargs.setdefault("RpcPrepDataContainer", "")
389 if not flags.Detector.EnableTGC:
390 kwargs.setdefault("TgcPrepDataContainer", "")
391
392 kwargs.setdefault('TgcPrepDataContainer', 'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC else 'TGC_Measurements')
393 kwargs.setdefault("CscPrepDataContainer", "CSC_Clusters" if flags.Detector.EnableCSC else "")
394 kwargs.setdefault("sTgcPrepDataContainer", "STGC_Measurements" if flags.Detector.EnablesTGC else "")
395 kwargs.setdefault('TgcPrepDataContainer', 'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC else 'TGC_Measurements')
396 kwargs.setdefault("MMPrepDataContainer", "MM_Measurements" if flags.Detector.EnableMM else "")
397
398 kwargs.setdefault("PrintSummary", flags.Muon.printSummary)
399 kwargs.setdefault("printerTool", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags) ))
400
401 hough_tool = result.getPrimaryAndMerge(MuonLayerHoughToolCfg(flags,
402 name = "MuonLayerHoughTool")) if flags.Beam.Type is not BeamType.Cosmics else \
403 result.popToolsAndMerge(MuonHoughPatternFinderToolCfg(flags, name="MuonHoughPatternFinderTool"))
404 kwargs.setdefault("MuonLayerScanTool", hough_tool)
405
406 the_alg = CompFactory.MuonLayerHoughAlg(name = name,**kwargs)
407 result.addEventAlgo( the_alg, primary = True )
408 return result
409
410
411def MuonPatternCalibrationCfg(flags, name="MuonPatternCalibration", **kwargs):
412 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg, MdtDriftCircleOnTrackCreatorCfg, MdtCalibToolForRotsCfg
413 result = ComponentAccumulator()
414
415 if not flags.Detector.EnableRPC:
416 kwargs.setdefault("RpcPrepDataContainer", "")
417 if not flags.Detector.EnableTGC:
418 kwargs.setdefault("TgcPrepDataContainer", "")
419
420 if "MdtCreator" not in kwargs:
421 # on data configure a MdtDriftCircleOnTrackCreator for the segment finding with reduced errors
422 # when using the t0 refit enlarge the time window
423 if not flags.Input.isMC and flags.Beam.Type is BeamType.Collisions:
424 if flags.Muon.doSegmentT0Fit:
425 timeWindowSetting = MdtCalibWindowNumber('Collision_t0fit')
426 else:
427 timeWindowSetting = MdtCalibWindowNumber('Collision_data')
428 acc = MdtDriftCircleOnTrackCreatorCfg(flags, name="MdtDriftCircleOnTrackCreatorSegmentFinding",
429 CreateTubeHit = False,
430 CalibrationTool = result.popToolsAndMerge(MdtCalibToolForRotsCfg(flags,
431 TimeWindowSetting = timeWindowSetting))
432 )
433 else:
434 # I think we need to configure a 'default' version of the MdtDriftCircleOnTrackCreator here
435 acc = MdtDriftCircleOnTrackCreatorCfg(flags)
436
437 kwargs.setdefault('MdtCreator', result.popToolsAndMerge(acc))
438
439 kwargs.setdefault('ClusterCreator', result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)))
440 kwargs.setdefault("Printer", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags) ))
441 kwargs.setdefault('TgcPrepDataContainer', 'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC else 'TGC_Measurements')
442
443 if flags.Beam.Type is BeamType.Cosmics:
444 kwargs.setdefault("AngleCutPhi", 1e9)
445 kwargs.setdefault("DropDistance", 100000000.)
446 # Won't explicitly configure MuonIdHelperSvc
447 result.setPrivateTools( CompFactory.Muon.MuonPatternCalibration(name, **kwargs) )
448 return result
449
450def MuonSegmentFinderNCBAlgCfg(flags, name="MuonSegmentMaker_NCB", **kwargs):
451 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg
452 result = ComponentAccumulator()
453
454 kwargs.setdefault("doStgcSegments", flags.Detector.EnablesTGC)
455 kwargs.setdefault("doMMSegments", flags.Detector.EnableMM)
456 kwargs.setdefault("doMdtSegments", False)
457 kwargs.setdefault("CSC_clusterkey", "CSC_Clusters" if flags.Detector.EnableCSC else "")
458
459 kwargs.setdefault("SegmentCollectionName", "NCB_TrackMuonSegments")
460
461 kwargs.setdefault("NSWSegmentCollectionName", "")
462 kwargs.setdefault("SegmentQuality", 1)
463
464
465
466 if flags.Detector.EnableCSC:
467 csc_segment_util_tool = result.popToolsAndMerge(CscSegmentUtilToolCfg(flags,
468 name='CscSegmentUtilTool_NCB',
469 TightenChi2 = False,
470 IPconstraint=False))
471
472 csc_2d_segment_maker = result.popToolsAndMerge(Csc2dSegmentMakerCfg(flags,
473 name='Csc2dSegmentMaker_NCB',
474 segmentTool=csc_segment_util_tool))
475
476 csc_4d_segment_maker = result.popToolsAndMerge(Csc4dSegmentMakerCfg(flags,
477 name='Csc4dSegmentMaker_NCB',
478 segmentTool=csc_segment_util_tool))
479
480 kwargs.setdefault("Csc2dSegmentMaker", csc_2d_segment_maker)
481 kwargs.setdefault("Csc4dSegmentMaker", csc_4d_segment_maker)
482
483 if flags.Detector.EnablesTGC or flags.Detector.EnableMM:
484 kwargs.setdefault("MuonClusterCreator", result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)))
485 # Configure subtools needed by MuonNSWSegmentFinderTool
486 extrapolator = result.getPrimaryAndMerge(MuonStraightLineExtrapolatorCfg(flags))
487 result.addPublicTool(extrapolator)
488 cleaner = result.popToolsAndMerge( MuonTrackCleanerCfg(flags, name='MuonTrackCleaner_seg',seg=True) )
489 segment_finder = result.popToolsAndMerge(MuonNSWSegmentFinderToolCfg(flags,
490 name ="MuonNSWSegmentFinderTool",
491 TrackCleaner = cleaner,
492 SeedMMStereos = False,
493 IPConstraint = False,
494 CaloConstraint = True))
495 kwargs.setdefault("NSWSegmentMaker", segment_finder)
496 the_alg = CompFactory.MuonSegmentFinderAlg(name, **kwargs)
497 result.addEventAlgo(the_alg, primary = True)
498 return result
499
500def MuonSegmentFinderAlgCfg(flags, name="MuonSegmentMaker", **kwargs):
501 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg
502 result = ComponentAccumulator()
503 # Won't configure MuonIdHelperSvc
504 kwargs.setdefault("EDMPrinter", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags)) )
505
506 # for test purposes allow parallel running of truth segment finding and new segment finder
507 kwargs.setdefault('MuonPatternCalibration', result.popToolsAndMerge( MuonPatternCalibrationCfg(flags) ) )
508 segment_maker = result.getPrimaryAndMerge(DCMathSegmentMakerCfg(flags,name="DCMathSegmentMaker"))
509 kwargs.setdefault('SegmentMaker', segment_maker)
510 # Not yet configuring MuonSegmentOverlapRemovalTool
511
512 if flags.Detector.EnableMM or flags.Detector.EnablesTGC:
513 kwargs.setdefault("MuonClusterCreator", result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)))
514
515 # Configure subtools needed by MuonNSWSegmentFinderTool
516 extrapolator = result.getPrimaryAndMerge(MuonStraightLineExtrapolatorCfg(flags))
517 result.addPublicTool(extrapolator)
518 cleaner = result.popToolsAndMerge( MuonTrackCleanerCfg(flags, name='MuonTrackCleaner_seg',seg=True) )
519 segment_finder = result.getPrimaryAndMerge(MuonNSWSegmentFinderToolCfg(flags, name ="MuonNSWSegmentFinderTool", TrackCleaner = cleaner))
520 kwargs.setdefault("NSWSegmentMaker", segment_finder)
521
522
523 if flags.Detector.EnableCSC:
524 kwargs.setdefault("Csc2dSegmentMaker", result.popToolsAndMerge(Csc2dSegmentMakerCfg(flags)))
525 kwargs.setdefault("Csc4dSegmentMaker", result.popToolsAndMerge(Csc4dSegmentMakerCfg(flags)))
526 else:
527 kwargs.setdefault("CSC_clusterkey", "")
528
529 kwargs.setdefault("PrintSummary", flags.Muon.printSummary)
530 kwargs.setdefault("doStgcSegments", flags.Detector.EnablesTGC)
531 kwargs.setdefault("doMMSegments", flags.Detector.EnableMM)
532
533 kwargs.setdefault("SegmentCollectionName", "TrackMuonSegments" if flags.Muon.segmentOrigin != "TruthTracking" else "ThirdChainSegments")
534
535 the_alg = CompFactory.MuonSegmentFinderAlg( name, **kwargs)
536 result.addEventAlgo(the_alg)
537 return result
538
539def MuonSegmentFilterAlgCfg(flags, name="MuonSegmentFilterAlg", **kwargs):
540 result = ComponentAccumulator()
541 kwargs.setdefault("SegmentCollectionName", "TrackMuonSegments")
542
543 kwargs.setdefault("FilteredCollectionName", "TrackMuonSegmentsEMEO")
544 the_alg = CompFactory.MuonSegmentFilterAlg(name, **kwargs)
545 result.addEventAlgo(the_alg)
546 return result
547
548def MuonSegmentCnvAlgCfg(flags, name="MuonSegmentCnvAlg", **kwargs):
549 result = ComponentAccumulator()
550 from MuonCombinedConfig.MuonCombinedRecToolsConfig import MuonSegmentConverterToolCfg
551 kwargs.setdefault("MuonSegmentConverterTool", result.popToolsAndMerge(MuonSegmentConverterToolCfg(flags)))
552 the_alg = CompFactory.xAODMaker.MuonSegmentCnvAlg(name, **kwargs)
553 result.addEventAlgo(the_alg, primary = True)
554 return result
555
556
557def MuonSegmentFindingCfg(flags, setup_bytestream = True):
558 """
559 Returns a CA setting up Muon Segment Finding
560 @param setup_bytestream if True and if Format.BS, sets up reading from bytestream. If False, disables setting up BS, even if Format.BS is True
561 """
562 # Set up some general stuff needed by muon reconstruction
563
564 result = ComponentAccumulator()
565
566 from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
567 result.merge( MuonGeoModelCfg(flags) )
568 from MuonConfig.MuonRecToolsConfig import MuonEDMHelperSvcCfg
569 result.merge(MuonEDMHelperSvcCfg(flags))
570
571 if setup_bytestream:
572 # We need to be able to disable this when using MuonCalibStream,
573 # as the normal BS convertors clash with the special MCS converters.
574 if flags.Input.Format is Format.BS:
575 from MuonConfig.MuonBytestreamDecodeConfig import MuonByteStreamDecodersCfg
576 result.merge( MuonByteStreamDecodersCfg(flags) )
577
578 if flags.Input.Format is Format.BS or 'StreamRDO' in flags.Input.ProcessingTags:
579 from MuonConfig.MuonRdoDecodeConfig import MuonRDOtoPRDConvertorsCfg
580 result.merge( MuonRDOtoPRDConvertorsCfg(flags) )
581
582
585 if flags.Muon.scheduleActsReco:
586 if not flags.Muon.usePhaseIIGeoSetup:
587 raise RuntimeError("The phase II reconstruction flag cannot be set to true without also running the job from a proper SQLite input")
588 from MuonPatternRecognitionAlgs.MuonPatternRecognitionConfig import MuonPatternRecognitionCfg
589
590 result.merge(MuonPatternRecognitionCfg(flags))
591
592 return result
593 # We need to add two algorithms - one for normal collisions, one for NCB
594 result.merge(MuonLayerHoughAlgCfg(flags))
595 result.merge(MuonSegmentFinderAlgCfg(flags, name="MuonSegmentMaker"))
596
597
598 if flags.Muon.runCommissioningChain:
599 result.merge(MuonSegmentFilterAlgCfg(flags))
600
601 if flags.Beam.Type is BeamType.Collisions:
602 result.merge(MuonSegmentFinderNCBAlgCfg(flags))
603 result.merge(MuonSegmentCnvAlgCfg(flags, "MuonSegmentCnvAlg_NCB",
604 SegmentContainerName="NCB_TrackMuonSegments",
605 xAODContainerName="NCB_MuonSegments") )
606
607 if flags.Detector.EnableMM or flags.Detector.EnablesTGC:
608 result.merge(MuonSegmentCnvAlgCfg(flags, "QuadNSW_MuonSegmentCnvAlg",
609 SegmentContainerName="TrackMuonNSWSegments",
610 xAODContainerName="xAODNSWSegments"))
611 return result
612
613if __name__=="__main__":
614 # To run this, do e.g.
615 # python -m MuonConfig.MuonSegmentFindingConfig --threads=1
616 from MuonConfig.MuonConfigUtils import SetupMuonStandaloneConfigFlags, SetupMuonStandaloneOutput, SetupMuonStandaloneCA
617
618 flags = SetupMuonStandaloneConfigFlags()
619 cfg = SetupMuonStandaloneCA(flags)
620
621 # Run the actual test.
623 cfg.merge(acc)
624
625 # This is a temporary fix - it should go someplace central as it replaces the functionality of addInputRename from here:
626 # https://gitlab.cern.ch/atlas/athena/blob/master/Control/SGComps/python/AddressRemappingSvc.py
627 AddressRemappingSvc, ProxyProviderSvc=CompFactory.getComps("AddressRemappingSvc","ProxyProviderSvc",)
630 pps.ProviderNames += [ 'AddressRemappingSvc' ]
631 ars.TypeKeyRenameMaps += [ '%s#%s->%s' % ("Trk::SegmentCollection", "TrackMuonSegments", "TrackMuonSegments_old") ]
632 ars.TypeKeyRenameMaps += [ '%s#%s->%s' % ("Trk::SegmentCollection", "NCB_TrackMuonSegments", "NCB_TrackMuonSegments_old") ]
633
634 cfg.addService(pps)
635 cfg.addService(ars)
636
637 itemsToRecord = ["Trk::SegmentCollection#TrackMuonSegments", "Trk::SegmentCollection#NCB_TrackMuonSegments"]
638 SetupMuonStandaloneOutput(cfg, flags, itemsToRecord)
639
640 # cfg.getService("StoreGateSvc").Dump = True
641 cfg.printConfig()
642 f=open("MuonSegmentFinding.pkl","wb")
643 cfg.store(f)
644 f.close()
645
646 from MuonConfig.MuonConfigUtils import executeTest
647 executeTest(cfg)
This class provides the interface to the LCG POOL persistency software.
manages the address providers and add proxies on demand to the store
Csc2dSegmentMakerCfg(flags, name="Csc2dSegmentMaker", **kwargs)
MuonSegmentCnvAlgCfg(flags, name="MuonSegmentCnvAlg", **kwargs)
MuonSegmentFinderNCBAlgCfg(flags, name="MuonSegmentMaker_NCB", **kwargs)
MuonCombinePatternToolCfg(flags, name="MuonCombinePatternTool", **kwargs)
MuonSegmentFilterAlgCfg(flags, name="MuonSegmentFilterAlg", **kwargs)
MuonHoughPatternFinderToolCfg(flags, name="MuonHoughPatternFinderTool", **kwargs)
MuonNSWSegmentFinderToolCfg(flags, name='MuonNSWSegmentFinderTool', **kwargs)
MdtMathSegmentFinderCfg(flags, name="MdtMathSegmentFinder", **kwargs)
MuonHoughPatternToolCfg(flags, name="MuonHoughPatternTool", **kwargs)
CalibCscStripFitterCfg(flags, name="CalibCscStripFitter", **kwargs)
Csc4dSegmentMakerCfg(flags, name="Csc4dSegmentMaker", **kwargs)
MuonSegmentFindingCfg(flags, setup_bytestream=True)
MdtSegmentT0FitterCfg(flags, name="MdtSegmentT0Fitter", **kwargs)
MuonPRDSelectionToolCfg(flags, name="MuonPRDSelectionTool", **kwargs)
DCMathSegmentMakerCfg(flags, name='DCMathSegmentMaker', doSegmentT0Fit=False, **kwargs)
MuonSegmentFinderAlgCfg(flags, name="MuonSegmentMaker", **kwargs)
CscClusterUtilToolCfg(flags, name='CscClusterUtilTool', **kwargs)
MuonLayerHoughToolCfg(flags, name="MuonLayerHoughTool", **kwargs)
MuonLayerHoughAlgCfg(flags, name="MuonLayerHoughAlg", **kwargs)
MuonSegmentFittingToolCfg(flags, name="MuonSegmentFittingTool", **kwargs)
MuonPatternCalibrationCfg(flags, name="MuonPatternCalibration", **kwargs)
CscSegmentUtilToolCfg(flags, name='CscSegmentUtilTool', **kwargs)