8 from AthenaCommon
import JobProperties
9 from PyJobTransforms.TransformUtils
import (processPreExec, processPreInclude,
10 processPostExec, processPostInclude)
13 JobProperties.jobPropertiesDisallowed =
True
17 """ Configure POOL2EI global vars """
19 class AttributeDict(dict):
20 def __getattr__(self, attr):
28 from AthenaCommon.Logging
import logging
29 eilog = logging.getLogger(
'pool_to_ei')
33 for filetype
in (
'POOL',
'AOD',
'ESD',
'EVNT',
'HITS',
'RDO',
'AOD_MRG'):
34 if hasattr(runArgs,
"input" + filetype +
"File"):
35 In = getattr(runArgs,
"input" + filetype +
"File")
36 if type(In)
is not list:
38 flags.Input.Files = In
41 if inputFileGiven == 0:
42 raise RuntimeError(
"No input file given")
43 if inputFileGiven > 1:
44 raise RuntimeError(
"Only one input file format is allowed")
46 def getArgVal(args, key, defaultValue):
47 if hasattr(args, key):
48 return getattr(args, key)
54 job.Out = getArgVal(runArgs,
"outputEIFile",
55 'pool2ei.{:08d}.spb'.
format(os.getpid()))
58 job.DoProvenanceRef = getArgVal(runArgs,
"provenance",
True)
59 job.DoTriggerInfo = getArgVal(runArgs,
'trigger',
True)
60 job.SendToBroker = getArgVal(runArgs,
"sendtobroker",
False)
61 job.EiDsName = getArgVal(runArgs,
"eidsname",
None)
62 job.TestBrk = getArgVal(runArgs,
"testbrk",
False)
63 job.EiFmt = getArgVal(runArgs,
"eifmt", 0)
66 job.TaskID = getArgVal(runArgs,
"_taskid",
None)
67 job.JobID = getArgVal(runArgs,
"_jobid",
None)
68 job.AttemptNumber = getArgVal(runArgs,
"_attempt",
None)
70 def findFirstKeyforValue(dict, value):
71 """ Look for value in dict and return the first key or None if not found """
72 k =
next((k
for k, v
in dict.items()
if v == value),
None)
76 EventStreamInfo_key = findFirstKeyforValue(
77 flags.Input.MetadataItems,
'EventStreamInfo')
79 metadata_items = flags.Input.MetadataItems
80 job.meta_hlt_hltconfigkeys = (
81 '/TRIGGER/HLT/HltConfigKeys' in metadata_items)
82 job.meta_hlt_prescalekey = (
'/TRIGGER/HLT/PrescaleKey' in metadata_items)
83 job.meta_lvl1_lvl1configkey = (
84 '/TRIGGER/LVL1/Lvl1ConfigKey' in metadata_items)
85 job.meta_hlt_menu = (
'/TRIGGER/HLT/Menu' in metadata_items)
86 job.meta_lvl1_menu = (
'/TRIGGER/LVL1/Menu' in metadata_items)
87 job.meta_triggermenu = (
'TriggerMenu' in metadata_items)
88 job.meta_triggermenujson_hlt = (
'TriggerMenuJson_HLT' in metadata_items)
89 job.meta_triggermenujson_l1 = (
'TriggerMenuJson_L1' in metadata_items)
91 eilog.info(
"meta_hlt_hltconfigkeys: {}".
format(job.meta_hlt_hltconfigkeys))
92 eilog.info(
"meta_hlt_prescalekey: {}".
format(job.meta_hlt_prescalekey))
93 eilog.info(
"meta_lvl1_lvl1configkey: {}".
format(
94 job.meta_lvl1_lvl1configkey))
95 eilog.info(
"meta_hlt_menu: {}".
format(job.meta_hlt_menu))
96 eilog.info(
"meta_lvl1_menu: {}".
format(job.meta_lvl1_menu))
97 eilog.info(
"meta_triggermenu: {}".
format(job.meta_triggermenu))
98 eilog.info(
"meta_triggermenujson_hlt: {}".
format(
99 job.meta_triggermenujson_hlt))
100 eilog.info(
"meta_triggermenujson_l1: {}".
format(
101 job.meta_triggermenujson_l1))
103 collections = flags.Input.TypedCollections
104 job.item_eventinfo = (
'EventInfo#EventInfo' in collections
105 or 'EventInfo#McEventInfo' in collections)
106 job.item_eventinfoBS = (
'EventInfo#ByteStreamEventInfo' in collections)
107 job.item_xaod_eventinfo = (
'xAOD::EventInfo#EventInfo' in collections)
108 job.item_xaod_TrigConfKeys = (
109 'xAOD::TrigConfKeys#TrigConfKeys' in collections)
110 job.item_xaod_TrigDecision = (
111 'xAOD::TrigDecision#xTrigDecision' in collections)
113 if not (job.item_eventinfo
or job.item_xaod_eventinfo
or job.item_eventinfoBS):
115 job.item_eventinfo =
True
117 eilog.info(
"item_eventinfo: {}".
format(job.item_eventinfo))
118 eilog.info(
"item_eventinfoBS: {}".
format(job.item_eventinfoBS))
119 eilog.info(
"item_xaod_eventinfo: {}".
format(job.item_xaod_eventinfo))
120 eilog.info(
"item_xaod_TrigConfKeys: {}".
format(job.item_xaod_TrigConfKeys))
121 eilog.info(
"item_xaod_TrigDecision: {}".
format(job.item_xaod_TrigDecision))
123 job.projectName = flags.Input.ProjectName
126 if job.DoTriggerInfo:
128 if (EventStreamInfo_key
is not None and (
'StreamEVGEN' in flags.Input.ProcessingTags
or 'StreamEVNT' in flags.Input.ProcessingTags)):
129 eilog.info(
"Disable trigger processing for EVNT files")
130 job.DoTriggerInfo =
False
132 if (EventStreamInfo_key
is not None and flags.Input.isMC):
133 if not (job.meta_hlt_hltconfigkeys
or job.item_xaod_TrigConfKeys):
134 eilog.info(
"Disable trigger processing for MC files "
135 "with no trigger inside")
136 job.DoTriggerInfo =
False
144 """ Configure and run the transformation """
146 from AthenaCommon.Logging
import logging
149 eilog = logging.getLogger(
'pool_to_ei')
150 eilog.info(
'****************** STARTING POOL->EI MAKING *****************')
154 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
157 from PyJobTransforms.CommonRunArgsToFlags
import commonRunArgsToFlags
173 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
175 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
177 from AthenaServices.MetaDataSvcConfig
import MetaDataSvcCfg
182 if job.item_eventinfo:
184 loadFromSG.append((
'EventInfo',
'StoreGateSvc+McEventInfo'))
186 loadFromSG.append((
'EventInfo',
'StoreGateSvc+EventInfo'))
187 if job.item_eventinfoBS:
188 loadFromSG.append((
'EventInfo',
'StoreGateSvc+ByteStreamEventInfo'))
189 if job.item_xaod_eventinfo:
190 loadFromSG.append((
'xAOD::EventInfo',
'StoreGateSvc+EventInfo'))
191 if job.item_xaod_TrigConfKeys:
192 loadFromSG.append((
'xAOD::TrigConfKeys',
'StoreGateSvc+TrigConfKeys'))
193 if job.item_xaod_TrigDecision:
194 loadFromSG.append((
'xAOD::TrigDecision',
'StoreGateSvc+xTrigDecision'))
195 loadFromSG.append((
'DataHeader',
'StoreGateSvc+EventSelector'))
197 from SGComps.SGInputLoaderConfig
import SGInputLoaderCfg
200 if job.item_eventinfoBS:
202 job.item_eventinfo =
True
205 from EventIndexProducer.POOL2EI_Lib
import POOL2EI
206 pool2ei = POOL2EI(
'pool2ei', OutputLevel=INFO, **job)
207 cfg.addEventAlgo(pool2ei)
210 from EventIndexProducer.POOL2EI_Lib
import POOL2EISvc
211 pool2eisvc = POOL2EISvc(algo=pool2ei)
212 cfg.addService(pool2eisvc, create=
True)
220 if flags.Exec.OutputLevel <= INFO:
227 sys.exit(sc.isFailure())