ATLAS Offline Software
Loading...
Searching...
No Matches
TestReadWriteEventFormat.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2import sys
3
4from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
5from AthenaServices.MetaDataSvcConfig import MetaDataSvcCfg
6from AthenaConfiguration.ComponentFactory import CompFactory
7from xAODEventInfoCnv.xAODEventInfoCnvConfig import EventInfoCnvAlgCfg
8from xAODEventFormatCnv.EventFormatTestConfig import (
9 EventFormatTestFlags,
10 EventFormatTestOutputCfg,
11)
12
13
14def main():
15 numberOfStreams = 1
16 flags = EventFormatTestFlags(
17 inputFiles=["Test0.pool.root"],
18 eventsPerFile=1,
19 )
20 streamName = "ReadWriteTest"
21 for i in range(numberOfStreams):
22 flags.addFlag(
23 f"Output.{streamName}{i}FileName",
24 f"{streamName}{i}.pool.root",
25 )
26 flags.addFlag(f"Output.doWrite{streamName}{i}", True)
27
28 flags.fillFromArgs()
29 flags.lock()
30
31 itemList = [
32 "xAODMakerTest::AVec#TestObject",
33 "xAODMakerTest::AAuxContainer#TestObjectAux.",
34 "xAODMakerTest::AVec#TestObject2",
35 "xAODMakerTest::AAuxContainer#TestObject2Aux.",
36 "xAOD::EventInfo#EventInfo",
37 "xAOD::EventAuxInfo#EventInfoAux.",
38 ]
39
40 acc = EventFormatTestOutputCfg(
41 flags,
42 streamName="ReadWriteTest",
43 itemList=itemList,
44 numberOfStreams=numberOfStreams,
45 )
46
47 acc.addEventAlgo(
48 CompFactory.xAODMakerTest.ACreatorAlg("ACreator", OutputKey="TestObject2")
49 )
50 acc.merge(EventInfoCnvAlgCfg(flags=flags, inputKey="", disableBeamSpot=True))
51 acc.merge(PoolReadCfg(flags))
52 acc.merge(
53 MetaDataSvcCfg(
54 flags,
55 tools=[
56 CompFactory.xAODMaker.EventFormatMetaDataTool(
57 "EventFormatMetaDataTool",
58 OutputLevel=1,
59 Keys=[
60 "EventFormatStreamTest0",
61 "EventFormatAOD",
62 "SomeNotExistentKey",
63 ],
64 ),
65 CompFactory.xAODMaker.FileMetaDataTool(
66 "FileMetaDataTool",
67 OutputLevel=3,
68 ),
69 ],
70 )
71 )
72 acc.addEventAlgo(CompFactory.xAODMakerTest.EventFormatPrinterAlg())
73 acc.addEventAlgo(
74 CompFactory.xAODMakerTest.ACreatorAlg("ACreator", OutputKey="TestObject2")
75 )
76 acc.run(flags.Exec.MaxEvents)
77
78
79if __name__ == "__main__":
80 sys.exit(main())