3 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory
import CompFactory
5 from AthenaConfiguration.AccumulatorCache
import AccumulatorCache
6 from TrkConfig.TrkGlobalChi2FitterConfig
import MCTBFitterCfg, MCTBSLFitterCfg
7 from MuonConfig.MuonRecToolsConfig
import MuonTrackCleanerCfg, MuonSegmentMomentumFromFieldCfg, MuonSeededSegmentFinderCfg, MuonEDMPrinterToolCfg
8 from AthenaConfiguration.Enums
import BeamType
9 from MuonConfig.MuonSegmentFindingConfig
import MuonSegmentFittingToolCfg
14 Muon__MooTrackFitter=CompFactory.Muon.MooTrackFitter
15 MuonSegmentMomentum=CompFactory.MuonSegmentMomentum
16 from MuonConfig.MuonRecToolsConfig
import MuonPhiHitSelectorCfg, MuonTrackToSegmentToolCfg, MuonTrackSummaryHelperToolCfg, MuPatHitToolCfg
19 mctb_fitter = result.getPrimaryAndMerge(
MCTBFitterCfg(flags, name = prefix+
'MCTBFitter'))
20 kwargs.setdefault(
"Fitter", mctb_fitter)
23 result.addPublicTool(mu_pat_hit_tool)
24 kwargs.setdefault(
"HitTool", mu_pat_hit_tool)
26 from TrkConfig.TrkExSTEP_PropagatorConfig
import AtlasSTEP_PropagatorCfg
29 kwargs.setdefault(
"Propagator", muon_prop)
30 kwargs.setdefault(
"SLFit" ,
not (flags.BField.barrelToroidOn
and flags.BField.endcapToroidOn) )
31 if flags.Muon.MuonTrigger:
32 kwargs.setdefault(
"SLFit",
False)
33 kwargs.setdefault(
"ReducedChi2Cut", flags.Muon.Chi2NDofCut)
36 if flags.Beam.Type
is BeamType.Cosmics:
41 result.addPublicTool(momentum_estimator)
42 kwargs.setdefault(
"SegmentMomentum", momentum_estimator )
47 kwargs.setdefault(
"TrackToSegmentTool", track_to_segment_tool)
56 kwargs.setdefault(
"TrackSummaryTool", track_summary_helper)
58 kwargs.setdefault(
"CleanPhiHits",
True)
59 kwargs.setdefault(
"UsePreciseHits",
True)
60 kwargs.setdefault(
"UsePrefit",
False)
61 kwargs.setdefault(
"SeedAtStartOfTrack",
False)
63 fitter = Muon__MooTrackFitter(prefix + name, **kwargs)
64 result.setPrivateTools(fitter)
68 def MooTrackBuilderCfg(flags, name="MooTrackBuilderTemplate", prefix="", doSegmentPhiMatching=True, **kwargs):
69 Muon__MooTrackBuilder=CompFactory.Muon.MooTrackBuilder
70 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MdtDriftCircleOnTrackCreatorCfg, TriggerChamberClusterOnTrackCreatorCfg
71 from MuonConfig.MuonRecToolsConfig
import MuonTrackToSegmentToolCfg, MuonTrackExtrapolationToolCfg
72 from MagFieldServices.MagFieldServicesConfig
import AtlasFieldCacheCondAlgCfg
77 moo_track_fitter = result.popToolsAndMerge(
MooTrackFitterCfg(flags, name=
'MooTrackFitter', prefix=prefix))
78 kwargs.setdefault(
"Fitter", moo_track_fitter)
82 mctbslfitter = result.popToolsAndMerge(
MCTBSLFitterCfg(flags, name=prefix+
'MCTBSLFitter'))
85 from TrkConfig.TrkExSTEP_PropagatorConfig
import AtlasSTEP_PropagatorCfg
88 moo_sl_track_fitter = result.popToolsAndMerge(
MooTrackFitterCfg( flags, name=
"MooSLTrackFitter", prefix=prefix, Fitter = mctbslfitter, Propagator=muon_prop, ReducedChi2Cut=10.0, SLFit=
True))
90 kwargs.setdefault(
"SLFitter", moo_sl_track_fitter)
91 kwargs.setdefault(
"RecalibrateMDTHitsOnTrack", ( (
not flags.Muon.doSegmentT0Fit)
and flags.Beam.Type
is BeamType.Collisions) )
94 kwargs.setdefault(
"SeededSegmentFinder", muon_seeded_segment_finder)
97 kwargs.setdefault(
"MdtRotCreator", mdt_dcot_creator)
100 kwargs.setdefault(
"CompetingClustersCreator", muon_comp_cluster_creator)
102 kwargs.setdefault(
"Propagator", muon_prop)
103 kwargs.setdefault(
"ChamberHoleRecoveryTool",
116 kwargs.setdefault(
"CandidateMatchingTool",
118 doSegmentPhiMatching=doSegmentPhiMatching, prefix=prefix)))
120 from TrkConfig.TrkTrackSummaryToolConfig
import MuonTrackSummaryToolCfg
123 if "PullCalculator" not in kwargs:
124 from TrkConfig.TrkResidualPullCalculatorConfig
import (
125 ResidualPullCalculatorCfg)
126 kwargs.setdefault(
"PullCalculator", result.popToolsAndMerge(
129 result.setPrivateTools(Muon__MooTrackBuilder(name, **kwargs))
133 from MuonConfig.MuonRecToolsConfig
import MuonEDMHelperSvcCfg
134 from TrkConfig.TrkExRungeKuttaPropagatorConfig
import RungeKuttaPropagatorCfg
138 kwargs.setdefault(
"AtlasRungeKuttaPropagator", result.popToolsAndMerge(
141 if "ResidualPullCalculator" not in kwargs:
142 from TrkConfig.TrkResidualPullCalculatorConfig
import (
143 ResidualPullCalculatorCfg)
144 kwargs.setdefault(
"ResidualPullCalculator", result.popToolsAndMerge(
147 result.setPrivateTools(CompFactory.Muon.MuonSegmentInOverlapResolvingTool(name, **kwargs))
153 Muon__MuonSegmentMatchingTool=CompFactory.Muon.MuonSegmentMatchingTool
155 kwargs.setdefault(
"doThetaMatching", flags.Muon.useSegmentMatching)
156 kwargs.setdefault(
"doPhiMatching",
False )
157 if flags.Beam.Type
is BeamType.Cosmics:
158 kwargs.setdefault(
"OverlapMatchAveragePhiHitPullCut", 200.)
159 kwargs.setdefault(
"ToroidOn",
False )
168 kwargs.setdefault(
"Printer", result.getPrimary() )
169 kwargs.setdefault(
"MuonSegmentInOverlapResolvingTool", result.popToolsAndMerge(
171 kwargs.setdefault(
"MuonSegmentPairMatchingTool", CompFactory.Muon.MuonSegmentPairMatchingTool(
'MuonSegmentPairMatchingTool'))
173 matching = Muon__MuonSegmentMatchingTool(name, **kwargs)
174 result.setPrivateTools(matching)
178 Muon__MooCandidateMatchingTool=CompFactory.Muon.MooCandidateMatchingTool
179 from TrkConfig.AtlasExtrapolatorConfig
import AtlasExtrapolatorCfg
188 muon_seg_matching = acc.getPrimary()
190 kwargs.setdefault(
"SegmentMatchingTool", muon_seg_matching)
192 acc =
MuonSegmentMatchingToolCfg(flags, name = prefix+
"MuonSegmentMatchingToolTight", TightSegmentMatching=
True, doPhiMatching = doSegmentPhiMatching)
193 muon_seg_matching_tight = acc.getPrimary()
195 kwargs.setdefault(
"SegmentMatchingToolTight", muon_seg_matching_tight)
197 kwargs.setdefault(
"DoTrackSegmentMatching", flags.Muon.useTrackSegmentMatching)
198 kwargs.setdefault(
"RequireSameSide", flags.Beam.Type
is not BeamType.Collisions)
199 if flags.Muon.useAlignmentCorrections:
200 kwargs.setdefault(
"AlignmentErrorPosX", 5.0)
201 kwargs.setdefault(
"AlignmentErrorPosY", 0.2)
202 kwargs.setdefault(
"AlignmentErrorAngleX", 0.002)
203 kwargs.setdefault(
"AlignmentErrorAngleY", 0.001)
206 kwargs.setdefault(
"AlignmentErrorPosX", 10.0)
207 kwargs.setdefault(
"AlignmentErrorPosY", 5.0)
208 kwargs.setdefault(
"AlignmentErrorAngleX", 0.004)
209 kwargs.setdefault(
"AlignmentErrorAngleY", 0.002)
213 moo_cand_matching_tool = Muon__MooCandidateMatchingTool(prefix+name,**kwargs)
214 result.setPrivateTools(moo_cand_matching_tool)
218 from TrkConfig.AtlasExtrapolatorConfig
import MuonExtrapolatorCfg
219 from TrkConfig.TrkTrackSummaryToolConfig
import MuonTrackSummaryToolCfg
220 from MuonConfig.MuonCondAlgConfig
import MuonStationIntersectCondAlgCfg
221 from MuonCombinedConfig.MuonCombinedRecToolsConfig
import CombinedMuonTrackBuilderFitCfg
222 from MuonConfig.MuonRecToolsConfig
import MuonHitSummaryToolCfg
227 kwargs.setdefault(
"SeededSegmentFinder",
230 kwargs.setdefault(
"TrackSegmentMatchingTool",
233 kwargs.setdefault(
"ChamberHoleRecoveryTool",
236 kwargs.setdefault(
"Extrapolator",
238 if 'OnlyEO' in kwargs:
240 kwargs.setdefault(
"Builder", result.popToolsAndMerge(
243 kwargs.setdefault(
"Builder", result.popToolsAndMerge(
247 kwargs.setdefault(
"Fitter",
250 kwargs.setdefault(
"EDMPrinter", result.getPrimaryAndMerge(
256 from RegionSelector.RegSelToolConfig
import regSelTool_MDT_Cfg, regSelTool_RPC_Cfg, regSelTool_TGC_Cfg
257 if flags.Detector.GeometryMDT:
258 kwargs.setdefault(
"MDTRegionSelector", result.popToolsAndMerge(
regSelTool_MDT_Cfg(flags)))
260 if flags.Detector.GeometryTGC:
261 kwargs.setdefault(
"TGCRegionSelector", result.popToolsAndMerge(
regSelTool_TGC_Cfg(flags)))
263 if flags.Detector.GeometryRPC:
264 kwargs.setdefault(
"RPCRegionSelector", result.popToolsAndMerge(
regSelTool_RPC_Cfg(flags)))
266 if flags.Detector.GeometryCSC:
267 from RegionSelector.RegSelToolConfig
import regSelTool_CSC_Cfg
268 kwargs.setdefault(
"CSCRegionSelector", result.popToolsAndMerge(
regSelTool_CSC_Cfg(flags)))
270 if flags.Detector.GeometrysTGC:
271 from RegionSelector.RegSelToolConfig
import regSelTool_STGC_Cfg
272 kwargs.setdefault(
"STGCRegionSelector", result.popToolsAndMerge(
regSelTool_STGC_Cfg(flags)))
274 if flags.Detector.GeometryMM:
275 from RegionSelector.RegSelToolConfig
import regSelTool_MM_Cfg
276 kwargs.setdefault(
"MMRegionSelector", result.popToolsAndMerge(
regSelTool_MM_Cfg(flags)))
280 segment_region_recovery_tool = CompFactory.Muon.MuonSegmentRegionRecoveryTool(name, **kwargs)
281 result.setPrivateTools(segment_region_recovery_tool)
287 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MdtDriftCircleOnTrackCreatorCfg, TriggerChamberClusterOnTrackCreatorCfg
288 from MuonCombinedConfig.MuonCombinedRecToolsConfig
import MuonSegmentSelectionToolCfg
290 kwargs.setdefault(
"MdtRotCreator", result.getPrimary())
292 if flags.Detector.GeometryCSC:
293 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import CscClusterOnTrackCreatorCfg
296 kwargs.setdefault(
"CscRotCreator",
"")
302 from MuonConfig.MuonRecToolsConfig
import MuPatHitToolCfg
303 kwargs.setdefault(
"HitTool", result.getPrimaryAndMerge(
MuPatHitToolCfg(flags)))
306 result.setPrivateTools(CompFactory.Muon.MuPatCandidateTool(name, **kwargs))
313 from TrkConfig.AtlasExtrapolatorConfig
import MuonExtrapolatorCfg
316 from MuonConfig.MuonGeometryConfig
import TrackingVolumesSvcCfg
319 if not flags.Detector.GeometryMDT:
320 kwargs.setdefault(
"MdtPrepDataContainer",
"")
322 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MdtDriftCircleOnTrackCreatorCfg, MuonClusterOnTrackCreatorCfg
325 if not flags.Detector.GeometryRPC:
326 kwargs.setdefault(
"RpcPrepDataContainer",
"")
327 if not flags.Detector.GeometryTGC:
328 kwargs.setdefault(
"TgcPrepDataContainer",
"")
330 kwargs.setdefault(
"AddMeasurements",
not flags.Muon.doSegmentT0Fit )
333 if flags.Detector.GeometryCSC:
334 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import CscClusterOnTrackCreatorCfg
337 kwargs.setdefault(
"CscPrepDataContainer",
"")
341 if not flags.Detector.GeometrysTGC:
342 kwargs.setdefault(
"sTgcPrepDataContainer",
"")
344 if not flags.Detector.GeometryMM:
345 kwargs.setdefault(
"MMPrepDataContainer",
"")
347 kwargs.setdefault(
'TgcPrepDataContainer',
'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC
else 'TGC_Measurements')
350 if "PullCalculator" not in kwargs:
351 from TrkConfig.TrkResidualPullCalculatorConfig
import (
352 ResidualPullCalculatorCfg)
353 kwargs.setdefault(
"PullCalculator", result.popToolsAndMerge(
356 result.setPrivateTools(CompFactory.Muon.MuonChamberHoleRecoveryTool(name, **kwargs))
362 sTgcPrepDataContainer=
"",
363 MMPrepDataContainer=
"")
366 Muon__MuonTrackSteering=CompFactory.Muon.MuonTrackSteering
372 "BarrelCombined[CombineSegInStation,DoRefinement,DoAmbiSolving,CutSeedsOnTracks]:BML,BMS;BOL,BOS;BIL,BIS",
373 "EndcapCombined[CombineSegInStation,DoRefinement,DoAmbiSolving,CutSeedsOnTracks]:EML,EMS;EOL,EOS;EIL,EIS;CSL,CSS;EEL,EES;BEE",
374 "BarrelEndcap[CombineSegInStation,DoRefinement,DoAmbiSolving,CutSeedsOnTracks,BarrelEndcapFilter]:EML,EMS;EEL,EES;BML,BMS;EIL,EIS;BIL,BIS;BOL,BOS"]
376 kwargs.setdefault(
"StrategyList", MoorelikeStrategy)
382 mctbslfitter = result.getPrimary()
385 muon_eo_recovery_tool = acc.getPrimary()
388 kwargs.setdefault(
"HoleRecoveryTool", muon_eo_recovery_tool)
389 kwargs.setdefault(
"SegSeedQCut", 2
if flags.Beam.Type != BeamType.Cosmics
else 1)
390 kwargs.setdefault(
"Seg2ndQCut", 1)
392 if "TrackBuilderTool" not in kwargs:
400 kwargs[
"TrackBuilderTool"] = result.popToolsAndMerge(
MooTrackBuilderCfg(flags, name=
'MooMuonTrackBuilder', prefix=
"MuSt_"))
402 if "TrackRefinementTool" not in kwargs:
403 kwargs[
"TrackRefinementTool"] = result.popToolsAndMerge(
MooTrackBuilderCfg(flags, name=
'MooTrackBuilderTemplate', doSegmentPhiMatching=
False))
406 cand_tool = acc.getPrimary()
408 kwargs.setdefault(
"MuPatCandidateTool", cand_tool)
410 from MuonConfig.MuonRecToolsConfig
import MuonAmbiProcessorCfg
412 ambi = acc.getPrimary()
414 kwargs.setdefault(
"AmbiguityTool", ambi)
416 kwargs.setdefault(
"MooBuilderTool", result.popToolsAndMerge(
MooTrackBuilderCfg(flags, name=
'MooMuonTrackBuilder', prefix=
"MuSt_")))
418 kwargs.setdefault(
"CandidateMatchingTool",
421 kwargs.setdefault(
"MuonSegmentFittingTool",
423 kwargs.setdefault(
"MuonTrackSelector",
426 kwargs.setdefault(
"HoleRecoveryTool",
429 from TrkConfig.TrkTrackSummaryToolConfig
import MuonTrackSummaryToolCfg
431 kwargs.setdefault(
"DoSummary", flags.Muon.printSummary)
434 track_maker_steering = Muon__MuonTrackSteering(name,**kwargs)
435 result.setPrivateTools(track_maker_steering)
439 from MuonConfig.MuonRecToolsConfig
import MuonTrackSummaryHelperToolCfg
442 if flags.Beam.Type
in [BeamType.Cosmics, BeamType.SingleBeam]
or not flags.Input.isMC:
443 kwargs.setdefault(
"UseRPCHoles",
False)
444 kwargs.setdefault(
"UseTGCHoles",
False)
445 kwargs.setdefault(
"MaxMdtHolesOnTwoStationTrack", 10)
446 kwargs.setdefault(
"MaxMdtHolesOnTrack", 30)
447 kwargs.setdefault(
"HolesToHitsRatioCutPerStation", 2)
448 kwargs.setdefault(
"CountMDTOutlierAsHoles",
False)
450 kwargs.setdefault(
"MaxMdtHolesOnTwoStationTrack", 4)
451 kwargs.setdefault(
"MaxMdtHolesOnTrack", 5)
452 kwargs.setdefault(
"CountMDTOutlierAsHoles",
True)
456 theTool = CompFactory.Muon.MuonTrackSelectorTool(name, **kwargs)
457 result.setPrivateTools(theTool)
465 name =
"MooMuonTrackBuilder_EMEO",
466 ChamberHoleRecoveryTool = recovery_tool)
468 track_builder= result.getPrimaryAndMerge(acc)
471 name =
"MuonTrackSteering_EMEO",
472 TrackBuilderTool = track_builder)
473 track_steering = acc.getPrimary()
476 kwargs.setdefault(
"TrackSteering", track_steering)
477 kwargs.setdefault(
"MuonSegmentCollection",
"TrackMuonSegmentsEMEO")
478 kwargs.setdefault(
"SpectrometerTrackOutputLocation",
"EMEO_MuonSpectrometerTracks")
480 the_alg = CompFactory.MuPatTrackBuilder(name = name, **kwargs)
481 result.addEventAlgo(the_alg, primary =
True)
487 track_steering = acc.getPrimary()
490 kwargs.setdefault(
"TrackSteering", track_steering)
491 kwargs.setdefault(
"MuonSegmentCollection",
"TrackMuonSegments")
492 kwargs.setdefault(
"SpectrometerTrackOutputLocation",
"MuonSpectrometerTracks")
494 track_builder = CompFactory.MuPatTrackBuilder(name=name, **kwargs)
495 result.addEventAlgo( track_builder, primary=
True )
503 from MuonConfig.MuonGeometryConfig
import MuonGeoModelCfg
505 from MuonConfig.MuonRecToolsConfig
import MuonEDMHelperSvcCfg
509 from MuonConfig.MuonSegmentNameFixConfig
import MuonSegmentNameFixCfg
513 if flags.Muon.runCommissioningChain:
518 if __name__==
"__main__":
521 from MuonConfig.MuonConfigUtils
import SetupMuonStandaloneConfigFlags, SetupMuonStandaloneOutput, SetupMuonStandaloneCA
533 AddressRemappingSvc, ProxyProviderSvc=CompFactory.getComps(
"AddressRemappingSvc",
"ProxyProviderSvc",)
536 pps.ProviderNames += [
'AddressRemappingSvc' ]
537 ars.TypeKeyRenameMaps += [
'%s#%s->%s' % (
"TrackCollection",
"MuonSpectrometerTracks",
"MuonSpectrometerTracks_old") ]
542 itemsToRecord = [
"TrackCollection#MuonSpectrometerTracks"]
545 cfg.printConfig(withDetails =
True)
547 f=
open(
"MuonTrackBuilding.pkl",
"wb")
551 if not args.config_only:
553 if not sc.isSuccess():
555 sys.exit(
"Execution failed")