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("CscPrepDataContainer", "CSC_Clusters" if flags.Detector.EnableCSC else "")
393 kwargs.setdefault("sTgcPrepDataContainer", "STGC_Measurements" if flags.Detector.EnablesTGC else "")
394 kwargs.setdefault('TgcPrepDataContainer', 'TGC_MeasurementsAllBCs')
395 kwargs.setdefault("MMPrepDataContainer", "MM_Measurements" if flags.Detector.EnableMM else "")
396
397 kwargs.setdefault("PrintSummary", flags.Muon.printSummary)
398 kwargs.setdefault("printerTool", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags) ))
399
400 hough_tool = result.getPrimaryAndMerge(MuonLayerHoughToolCfg(flags,
401 name = "MuonLayerHoughTool")) if flags.Beam.Type is not BeamType.Cosmics else \
402 result.popToolsAndMerge(MuonHoughPatternFinderToolCfg(flags, name="MuonHoughPatternFinderTool"))
403 kwargs.setdefault("MuonLayerScanTool", hough_tool)
404
405 the_alg = CompFactory.MuonLayerHoughAlg(name = name,**kwargs)
406 result.addEventAlgo( the_alg, primary = True )
407 return result
408
409
410def MuonPatternCalibrationCfg(flags, name="MuonPatternCalibration", **kwargs):
411 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg, MdtDriftCircleOnTrackCreatorCfg, MdtCalibToolForRotsCfg
412 result = ComponentAccumulator()
413
414 if not flags.Detector.EnableRPC:
415 kwargs.setdefault("RpcPrepDataContainer", "")
416 if not flags.Detector.EnableTGC:
417 kwargs.setdefault("TgcPrepDataContainer", "")
418
419 if "MdtCreator" not in kwargs:
420 # on data configure a MdtDriftCircleOnTrackCreator for the segment finding with reduced errors
421 # when using the t0 refit enlarge the time window
422 if not flags.Input.isMC and flags.Beam.Type is BeamType.Collisions:
423 if flags.Muon.doSegmentT0Fit:
424 timeWindowSetting = MdtCalibWindowNumber('Collision_t0fit')
425 else:
426 timeWindowSetting = MdtCalibWindowNumber('Collision_data')
427 acc = MdtDriftCircleOnTrackCreatorCfg(flags, name="MdtDriftCircleOnTrackCreatorSegmentFinding",
428 CreateTubeHit = False,
429 CalibrationTool = result.popToolsAndMerge(MdtCalibToolForRotsCfg(flags,
430 TimeWindowSetting = timeWindowSetting))
431 )
432 else:
433 # I think we need to configure a 'default' version of the MdtDriftCircleOnTrackCreator here
434 acc = MdtDriftCircleOnTrackCreatorCfg(flags)
435
436 kwargs.setdefault('MdtCreator', result.popToolsAndMerge(acc))
437
438 kwargs.setdefault('ClusterCreator', result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)))
439 kwargs.setdefault("Printer", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags) ))
440 kwargs.setdefault('TgcPrepDataContainer', 'TGC_MeasurementsAllBCs')
441
442 if flags.Beam.Type is BeamType.Cosmics:
443 kwargs.setdefault("AngleCutPhi", 1e9)
444 kwargs.setdefault("DropDistance", 100000000.)
445 # Won't explicitly configure MuonIdHelperSvc
446 result.setPrivateTools( CompFactory.Muon.MuonPatternCalibration(name, **kwargs) )
447 return result
448
449def MuonSegmentFinderNCBAlgCfg(flags, name="MuonSegmentMaker_NCB", **kwargs):
450 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg
451 result = ComponentAccumulator()
452
453 kwargs.setdefault("doStgcSegments", flags.Detector.EnablesTGC)
454 kwargs.setdefault("doMMSegments", flags.Detector.EnableMM)
455 kwargs.setdefault("doMdtSegments", False)
456 kwargs.setdefault("CSC_clusterkey", "CSC_Clusters" if flags.Detector.EnableCSC else "")
457
458 kwargs.setdefault("SegmentCollectionName", "NCB_TrackMuonSegments")
459
460 kwargs.setdefault("NSWSegmentCollectionName", "")
461 kwargs.setdefault("SegmentQuality", 1)
462
463
464
465 if flags.Detector.EnableCSC:
466 csc_segment_util_tool = result.popToolsAndMerge(CscSegmentUtilToolCfg(flags,
467 name='CscSegmentUtilTool_NCB',
468 TightenChi2 = False,
469 IPconstraint=False))
470
471 csc_2d_segment_maker = result.popToolsAndMerge(Csc2dSegmentMakerCfg(flags,
472 name='Csc2dSegmentMaker_NCB',
473 segmentTool=csc_segment_util_tool))
474
475 csc_4d_segment_maker = result.popToolsAndMerge(Csc4dSegmentMakerCfg(flags,
476 name='Csc4dSegmentMaker_NCB',
477 segmentTool=csc_segment_util_tool))
478
479 kwargs.setdefault("Csc2dSegmentMaker", csc_2d_segment_maker)
480 kwargs.setdefault("Csc4dSegmentMaker", csc_4d_segment_maker)
481
482 if flags.Detector.EnablesTGC or flags.Detector.EnableMM:
483 kwargs.setdefault("MuonClusterCreator", result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)))
484 # Configure subtools needed by MuonNSWSegmentFinderTool
485 extrapolator = result.getPrimaryAndMerge(MuonStraightLineExtrapolatorCfg(flags))
486 result.addPublicTool(extrapolator)
487 cleaner = result.popToolsAndMerge( MuonTrackCleanerCfg(flags, name='MuonTrackCleaner_seg',seg=True) )
488 segment_finder = result.popToolsAndMerge(MuonNSWSegmentFinderToolCfg(flags,
489 name ="MuonNSWSegmentFinderTool",
490 TrackCleaner = cleaner,
491 SeedMMStereos = False,
492 IPConstraint = False,
493 CaloConstraint = True))
494 kwargs.setdefault("NSWSegmentMaker", segment_finder)
495 the_alg = CompFactory.MuonSegmentFinderAlg(name, **kwargs)
496 result.addEventAlgo(the_alg, primary = True)
497 return result
498
499def MuonSegmentFinderAlgCfg(flags, name="MuonSegmentMaker", **kwargs):
500 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig import MuonClusterOnTrackCreatorCfg
501 result = ComponentAccumulator()
502 # Won't configure MuonIdHelperSvc
503 kwargs.setdefault("EDMPrinter", result.getPrimaryAndMerge(MuonEDMPrinterToolCfg(flags)) )
504
505 # for test purposes allow parallel running of truth segment finding and new segment finder
506 kwargs.setdefault('MuonPatternCalibration', result.popToolsAndMerge( MuonPatternCalibrationCfg(flags) ) )
507 segment_maker = result.getPrimaryAndMerge(DCMathSegmentMakerCfg(flags,name="DCMathSegmentMaker"))
508 kwargs.setdefault('SegmentMaker', segment_maker)
509 # Not yet configuring MuonSegmentOverlapRemovalTool
510
511 if flags.Detector.EnableMM or flags.Detector.EnablesTGC:
512 kwargs.setdefault("MuonClusterCreator", result.popToolsAndMerge(MuonClusterOnTrackCreatorCfg(flags)))
513
514 # Configure subtools needed by MuonNSWSegmentFinderTool
515 extrapolator = result.getPrimaryAndMerge(MuonStraightLineExtrapolatorCfg(flags))
516 result.addPublicTool(extrapolator)
517 cleaner = result.popToolsAndMerge( MuonTrackCleanerCfg(flags, name='MuonTrackCleaner_seg',seg=True) )
518 segment_finder = result.getPrimaryAndMerge(MuonNSWSegmentFinderToolCfg(flags, name ="MuonNSWSegmentFinderTool", TrackCleaner = cleaner))
519 kwargs.setdefault("NSWSegmentMaker", segment_finder)
520
521
522 if flags.Detector.EnableCSC:
523 kwargs.setdefault("Csc2dSegmentMaker", result.popToolsAndMerge(Csc2dSegmentMakerCfg(flags)))
524 kwargs.setdefault("Csc4dSegmentMaker", result.popToolsAndMerge(Csc4dSegmentMakerCfg(flags)))
525 else:
526 kwargs.setdefault("CSC_clusterkey", "")
527
528 kwargs.setdefault("PrintSummary", flags.Muon.printSummary)
529 kwargs.setdefault("doStgcSegments", flags.Detector.EnablesTGC)
530 kwargs.setdefault("doMMSegments", flags.Detector.EnableMM)
531
532 kwargs.setdefault("SegmentCollectionName", "TrackMuonSegments" if flags.Muon.segmentOrigin != "TruthTracking" else "ThirdChainSegments")
533
534 the_alg = CompFactory.MuonSegmentFinderAlg( name, **kwargs)
535 result.addEventAlgo(the_alg)
536 return result
537
538def MuonSegmentFilterAlgCfg(flags, name="MuonSegmentFilterAlg", **kwargs):
539 result = ComponentAccumulator()
540 kwargs.setdefault("SegmentCollectionName", "TrackMuonSegments")
541
542 kwargs.setdefault("FilteredCollectionName", "TrackMuonSegmentsEMEO")
543 the_alg = CompFactory.MuonSegmentFilterAlg(name, **kwargs)
544 result.addEventAlgo(the_alg)
545 return result
546
547def MuonSegmentCnvAlgCfg(flags, name="MuonSegmentCnvAlg", **kwargs):
548 result = ComponentAccumulator()
549 from MuonCombinedConfig.MuonCombinedRecToolsConfig import MuonSegmentConverterToolCfg
550 kwargs.setdefault("MuonSegmentConverterTool", result.popToolsAndMerge(MuonSegmentConverterToolCfg(flags)))
551 the_alg = CompFactory.xAODMaker.MuonSegmentCnvAlg(name, **kwargs)
552 result.addEventAlgo(the_alg, primary = True)
553 return result
554
555
556def MuonSegmentFindingCfg(flags, setup_bytestream = True):
557 """
558 Returns a CA setting up Muon Segment Finding
559 @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
560 """
561 # Set up some general stuff needed by muon reconstruction
562
563 result = ComponentAccumulator()
564
565 from MuonConfig.MuonGeometryConfig import MuonGeoModelCfg
566 result.merge( MuonGeoModelCfg(flags) )
567 from MuonConfig.MuonRecToolsConfig import MuonEDMHelperSvcCfg
568 result.merge(MuonEDMHelperSvcCfg(flags))
569
570 if setup_bytestream:
571 # We need to be able to disable this when using MuonCalibStream,
572 # as the normal BS convertors clash with the special MCS converters.
573 if flags.Input.Format is Format.BS:
574 from MuonConfig.MuonBytestreamDecodeConfig import MuonByteStreamDecodersCfg
575 result.merge( MuonByteStreamDecodersCfg(flags) )
576
577 if flags.Input.Format is Format.BS or 'StreamRDO' in flags.Input.ProcessingTags:
578 from MuonConfig.MuonRdoDecodeConfig import MuonRDOtoPRDConvertorsCfg
579 result.merge( MuonRDOtoPRDConvertorsCfg(flags) )
580
581
584 if flags.Muon.scheduleActsReco:
585 if not flags.Muon.usePhaseIIGeoSetup:
586 raise RuntimeError("The phase II reconstruction flag cannot be set to true without also running the job from a proper SQLite input")
587 from MuonPatternRecognitionAlgs.MuonPatternRecognitionConfig import MuonPatternRecognitionCfg
588
589 result.merge(MuonPatternRecognitionCfg(flags))
590
591 return result
592 # We need to add two algorithms - one for normal collisions, one for NCB
593 result.merge(MuonLayerHoughAlgCfg(flags))
594 result.merge(MuonSegmentFinderAlgCfg(flags, name="MuonSegmentMaker"))
595
596
597 if flags.Muon.runCommissioningChain:
598 result.merge(MuonSegmentFilterAlgCfg(flags))
599
600 if flags.Beam.Type is BeamType.Collisions:
601 result.merge(MuonSegmentFinderNCBAlgCfg(flags))
602 result.merge(MuonSegmentCnvAlgCfg(flags, "MuonSegmentCnvAlg_NCB",
603 SegmentContainerName="NCB_TrackMuonSegments",
604 xAODContainerName="NCB_MuonSegments") )
605
606 if flags.Detector.EnableMM or flags.Detector.EnablesTGC:
607 result.merge(MuonSegmentCnvAlgCfg(flags, "QuadNSW_MuonSegmentCnvAlg",
608 SegmentContainerName="TrackMuonNSWSegments",
609 xAODContainerName="xAODNSWSegments"))
610 return result
611
612if __name__=="__main__":
613 # To run this, do e.g.
614 # python -m MuonConfig.MuonSegmentFindingConfig --threads=1
615 from MuonConfig.MuonConfigUtils import SetupMuonStandaloneConfigFlags, SetupMuonStandaloneOutput, SetupMuonStandaloneCA
616
617 flags = SetupMuonStandaloneConfigFlags()
618 cfg = SetupMuonStandaloneCA(flags)
619
620 # Run the actual test.
622 cfg.merge(acc)
623
624 # This is a temporary fix - it should go someplace central as it replaces the functionality of addInputRename from here:
625 # https://gitlab.cern.ch/atlas/athena/blob/master/Control/SGComps/python/AddressRemappingSvc.py
626 AddressRemappingSvc, ProxyProviderSvc=CompFactory.getComps("AddressRemappingSvc","ProxyProviderSvc",)
629 pps.ProviderNames += [ 'AddressRemappingSvc' ]
630 ars.TypeKeyRenameMaps += [ '%s#%s->%s' % ("Trk::SegmentCollection", "TrackMuonSegments", "TrackMuonSegments_old") ]
631 ars.TypeKeyRenameMaps += [ '%s#%s->%s' % ("Trk::SegmentCollection", "NCB_TrackMuonSegments", "NCB_TrackMuonSegments_old") ]
632
633 cfg.addService(pps)
634 cfg.addService(ars)
635
636 itemsToRecord = ["Trk::SegmentCollection#TrackMuonSegments", "Trk::SegmentCollection#NCB_TrackMuonSegments"]
637 SetupMuonStandaloneOutput(cfg, flags, itemsToRecord)
638
639 # cfg.getService("StoreGateSvc").Dump = True
640 cfg.printConfig()
641 f=open("MuonSegmentFinding.pkl","wb")
642 cfg.store(f)
643 f.close()
644
645 from MuonConfig.MuonConfigUtils import executeTest
646 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)