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.Muon.setupTruthAlgorithms:
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 kwargs.setdefault("isSeededReco", flags.Trigger.doHLT)
23
24 if flags.Detector.GeometryMDT or flags.Detector.GeometryRPC or flags.Detector.GeometryTGC:
25 kwargs.setdefault("SpacePointKey", "MuonSpacePoints")
26 else:
27 kwargs.setdefault("SpacePointKey", "")
28 if flags.Detector.GeometryMM or flags.Detector.GeometrysTGC:
29 kwargs.setdefault("NswSpacePointKey", "NswSpacePoints")
30 else:
31 kwargs.setdefault("NswSpacePointKey", "")
32
33 theAlg = CompFactory.MuonValR4.MuonFastRecoTester(name, **kwargs)
34 result.addEventAlgo(theAlg, primary=True)
35 return result
36
37if __name__=="__main__":
38 from MuonGeoModelTestR4.testGeoModel import setupGeoR4TestCfg, SetupArgParser
39 from MuonConfig.MuonConfigUtils import executeTest,setupHistSvcCfg
40 parser = SetupArgParser()
41 parser.set_defaults(nEvents = -1)
42 parser.add_argument("--noPerfMon", help="If set to true, full perfmonMT is enabled",
43 default=False, action='store_true')
44 parser.add_argument("--writeSpacePoints", help="If set to true, the spacepoints in the bucket are saved to disk",
45 default=False, action='store_true')
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("--runHoughTest", help="If set to true, the hough transform test is run on the output of the fast reco alg",
49 default=False, action='store_true')
50 parser.add_argument("--runMSTrackTest", help="If set to true, the MS Track Finding test is run on the output of the fast reco alg",
51 default=False, action='store_true')
52 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",
53 default=False, action='store_true')
54 parser.add_argument("--vTune", help="If set to true, the code is profiled with VTune (With the proper command!)",
55 default=False, action='store_true')
56
57 parser.set_defaults(outRootFile="FastRecoTester.root")
58 from MuonGeoModelTestR4.testGeoModel import MuonPhaseIITestDefaults
59 parser.set_defaults(inputFile = MuonPhaseIITestDefaults.HITS_PG_R3)
60 parser.set_defaults(eventPrintoutLevel = 50)
61
62 args = parser.parse_args()
63 from AthenaConfiguration.AllConfigFlags import initConfigFlags
64 flags = initConfigFlags()
65 flags.PerfMon.doFullMonMT = not args.noPerfMon
66 flags.PerfMon.OutputJSON="perfmonmt_MuonR4FastReco.json"
67 flags.PerfMon.VTune.ProfiledAlgs = ["MuonFastReconstructionAlg"]
68
69 flags, cfg = setupGeoR4TestCfg(args,flags)
70
71 #cfg.getService("MessageSvc").setVerbose = ["MuonFastReconstructionAlg", "MuonFastRecoTester"]
72 if args.vTune:
73 from PerfMonVTune.PerfMonVTuneConfig import VTuneProfilerServiceCfg
74 cfg.merge(VTuneProfilerServiceCfg(flags))
75
76 # Schedule data preparation and space point formation
77 from MuonConfig.MuonDataPrepConfig import xAODUncalibMeasPrepCfg
78 cfg.merge(xAODUncalibMeasPrepCfg(flags))
79 from MuonSpacePointFormation.SpacePointFormationConfig import MuonSpacePointFormationCfg
80 cfg.merge(MuonSpacePointFormationCfg(flags))
81
82 # Schedule fast reconstruction alg & the Fast Reco Tester Alg
83 from MuonFastRecoAlgs.MuonFastReconstructionConfig import MuonFastReconstructionAlgCfg, PatternRecognitionFromFastRecoCfg
84 cfg.merge(MuonFastReconstructionAlgCfg(flags))
85 cfg.merge(setupHistSvcCfg(flags,outFile=args.outRootFile,
86 outStream="FastRecoTester"))
87 cfg.merge(MuonFastRecoTesterCfg(flags,
88 name = "MuonFastRecoTester",
89 writeSpacePoints = args.writeSpacePoints))
90
91 # Schedule the pattern recognition algs either on the space points from the fast reco or from the standard space point maker
92 if args.useFastRecoSpacePoints:
93 cfg.merge(PatternRecognitionFromFastRecoCfg(flags))
94 else:
95 from MuonPatternRecognitionAlgs.MuonPatternRecognitionConfig import MuonPatternRecognitionCfg
96 cfg.merge(MuonPatternRecognitionCfg(flags))
97
98 # If desired, schedule the hough transform test
99 if args.runHoughTest:
100 cfg.merge(setupHistSvcCfg(flags,outFile="HoughTransformTester.root",
101 outStream="MuonEtaHoughTransformTest"))
102 from MuonPatternRecognitionTest.PatternTestConfig import MuonHoughTransformTesterCfg, PatternVisualizationToolCfg
103 cfg.merge(MuonHoughTransformTesterCfg(flags,
104 name = "MuonHoughTransformTester",
105 writeSpacePoints = False,
106 VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags, CanvasLimits =0))))
107
108 # If desired, schedule the MS Track Finding test
109 if args.runMSTrackTest:
110 cfg.merge(setupHistSvcCfg(flags,outFile="MsTrackTester.root",
111 outStream="MuonTrackTester"))
112 from MuonTrackFindingAlgs.TrackFindingConfig import MSTrackFinderAlgCfg
113 cfg.merge(MSTrackFinderAlgCfg(flags))
114 from MuonTrackFindingTest.MsTrackFindingTester import MsTrackTesterCfg
115 cfg.merge(MsTrackTesterCfg(flags, LegacyTrackKey="", LegacyMuonKey="", LegacySegmentKey=""))
116
117
118 if flags.Input.isMC:
119
122 from IOVDbSvc.IOVDbSvcConfig import addOverride
123 cfg.merge(addOverride(flags, "/MDT/TWINMAPPING", "MDTTwinMapping_compactFormat_Run123"))
124
125 if not args.noMonitorPlots:
126 cfg.getEventAlgo("MuonFastReconstructionAlg").VisualizationTool = cfg.popToolsAndMerge(FastRecoVisualizationToolCfg(flags,
127 CanvasPreFix="FastRecoValid",
128 doPhiBucketViews = False,
129 doEtaBucketViews = False,
130 doRZBucketViews = True,
131 paintTruthSegment = False,
132 outSubDir="FastReconstructionValidPlots",
133 displayTruthOnly = False,
134 saveSinglePDFs = True))
135 executeTest(cfg)
MuonFastRecoTesterCfg(flags, name="MuonFastRecoTester", **kwargs)
FastRecoVisualizationToolCfg(flags, name="FastRecoVisualizationTool", **kwargs)