3 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory
import CompFactory
5 from AthenaConfiguration.Enums
import Format
10 MdtCache =
"MdtPrdCache"
11 CscCache =
"CscPrdCache"
12 CscStripCache =
"CscStripPrdCache"
13 RpcCache =
"RpcPrdCache"
14 TgcCache =
"TgcPrdCache"
15 sTgcCache =
"sTgcPrdCache"
16 MmCache =
"MmPrdCache"
17 RpcCoinCache =
"RpcCoinCache"
18 TgcCoinCache =
"TgcCoinCache"
30 MuonPRDCacheCreator=CompFactory.MuonPRDCacheCreator
31 cacheCreator =
MuonPRDCacheCreator(CscStripCacheKey = (MuonPrdCacheNames.CscStripCache
if flags.Detector.GeometryCSC
else ""),
32 MdtCacheKey = MuonPrdCacheNames.MdtCache,
33 CscCacheKey = (MuonPrdCacheNames.CscCache
if flags.Detector.GeometryCSC
else ""),
34 RpcCacheKey = MuonPrdCacheNames.RpcCache,
35 TgcCacheStr = MuonPrdCacheNames.TgcCache,
36 sTgcCacheKey = (MuonPrdCacheNames.sTgcCache
if flags.Detector.GeometrysTGC
else ""),
37 MmCacheKey = (MuonPrdCacheNames.MmCache
if flags.Detector.GeometryMM
else ""),
38 TgcCoinCacheStr = MuonPrdCacheNames.TgcCoinCache,
39 RpcCoinCacheKey = MuonPrdCacheNames.RpcCoinCache,
42 acc.addEventAlgo( cacheCreator, primary=
True )
48 from MuonConfig.MuonGeometryConfig
import MuonGeoModelCfg
51 kwargs.setdefault(
"DoSeededDecoding", flags.Trigger.doHLT )
52 the_alg = CompFactory.MuonRdoToPrepDataAlg(name, **kwargs)
53 result.addEventAlgo(the_alg, primary =
True)
62 if flags.Input.isMC
and flags.Muon.usePhaseIIGeoSetup
and \
63 len([x
for x
in flags.Input.TypedCollections
if x.find(
"RpcPadContainer#") != -1]):
65 from MuonConfig.MuonByteStreamCnvTestConfig
import RpcRdoToRpcDigitCfg, NrpcDigitToNrpcRDOCfg
68 if RDOContainer: cnv_args.setdefault(
"RpcRdoContainer", RDOContainer)
70 RpcDigitContainer=
"CnvRpcDigits", **cnv_args))
73 NrpcRdoKey=
"CnvRpcRDOs"))
75 kwargs.setdefault(
"RdoCollection",
"CnvRpcRDOs")
79 kwargs.setdefault(
"RpcRdoContainer", RDOContainer)
81 if flags.Input.isMC
and flags.Muon.usePhaseIIGeoSetup:
82 from MuonConfig.MuonCablingConfig
import NRPCCablingConfigCfg
84 from AthenaConfiguration.Enums
import LHCPeriod
85 kwargs.setdefault(
"decode2DStrips", flags.GeoModel.Run >= LHCPeriod.Run4)
86 if not kwargs[
"decode2DStrips"]:
87 kwargs.setdefault(
"OutputContainer",
"xRpcMeasurements")
88 the_tool = CompFactory.MuonR4.RpcRdoToRpcPrepDataTool(name, **kwargs)
89 result.setPrivateTools(the_tool)
93 from MuonConfig.MuonCablingConfig
import RPCLegacyCablingConfigCfg
96 if not flags.Input.isMC:
97 kwargs[
"reduceCablingOverlap"] =
True
98 kwargs[
"produceRpcCoinDatafromTriggerWords"] =
True
99 kwargs[
"overlap_timeTolerance"] = 1000
100 kwargs[
"solvePhiAmbiguities"] =
True
101 kwargs[
"etaphi_coincidenceTime"] = 1000
102 if not flags.Trigger.doHLT:
103 kwargs[
"RpcPrdContainerCacheKey"] =
""
104 kwargs[
"RpcCoinDataContainerCacheKey"] =
""
106 from MuonConfig.MuonCondAlgConfig
import RpcCondDbAlgCfg
109 kwargs[
"RPCInfoFromDb"] =
False
111 if not flags.Muon.enableNRPC:
112 kwargs[
"NrpcInputCollection"] =
""
114 kwargs[
"xAODKey"] =
"xRpcMeasurements" if flags.Muon.writexAODPRD
or \
115 flags.Muon.usePhaseIIGeoSetup
else ""
118 if flags.Muon.MuonTrigger:
119 kwargs[
"RdoDecoderTool"] = CompFactory.Muon.RpcRDO_Decoder(
"RpcRDO_Decoder", BCZERO=flags.Trigger.L1MuonSim.RPCNBCZ)
121 the_tool = CompFactory.Muon.RpcRdoToPrepDataToolMT(name=
"RpcPrepDataProviderTool",**kwargs)
122 result.setPrivateTools(the_tool)
126 def RpcRDODecodeCfg(flags, name="RpcRdoToRpcPrepData", RDOContainer = None, **kwargs):
133 from RegionSelector.RegSelToolConfig
import regSelTool_RPC_Cfg
135 kwargs.setdefault(
"useROBs",
False)
142 def TgcRDODecodeCfg(flags, name="TgcRdoToTgcPrepData", RDOContainer = None, **kwargs):
146 from MuonConfig.MuonCablingConfig
import TGCCablingConfigCfg
151 if not flags.Trigger.doHLT:
152 tool_args.setdefault(
"PrdCacheString",
"")
153 tool_args.setdefault(
"CoinCacheString",
"")
154 tool_args.setdefault(
"xAODKey",
"xTgcStrips" if flags.Muon.writexAODPRD
or flags.Muon.usePhaseIIGeoSetup
else "")
156 if RDOContainer: tool_args.setdefault(
"RDOContainer", RDOContainer)
157 kwargs.setdefault(
"DecodingTool", CompFactory.Muon.TgcRdoToPrepDataToolMT(name=
"TgcPrepDataProviderTool", **tool_args))
160 from RegionSelector.RegSelToolConfig
import regSelTool_TGC_Cfg
162 kwargs.setdefault(
"useROBs",
False)
171 the_tool = CompFactory.Muon.TgcPrepDataReplicationToolAllBCto3BC(name, **kwargs)
172 acc.setPrivateTools(the_tool)
178 acc.addEventAlgo(CompFactory.Muon.TgcPrepDataReplicationAlg(name, **kwargs))
184 kwargs.setdefault(
"PrdCacheKey" , MuonPrdCacheNames.sTgcCache
if flags.Muon.MuonTrigger
else "")
185 kwargs.setdefault(
"UseR4DetMgr", flags.Muon.usePhaseIIGeoSetup)
186 if flags.Muon.writexAODPRD
or flags.Muon.usePhaseIIGeoSetup:
187 kwargs.setdefault(
"xAODStripKey",
"xAODsTgcStrips")
188 kwargs.setdefault(
"xAODWireKey",
"xAODsTgcWires")
189 kwargs.setdefault(
"xAODPadKey",
"xAODsTgcPads")
191 from MuonConfig.MuonRecToolsConfig
import SimpleSTgcClusterBuilderToolCfg
193 from MuonConfig.MuonCalibrationConfig
import NSWCalibToolCfg
194 kwargs.setdefault(
"NSWCalibTool", result.popToolsAndMerge(
NSWCalibToolCfg(flags)))
195 the_tool = CompFactory.Muon.sTgcRdoToPrepDataToolMT(name, **kwargs)
196 result.setPrivateTools(the_tool)
205 from RegionSelector.RegSelToolConfig
import regSelTool_STGC_Cfg
207 kwargs.setdefault(
"useROBs",
False)
216 kwargs.setdefault(
"PrdCacheKey" , MuonPrdCacheNames.MmCache
if flags.Trigger.doHLT
else "")
218 from MuonConfig.MuonRecToolsConfig
import SimpleMMClusterBuilderToolCfg
220 from MuonConfig.MuonCalibrationConfig
import NSWCalibToolCfg
221 kwargs.setdefault(
"NSWCalibTool", result.popToolsAndMerge(
NSWCalibToolCfg(flags)))
222 kwargs[
"xAODKey"] =
"xAODMMClusters" if flags.Muon.writexAODPRD
or flags.Muon.usePhaseIIGeoSetup
else ""
224 the_tool = CompFactory.Muon.MmRdoToPrepDataToolMT(name, **kwargs)
225 result.setPrivateTools(the_tool)
234 from RegionSelector.RegSelToolConfig
import regSelTool_MM_Cfg
236 kwargs.setdefault(
"useROBs",
False)
242 def MdtRDODecodeCfg(flags, name="MdtRdoToMdtPrepData", RDOContainer = None, **kwargs):
244 from MuonConfig.MuonCalibrationConfig
import MdtCalibrationToolCfg
247 from MuonConfig.MuonCablingConfig
import MDTCablingConfigCfg, MdtTwinTubeMapCondAlgCfg
252 tool_kwargs[
"xAODKey"] =
"xMdtDriftCircles" if flags.Muon.writexAODPRD
or flags.Muon.usePhaseIIGeoSetup
else ""
253 tool_kwargs[
"xAODTwinKey"] =
"xMdtTwinDriftCircles" if flags.Muon.writexAODPRD
or flags.Muon.usePhaseIIGeoSetup
else ""
256 tool_kwargs[
"UseR4DetMgr"] = flags.Muon.usePhaseIIGeoSetup
257 tool_kwargs[
"CalibrationTool"] = acc.popToolsAndMerge(
MdtCalibrationToolCfg(flags, TimeWindowSetting = 2, DoPropagationCorrection =
False))
258 if RDOContainer: tool_kwargs[
"RDOContainer"] = RDOContainer
260 kwargs.setdefault(
"DecodingTool", CompFactory.Muon.MdtRdoToPrepDataToolMT(name=
"MdtPrepDataProviderTool", **tool_kwargs))
263 from RegionSelector.RegSelToolConfig
import regSelTool_MDT_Cfg
271 def CscRDODecodeCfg(flags, name="CscRdoToCscPrepData", RDOContainer = None, **kwargs):
275 from MuonConfig.MuonCablingConfig
import CSCCablingConfigCfg
278 from MuonConfig.MuonCondAlgConfig
import CscCondDbAlgCfg
283 kwargs.setdefault(
"useROBs",
False)
284 kwargs.setdefault(
"DecodingTool", CompFactory.Muon.CscRdoToCscPrepDataToolMT(name=
"CscPrepDataProviderTool"))
286 kwargs[
"DecodingTool"].RDOContainer = RDOContainer
288 from RegionSelector.RegSelToolConfig
import regSelTool_CSC_Cfg
298 from MuonConfig.MuonGeometryConfig
import MuonIdHelperSvcCfg
299 from MuonConfig.MuonSegmentFindingConfig
import CalibCscStripFitterCfg, QratCscClusterFitterCfg, CscAlignmentTool
300 from MuonConfig.MuonCalibrationConfig
import CscCalibToolCfg
307 SimpleCscClusterFitter = CompFactory.SimpleCscClusterFitter(CscAlignmentTool =
CscAlignmentTool(flags) )
308 CscSplitClusterFitter = CompFactory.CscSplitClusterFitter( precision_fitter = QratCscClusterFitter,
309 default_fitter = SimpleCscClusterFitter )
311 CscThresholdClusterBuilderTool=CompFactory.CscThresholdClusterBuilderTool
313 MuonIdHelperSvc = MuonIdHelperSvc,
314 strip_fitter = CalibCscStripFitter,
315 precision_fitter = QratCscClusterFitter,
316 default_fitter = SimpleCscClusterFitter,
317 split_fitter = CscSplitClusterFitter,
318 cscCalibTool = CscCalibTool)
321 CscThresholdClusterBuilder=CompFactory.CscThresholdClusterBuilder
323 cluster_builder = CscClusterBuilderTool,
324 MuonIdHelperSvc = MuonIdHelperSvc
326 acc.addEventAlgo(CscClusterBuilder)
332 from MuonConfig.MuonGeometryConfig
import MuonIdHelperSvcCfg
336 if not flags.Detector.GeometryMDT: kwargs.setdefault(
"MdtPrdKey",
"")
337 if not flags.Detector.GeometryRPC: kwargs.setdefault(
"RpcPrdKey",
"")
338 if not flags.Detector.GeometryTGC: kwargs.setdefault(
"TgcPrdKey",
"")
339 if not flags.Detector.GeometryCSC: kwargs.setdefault(
"CscPrdKey",
"")
341 if not flags.Detector.GeometrysTGC: kwargs.setdefault(
"sTgcPrdKey",
"")
342 if not flags.Detector.GeometryMM: kwargs.setdefault(
"MmPrdKey",
"")
344 kwargs.setdefault(
"TgcPrdKey",
'TGC_MeasurementsAllBCs' if not flags.Muon.useTGCPriorNextBC
else 'TGC_Measurements')
345 result.addEventAlgo(CompFactory.MuonPRD_MultiTruthMaker(name, **kwargs), primary =
True)
353 if flags.Detector.GeometryMDT:
356 if flags.Detector.GeometryRPC:
359 if flags.Detector.GeometryTGC:
362 if flags.Detector.GeometrysTGC:
365 if flags.Detector.GeometryMM:
369 if flags.Detector.GeometryCSC:
373 if flags.Input.isMC
and not flags.Muon.usePhaseIIGeoSetup:
381 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
382 from AthenaConfiguration.TestDefaults
import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
384 flags.Input.Files = defaultTestFiles.RAW_RUN2
385 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
386 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
391 from AthenaCommon.Logging
import log
394 log.info(
'About to setup Raw data decoding')
396 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
402 from MuonConfig.MuonBytestreamDecodeConfig
import MuonCacheCfg
405 if flags.Input.Format
is Format.BS:
406 from MuonConfig.MuonBytestreamDecodeConfig
import MuonByteStreamDecodersCfg
411 log.info(
'Print Config')
412 cfg.printConfig(withDetails=
True)
415 pklName =
'MuonRdoDecode_Cache.pkl'
417 pklName =
'MuonRdoDecode.pkl'
420 log.info(
'Save Config')
421 with open(pklName,
'wb')
as f:
429 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
431 flags.Input.Files = [
"/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TriggerTest/valid1.110401.PowhegPythia_P2012_ttbar_nonallhad.recon.RDO.e3099_s2578_r7572_tid07644622_00/RDO.07644622._000001.pool.root.1"]
436 from AthenaCommon.Logging
import log
439 log.info(
'About to setup Rpc RDO data decoding')
444 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
450 log.info(
'Print Config')
451 cfg.printConfig(withDetails=
True)
454 log.info(
'Save Config')
455 with open(
'MuonRdoDecode.pkl',
'wb')
as f:
460 if __name__==
"__main__":