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 parser.add_argument('--evtNumber',default=None,nargs="+",type=int,help="specify to select an evtNumber")
57
58 parser.set_defaults(outRootFile="FastRecoTester.root")
59 from MuonGeoModelTestR4.testGeoModel import MuonPhaseIITestDefaults
60 parser.set_defaults(inputFile = MuonPhaseIITestDefaults.HITS_PG_R3)
61 parser.set_defaults(eventPrintoutLevel = 50)
62
63 args = parser.parse_args()
64 from AthenaConfiguration.AllConfigFlags import initConfigFlags
65 flags = initConfigFlags()
66 flags.PerfMon.doFullMonMT = not args.noPerfMon
67 flags.PerfMon.OutputJSON="perfmonmt_MuonR4FastReco.json"
68 flags.PerfMon.VTune.ProfiledAlgs = ["MuonFastReconstructionAlg"]
69
70 flags, cfg = setupGeoR4TestCfg(args,flags)
71
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.runHoughTest or args.runMSTrackTest:
93 if args.useFastRecoSpacePoints:
94 cfg.merge(PatternRecognitionFromFastRecoCfg(flags))
95 else:
96 from MuonPatternRecognitionAlgs.MuonPatternRecognitionConfig import MuonPatternRecognitionCfg
97 cfg.merge(MuonPatternRecognitionCfg(flags))
98
99 # If desired, schedule the hough transform test
100 if args.runHoughTest:
101 cfg.merge(setupHistSvcCfg(flags,outFile="HoughTransformTester.root",
102 outStream="MuonEtaHoughTransformTest"))
103 from MuonPatternRecognitionTest.PatternTestConfig import MuonHoughTransformTesterCfg, PatternVisualizationToolCfg
104 cfg.merge(MuonHoughTransformTesterCfg(flags,
105 name = "MuonHoughTransformTester",
106 writeSpacePoints = False,
107 VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags, CanvasLimits =0))))
108
109 # If desired, schedule the MS Track Finding test
110 if args.runMSTrackTest:
111 cfg.merge(setupHistSvcCfg(flags,outFile="MsTrackTester.root",
112 outStream="MuonTrackTester"))
113 from MuonTrackFindingAlgs.TrackFindingConfig import MSTrackFinderAlgCfg
114 cfg.merge(MSTrackFinderAlgCfg(flags))
115 from MuonTrackFindingTest.MsTrackFindingTester import MsTrackTesterCfg
116 cfg.merge(MsTrackTesterCfg(flags, LegacyTrackKey="", LegacyMuonKey="", LegacySegmentKey=""))
117
118
119 if flags.Input.isMC:
120
123 from IOVDbSvc.IOVDbSvcConfig import addOverride
124 cfg.merge(addOverride(flags, "/MDT/TWINMAPPING", "MDTTwinMapping_compactFormat_Run123"))
125
126 if not args.noMonitorPlots:
127 cfg.getEventAlgo("MuonFastReconstructionAlg").VisualizationTool = cfg.popToolsAndMerge(FastRecoVisualizationToolCfg(flags,
128 CanvasPreFix="FastRecoValid",
129 doPhiBucketViews = False,
130 doEtaBucketViews = False,
131 doRZBucketViews = True,
132 paintTruthSegment = False,
133 outSubDir="FastReconstructionValidPlots",
134 displayTruthOnly = False,
135 saveSinglePDFs = True))
136
137 if args.evtNumber is not None:
138 mainSeq = "AthAllAlgSeq"
139 topSeq = cfg.getSequence("AthAlgEvtSeq")
140 algSeq = cfg.getSequence(mainSeq)
141 mainSeq = "New" + mainSeq
142 # topSeq has three sub-sequencers ... preserve first and last
143 topSeq.Members = [topSeq.Members[0],
144 CompFactory.AthSequencer(mainSeq, Sequential=True, ModeOR=False, StopOverride=False),
145 topSeq.Members[-1]]
146 cfg.addEventAlgo(CompFactory.EventNumberFilterAlgorithm("EvtNumberFilter",EventNumbers=args.evtNumber),sequenceName=mainSeq)
147 cfg.getSequence(mainSeq).Members += [algSeq]
148
149 cfg.getService("MessageSvc").setVerbose = ["MuonFastReconstructionAlg", "MuonFastRecoTester"]
150
151 executeTest(cfg)
MuonFastRecoTesterCfg(flags, name="MuonFastRecoTester", **kwargs)
FastRecoVisualizationToolCfg(flags, name="FastRecoVisualizationTool", **kwargs)