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
29 cfg.addEventAlgo( CompFactory.WriteHepMC(
'WriteHepMC',
30 OutputFile = flags.Output.HepMCFileName.replace(
'.tgz',
''),
31 McEventKey = McEventKey ) )
32 cfg.run(flags.Exec.MaxEvents)
35 if flags.Output.CompressHepMC:
36 print(
'Compressing output (this may take a moment)')
38 final_name = flags.Output.HepMCFileName
if '.tgz' in flags.Output.HepMCFileName
else flags.Output.HepMCFileName+
'.tgz'
39 tar = tarfile.open(final_name,
'w:gz')
40 tar.add(flags.Output.HepMCFileName.replace(
'.tgz',
''))
44 os.remove(flags.Output.HepMCFileName.replace(
'.tgz',
''))