2 """Test multi-threaded xAOD::FileMetaData writing
4 Read default test HITS and configure to write output stream with
5 xAOD::FileMetaData object. Set up to process 4 concurrent events. Inspect the
6 produced file for xAOD::FileMetaData metadata items.
9 python -m xAODMetaDataCnv.TestWriteFileMetaDataHITS |tee log
12 from AthenaConfiguration
import AllConfigFlags, Enums, TestDefaults, MainServicesConfig
13 from AthenaCommon
import Constants, Logging
14 from OutputStreamAthenaPool
import OutputStreamConfig
15 from PyUtils
import MetaReader
16 from xAODEventInfoCnv
import xAODEventInfoCnvConfig
17 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
18 from xAODMetaDataCnv.InfileMetaDataConfig
import SetupMetaDataForStreamCfg
22 """set up an output stream and xAOD::EventInfo"""
23 accumulator = OutputStreamConfig.OutputStreamCfg(flags, streamName=
"HITS")
27 xAODEventInfoCnvConfig.EventInfoCnvAlgCfg(
28 flags=flags, inputKey=
"", disableBeamSpot=flags.Common.Project
is not Enums.Project.Athena
36 """Check that file metadata is in output"""
37 meta = MetaReader.read_metadata([file_name])[file_name][
"metadata_items"]
39 v
for _, v
in meta.items()
if "FileMetaData" in v
41 print(
"found file metadata objects:", file_info_items)
42 return bool(file_info_items)
46 """Run a job writing a file with FileMetaData"""
47 msg = Logging.logging.getLogger(
"TestFileMetaData")
49 flags = AllConfigFlags.initConfigFlags()
50 flags.Exec.OutputLevel = Constants.DEBUG
51 flags.Input.Files = TestDefaults.defaultTestFiles.HITS_RUN2
52 flags.Output.HITSFileName =
"test.pool.root"
53 flags.Concurrency.NumThreads = 4
54 flags.Concurrency.NumConcurrentEvents = 4
57 write = MainServicesConfig.MainServicesCfg(flags)
64 msg.info(
"File contains xAOD::FileMetaData")
66 msg.error(
"File does not contain xAOD::FileMetaData")
67 except ReferenceError:
68 msg.error(
"Failed to produce output file")
70 msg.error(
"Failed to get metadata item list from file")
74 if __name__ ==
"__main__":