7 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
9 flags.addFlag(
'Output.HepMCFileName',
'events.hepmc',help=
'Name of the output HepMC file')
10 flags.addFlag(
'Output.CompressHepMC',
False,help=
'Compress the output after Athena finishes')
14 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
15 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
20 McEventKey =
'GEN_EVENT'
21 if 'McEventCollection#GEN_EVENT' not in flags.Input.TypedCollections:
22 if 'McEventCollection#TruthEvent' in flags.Input.TypedCollections:
23 McEventKey =
'TruthEvent'
25 print(
'Truth collection not found in input file. Might be a problem.')
28 from AthenaConfiguration.ComponentFactory
import CompFactory
32 cfg.addEventAlgo(CompFactory.FixHepMC(
"FixHepMC"))
35 cfg.addEventAlgo( CompFactory.WriteHepMC(
'WriteHepMC',
36 OutputFile = flags.Output.HepMCFileName.replace(
'.tgz',
''),
37 McEventKey = McEventKey ) )
38 cfg.run(flags.Exec.MaxEvents)
41 if flags.Output.CompressHepMC:
42 print(
'Compressing output (this may take a moment)')
44 final_name = flags.Output.HepMCFileName
if '.tgz' in flags.Output.HepMCFileName
else flags.Output.HepMCFileName+
'.tgz'
45 tar = tarfile.open(final_name,
'w:gz')
46 tar.add(flags.Output.HepMCFileName.replace(
'.tgz',
''))
50 os.remove(flags.Output.HepMCFileName.replace(
'.tgz',
''))