ATLAS Offline Software
Loading...
Searching...
No Matches
MuonFastReconstructionTesterConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5
6def FastRecoVisualizationToolCfg(flags, name="FastRecoVisualizationTool", **kwargs):
7 result = ComponentAccumulator()
8 from MuonConfig.MuonDataPrepConfig import PrimaryMeasContNamesCfg
9 kwargs.setdefault("PrdContainer", PrimaryMeasContNamesCfg(flags))
10 if flags.Input.isMC:
11 from MuonObjectMarker.ObjectMarkerConfig import TruthMeasMarkerAlgCfg
12 markerAlg = result.getPrimaryAndMerge(TruthMeasMarkerAlgCfg(flags))
13 kwargs.setdefault("TruthSegDecors", [markerAlg.SegmentLinkKey])
14 kwargs["TruthSegDecors"] += [markerAlg.SegmentLinkKey]
15 the_tool = CompFactory.MuonValR4.FastRecoVisualizationTool(name, **kwargs)
16 result.setPrivateTools(the_tool)
17 return result
18
19def MuonFastRecoTesterCfg(flags, name = "MuonFastRecoTester", **kwargs):
20 result = ComponentAccumulator()
21 kwargs.setdefault("isMC", flags.Input.isMC)
22
23 if flags.Detector.GeometryMDT or flags.Detector.GeometryRPC or flags.Detector.GeometryTGC:
24 kwargs.setdefault("SpacePointKey", "MuonSpacePoints")
25 else:
26 kwargs.setdefault("SpacePointKey", "")
27 if flags.Detector.GeometryMM or flags.Detector.GeometrysTGC:
28 kwargs.setdefault("NswSpacePointKey", "NswSpacePoints")
29 else:
30 kwargs.setdefault("NswSpacePointKey", "")
31
32 theAlg = CompFactory.MuonValR4.MuonFastRecoTester(name, **kwargs)
33 result.addEventAlgo(theAlg, primary=True)
34 return result
35
36if __name__=="__main__":
37 from MuonGeoModelTestR4.testGeoModel import setupGeoR4TestCfg, SetupArgParser
38 from MuonConfig.MuonConfigUtils import executeTest,setupHistSvcCfg
39 parser = SetupArgParser()
40 parser.set_defaults(nEvents = -1)
41 parser.add_argument("--noPerfMon", help="If set to true, full perfmonMT is enabled",
42 default=False, action='store_true')
43 parser.add_argument("--writeSpacePoints", help="If set to true, the spacepoints in the bucket are saved to disk",
44 default=False, action='store_true')
45 parser.add_argument("--noMonitorPlots", help="If set to true, there're no monitoring plots", default = False,
46 action='store_true')
47 parser.add_argument("--runHoughTest", help="If set to true, the hough transform test is run on the output of the fast reco alg",
48 default=False, action='store_true')
49 parser.add_argument("--runMSTrackTest", help="If set to true, the MS Track Finding test is run on the output of the fast reco alg",
50 default=False, action='store_true')
51 parser.add_argument("--useFastRecoSpacePoints", help="If set to true, we run the pattern recognition chain on the space points from the fast reco instead of spacepointMaker",
52 default=False, action='store_true')
53 parser.add_argument("--vTune", help="If set to true, the code is profiled with VTune (With the proper command!)",
54 default=False, action='store_true')
55 parser.set_defaults(outRootFile="FastRecoTester.root")
56 from MuonGeoModelTestR4.testGeoModel import MuonPhaseIITestDefaults
57 parser.set_defaults(inputFile = MuonPhaseIITestDefaults.HITS_PG_R3)
58 parser.set_defaults(eventPrintoutLevel = 50)
59
60 args = parser.parse_args()
61 from AthenaConfiguration.AllConfigFlags import initConfigFlags
62 flags = initConfigFlags()
63 flags.PerfMon.doFullMonMT = not args.noPerfMon
64 flags.PerfMon.OutputJSON="perfmonmt_MuonR4FastReco.json"
65 flags.PerfMon.VTune.ProfiledAlgs = ["MuonFastReconstructionAlg"]
66
67 flags, cfg = setupGeoR4TestCfg(args,flags)
68
69 #cfg.getService("MessageSvc").setVerbose = ["MuonFastReconstructionAlg"]
70 if args.vTune:
71 from PerfMonVTune.PerfMonVTuneConfig import VTuneProfilerServiceCfg
72 cfg.merge(VTuneProfilerServiceCfg(flags))
73
74 # Schedule data preparation and space point formation
75 from MuonConfig.MuonDataPrepConfig import xAODUncalibMeasPrepCfg
76 cfg.merge(xAODUncalibMeasPrepCfg(flags))
77 from MuonSpacePointFormation.SpacePointFormationConfig import MuonSpacePointFormationCfg
78 cfg.merge(MuonSpacePointFormationCfg(flags))
79
80 # Schedule fast reconstruction alg & the Fast Reco Tester Alg
81 from MuonFastRecoAlgs.MuonFastReconstructionConfig import MuonFastReconstructionAlgCfg, PatternRecognitionFromFastRecoCfg
82 cfg.merge(MuonFastReconstructionAlgCfg(flags))
83 cfg.merge(setupHistSvcCfg(flags,outFile=args.outRootFile,
84 outStream="FastRecoTester"))
85 cfg.merge(MuonFastRecoTesterCfg(flags,
86 name = "MuonFastRecoTester",
87 writeSpacePoints = args.writeSpacePoints))
88
89 # Schedule the pattern recognition algs either on the space points from the fast reco or from the standard space point maker
90 if args.useFastRecoSpacePoints:
91 cfg.merge(PatternRecognitionFromFastRecoCfg(flags))
92 else:
93 from MuonPatternRecognitionAlgs.MuonPatternRecognitionConfig import MuonPatternRecognitionCfg
94 cfg.merge(MuonPatternRecognitionCfg(flags))
95
96 # If desired, schedule the hough transform test
97 if args.runHoughTest:
98 cfg.merge(setupHistSvcCfg(flags,outFile="HoughTransformTester.root",
99 outStream="MuonEtaHoughTransformTest"))
100 from MuonPatternRecognitionTest.PatternTestConfig import MuonHoughTransformTesterCfg, PatternVisualizationToolCfg
101 cfg.merge(MuonHoughTransformTesterCfg(flags,
102 name = "MuonHoughTransformTester",
103 SpacePointKey = "MuonSpacePointsFastReco" if args.useFastRecoSpacePoints else "MuonSpacePoints",
104 writeSpacePoints = False,
105 VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags, CanvasLimits =0))))
106
107 # If desired, schedule the MS Track Finding test
108 if args.runMSTrackTest:
109 cfg.merge(setupHistSvcCfg(flags,outFile="MsTrackTester.root",
110 outStream="MuonTrackTester"))
111 from MuonTrackFindingAlgs.TrackFindingConfig import MSTrackFinderAlgCfg
112 cfg.merge(MSTrackFinderAlgCfg(flags))
113 from MuonTrackFindingTest.MsTrackFindingTester import MsTrackTesterCfg
114 cfg.merge(MsTrackTesterCfg(flags, LegacyTrackKey="", LegacyMuonKey="", LegacySegmentKey=""))
115
116
117 if flags.Input.isMC:
118
121 from IOVDbSvc.IOVDbSvcConfig import addOverride
122 cfg.merge(addOverride(flags, "/MDT/TWINMAPPING", "MDTTwinMapping_compactFormat_Run123"))
123
124 if not args.noMonitorPlots:
125 cfg.getEventAlgo("MuonFastReconstructionAlg").VisualizationTool = cfg.popToolsAndMerge(FastRecoVisualizationToolCfg(flags,
126 CanvasPreFix="FastRecoValid",
127 doPhiBucketViews = False,
128 doEtaBucketViews = False,
129 doRZBucketViews = True,
130 paintTruthSegment = False,
131 outSubDir="FastReconstructionValidPlots",
132 displayTruthOnly = False,
133 saveSinglePDFs = True))
134 executeTest(cfg)
MuonFastRecoTesterCfg(flags, name="MuonFastRecoTester", **kwargs)
FastRecoVisualizationToolCfg(flags, name="FastRecoVisualizationTool", **kwargs)