8 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
9 from AthenaConfiguration.ComponentFactory
import CompFactory
16 if flags.Detector.GeometryBpipe:
17 from BeamPipeGeoModel.BeamPipeGMConfig
import BeamPipeGeometryCfg
21 if flags.Detector.GeometryPixel:
22 from PixelGeoModel.PixelGeoModelConfig
import PixelReadoutGeometryCfg
27 if flags.Detector.GeometrySCT:
28 from SCT_GeoModel.SCT_GeoModelConfig
import SCT_ReadoutGeometryCfg
31 if flags.Detector.GeometryTRT:
32 from TRT_GeoModel.TRT_GeoModelConfig
import TRT_ReadoutGeometryCfg
38 if flags.Detector.GeometryID:
39 from InDetServMatGeoModel.InDetServMatGeoModelConfig
import (
40 InDetServiceMaterialCfg)
44 if flags.Detector.GeometryLAr:
45 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
48 if flags.Detector.GeometryTile:
49 from TileGeoModel.TileGMConfig
import TileGMCfg
54 cfg.getService(
"GeoModelSvc").DetectorTools[
"TileDetectorTool"].GeometryConfig=
"FULL"
59 if flags.Detector.GeometryMuon:
60 from MuonConfig.MuonGeometryConfig
import MuonGeoModelCfg
64 if flags.Detector.GeometryHGTD:
66 if flags.HGTD.Geometry.useGeoModelXml:
67 from HGTD_GeoModelXml.HGTD_GeoModelConfig
import HGTD_SimulationGeometryCfg
69 from HGTD_GeoModel.HGTD_GeoModelConfig
import HGTD_SimulationGeometryCfg
73 if flags.Detector.GeometryITkPixel:
74 from PixelGeoModelXml.ITkPixelGeoModelConfig
import ITkPixelReadoutGeometryCfg
76 if flags.Detector.GeometryITkStrip:
77 from StripGeoModelXml.ITkStripGeoModelConfig
import ITkStripReadoutGeometryCfg
84 if flags.Detector.GeometryCavern:
85 from AtlasGeoModel.CavernGMConfig
import CavernGeometryCfg
89 if flags.Detector.GeometryLucid
or flags.Detector.GeometryALFA
or flags.Detector.GeometryAFP
or flags.Detector.GeometryFwdRegion :
90 from AtlasGeoModel.ForDetGeoModelConfig
import ForDetGeometryCfg
92 if flags.Detector.GeometryZDC:
93 from ZDC_GeoM.ZdcGeoModelConfig
import ZDC_DetToolCfg
101 if "ForwardRegionGeoModelTool" in cfg.getService(
"GeoModelSvc").DetectorTools:
102 cfg.getService(
"GeoModelSvc").DetectorTools[
"ForwardRegionGeoModelTool"].vp1Compatibility=
True
108 if "AtlasVersion" in os.environ:
109 return os.environ[
"AtlasVersion"]
110 if "AtlasBaseVersion" in os.environ:
111 return os.environ[
"AtlasBaseVersion"]
114 def DumpGeoCfg(flags, name="DumpGeoCA", outFileName="", **kwargs):
128 _logger.verbose(
"Using GeoModel ATLAS version: %s", flags.GeoModel.AtlasVersion)
130 kwargs.setdefault(
"AtlasVersion", flags.GeoModel.AtlasVersion)
131 kwargs.setdefault(
"OutSQLiteFileName", outFileName)
132 if args.filterDetManagers:
133 kwargs.setdefault(
"UserFilterDetManager", args.filterDetManagers.split(
","))
134 if args.showTreetopContent:
135 kwargs.setdefault(
"ShowTreetopContent",
True)
137 the_alg = CompFactory.DumpGeo(name=
"DumpGeoAlg", **kwargs)
138 result.addEventAlgo(the_alg, primary=
True)
142 if __name__==
"__main__":
147 from AthenaCommon.Logging
import logging
150 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
153 _logger = logging.getLogger(
'DumpGeo')
154 _logger.setLevel(VERBOSE)
156 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
158 flags.Exec.MaxEvents = 0
170 flags.Concurrency.NumThreads = 0
177 parser = flags.getArgumentParser()
178 parser.prog =
'dump-geo'
180 parser.add_argument(
"--detDescr", default=defaultGeometryTags.RUN3,
181 help=
"The ATLAS geometry tag you want to dump (a convenience alias for the Athena flag 'GeoModel.AtlasVersion=TAG')", metavar=
"TAG")
183 parser.add_argument(
"--filterDetManagers", help=
"Only output the GeoModel Detector Managers specified in the FILTER list; input is a comma-separated list")
184 parser.add_argument(
"-f",
"--forceOverwrite",
185 help=
"Force to overwrite an existing SQLite output file with the same name, if any", action =
'store_true')
186 parser.add_argument(
"--showTreetopContent",
187 help=
"Show the content of the Treetops --- (by default, only the list of Treetops is shown)", action =
'store_true')
188 parser.add_argument(
"--debugCA", help=
"Debug the CA configuration: print flags, tools, ... --- mainly, for DumpGeo developers. '1' prints a subset of the CA flags, '2' prints all of them.")
190 args = flags.fillFromArgs(parser=parser)
196 _logger.verbose(
"+ About to set flags related to the input")
200 dumpgeo_empty_input =
False
203 if (flags.Input.Files == []
or
204 flags.Input.Files == [
'_ATHENA_GENERIC_INPUTFILE_NAME_']):
205 from Campaigns.Utils
import Campaign
206 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
208 dumpgeo_empty_input =
True
216 flags.Input.ProjectName =
"mc20_13TeV"
217 flags.Input.RunNumbers = [330000]
218 flags.Input.TimeStamps = [1]
219 flags.Input.TypedCollections = []
222 flags.IOVDb.GlobalTag =
"OFLCOND-MC23-SDR-RUN3-02"
223 flags.Input.isMC =
True
224 flags.Input.MCCampaign = Campaign.Unknown
225 flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN3
226 _logger.verbose(
"+ ... Done")
227 _logger.verbose(
"+ empty input: '%s'" % dumpgeo_empty_input)
229 _logger.verbose(
"+ detDescr flag: '%s'" % args.detDescr)
232 _logger.verbose(
"+ About to set the detector flags")
234 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorFlags
236 toggle_geometry=
True, keep_beampipe=
True)
237 _logger.verbose(
"+ ... Done")
240 _logger.verbose(
"+ About to set this detector description tag: '%s'" % args.detDescr)
241 flags.GeoModel.AtlasVersion = args.detDescr
242 _logger.verbose(
"+ ... Done")
252 outFileName =
"geometry"
253 filterDetManagers = []
258 geoTAG = flags.GeoModel.AtlasVersion
259 print(
"+ DumpGeo -- INFO -- This is the Detector Description geometry TAG you are dumping: '%s'" % geoTAG)
260 outFileName = outFileName +
"-" + geoTAG
263 if args.filterDetManagers:
264 print(
"+ DumpGeo -- NOTE -- Your 'GeoModel Detector Manager' filter set: '%s'" % args.filterDetManagers)
265 filterDetManagers = args.filterDetManagers.split(
",")
266 outFileName = outFileName +
"-" +
"-".
join(filterDetManagers)
268 outFileName = outFileName +
".db"
271 if os.path.exists(outFileName):
272 if args.forceOverwrite
is True:
273 print(
"+ DumpGeo -- NOTE -- You chose to overwrite an existing geometry dump file with the same name, if present.")
276 if os.path.exists(outFileName):
277 os.remove(outFileName)
278 print(f
"The file {outFileName} has been deleted.")
280 print(f
"The file {outFileName} does not exist. So, it was not needed to 'force-delete' it. Continuing...")
282 print(f
"\nDumpGeo -- ERROR! The ouput file '{outFileName}' exists already!\nPlease move or remove it, or use the 'force' option: '-f' or '--forceOverWrite'.\n\n")
289 _logger.verbose(
"+ Setup main services")
290 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
292 _logger.verbose(
"+ ...Done")
294 _logger.verbose(
"+ About to setup geometry")
296 _logger.verbose(
"+ ...Done")
300 debugCAlevel =
int(args.debugCA)
301 if debugCAlevel >= 1:
302 _logger.verbose(
"Debug --- printing flags...")
303 print(
"\nflags:", flags)
306 print(
"\nflags.Tile:", flags.Tile)
307 for fl
in flags.Tile:
308 print(
"fl.Tile:", fl)
310 print(
"cfg._privateTools: ", cfg._privateTools)
311 print(
"cfg._publicTools: ", cfg._publicTools)
312 if debugCAlevel >= 2:
314 flags._loadDynaFlags(
'GeoModel')
315 flags._loadDynaFlags(
'Detector')
316 flags.dump(
'Detector.(Geometry|Enable)',
True)
317 if debugCAlevel >= 1:
318 _logger.verbose(
"We're in a debugCA session, flags have been printed out, now exiting...")
323 cfg.merge(
DumpGeoCfg(flags, args, outFileName=outFileName))