10 from AthenaConfiguration.ComponentFactory
import CompFactory
11 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
12 from AthenaConfiguration.Enums
import BeamType, Format
15 from TrkConfig.TrkGlobalChi2FitterConfig
import MCTBFitterCfg, MCTBSLFitterCfg, MCTBSLFitterMaterialFromTrackCfg
16 from MuonConfig.MuonRecToolsConfig
import MuonAmbiProcessorCfg, MuonTrackCleanerCfg, MuonEDMPrinterToolCfg
17 from MuonConfig.MuonCondAlgConfig
import MuonStationIntersectCondAlgCfg
18 from TrkConfig.AtlasExtrapolatorConfig
import MuonStraightLineExtrapolatorCfg
19 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MdtCalibWindowNumber
24 kwargs.setdefault(
"UseTightAssociation",flags.Beam.Type
is BeamType.Collisions)
25 kwargs.setdefault(
"UseCosmics", flags.Beam.Type
is not BeamType.Collisions )
26 the_tool = CompFactory.MuonCombinePatternTool(name,**kwargs)
27 result.setPrivateTools(the_tool)
32 if flags.Beam.Type
is not BeamType.Collisions:
33 kwargs.setdefault(
"UseCosmics",
True)
34 kwargs.setdefault(
"NumberOfMaximaPerIterations", 1)
35 the_tool = CompFactory.MuonHoughPatternTool(name,**kwargs)
36 result.setPrivateTools(the_tool)
40 if flags.Beam.Type
is BeamType.Collisions:
41 kwargs.setdefault(
"MDT_TDC_cut",
False)
42 kwargs.setdefault(
"RecordAll",
False)
45 kwargs.setdefault(
"DoSummary", flags.Muon.printSummary)
46 the_tool = CompFactory.Muon.MuonHoughPatternFinderTool(name,**kwargs)
47 result.setPrivateTools(the_tool)
51 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MuonClusterOnTrackCreatorCfg
52 kwargs.setdefault(
"TimingMode", 3)
53 kwargs.setdefault(
"DoTofCorrection",
True)
60 if flags.Beam.Type
is BeamType.Cosmics:
61 kwargs.setdefault(
"DoTof", 0)
63 kwargs.setdefault(
"DoTof", 1)
65 AdjT0__AdjustableT0Tool=CompFactory.getComp(
"AdjT0::AdjustableT0Tool")
66 return AdjT0__AdjustableT0Tool(**kwargs)
73 doSegmentT0Fit = kwargs.pop(
'doSegmentT0Fit', flags.Muon.doSegmentT0Fit)
75 kwargs.setdefault(
"FinderDebugLevel", 0)
77 if doSegmentT0Fit
and not (flags.Muon.MuonTrigger
and flags.Beam.Type
in [BeamType.SingleBeam, BeamType.Cosmics]):
78 kwargs.setdefault(
"AssociationRoadWidth", 3.)
79 kwargs.setdefault(
"MDTAssocationPullcut", 3.)
80 kwargs.setdefault(
"RecoverMdtOutliers",
False)
83 if flags.Beam.Type
in [BeamType.SingleBeam, BeamType.Cosmics]
or flags.Input.isMC
is False:
84 kwargs.setdefault(
"AssociationRoadWidth", 2.)
85 kwargs.setdefault(
"MDTAssocationPullcut", 4.)
86 kwargs.setdefault(
"RecoverMdtOutliers",
True )
89 if flags.Muon.enableCurvedSegmentFinding:
90 kwargs.setdefault(
"DoCurvedSegmentFinder",
True)
91 result.setPrivateTools(CompFactory.Muon.MdtMathSegmentFinder(name=name,**kwargs))
95 from TrkConfig.TrkExRungeKuttaPropagatorConfig
import RungeKuttaPropagatorCfg
97 kwargs.setdefault(
"SLPropagator",
98 result.popPrivateTools())
99 kwargs.setdefault(
"SLFitter",
101 kwargs.setdefault(
"CurvedFitter",
105 result.setPrivateTools(CompFactory.Muon.MuonSegmentFittingTool(name,**kwargs))
110 kwargs.setdefault(
"FloatSegDirection", flags.Beam.Type
is BeamType.Cosmics)
111 result.setPrivateTools(CompFactory.TrkDriftCircleMath.MdtSegmentT0Fitter(name, **kwargs))
115 name='DCMathSegmentMaker',
116 doSegmentT0Fit=False,
119 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MdtDriftCircleOnTrackCreatorCfg, TriggerChamberClusterOnTrackCreatorCfg, MdtCalibToolForRotsCfg
120 from MuonCombinedConfig.MuonCombinedRecToolsConfig
import MuonSegmentSelectionToolCfg
137 from MuonConfig.MuonRecToolsConfig
import MuonEDMHelperSvcCfg
139 kwargs.setdefault(
"RefitSegment",
True)
140 kwargs.setdefault(
"AssumePointingPhi", flags.Beam.Type
is not BeamType.Cosmics)
141 kwargs.setdefault(
"OutputFittedT0",
True)
145 kwargs.setdefault(
"UsePreciseError",
True)
146 kwargs.setdefault(
"SinAngleCut", 0.4)
148 doSegmentT0Fit = doSegmentT0Fit
or flags.Beam.Type
in [BeamType.SingleBeam, BeamType.Cosmics]
149 if flags.Beam.Type
in [BeamType.SingleBeam, BeamType.Cosmics]:
150 kwargs.setdefault(
"SinAngleCut", 0.9)
151 kwargs.setdefault(
"AddUnassociatedPhiHits",
True)
152 kwargs.setdefault(
"RecoverBadRpcCabling",
True)
153 kwargs.setdefault(
"CurvedErrorScaling",
False)
154 elif not flags.Input.isMC:
155 kwargs.setdefault(
"AddUnassociatedPhiHits",
True)
156 kwargs.setdefault(
"RecoverBadRpcCabling",
True)
158 if flags.Muon.updateSegmentSecondCoordinate:
159 kwargs.setdefault(
"UpdatePhiUsingPhiHits",
True)
161 if flags.Muon.enableCurvedSegmentFinding:
162 kwargs.setdefault(
"CurvedErrorScaling",
False)
163 kwargs.setdefault(
"PreciseErrorScale", 1)
164 kwargs.setdefault(
"UsePreciseError",
True)
174 kwargs.setdefault(
"EDMPrinter", edm_printer )
177 name=
"MdtDriftCircleOnTrackCreatorAdjustableT0",
180 DoTofCorrection=
True,
182 kwargs.setdefault(
"MdtCreatorT0", result.getPrimaryAndMerge(mdt_dcot_CA))
183 kwargs.setdefault(
"MdtSegmentFinder", result.getPrimaryAndMerge(
MdtMathSegmentFinderCfg(flags, name=
'MdtMathT0FitSegmentFinder', doSegmentT0Fit=
True)))
185 kwargs.setdefault(
"MdtCreatorT0",
"")
188 kwargs.setdefault(
"SegmentFitter", result.getPrimaryAndMerge(
MuonSegmentFittingToolCfg(flags, name=
"MuonSegmentFittingTool")))
192 dc_segment_maker = CompFactory.Muon.DCMathSegmentMaker(name=name, **kwargs)
193 result.setPrivateTools(dc_segment_maker)
199 CscAlignmentTool=CompFactory.CscAlignmentTool
200 etaposAlignConsts = [
201 0.0, -0.0902347, -0.0984321, -0.141175,
202 0.0, -0.166412, -0.150399, -0.18592,
203 0.0, -0.0544449, 0.101448, -0.0433321,
204 0.0, -0.047769, -0.156247, -0.0854826,
205 0.0, -0.0970101, -0.227578, -0.301079,
206 0.0, -0.152912, -0.365218, -0.314042,
207 0.0, 0.0338696, -0.264766, -0.224567,
208 0.0, -0.107372, -0.16099, -0.13508,
209 0.0, -0.0663979, -0.0312645, -0.130711,
210 0.0, -0.249974, -0.269372, -0.353648,
211 0.0, -0.194175, 0.0238348, -0.188433,
212 0.0, 0.0977346, 0.0492461, 0.150434,
213 0.0, 0.0444637, -0.0871214, -0.0627541,
214 0.0, 0.0347245, -0.0226186, -0.0826478,
215 0.0, -0.00408879, -0.0638005, -0.206868,
216 0.0, 0.0331328, 0.0402103, 0.118611,
217 0.0, -0.0634537, -0.0516743, 0.0045364,
218 0.0, -0.0957718, -0.235246, -0.439811,
219 0.0, -0.163504, -0.0129115, 0.00140143,
220 0.0, -0.182903, -0.0503858, -0.207799,
221 0.0, -0.0970927, 0, 0.124744,
222 0.0, -0.0169602, -0.0527447, 0.0319154,
223 0.0, -0.176499, -0.196542, -0.0846979,
224 0.0, 0.0589994, 0.0131431, 0.0461769,
225 0.0, -0.0237507, -0.0307316, 0.144429,
226 0.0, -0.0144483, -0.0328234, -0.00553684,
227 0.0, 0.113188, -0.176182, 0.0635706,
228 0.0, -0.109776, -0.727705, -0.756824,
229 0.0, -0.0553061, -0.056162, -0.0336955,
230 0.0, -0.070077, -0.127203, -0.140082,
231 0.0, -0.0844368, -0.0735331, -0.016667,
232 0.0, 0.0426443, -0.153659, -0.129711,
235 phiposAlignConsts = [
269 kwargs.setdefault(
"phiposAlignConsts", phiposAlignConsts)
270 kwargs.setdefault(
"etaposAlignConsts", etaposAlignConsts)
271 kwargs.setdefault(
"useAlignment", flags.Input.isMC
is False and flags.Muon.Align.UseILines
is False )
278 QratCscClusterFitter=CompFactory.QratCscClusterFitter
281 0.000000, 0.000000, 0.000000, 0.000000, 0.0699381, 0.178291, 0.271303, 0.345611,
282 0.400738, 0.452451, 0.493772, 0.526792, 0.553845, 0.580111, 0.603337, 0.624749,
283 0.646065, 0.663924, 0.681897, 0.701345, 0.716067, 0.730324, 0.743168, 0.760598,
284 0.773341, 0.786406, 0.798358, 0.811339, 0.820949, 0.832676, 0.843917, 0.85412,
285 0.863914, 0.873229, 0.88251, 0.892856, 0.903296, 0.910067, 0.917892, 0.928028,
286 0.93461, 0.943679, 0.951617, 0.958326, 0.964428, 0.97341, 0.978204, 0.987075,
290 0.000000, 0.000000, 0.000000, 0.000000, 0.0290177, 0.0834867, 0.188683, 0.269967,
291 0.334887, 0.393036, 0.440317, 0.481884, 0.51725, 0.545107, 0.56959, 0.592327,
292 0.614087, 0.635344, 0.655252, 0.672766, 0.690929, 0.707293, 0.722742, 0.738323,
293 0.753562, 0.76749, 0.780983, 0.79354, 0.806521, 0.818085, 0.829987, 0.841443,
294 0.853723, 0.863393, 0.87431, 0.883139, 0.892962, 0.902803, 0.911276, 0.921417,
295 0.929387, 0.938106, 0.947072, 0.954406, 0.961692, 0.97055, 0.978517, 0.985133,
298 kwargs.setdefault(
"qratcor_csl_eta",qratcor_csl_eta)
299 kwargs.setdefault(
"qratcor_css_eta",qratcor_css_eta)
301 kwargs.setdefault(
"CscAlignmentTool", csc_align_tool )
307 CalibCscStripFitter=CompFactory.CalibCscStripFitter
308 from MuonConfig.MuonCalibrationConfig
import CscCalibToolCfg
310 kwargs.setdefault(
"cscCalibTool", result.popPrivateTools() )
315 CscClusterUtilTool=CompFactory.CscClusterUtilTool
318 kwargs.setdefault(
"strip_fitter", result.popPrivateTools() )
321 kwargs.setdefault(
"precision_fitter", acc.popPrivateTools() )
327 CscSegmentUtilTool=CompFactory.CscSegmentUtilTool
328 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import CscClusterOnTrackCreatorCfg
331 csc_cluster_creator = result.popPrivateTools()
332 kwargs.setdefault(
"rot_creator", csc_cluster_creator )
338 Csc2dSegmentMaker=CompFactory.Csc2dSegmentMaker
340 if 'segmentTool' not in kwargs:
342 csc_segment_util_tool = acc.getPrimary()
343 result.addPublicTool(csc_segment_util_tool)
344 kwargs.setdefault(
'segmentTool', csc_segment_util_tool)
350 result.setPrivateTools(csc_segment_maker)
357 kwargs.setdefault(
"segmentTool", result.getPrimary() )
359 result.setPrivateTools(CompFactory.Csc4dSegmentMaker(name=name, **kwargs))
364 from MuonConfig.MuonRecToolsConfig
import MuonTrackToSegmentToolCfg
365 from TrkConfig.TrkTrackSummaryToolConfig
import MuonTrackSummaryToolCfg
367 kwargs.setdefault(
"IPConstraint", flags.Beam.Type
is BeamType.Collisions)
368 kwargs.setdefault(
'SegmentAmbiguityTool', result.popToolsAndMerge(
MuonAmbiProcessorCfg(flags) ) )
372 if flags.Beam.Type
is not BeamType.Collisions:
373 kwargs.setdefault(
"MmOccupancyBinWidth", 2048)
375 kwargs.setdefault(
'TrackCleaner', result.popToolsAndMerge(
MuonTrackCleanerCfg(flags, name=
'MuonTrackCleaner_seg',seg=
True) ) )
376 kwargs.setdefault(
'TrackSummaryTool', result.popToolsAndMerge(
MuonTrackSummaryToolCfg(flags, name=
'MuonTrackSummary') ) )
378 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MuonClusterOnTrackCreatorCfg
381 result.setPrivateTools(CompFactory.Muon.MuonNSWSegmentFinderTool(name,**kwargs))
385 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MuonClusterOnTrackCreatorCfg, MdtDriftCircleOnTrackCreatorCfg
391 the_tool = CompFactory.Muon.MuonPRDSelectionTool(name, **kwargs)
392 result.setPrivateTools(the_tool)
398 layer_hough_tool = CompFactory.Muon.MuonLayerHoughTool(name, **kwargs)
399 result.setPrivateTools(layer_hough_tool)
405 if not flags.Detector.EnableMDT:
406 kwargs.setdefault(
"MdtPrepDataContainer",
"")
407 if not flags.Detector.EnableRPC:
408 kwargs.setdefault(
"RpcPrepDataContainer",
"")
409 if not flags.Detector.EnableTGC:
410 kwargs.setdefault(
"TgcPrepDataContainer",
"")
412 kwargs.setdefault(
'TgcPrepDataContainer',
'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC
else 'TGC_Measurements')
413 kwargs.setdefault(
"CscPrepDataContainer",
"CSC_Clusters" if flags.Detector.EnableCSC
else "")
414 kwargs.setdefault(
"sTgcPrepDataContainer",
"STGC_Measurements" if flags.Detector.EnablesTGC
else "")
415 kwargs.setdefault(
'TgcPrepDataContainer',
'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC
else 'TGC_Measurements')
416 kwargs.setdefault(
"MMPrepDataContainer",
"MM_Measurements" if flags.Detector.EnableMM
else "")
418 kwargs.setdefault(
"PrintSummary", flags.Muon.printSummary)
422 name =
"MuonLayerHoughTool"))
if flags.Beam.Type
is not BeamType.Cosmics
else \
424 kwargs.setdefault(
"MuonLayerScanTool", hough_tool)
426 the_alg = CompFactory.MuonLayerHoughAlg(name = name,**kwargs)
427 result.addEventAlgo( the_alg, primary =
True )
432 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MuonClusterOnTrackCreatorCfg, MdtDriftCircleOnTrackCreatorCfg, MdtCalibToolForRotsCfg
435 if not flags.Detector.EnableRPC:
436 kwargs.setdefault(
"RpcPrepDataContainer",
"")
437 if not flags.Detector.EnableTGC:
438 kwargs.setdefault(
"TgcPrepDataContainer",
"")
440 if "MdtCreator" not in kwargs:
443 if not flags.Input.isMC
and flags.Beam.Type
is BeamType.Collisions:
444 if flags.Muon.doSegmentT0Fit:
449 CreateTubeHit =
False,
451 TimeWindowSetting = timeWindowSetting))
457 kwargs.setdefault(
'MdtCreator', result.popToolsAndMerge(acc))
461 kwargs.setdefault(
'TgcPrepDataContainer',
'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC
else 'TGC_Measurements')
463 if flags.Beam.Type
is BeamType.Cosmics:
464 kwargs.setdefault(
"AngleCutPhi", 1e9)
465 kwargs.setdefault(
"DropDistance", 100000000.)
467 result.setPrivateTools( CompFactory.Muon.MuonPatternCalibration(name, **kwargs) )
471 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MuonClusterOnTrackCreatorCfg
473 kwargs.setdefault(
"doStgcSegments", flags.Detector.EnablesTGC)
474 kwargs.setdefault(
"doMMSegments", flags.Detector.EnableMM)
475 kwargs.setdefault(
"doMdtSegments",
False)
476 kwargs.setdefault(
"CSC_clusterkey",
"CSC_Clusters" if flags.Detector.EnableCSC
else "")
478 kwargs.setdefault(
"SegmentCollectionName",
"NCB_TrackMuonSegments")
480 kwargs.setdefault(
"NSWSegmentCollectionName",
"")
481 kwargs.setdefault(
"SegmentQuality", 1)
485 if flags.Detector.EnableCSC:
487 name=
'CscSegmentUtilTool_NCB',
492 name=
'Csc2dSegmentMaker_NCB',
493 segmentTool=csc_segment_util_tool))
496 name=
'Csc4dSegmentMaker_NCB',
497 segmentTool=csc_segment_util_tool))
499 kwargs.setdefault(
"Csc2dSegmentMaker", csc_2d_segment_maker)
500 kwargs.setdefault(
"Csc4dSegmentMaker", csc_4d_segment_maker)
502 if flags.Detector.EnablesTGC
or flags.Detector.EnableMM:
506 result.addPublicTool(extrapolator)
507 cleaner = result.popToolsAndMerge(
MuonTrackCleanerCfg(flags, name=
'MuonTrackCleaner_seg',seg=
True) )
509 name =
"MuonNSWSegmentFinderTool",
510 TrackCleaner = cleaner,
511 SeedMMStereos =
False,
512 IPConstraint =
False,
513 CaloConstraint =
True))
514 kwargs.setdefault(
"NSWSegmentMaker", segment_finder)
515 the_alg = CompFactory.MuonSegmentFinderAlg(name, **kwargs)
516 result.addEventAlgo(the_alg, primary =
True)
520 from MuonConfig.MuonRIO_OnTrackCreatorToolConfig
import MuonClusterOnTrackCreatorCfg
528 kwargs.setdefault(
'SegmentMaker', segment_maker)
531 if flags.Detector.EnableMM
or flags.Detector.EnablesTGC:
536 result.addPublicTool(extrapolator)
537 cleaner = result.popToolsAndMerge(
MuonTrackCleanerCfg(flags, name=
'MuonTrackCleaner_seg',seg=
True) )
538 segment_finder = result.getPrimaryAndMerge(
MuonNSWSegmentFinderToolCfg(flags, name =
"MuonNSWSegmentFinderTool", TrackCleaner = cleaner))
539 kwargs.setdefault(
"NSWSegmentMaker", segment_finder)
542 if flags.Detector.EnableCSC:
546 kwargs.setdefault(
"CSC_clusterkey",
"")
548 kwargs.setdefault(
"PrintSummary", flags.Muon.printSummary)
549 kwargs.setdefault(
"doStgcSegments", flags.Detector.EnablesTGC)
550 kwargs.setdefault(
"doMMSegments", flags.Detector.EnableMM)
552 kwargs.setdefault(
"SegmentCollectionName",
"TrackMuonSegments" if flags.Muon.segmentOrigin !=
"TruthTracking" else "ThirdChainSegments")
554 the_alg = CompFactory.MuonSegmentFinderAlg( name, **kwargs)
555 result.addEventAlgo(the_alg)
560 kwargs.setdefault(
"SegmentCollectionName",
"TrackMuonSegments")
562 kwargs.setdefault(
"FilteredCollectionName",
"TrackMuonSegmentsEMEO")
563 the_alg = CompFactory.MuonSegmentFilterAlg(name, **kwargs)
564 result.addEventAlgo(the_alg)
569 from MuonCombinedConfig.MuonCombinedRecToolsConfig
import MuonSegmentConverterToolCfg
571 the_alg = CompFactory.xAODMaker.MuonSegmentCnvAlg(name, **kwargs)
572 result.addEventAlgo(the_alg, primary =
True)
578 Returns a CA setting up Muon Segment Finding
579 @param setup_bytestream if True and if Format.BS, sets up reading from bytestream. If False, disables setting up BS, even if Format.BS is True
585 from MuonConfig.MuonGeometryConfig
import MuonGeoModelCfg
587 from MuonConfig.MuonRecToolsConfig
import MuonEDMHelperSvcCfg
590 if (setup_bytestream):
593 if flags.Input.Format
is Format.BS:
594 from MuonConfig.MuonBytestreamDecodeConfig
import MuonByteStreamDecodersCfg
597 if flags.Input.Format
is Format.BS
or 'StreamRDO' in flags.Input.ProcessingTags:
598 from MuonConfig.MuonRdoDecodeConfig
import MuonRDOtoPRDConvertorsCfg
606 if flags.Muon.runCommissioningChain:
609 if flags.Beam.Type
is BeamType.Collisions:
612 SegmentContainerName=
"NCB_TrackMuonSegments",
613 xAODContainerName=
"NCB_MuonSegments") )
615 if flags.Detector.EnableMM
or flags.Detector.EnablesTGC:
617 SegmentContainerName=
"TrackMuonNSWSegments",
618 xAODContainerName=
"xAODNSWSegments"))
621 if __name__==
"__main__":
624 from MuonConfig.MuonConfigUtils
import SetupMuonStandaloneConfigFlags, SetupMuonStandaloneOutput, SetupMuonStandaloneCA
635 AddressRemappingSvc, ProxyProviderSvc=CompFactory.getComps(
"AddressRemappingSvc",
"ProxyProviderSvc",)
638 pps.ProviderNames += [
'AddressRemappingSvc' ]
639 ars.TypeKeyRenameMaps += [
'%s#%s->%s' % (
"Trk::SegmentCollection",
"TrackMuonSegments",
"TrackMuonSegments_old") ]
640 ars.TypeKeyRenameMaps += [
'%s#%s->%s' % (
"Trk::SegmentCollection",
"NCB_TrackMuonSegments",
"NCB_TrackMuonSegments_old") ]
645 itemsToRecord = [
"Trk::SegmentCollection#TrackMuonSegments",
"Trk::SegmentCollection#NCB_TrackMuonSegments"]
650 f=
open(
"MuonSegmentFinding.pkl",
"wb")
654 if not args.config_only:
656 if not sc.isSuccess():
658 sys.exit(
"Execution failed")