ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCablingConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5
6def NRPCCablingConfigCfg(flags, name = "MuonNRPC_CablingAlg", **kwargs):
7 result = ComponentAccumulator()
8
9
10 kwargs.setdefault("JSONFile", "")
11 if len(kwargs["JSONFile"]) == 0:
12 from IOVDbSvc.IOVDbSvcConfig import addFolders
13 dbName = 'RPC_OFL' if flags.Input.isMC else 'RPC'
14 cablingFolder = "/RPC/NCABLING/JSON" if flags.Input.isMC else "/RPC/Onl/NCABLING/JSON"
15 cablingTag = "RpcNcablingJson-RUN3-09"
16 from AthenaConfiguration.Enums import LHCPeriod
17 if flags.Muon.usePhaseIIGeoSetup:
18 if flags.GeoModel.Run <= LHCPeriod.Run3:
19 if flags.Input.isMC:
20 cablingTag = "RpcNcablingJson-RUN3-FantasyCabling-5"
21 else:
22 cablingTag = "RpcNcablingJson-RUN3-FantasyHybridCabling-1"
23 elif flags.Input.isMC: #Run4 MC
24 cablingTag = "RpcNcablingJson-RUN4-FantasyCabling-8"
25 result.merge(addFolders(flags, [cablingFolder], detDb=dbName, className='CondAttrListCollection', tag=cablingTag))
26 kwargs.setdefault("MapFolders", cablingFolder)
27
28
29 NRPCCablingAlg = CompFactory.Muon.NRpcCablingAlg(name, **kwargs)
30
31 result.addCondAlgo( NRPCCablingAlg, primary= True)
32 return result
33
34
36 acc = ComponentAccumulator()
37 if not flags.Detector.GeometryRPC: return acc
38 if flags.Muon.enableNRPC:
39 acc.merge(NRPCCablingConfigCfg(flags))
40 acc.merge(RPCLegacyCablingConfigCfg(flags))
41 return acc
42
44 acc = ComponentAccumulator()
45 dbName = 'RPC_OFL' if flags.Input.isMC else 'RPC'
46 dbRepo="MuonRPC_Cabling/ATLAS.data"
47 rpcCabMap="/RPC/CABLING/MAP_SCHEMA"
48 rpcCabMapCorr="/RPC/CABLING/MAP_SCHEMA_CORR"
49 rpcTrigEta="/RPC/TRIGGER/CM_THR_ETA"
50 rpcTrigPhi="/RPC/TRIGGER/CM_THR_PHI"
51
52 from IOVDbSvc.IOVDbSvcConfig import addFolders
53 acc.merge(addFolders(flags, [rpcCabMap,rpcCabMapCorr], dbName, className='CondAttrListCollection' ))
54
55 acc.merge(addFolders(flags, [rpcTrigEta,rpcTrigPhi], dbName, className='CondAttrListCollection'))
56
57 RpcCablingCondAlg=CompFactory.RpcCablingCondAlg
58 RpcCablingAlg = RpcCablingCondAlg("RpcCablingCondAlg",DatabaseRepository=dbRepo)
59 acc.addCondAlgo( RpcCablingAlg )
60
61 return acc
62
63
64def TGCCablingConfigCfg(flags, name="TgcCablingCondAlg", **kwargs):
65 acc = ComponentAccumulator()
66 if not flags.Detector.GeometryTGC: return acc
67
68 from AthenaConfiguration.Enums import LHCPeriod
69 kwargs.setdefault("isRun4", flags.GeoModel.Run > LHCPeriod.Run3)
70 kwargs.setdefault("databaseASDtoPPdiff", 'ASD2PP_diff_12_OFL.db' if flags.Input.isMC else 'ASD2PP_diff_12_ONL.db')
71 the_alg = CompFactory.Muon.TgcCablingCondAlg(name, **kwargs)
72 acc.addCondAlgo(the_alg, primary = True)
73 return acc
74
75# This should be checked by experts since I just wrote it based on
76# athena/MuonSpectrometer/MuonCnv/MuonCnvExample/python/MuonCablingConfig.py
77def MDTCablingConfigCfg(flags, name = "MuonMDT_CablingAlg", **kwargs):
78 acc = ComponentAccumulator()
79 if not flags.Detector.GeometryMDT: return acc
80 from AthenaConfiguration.Enums import LHCPeriod
81
82 kwargs.setdefault("UseJSONFormat", flags.GeoModel.Run >= LHCPeriod.Run3)
83 kwargs.setdefault("MezzanineJSON", "")
84 kwargs.setdefault("CablingJSON", "")
85
86 kwargs.setdefault("isRun3", flags.GeoModel.Run >= LHCPeriod.Run3 )
87 from IOVDbSvc.IOVDbSvcConfig import addFolders
88 if len(kwargs["MezzanineJSON"]) == 0 and len(kwargs["CablingJSON"]) == 0:
89 if flags.Input.isMC is True:
90 dbTagMezz = None
91 dbTagSchema = None
92 #In DD1 the phase II geometry actually uses the R3 muon geometry. So until DD2 is deployed we need to override the cabling map for phase II geometry to use the R3 cabling map.
93 if not flags.Muon.usePhaseIIGeoSetup and flags.GeoModel.Run >= LHCPeriod.Run4:
94 dbTagSchema = "MDTCablingMapSchemaJSON_RUN3BestKnowledge"
95 dbTagMezz = "MDTMezMapSchemaJSON_RUN3BestKnowledge"
96 if kwargs["UseJSONFormat"]:
97 kwargs.setdefault("MapFolders", "/MDT/CABLING/MAP_SCHEMA_JSON")
98 kwargs.setdefault("MezzanineFolders", "/MDT/CABLING/MEZZANINE_SCHEMA_JSON")
99 else:
100 kwargs.setdefault("MapFolders", "/MDT/Ofl/CABLING/MAP_SCHEMA")
101 kwargs.setdefault("MezzanineFolders", "/MDT/Ofl/CABLING/MEZZANINE_SCHEMA")
102 acc.merge( addFolders( flags, [kwargs["MapFolders"]], 'MDT_OFL',
103 className="CondAttrListCollection", tag = dbTagSchema))
104 acc.merge( addFolders( flags, [kwargs["MezzanineFolders"]], 'MDT_OFL',
105 className="CondAttrListCollection", tag = dbTagMezz) )
106 else:
107 if kwargs["UseJSONFormat"]:
108 kwargs.setdefault("MapFolders", "/MDT/CABLING/MAP_SCHEMA_JSON")
109 kwargs.setdefault("MezzanineFolders", "/MDT/CABLING/MEZZANINE_SCHEMA_JSON")
110 else:
111 kwargs.setdefault("MapFolders", "/MDT/CABLING/MAP_SCHEMA")
112 kwargs.setdefault("MezzanineFolders", "/MDT/CABLING/MEZZANINE_SCHEMA")
113 acc.merge( addFolders( flags, [kwargs["MapFolders"], kwargs["MezzanineFolders"]], 'MDT',
114 className="CondAttrListCollection") )
115
116
117 MDTCablingAlg = CompFactory.MuonMDT_CablingAlg(name, **kwargs)
118 acc.addCondAlgo( MDTCablingAlg, primary = True )
119
120 return acc
121
122def MdtTwinTubeMapCondAlgCfg(flags, name="MdtTwinTubeCondAlg", **kwargs):
123 result = ComponentAccumulator()
124 if not flags.Detector.GeometryMDT: return result
125 kwargs.setdefault("JSONFile","")
126 if(not kwargs["JSONFile"]):
127 kwargs.setdefault("FolderName","/MDT/TWINMAPPING")
128 from IOVDbSvc.IOVDbSvcConfig import addFolders
129 result.merge(addFolders(flags,[kwargs["FolderName"]], ("MDT_OFL" if flags.Input.isMC else "MDT"),className="CondAttrListCollection", tag="MDTTwinMapping_compactFormat_Run123"))
130 else:
131 kwargs["FolderName"] = ""
132
133 the_alg = CompFactory.Muon.TwinTubeMappingCondAlg(name, **kwargs)
134 result.addCondAlgo(the_alg, primary = True)
135 return result
136
137# This should be checked by experts
139 acc = ComponentAccumulator()
140 if not flags.Detector.GeometryCSC: return acc
141 CSCcablingSvc=CompFactory.CSCcablingSvc
142 cscCablingSvc = CSCcablingSvc()
143
144 acc.addService( cscCablingSvc, primary=True )
145
146 return acc
147
148def MmCablingCfg(flags, name = "MuonMm_CablingAlg", **kwargs):
149 result = ComponentAccumulator()
150
151 if flags.Input.isMC or (not flags.Detector.GeometryMM):
152 return result
153
154 from IOVDbSvc.IOVDbSvcConfig import addFolders
155 cablingFolder = ["/MDT/MM/CABLING" if not flags.Common.isOnline else "/MDT/Onl/MM/CABLING"]
156 kwargs.setdefault("CablingFolder",cablingFolder)
157 result.merge(addFolders(flags, kwargs["CablingFolder"], detDb=("MDT_OFL" if not flags.Common.isOnline else "MDT_ONL"), className="CondAttrListCollection"))
158
159 the_alg = CompFactory.MuonNSW_CablingAlg(name, **kwargs)
160 result.addCondAlgo(the_alg, primary = True)
161 return result
162
163def sTgcCablingCfg(flags, name = "MuonsTgc_CablingAlg", **kwargs):
164 result = ComponentAccumulator()
165
166 if flags.Input.isMC or (not flags.Detector.GeometrysTGC):
167 return result
168
169 from IOVDbSvc.IOVDbSvcConfig import addFolders
170 cablingFolder = ["/TGC/NSW/CABLING" if not flags.Common.isOnline else "/TGC/Onl/NSW/CABLING"]
171 kwargs.setdefault("CablingFolder",cablingFolder)
172 kwargs.setdefault("WriteKey",'stgcCablingMap')
173 result.merge(addFolders(flags, kwargs["CablingFolder"], detDb=("TGC_OFL" if not flags.Common.isOnline else "TGC_ONL"), className="CondAttrListCollection"))
174
175 the_alg = CompFactory.MuonNSW_CablingAlg(name, **kwargs)
176 result.addCondAlgo(the_alg, primary = True)
177 return result
178
179
180
181#All the cabling configs together (convenience function)
183 acc = ComponentAccumulator()
184 acc.merge( RPCCablingConfigCfg(flags) )
185 acc.merge( TGCCablingConfigCfg(flags) )
186
187 acc.merge( MDTCablingConfigCfg(flags) )
188
189 acc.merge( CSCCablingConfigCfg(flags) )
190
191 acc.merge(MmCablingCfg(flags))
192 acc.merge(sTgcCablingCfg(flags))
193
194 return acc
195
196if __name__ == '__main__':
197 from AthenaConfiguration.AllConfigFlags import initConfigFlags
198 from AthenaConfiguration.TestDefaults import defaultTestFiles, defaultGeometryTags
199 flags = initConfigFlags()
200 flags.Input.Files = defaultTestFiles.RAW_RUN2
201 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
202 flags.lock()
203
204 acc = ComponentAccumulator()
205
206 result = MuonCablingConfigCfg(flags)
207 acc.merge( result )
208
209 f=open('MuonCabling.pkl','wb')
210 acc.store(f)
211 f.close()
if(pathvar)
MmCablingCfg(flags, name="MuonMm_CablingAlg", **kwargs)
MDTCablingConfigCfg(flags, name="MuonMDT_CablingAlg", **kwargs)
sTgcCablingCfg(flags, name="MuonsTgc_CablingAlg", **kwargs)
TGCCablingConfigCfg(flags, name="TgcCablingCondAlg", **kwargs)
MdtTwinTubeMapCondAlgCfg(flags, name="MdtTwinTubeCondAlg", **kwargs)
NRPCCablingConfigCfg(flags, name="MuonNRPC_CablingAlg", **kwargs)