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",
False)
96 the_alg = CompFactory.MuonGMR4.NswGeoPlottingAlg(name, **kwargs)
97 result.addEventAlgo(the_alg, primary =
True)
101 from AthenaCommon.Logging
import logging
102 log = logging.getLogger(
'GeometryConfiguration')
104 if not flags.GeoModel.SQLiteDB:
105 raise ValueError(
"Default tag configuration only works for SQLite")
107 from AthenaConfiguration.TestDefaults
import defaultConditionsTags, defaultGeometryTags
108 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
109 from AthenaConfiguration.Enums
import LHCPeriod
110 if flags.GeoModel.Run == LHCPeriod.Run3:
111 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_MC
if flags.Input.isMC
else defaultConditionsTags.RUN3_DATA
112 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
113 elif flags.GeoModel.Run == LHCPeriod.Run4:
114 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
115 flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
117 raise ValueError(f
"Invalid run period {flags.GeoModel.Run}")
118 log.info(f
"Setup {flags.GeoModel.AtlasVersion} geometry loading {flags.GeoModel.SQLiteDBFullPath}")
119 log.info(f
"Use conditions tag {flags.IOVDb.GlobalTag}")
125 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
127 flags.Concurrency.NumThreads = args.threads
128 flags.Concurrency.NumConcurrentEvents = args.threads
129 flags.Exec.MaxEvents = args.nEvents
130 flags.Exec.SkipEvents = args.skipEvents
131 from os
import path, system, listdir
132 flags.Input.Files = []
135 for fileArg
in args.inputFile:
136 if path.isdir(fileArg):
137 flags.Input.Files += [
"{dir}/{file}".
format(dir=fileArg, file=y)
for y
in listdir(fileArg) ]
139 if fileArg[fileArg.rfind(
".")+1 :]
not in [
"txt",
"conf"]:
140 flags.Input.Files+=[fileArg]
142 with open(fileArg)
as inStream:
143 flags.Input.Files+=[ line.strip()
for line
in inStream
if line[0]!=
'#']
146 flags.Exec.EventPrintoutInterval = 500
148 if args.defaultGeoFile ==
"RUN3":
150 elif args.defaultGeoFile ==
"RUN4":
152 elif args.geoModelFile.startswith(
"root://"):
153 if not path.exists(
"Geometry/{geoTag}.db".
format(geoTag=args.geoTag)):
154 print (
"Copy geometry file from EOS {source}".
format(source = args.geoModelFile))
155 system(
"mkdir Geometry/")
156 system(
"xrdcp {source} Geometry/{geoTag}.db".
format(source = args.geoModelFile,
159 args.geoModelFile =
"Geometry/{geoTag}.db".
format(geoTag=args.geoTag)
161 flags.GeoModel.SQLiteDBFullPath = args.geoModelFile
163 flags.GeoModel.SQLiteDB =
True
166 flags.Detector.GeometryBpipe =
False
168 flags.Detector.GeometryBCM =
False
169 flags.Detector.GeometryPixel =
False
170 flags.Detector.GeometrySCT =
False
171 flags.Detector.GeometryTRT =
False
173 flags.Detector.GeometryPLR =
False
174 flags.Detector.GeometryBCMPrime =
False
175 flags.Detector.GeometryITkPixel =
False
176 flags.Detector.GeometryITkStrip =
False
178 flags.Detector.GeometryHGTD =
False
180 flags.Detector.GeometryLAr =
False
181 flags.Detector.GeometryTile =
False
182 flags.Detector.GeometryMBTS =
False
183 flags.Detector.GeometryCalo =
False
185 flags.Detector.GeometryCSC =
False
187 flags.Detector.GeometrysTGC =
False
189 flags.Detector.GeometryMM =
False
191 flags.Detector.GeometryTGC =
False
193 flags.Detector.GeometryRPC =
False
195 flags.Detector.GeometryMDT =
False
197 flags.Scheduler.CheckDependencies =
True
198 flags.Scheduler.ShowDataDeps =
True
199 flags.Scheduler.ShowDataFlow =
True
200 flags.Scheduler.ShowControlFlow =
True
201 flags.Scheduler.EnableVerboseViews =
True
202 flags.Scheduler.AutoLoadUnmetDependencies =
True
206 flags.dump(evaluate =
True)
209 from MuonConfig.MuonGeometryConfig
import MuonGeoModelCfg
213 if not flags.Muon.usePhaseIIGeoSetup:
214 print (
"WARNING: New Muon plugin is not part of the Geometry file {geoDBFile}".
format(geoDBFile=args.geoModelFile))
216 from ActsAlignmentAlgs.AlignmentAlgsConfig
import ActsGeometryContextAlgCfg
219 cfg.getService(
"MessageSvc").verboseLimit = 10000000
220 cfg.getService(
"MessageSvc").debugLimit = 10000000
225 cfg.printConfig(withDetails=
True, summariseProps=
True)
226 if not cfg.run().isSuccess():
exit(1)
228 if __name__==
"__main__":
232 chambToTest = args.chambers
if len([x
for x
in args.chambers
if x ==
"all"]) ==0
else []
233 chambToExclude = args.excludedChambers
236 if flags.Muon.usePhaseIIGeoSetup:
237 cfg.getCondAlgo(
"MuonDetectorCondAlg").checkGeo =
True
238 from TrackingGeometryCondAlg.AtlasTrackingGeometryCondAlgConfig
import TrackingGeometryCondAlgCfg
242 cfg.getService(
"MessageSvc").setVerbose = []
244 if flags.Detector.GeometryMDT:
245 if not flags.Muon.usePhaseIIGeoSetup:
246 from MuonGeoModelTest.testGeoModel
import GeoModelMdtTestCfg
as LegacyTestCfg
247 cfg.merge(LegacyTestCfg(flags,
248 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"B" or ch[0] ==
"E"],
249 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"B" or ch[0] ==
"E"]))
252 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"B" or ch[0] ==
"E"],
253 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"B" or ch[0] ==
"E"],
254 ReadoutSideXML=
"ReadoutSides.xml",
255 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))
257 if flags.Detector.GeometryRPC:
258 if not flags.Muon.usePhaseIIGeoSetup:
259 from MuonGeoModelTest.testGeoModel
import GeoModelRpcTestCfg
as LegacyTestCfg
260 cfg.merge(LegacyTestCfg(flags,
261 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"B"],
262 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"B"]))
265 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"B"],
266 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"B"],
267 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))
269 if flags.Detector.GeometryTGC:
270 if not flags.Muon.usePhaseIIGeoSetup:
271 from MuonGeoModelTest.testGeoModel
import GeoModelTgcTestCfg
as LegacyTestCfg
272 cfg.merge(LegacyTestCfg(flags,
273 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"T"],
274 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"T"]))
277 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"T"],
278 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"T"],
279 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))
281 if flags.Detector.GeometryMM:
282 if not flags.Muon.usePhaseIIGeoSetup:
283 from MuonGeoModelTest.testGeoModel
import GeoModelMmTestCfg
as LegacyTestCfg
284 cfg.merge(LegacyTestCfg(flags,
285 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"M"],
286 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"M"]))
290 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"M"],
291 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"M"],
292 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))
294 if flags.Detector.GeometrysTGC:
295 if not flags.Muon.usePhaseIIGeoSetup:
296 from MuonGeoModelTest.testGeoModel
import GeoModelsTgcTestCfg
as LegacyTestCfg
297 cfg.merge(LegacyTestCfg(flags,
298 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"S"],
299 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"S"]))
302 TestStations = [ch
for ch
in chambToTest
if ch[0] ==
"S"],
303 ExcludeStations = [ch
for ch
in chambToExclude
if ch[0] ==
"S"],
304 ExtraInputs=[(
'MuonGM::MuonDetectorManager' ,
'ConditionStore+MuonDetectorManager' )]))