Skip to content

Particlegun with HepMC3

Andrii Verbytskyi requested to merge averbyts/athena:particlegun into 23.0

Particlegun with HepMC3.

The particle gun is a cppyy-based python script. Because HepMC3 uses smart pointers, several adjustments are required from the point of view of syntax.

The adjustments are also tested locally dropping the Athena-specific code and using a script

import cppyy
cppyy.include('HepMC3/GenParticle.h')
cppyy.include('HepMC3/GenEvent.h')
cppyy.include('HepMC3/FourVector.h')
cppyy.include('HepMC3/GenVertex.h')
cppyy.include('HepMC3/Print.h')
cppyy.include('HepMC3/WriterAscii.h')
cppyy.load_library('libHepMC3')
from cppyy.gbl import HepMC3 as HepMC
from cppyy.gbl import std as std
from ParticleGun import ParticleGun
evt = HepMC.GenEvent()
pg = ParticleGun()
pg.fillEvent(evt)
w=HepMC.WriterAscii("1.txt")
w.write_event(evt)

The resulting file contains

HepMC::Version 3.02.06
HepMC::Asciiv3-START_EVENT_LISTING
E 0 2 4
U MEV MM
W 1.0000000000000000000000e+00
A -2 barcode -2
A -1 barcode -1
A 1 barcode 1
A 2 barcode 2
A 3 barcode 3
A 4 barcode 4
P 1 0 4 0.0000000000000000e+00 0.0000000000000000e+00 -7.0000000000000000e+03 7.0000000000000000e+03 0.0000000000000000e+00 2212
P 2 0 4 0.0000000000000000e+00 0.0000000000000000e+00 7.0000000000000000e+03 7.0000000000000000e+03 0.0000000000000000e+00 2212
V -1 0 [1,2]
P 3 -1 999 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 1.0000000000000000e+00 11
P 4 3 999 0.0000000000000000e+00 0.0000000000000000e+00 0.0000000000000000e+00 1.0000000000000000e+00 1.0000000000000000e+00 1
HepMC::Asciiv3-END_EVENT_LISTING

Please note that in order to have a fully connected tree-like event, an additional ghost particle per each final state particle is needed.

Tag @ewelina @jchapman @zmarshal

Edited by Andrii Verbytskyi

Merge request reports