65def GetFileMD(filenames, allowEmpty=True, maxLevel='peeker'):
66 if not filenames
or '_ATHENA_GENERIC_INPUTFILE_NAME_' in filenames:
68 msg.info(
"Running an input-less job. Will have empty metadata.")
70 raise RuntimeError(
"Metadata can not be read in an input-less job.")
71 if isinstance(filenames, str):
72 filenames = [filenames]
73 for filename
in filenames:
74 if filename
not in _fileMetaData:
75 msg.info(
"Obtaining metadata of auto-configuration by peeking into '%s'", filename)
77 if _fileMetaData[filename].maxAccessLevel != maxLevel:
78 _fileMetaData[filename].maxAccessLevel = maxLevel
79 if _fileMetaData[filename][
'nentries']
not in [
None, 0]:
80 return _fileMetaData[filename]
82 msg.info(
"The file: %s has no entries, going to the next one for harvesting the metadata", filename)
83 msg.info(
"No file with events found, returning anyways metadata associated to the first file %s", filenames[0])
84 return _fileMetaData[filenames[0]]
87 """Read geometry database for all detectors"""
89 from AtlasGeoModel
import CommonGeoDB
90 from PixelGeoModel
import PixelGeoDB
91 from LArGeoAlgsNV
import LArGeoDB
92 from MuonGeoModel
import MuonGeoDB
96 from AtlasGeoModel.AtlasGeoDBInterface
import AtlasGeoDBInterface
97 dbGeomCursor = AtlasGeoDBInterface(geoTag)
98 dbGeomCursor.ConnectAndBrowseGeoDB()
100 params = {
'Common' : CommonGeoDB.InitializeGeometryParameters(dbGeomCursor),
104 'Luminosity' : CommonGeoDB.InitializeLuminosityDetectorParameters(dbGeomCursor),
107 msg.debug(
'Config parameters retrieved from Geometry DB (Frontier/Oracle):')
108 for key
in params.keys():
109 msg.debug(f
'{key} -> {params[key]}')
112 from AtlasGeoModel.AtlasGeoDBInterface
import AtlasGeoDBInterface_SQLite
113 sqliteReader = AtlasGeoDBInterface_SQLite(geoTag,sqliteDBFullPath)
114 sqliteReader.ConnectToDB()
116 params = {
'Common' : CommonGeoDB.InitializeGeometryParameters_SQLite(sqliteReader),
120 'Luminosity' : CommonGeoDB.InitializeLuminosityDetectorParameters_SQLite(sqliteReader),
123 msg.debug(
'Config parameters retrieved from Geometry DB (SQLite):')
124 for key
in params.keys():
125 msg.debug(f
'{key} -> {params[key]}')
147 """Query geometry DB for detector description.
148 Returns a set of detectors used in a geometry tag.
150 geoTag: geometry tag (e.g. ATLAS-R2-2016-01-00-01)
152 detectors =
DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Common'][
'Detectors']
154 manualConfig =
not DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Common'][
"DetectorsConfigured"]
158 detectors.add(
'Bpipe')
159 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Common'][
'Run']
not in [
'RUN1',
'RUN2',
'RUN3']:
160 detectors.add(
'ITkPixel')
161 detectors.add(
'ITkStrip')
162 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Luminosity'][
'BCMPrime']:
163 detectors.add(
'BCMPrime')
164 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Luminosity'][
'PLR']:
167 detectors.add(
'Pixel')
172 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Common'][
'Run']
not in [
'RUN1',
'RUN2',
'RUN3']:
173 detectors.add(
'HGTD')
176 detectors.add(
'Tile')
179 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Common'][
'Run']
in [
'RUN1',
'RUN2',
'RUN3']:
180 detectors.add(
'MBTS')
182 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Muon'][
'HasMDT']:
184 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Muon'][
'HasRPC']:
186 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Muon'][
'HasTGC']:
188 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Muon'][
'HasCSC']:
190 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Muon'][
'HasSTGC']:
191 detectors.add(
'sTGC')
192 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Muon'][
'HasMM']:
196 detectors.add(
'Lucid')
197 if DetDescrInfo(geoTag,sqliteDB,sqliteDBFullPath)[
'Common'][
'Run']
not in [
'RUN1']:
200 detectors.add(
'ALFA')
201 detectors.add(
'FwdRegion')
224 """Read in GeneratorsInfo from the input file
226 from AthenaConfiguration.Enums
import ProductionStep
227 inputFiles = flags.Input.Files
228 if flags.Common.ProductionStep
in [ProductionStep.Overlay, ProductionStep.FastChain]
and flags.Input.SecondaryFiles
and not flags.Overlay.ByteStream:
230 inputFiles = flags.Input.SecondaryFiles
231 generatorsString =
""
232 from AthenaConfiguration.AutoConfigFlags
import GetFileMD
234 generatorsString =
GetFileMD(inputFiles).
get(
"generators",
"")
235 from GeneratorConfig.Versioning
import generatorsGetFromMetadata
236 return generatorsGetFromMetadata( generatorsString )
240 """Read in special simulation job option fragments based on metadata
241 passed by the evgen stage
243 specialConfigDict = dict()
244 legacyPreIncludeToCAPostInclude = {
'SimulationJobOptions/preInclude.AMSB.py' :
'Charginos.CharginosConfig.AMSB_Cfg',
245 'SimulationJobOptions/preInclude.Monopole.py' :
'Monopole.MonopoleConfig.MonopoleCfg',
246 'SimulationJobOptions/preInclude.Quirks.py' :
'Quirks.QuirksConfig.QuirksCfg',
247 'SimulationJobOptions/preInclude.SleptonsLLP.py' :
'Sleptons.SleptonsConfig.SleptonsLLPCfg',
248 'SimulationJobOptions/preInclude.GMSB.py' :
'Sleptons.SleptonsConfig.GMSB_Cfg',
249 'SimulationJobOptions/preInclude.Qball.py' :
'Monopole.MonopoleConfig.QballCfg',
250 'SimulationJobOptions/preInclude.RHadronsPythia8.py' :
'RHadrons.RHadronsConfig.RHadronsCfg',
251 'SimulationJobOptions/preInclude.fcp.py' :
'Monopole.MonopoleConfig.fcpCfg',
252 'SimulationJobOptions/preInclude.Dyon.py' :
'Monopole.MonopoleConfig.DyonCfg' }
253 legacyPreIncludeToCAPreInclude = {
'SimulationJobOptions/preInclude.AMSB.py' :
None,
254 'SimulationJobOptions/preInclude.Monopole.py' :
'Monopole.MonopoleConfig.MonopolePreInclude',
255 'SimulationJobOptions/preInclude.Quirks.py' :
None,
256 'SimulationJobOptions/preInclude.SleptonsLLP.py' :
None,
257 'SimulationJobOptions/preInclude.GMSB.py' :
None,
258 'SimulationJobOptions/preInclude.Qball.py' :
'Monopole.MonopoleConfig.QballPreInclude',
259 'SimulationJobOptions/preInclude.RHadronsPythia8.py' :
'RHadrons.RHadronsConfig.RHadronsPreInclude',
260 'SimulationJobOptions/preInclude.fcp.py' :
'Monopole.MonopoleConfig.fcpPreInclude',
261 'SimulationJobOptions/preInclude.Dyon.py' :
'Monopole.MonopoleConfig.DyonPreInclude' }
262 specialConfigString =
''
263 from AthenaConfiguration.Enums
import ProductionStep
264 inputFiles = flags.Input.Files
265 secondaryInputFiles = flags.Input.SecondaryFiles
266 if flags.Common.ProductionStep
in [ProductionStep.Overlay, ProductionStep.FastChain]
and not flags.Overlay.DataOverlay
and flags.Input.SecondaryFiles:
268 inputFiles = flags.Input.SecondaryFiles
269 secondaryInputFiles = flags.Input.Files
270 from AthenaConfiguration.AutoConfigFlags
import GetFileMD
271 if len(inputFiles)>0:
272 specialConfigString =
GetFileMD(inputFiles).
get(
'specialConfiguration',
'')
273 if (
not len(specialConfigString)
or specialConfigString ==
'NONE')
and len(secondaryInputFiles)>0:
276 specialConfigString =
GetFileMD(secondaryInputFiles).
get(
'specialConfiguration',
'')
277 if len(specialConfigString)>0:
280 spcitems = specialConfigString.split(
";")
281 for spcitem
in spcitems:
284 if not spcitem
or spcitem.upper() ==
"NONE":
287 if "=" not in spcitem:
288 spcitem =
"preInclude=" + spcitem
290 k, v = spcitem.split(
"=")
291 if k ==
"preInclude" and v.endswith(
'.py'):
292 if v ==
'SimulationJobOptions/preInclude.RhadronsPythia8.py':
293 v =
'SimulationJobOptions/preInclude.RHadronsPythia8.py'
294 v1 = legacyPreIncludeToCAPreInclude[v]
296 specialConfigDict[k] = v1
297 v2 = legacyPreIncludeToCAPostInclude[v]
299 specialConfigDict[
'postInclude'] = v2
301 specialConfigDict[k] = v
302 return specialConfigDict