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,
7 outFile="MsTrkTester.root", **kwargs):
8 result = ComponentAccumulator()
9 kwargs.setdefault("isMC", flags.Input.isMC)
10 from MuonConfig.MuonConfigUtils import setupHistSvcCfg
11
12 result.merge(setupHistSvcCfg(flags, outFile=outFile,
13 outStream="MuonTrackTester"))
14
15 from MuonTrackFindingAlgs.TrackFindingConfig import SegmentSelectorCfg, TrackSummaryToolCfg, MsTrackSeedingToolCfg
16 kwargs.setdefault("SegmentSelectionTool", result.popToolsAndMerge(SegmentSelectorCfg(flags)))
17 kwargs.setdefault("SummaryTool", result.popToolsAndMerge(TrackSummaryToolCfg(flags)))
18 kwargs.setdefault("SeedingTool", result.popToolsAndMerge(MsTrackSeedingToolCfg(flags)))
19 if not scheduleLegacy:
20 kwargs.setdefault("LegacySegmentKey", "")
21 kwargs.setdefault("LegacyTrackKey", "")
22 kwargs.setdefault("LegacyMuonKey" , "")
23 the_alg = CompFactory.MuonValR4.MsTrackTester(name= name, **kwargs)
24 result.addEventAlgo(the_alg, primary = True)
25 return result
26
27def MsTrackVisualizationToolCfg(flags, name = "VisualizationTool", **kwargs):
28 result = ComponentAccumulator()
29 if not flags.Input.isMC:
30 from MuonPatternRecognitionTest.PatternTestConfig import LegacyMuonRecoChainCfg
31 result.merge(LegacyMuonRecoChainCfg(flags))
32 kwargs.setdefault("TruthSegkey", "MuonSegments")
33 from ActsConfig.ActsGeometryConfig import ActsExtrapolationToolCfg
34 kwargs.setdefault("ExtrapolationTool", result.popToolsAndMerge(ActsExtrapolationToolCfg(flags, MaxSteps=10000)))
35 from MuonTrackFindingAlgs.TrackFindingConfig import MsTrackSeedingToolCfg
36 kwargs.setdefault("SeedingTool", result.popToolsAndMerge(MsTrackSeedingToolCfg(flags)))
37
38 the_tool = CompFactory.MuonValR4.TrackVisualizationTool(name, **kwargs)
39 result.setPrivateTools(the_tool)
40 return result
41
42if __name__=="__main__":
43 from MuonGeoModelTestR4.testGeoModel import setupGeoR4TestCfg, SetupArgParser, MuonPhaseIITestDefaults
44 from MuonConfig.MuonConfigUtils import executeTest, setupHistSvcCfg
45 parser = SetupArgParser()
46 parser.add_argument("--noMonitorPlots", help="If set to true, there're no monitoring plots", default = False,
47 action='store_true')
48 parser.add_argument("--writeSpacePoints", help="If set to true, the spacepoints in the bucket are saved to disk",
49 default=False, action='store_true')
50 parser.add_argument("--noPerfMon", help="If set to true, disable performance monitoring.",
51 default=False, action='store_true')
52 parser.add_argument("--noLegacyChain", help="If set to true, the legacy chain is not scheduled",
53 default = False, action = 'store_true')
54 parser.set_defaults(nEvents = -1)
55
56 parser.set_defaults(outRootFile="MsTrkTester.root")
57 parser.set_defaults(inputFile=MuonPhaseIITestDefaults.RDO_R3)
58
59 args = parser.parse_args()
60 from AthenaConfiguration.AllConfigFlags import initConfigFlags
61 flags = initConfigFlags()
62 flags.PerfMon.doFullMonMT = not args.noPerfMon
63 flags.Trigger.Muon.useNewRegionSelector = False
64 flags.Muon.scheduleActsReco = True
65 flags.Muon.includePileUpTruth = True
66
67 from ActsConfig.ActsConfigFlags import TrackFitterType
68 if False: flags.Muon.TrackFitterType = TrackFitterType.KalmanFitter
69 if False: flags.Muon.trackGeometryMaterialMap = MuonPhaseIITestDefaults.TRKGEO_MATERIALMAP
70
71 flags, cfg = setupGeoR4TestCfg(args,flags)
72
73 cfg.getService("MessageSvc").setVerbose= []
74
75
76 from MuonConfig.ReconstructionConfigR4 import MuonReconstructionConfig
77 cfg.merge(MuonReconstructionConfig(flags))
78
79
80
81 from MuonPatternRecognitionTest.PatternTestConfig import LegacyMuonRecoChainCfg
82
83 if not args.noLegacyChain:
84 cfg.merge(LegacyMuonRecoChainCfg(flags))
85
86 cfg.merge(MsTrackTesterCfg(flags, scheduleLegacy = not args.noLegacyChain,
87 outFile = args.outRootFile))
88
89 cfg.merge(setupHistSvcCfg(flags,outFile=args.outRootFile,
90 outStream="MuonEtaHoughTransformTest"))
91
92 from MuonPatternRecognitionTest.PatternTestConfig import MuonHoughTransformTesterCfg, PatternVisualizationToolCfg
93
94
95 cfg.merge(MuonHoughTransformTesterCfg(flags,
96 VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags, CanvasLimits =0))))
97
98
99 if not args.noMonitorPlots:
100 cfg.getEventAlgo("MSTrackFinderAlg").VisualizationTool = cfg.popToolsAndMerge(MsTrackVisualizationToolCfg(flags))
101 cfg.getEventAlgo("MuonSegmentFittingAlg").VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags,
102 CanvasPreFix="SegmentPlotValid", outSubDir="SegmentValidPlots",
103 displayTruthOnly = True, saveSinglePDFs = False, saveSummaryPDF= True))
104
105 cfg.getEventAlgo("MuonNswSegmentFinderAlg").VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags,
106 CanvasPreFix="NswSegmentFitPlotValid", outSubDir="SegmentValidPlots",
107 doPhiBucketViews = False, saveSinglePDFs = False,
108 saveSummaryPDF= True,CanvasLimits=10000))
109
110
111
112#
113
114
115 executeTest(cfg)
MsTrackVisualizationToolCfg(flags, name="VisualizationTool", **kwargs)
MsTrackTesterCfg(flags, name="MsTrackTester", scheduleLegacy=True, outFile="MsTrkTester.root", **kwargs)