ATLAS Offline Software
Loading...
Searching...
No Matches
MsTrackFindingTester.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5
6def MsTrackTesterCfg(flags, name = "MsTrackTester", scheduleLegacy = True, **kwargs):
7 result = ComponentAccumulator()
8 kwargs.setdefault("isMC", flags.Input.isMC)
9 from MuonTrackFindingAlgs.TrackFindingConfig import SegmentSelectorCfg, TrackSummaryToolCfg
10 kwargs.setdefault("SegmentSelectionTool", result.popToolsAndMerge(SegmentSelectorCfg(flags)))
11 kwargs.setdefault("SummaryTool", result.popToolsAndMerge(TrackSummaryToolCfg(flags)))
12 if not scheduleLegacy:
13 kwargs.setdefault("LegacySegmentKey", "")
14 kwargs.setdefault("LegacyTrackKey", "")
15 kwargs.setdefault("LegacyMuonKey" , "")
16 the_alg = CompFactory.MuonValR4.MsTrackTester(name= name, **kwargs)
17 result.addEventAlgo(the_alg, primary = True)
18 return result
19
20def MsTrackVisualizationToolCfg(flags, name = "VisualizationTool", **kwargs):
21 result = ComponentAccumulator()
22 if not flags.Input.isMC:
23 from MuonPatternRecognitionTest.PatternTestConfig import LegacyMuonRecoChainCfg
24 result.merge(LegacyMuonRecoChainCfg(flags))
25 kwargs.setdefault("TruthSegkey", "MuonSegments")
26 from ActsConfig.ActsGeometryConfig import ActsExtrapolationToolCfg
27 kwargs.setdefault("ExtrapolationTool", result.popToolsAndMerge(ActsExtrapolationToolCfg(flags, MaxSteps=10000)))
28 the_tool = CompFactory.MuonValR4.TrackVisualizationTool(name, **kwargs)
29 result.setPrivateTools(the_tool)
30 return result
31
32if __name__=="__main__":
33 from MuonGeoModelTestR4.testGeoModel import setupGeoR4TestCfg, SetupArgParser, MuonPhaseIITestDefaults
34 from MuonConfig.MuonConfigUtils import executeTest, setupHistSvcCfg
35 parser = SetupArgParser()
36 parser.add_argument("--noMonitorPlots", help="If set to true, there're no monitoring plots", default = False,
37 action='store_true')
38 parser.add_argument("--writeSpacePoints", help="If set to true, the spacepoints in the bucket are saved to disk",
39 default=False, action='store_true')
40 parser.add_argument("--noPerfMon", help="If set to true, disable performance monitoring.",
41 default=False, action='store_true')
42 parser.add_argument("--noLegacyChain", help="If set to true, the legacy chain is not scheduled",
43 default = False, action = 'store_true')
44 parser.set_defaults(nEvents = -1)
45
46 parser.set_defaults(outRootFile="MsTrkTester.root")
47 parser.set_defaults(inputFile=MuonPhaseIITestDefaults.HITS_PG_R3)
48
49 args = parser.parse_args()
50 from AthenaConfiguration.AllConfigFlags import initConfigFlags
51 flags = initConfigFlags()
52 flags.PerfMon.doFullMonMT = not args.noPerfMon
53 flags.Trigger.Muon.useNewRegionSelector = False
54 flags, cfg = setupGeoR4TestCfg(args,flags)
55
56 cfg.merge(setupHistSvcCfg(flags,outFile=args.outRootFile,
57 outStream="MuonTrackTester"))
58
59 from MuonConfig.ReconstructionConfigR4 import MuonReconstructionConfig
60 cfg.merge(MuonReconstructionConfig(flags))
61
62
63
64 from MuonPatternRecognitionTest.PatternTestConfig import LegacyMuonRecoChainCfg
65
66 if not args.noLegacyChain:
67 cfg.merge(LegacyMuonRecoChainCfg(flags))
68
69 cfg.merge(MsTrackTesterCfg(flags, scheduleLegacy = not args.noLegacyChain))
70
71 cfg.merge(setupHistSvcCfg(flags,outFile=args.outRootFile,
72 outStream="MuonEtaHoughTransformTest"))
73
74 from MuonPatternRecognitionTest.PatternTestConfig import MuonHoughTransformTesterCfg, PatternVisualizationToolCfg
75
76
77 cfg.merge(MuonHoughTransformTesterCfg(flags,
78 VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags, CanvasLimits =0))))
79
80
81 if not args.noMonitorPlots:
82 cfg.getEventAlgo("MSTrackFinderAlg").VisualizationTool = cfg.popToolsAndMerge(MsTrackVisualizationToolCfg(flags))
83 cfg.getEventAlgo("MuonSegmentFittingAlg").VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags,
84 CanvasPreFix="SegmentPlotValid", outSubDir="SegmentValidPlots",
85 displayTruthOnly = True, saveSinglePDFs = False, saveSummaryPDF= True))
86
87 cfg.getEventAlgo("MuonNswSegmentFinderAlg").VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags,
88 CanvasPreFix="NswSegmentFitPlotValid", outSubDir="SegmentValidPlots",
89 doPhiBucketViews = False, saveSinglePDFs = False,
90 saveSummaryPDF= True,CanvasLimits=10000))
91
92
93
94#
95
96
97 executeTest(cfg)
MsTrackVisualizationToolCfg(flags, name="VisualizationTool", **kwargs)
MsTrackTesterCfg(flags, name="MsTrackTester", scheduleLegacy=True, **kwargs)