2 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
3 from AthenaConfiguration.ComponentFactory
import CompFactory
9 return "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/MuonGeomRTT/GeoDB/ATLAS-P2-RUN4-01-00-00.db"
10 return "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/MuonGeomRTT/GeoDB/ATLAS-R3S-2021-03-02-00.db"
13 from argparse
import ArgumentParser
15 parser = ArgumentParser()
16 parser.add_argument(
"--threads", type=int, help=
"number of threads", default=1)
17 parser.add_argument(
"--inputFile",
"-i", default=[
19 "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/MuonRecRTT/EVGEN_ParticleGun_FourMuon_Pt10to500.root"
21 help=
"Input file to run on ", nargs=
"+")
22 parser.add_argument(
"--geoModelFile", default =
geoModelFileDefault(), help=
"GeoModel SqLite file containing the muon geometry.")
23 parser.add_argument(
"--defaultGeoFile", help=
"Use the predefined GeoModel files on cvmfs", choices=[
"NONE",
"RUN3",
"RUN4" ], default=
"NONE")
24 parser.add_argument(
"--chambers", default=[
"all"], nargs=
"+", help=
"Chambers to check. If string is all, all chambers will be checked")
25 parser.add_argument(
"--excludedChambers", default=[], nargs=
"+", help=
"Chambers to exclude. If string contains 'none', all chambers will be checked. Note: adding a chamber to --excludedChambers will overwrite it being in --chambers.")
26 parser.add_argument(
"--outRootFile", default=
"NewGeoModelDump.root", help=
"Output ROOT file to dump the geomerty")
27 parser.add_argument(
"--nEvents", help=
"Number of events to run", type = int ,default = 1)
28 parser.add_argument(
"--skipEvents", help=
"Number of events to skip", type = int, default = 0)
29 parser.add_argument(
"--noMdt", help=
"Disable the Mdts from the geometry", action=
'store_true', default =
False)
30 parser.add_argument(
"--noRpc", help=
"Disable the Rpcs from the geometry", action=
'store_true', default =
False)
31 parser.add_argument(
"--noTgc", help=
"Disable the Tgcs from the geometry", action=
'store_true', default =
False)
32 parser.add_argument(
"--noMM", help=
"Disable the MMs from the geometry", action=
'store_true', default =
False)
33 parser.add_argument(
"--noSTGC", help=
"Disable the sTgcs from the geometry", action=
'store_true', default =
False)
34 parser.add_argument(
"--eventPrintoutLevel", type=int, help=
"Interval of event heartbeat printouts from the loop manager", default = 1)
38 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
41 from AthenaConfiguration.Enums
import Format
42 if flags.Input.Format
is Format.POOL:
43 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
45 elif flags.Input.Format == Format.BS:
46 from ByteStreamCnvSvc.ByteStreamConfig
import ByteStreamReadCfg
49 from PerfMonComps.PerfMonCompsConfig
import PerfMonMTSvcCfg
51 from MuonConfig.MuonGeometryConfig
import MuonIdHelperSvcCfg
55 def setupHistSvcCfg(flags, outFile="MdtGeoDump.root", outStream="GEOMODELTESTER"):
57 if len(outFile) == 0:
return result
58 histSvc = CompFactory.THistSvc(Output=[f
"{outStream} DATAFILE='{outFile}', OPT='RECREATE'"])
59 result.addService(histSvc, primary=
True)
65 the_alg = CompFactory.MuonGMR4.GeoModelMdtTest(name, **kwargs)
66 result.addEventAlgo(the_alg, primary =
True)
71 the_alg = CompFactory.MuonGMR4.GeoModelRpcTest(name, **kwargs)
72 result.addEventAlgo(the_alg, primary =
True)
77 the_alg = CompFactory.MuonGMR4.GeoModelTgcTest(name, **kwargs)
78 result.addEventAlgo(the_alg, primary =
True)
83 the_alg = CompFactory.MuonGMR4.GeoModelsTgcTest(name, **kwargs)
84 result.addEventAlgo(the_alg, primary =
True)
89 the_alg = CompFactory.MuonGMR4.GeoModelMmTest(name, **kwargs)
90 result.addEventAlgo(the_alg, primary =
True)
95 kwargs.setdefault(
"TestActsSurface",
True)
96 kwargs.setdefault(
"plotTgc", flags.Detector.GeometryTGC)
97 kwargs.setdefault(
"plotStgc", flags.Detector.GeometrysTGC)
98 kwargs.setdefault(
"plotMm", flags.Detector.GeometryMM)
100 the_alg = CompFactory.MuonGMR4.NswGeoPlottingAlg(name, **kwargs)
101 result.addEventAlgo(the_alg, primary =
True)
105 from AthenaCommon.Logging
import logging
106 log = logging.getLogger(
'GeometryConfiguration')
108 if not flags.GeoModel.SQLiteDB:
109 raise ValueError(
"Default tag configuration only works for SQLite")
111 from AthenaConfiguration.TestDefaults
import defaultConditionsTags, defaultGeometryTags
112 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
113 from AthenaConfiguration.Enums
import LHCPeriod
114 if flags.GeoModel.Run == LHCPeriod.Run3:
115 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_MC
if flags.Input.isMC
else defaultConditionsTags.RUN3_DATA
116 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
117 elif flags.GeoModel.Run == LHCPeriod.Run4:
118 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
119 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
121 raise ValueError(f
"Invalid run period {flags.GeoModel.Run}")
122 log.info(f
"Setup {flags.GeoModel.AtlasVersion} geometry loading {flags.GeoModel.SQLiteDBFullPath}")
123 log.info(f
"Use conditions tag {flags.IOVDb.GlobalTag}")
129 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
131 flags.Concurrency.NumThreads = args.threads
132 flags.Concurrency.NumConcurrentEvents = args.threads
133 flags.Exec.MaxEvents = args.nEvents
134 flags.Exec.SkipEvents = args.skipEvents
135 from os
import path, system, listdir
136 flags.Input.Files = []
139 for fileArg
in args.inputFile:
140 if path.isdir(fileArg):
141 flags.Input.Files += [
"{dir}/{file}".
format(dir=fileArg, file=y)
for y
in listdir(fileArg) ]
143 if fileArg[fileArg.rfind(
".")+1 :]
not in [
"txt",
"conf"]:
144 flags.Input.Files+=[fileArg]
146 with open(fileArg)
as inStream:
147 flags.Input.Files+=[ line.strip()
for line
in inStream
if line[0]!=
'#']
150 flags.Exec.EventPrintoutInterval = 500
152 if args.defaultGeoFile ==
"RUN3":
154 elif args.defaultGeoFile ==
"RUN4":
156 elif args.geoModelFile.startswith(
"root://"):
157 if not path.exists(
"Geometry/{geoTag}.db".
format(geoTag=args.geoTag)):
158 print (
"Copy geometry file from EOS {source}".
format(source = args.geoModelFile))
159 system(
"mkdir Geometry/")
160 system(
"xrdcp {source} Geometry/{geoTag}.db".
format(source = args.geoModelFile,
163 args.geoModelFile =
"Geometry/{geoTag}.db".
format(geoTag=args.geoTag)
165 flags.GeoModel.SQLiteDBFullPath = args.geoModelFile
167 flags.GeoModel.SQLiteDB =
True
170 flags.Detector.GeometryBpipe =
False
172 flags.Detector.GeometryBCM =
False
173 flags.Detector.GeometryPixel =
False
174 flags.Detector.GeometrySCT =
False
175 flags.Detector.GeometryTRT =
False
177 flags.Detector.GeometryPLR =
False
178 flags.Detector.GeometryBCMPrime =
False
179 flags.Detector.GeometryITkPixel =
False
180 flags.Detector.GeometryITkStrip =
False
182 flags.Detector.GeometryHGTD =
False
184 flags.Detector.GeometryLAr =
False
185 flags.Detector.GeometryTile =
False
186 flags.Detector.GeometryMBTS =
False
187 flags.Detector.GeometryCalo =
False
189 flags.Detector.GeometryCSC =
False
191 flags.Detector.GeometrysTGC =
False
193 flags.Detector.GeometryMM =
False
195 flags.Detector.GeometryTGC =
False
197 flags.Detector.GeometryRPC =
False
199 flags.Detector.GeometryMDT =
False
201 flags.Scheduler.CheckDependencies =
True
202 flags.Scheduler.ShowDataDeps =
True
203 flags.Scheduler.ShowDataFlow =
True
204 flags.Scheduler.ShowControlFlow =
True
205 flags.Scheduler.EnableVerboseViews =
True
206 flags.Scheduler.AutoLoadUnmetDependencies =
True
209 flags.dump(evaluate =
True)
212 from MuonConfig.MuonGeometryConfig
import MuonGeoModelCfg
216 if not flags.Muon.usePhaseIIGeoSetup:
217 print (
"WARNING: New Muon plugin is not part of the Geometry file {geoDBFile}".
format(geoDBFile=args.geoModelFile))
219 from ActsAlignmentAlgs.AlignmentAlgsConfig
import ActsGeometryContextAlgCfg
222 cfg.getService(
"MessageSvc").verboseLimit = 10000000
223 cfg.getService(
"MessageSvc").debugLimit = 10000000
228 cfg.printConfig(withDetails=
True, summariseProps=
True)
229 if not cfg.run().isSuccess():
exit(1)
231 if __name__==
"__main__":
235 chambToTest = args.chambers
if len([x
for x
in args.chambers
if x ==
"all"]) ==0
else []
236 chambToExclude = args.excludedChambers
239 if flags.Muon.usePhaseIIGeoSetup:
240 cfg.getCondAlgo(
"MuonDetectorCondAlg").checkGeo =
True
241 from TrackingGeometryCondAlg.AtlasTrackingGeometryCondAlgConfig
import TrackingGeometryCondAlgCfg
245 cfg.getService(
"MessageSvc").setVerbose = []
247 if flags.Detector.GeometryMDT:
248 if not flags.Muon.usePhaseIIGeoSetup:
249 from MuonGeoModelTest.testGeoModel
import GeoModelMdtTestCfg
as LegacyTestCfg
250 cfg.merge(LegacyTestCfg(flags,
251 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"B" or ch[0] ==
"E"],
252 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"B" or ch[0] ==
"E"]))
255 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"B" or ch[0] ==
"E"],
256 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"B" or ch[0] ==
"E"],
257 ReadoutSideXML=
"ReadoutSides.xml",
258 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))
260 if flags.Detector.GeometryRPC:
261 if not flags.Muon.usePhaseIIGeoSetup:
262 from MuonGeoModelTest.testGeoModel
import GeoModelRpcTestCfg
as LegacyTestCfg
263 cfg.merge(LegacyTestCfg(flags,
264 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"B"],
265 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"B"]))
268 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"B"],
269 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"B"],
270 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))
272 if flags.Detector.GeometryTGC:
273 if not flags.Muon.usePhaseIIGeoSetup:
274 from MuonGeoModelTest.testGeoModel
import GeoModelTgcTestCfg
as LegacyTestCfg
275 cfg.merge(LegacyTestCfg(flags,
276 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"T"],
277 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"T"]))
280 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"T"],
281 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"T"],
282 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))
284 if flags.Detector.GeometryMM:
285 if not flags.Muon.usePhaseIIGeoSetup:
286 from MuonGeoModelTest.testGeoModel
import GeoModelMmTestCfg
as LegacyTestCfg
287 cfg.merge(LegacyTestCfg(flags,
288 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"M"],
289 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"M"]))
293 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"M"],
294 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"M"],
295 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))
297 if flags.Detector.GeometrysTGC:
298 if not flags.Muon.usePhaseIIGeoSetup:
299 from MuonGeoModelTest.testGeoModel
import GeoModelsTgcTestCfg
as LegacyTestCfg
300 cfg.merge(LegacyTestCfg(flags,
301 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"S"],
302 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"S"]))
305 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"S"],
306 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"S"],
307 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))