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", outFile="FastRecoTester.root", **kwargs):
20 result = ComponentAccumulator()
21
22 cfg.merge(setupHistSvcCfg(flags,outFile=outFile,
23 outStream="FastRecoTester"))
24
25 kwargs.setdefault("isMC", flags.Input.isMC)
26 kwargs.setdefault("isSeededReco", flags.Trigger.doHLT)
27
28 if not flags.Input.isMC:
29 kwargs.setdefault("TruthSegmentKey", "")
30
31 if flags.Detector.GeometryMDT or flags.Detector.GeometryRPC or flags.Detector.GeometryTGC:
32 kwargs.setdefault("SpacePointKey", "MuonSpacePoints")
33 else:
34 kwargs.setdefault("SpacePointKey", "")
35 if flags.Detector.GeometryMM or flags.Detector.GeometrysTGC:
36 kwargs.setdefault("NswSpacePointKey", "NswSpacePoints")
37 else:
38 kwargs.setdefault("NswSpacePointKey", "")
39
40 theAlg = CompFactory.MuonValR4.MuonFastRecoTester(name, **kwargs)
41 result.addEventAlgo(theAlg, primary=True)
42 return result
43
44if __name__=="__main__":
45 from MuonGeoModelTestR4.testGeoModel import setupGeoR4TestCfg, SetupArgParser
46 from MuonConfig.MuonConfigUtils import executeTest,setupHistSvcCfg
47 parser = SetupArgParser()
48 parser.set_defaults(nEvents = -1)
49 parser.add_argument("--noPerfMon", help="If set to true, full perfmonMT is enabled",
50 default=False, action='store_true')
51 parser.add_argument("--writeSpacePoints", help="If set to true, the spacepoints in the bucket are saved to disk",
52 default=False, action='store_true')
53 parser.add_argument("--noMonitorPlots", help="If set to true, there're no monitoring plots", default = False,
54 action='store_true')
55 parser.add_argument("--runHoughTest", help="If set to true, the hough transform test is run on the output of the fast reco alg",
56 default=False, action='store_true')
57 parser.add_argument("--runMSTrackTest", help="If set to true, the MS Track Finding test is run on the output of the fast reco alg",
58 default=False, action='store_true')
59 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",
60 default=False, action='store_true')
61 parser.add_argument("--vTune", help="If set to true, the code is profiled with VTune (With the proper command!)",
62 default=False, action='store_true')
63 parser.add_argument('--evtNumber',default=None,nargs="+",type=int,help="specify to select an evtNumber")
64
65 parser.set_defaults(outRootFile="FastRecoTester.root")
66 from MuonGeoModelTestR4.testGeoModel import MuonPhaseIITestDefaults
67 parser.set_defaults(inputFile = MuonPhaseIITestDefaults.RDO_R3)
68 parser.set_defaults(eventPrintoutLevel = 50)
69
70 args = parser.parse_args()
71 from AthenaConfiguration.AllConfigFlags import initConfigFlags
72 flags = initConfigFlags()
73 flags.PerfMon.doFullMonMT = not args.noPerfMon
74 flags.PerfMon.OutputJSON="perfmonmt_MuonR4FastReco.json"
75 flags.PerfMon.VTune.ProfiledAlgs = ["MuonFastReconstructionAlg"]
76
77 flags, cfg = setupGeoR4TestCfg(args,flags)
78
79 if args.vTune:
80 from PerfMonVTune.PerfMonVTuneConfig import VTuneProfilerServiceCfg
81 cfg.merge(VTuneProfilerServiceCfg(flags))
82
83 # Schedule data preparation and space point formation
84 from MuonConfig.MuonDataPrepConfig import xAODUncalibMeasPrepCfg
85 cfg.merge(xAODUncalibMeasPrepCfg(flags))
86 from MuonSpacePointFormation.SpacePointFormationConfig import MuonSpacePointFormationCfg
87 cfg.merge(MuonSpacePointFormationCfg(flags))
88
89 # Schedule fast reconstruction alg & the Fast Reco Tester Alg
90 from MuonFastRecoAlgs.MuonFastReconstructionConfig import MuonFastReconstructionAlgCfg, PatternRecognitionFromFastRecoCfg
91 cfg.merge(MuonFastReconstructionAlgCfg(flags))
92 cfg.merge(MuonFastRecoTesterCfg(flags, outFile = args.outRootFile,
93 writeSpacePoints = args.writeSpacePoints))
94
95 if args.runHoughTest or args.runMSTrackTest:
96 # Schedule pattern recognition either on space points from fast reco or from standard space point maker
97 if args.useFastRecoSpacePoints:
98 cfg.merge(PatternRecognitionFromFastRecoCfg(flags))
99 else:
100 from MuonPatternRecognitionAlgs.MuonPatternRecognitionConfig import MuonPatternRecognitionCfg
101 cfg.merge(MuonPatternRecognitionCfg(flags))
102 # Shedule truth algs
103 from MuonTruthAlgsR4.MuonTruthAlgsConfig import MuonToTruthAssocAlgCfg, MuonTruthAlgsCfg
104 cfg.merge(MuonTruthAlgsCfg(flags))
105
106 # If desired, schedule the hough transform test
107 if args.runHoughTest:
108 cfg.merge(setupHistSvcCfg(flags,outFile="HoughTransformTester.root",
109 outStream="MuonEtaHoughTransformTest"))
110 from MuonPatternRecognitionTest.PatternTestConfig import MuonHoughTransformTesterCfg, PatternVisualizationToolCfg
111 cfg.merge(MuonHoughTransformTesterCfg(flags,
112 name = "MuonHoughTransformTester",
113 writeSpacePoints = False,
114 VisualizationTool = cfg.popToolsAndMerge(PatternVisualizationToolCfg(flags, CanvasLimits =0))))
115
116 # If desired, schedule the MS Track Finding test
117 if args.runMSTrackTest:
118 from MuonTrackFindingAlgs.TrackFindingConfig import MSTrackFinderAlgCfg, MuonCreatorAlgCfg, StandaloneTrackPartCnvCfg, MuidSaTagMakerAlgCfg
119 cfg.merge(MSTrackFinderAlgCfg(flags))
120 cfg.merge(MuonCreatorAlgCfg(flags, name = "MuonActsCreatorAlg",
121 TagKeys = ["MuonTagsSA"]))
122 cfg.merge(StandaloneTrackPartCnvCfg(flags))
123 cfg.merge(MuidSaTagMakerAlgCfg(flags))
124 cfg.merge(MuonToTruthAssocAlgCfg(flags))
125 from MuonTrackFindingTest.MsTrackFindingTester import MsTrackTesterCfg
126 cfg.merge(MsTrackTesterCfg(flags, scheduleLegacy=False))
127
128
129 if flags.Input.isMC:
130
133 from IOVDbSvc.IOVDbSvcConfig import addOverride
134 cfg.merge(addOverride(flags, "/MDT/TWINMAPPING", "MDTTwinMapping_compactFormat_Run123"))
135
136 if not args.noMonitorPlots:
137 cfg.getEventAlgo("MuonFastReconstructionAlg").VisualizationTool = cfg.popToolsAndMerge(FastRecoVisualizationToolCfg(flags,
138 CanvasPreFix="FastRecoValid",
139 doPhiBucketViews = False,
140 doEtaBucketViews = False,
141 doRZBucketViews = True,
142 paintTruthSegment = False,
143 outSubDir="FastReconstructionValidPlots",
144 displayTruthOnly = False,
145 saveSinglePDFs = True))
146
147 if args.evtNumber is not None:
148 mainSeq = "AthAllAlgSeq"
149 topSeq = cfg.getSequence("AthAlgEvtSeq")
150 algSeq = cfg.getSequence(mainSeq)
151 mainSeq = "New" + mainSeq
152 # topSeq has three sub-sequencers ... preserve first and last
153 topSeq.Members = [topSeq.Members[0],
154 CompFactory.AthSequencer(mainSeq, Sequential=True, ModeOR=False, StopOverride=False),
155 topSeq.Members[-1]]
156 cfg.addEventAlgo(CompFactory.EventNumberFilterAlgorithm("EvtNumberFilter",EventNumbers=args.evtNumber),sequenceName=mainSeq)
157 cfg.getSequence(mainSeq).Members += [algSeq]
158
159 cfg.getService("MessageSvc").setVerbose = ["MuonFastReconstructionAlg", "MuonFastRecoTester"]
160
161 executeTest(cfg)
MuonFastRecoTesterCfg(flags, name="MuonFastRecoTester", outFile="FastRecoTester.root", **kwargs)
FastRecoVisualizationToolCfg(flags, name="FastRecoVisualizationTool", **kwargs)