Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve python interface when adding collections to a frame #432

Closed
jmcarcell opened this issue Jun 20, 2023 · 1 comment · Fixed by #447
Closed

Improve python interface when adding collections to a frame #432

jmcarcell opened this issue Jun 20, 2023 · 1 comment · Fixed by #447

Comments

@jmcarcell
Copy link
Member

jmcarcell commented Jun 20, 2023

At the moment writing collections and frames is possible from python but a bit cumbersome:

from edm4hep import edm4hep
from ROOT import podio
from podio.root_io import Writer
import cppyy

writer = Writer('frame.root') # This will write the frame to a file called frame.root

frame = podio.Frame() # This is where the collection and other things will be stored
coll = edm4hep.MCParticleCollection() # Create an EDM4hep collection

coll.create() # Create a MutableMCParticle object

frame.put(cppyy.gbl.std.move(coll), "MCParticles") # Add collection to frame 

writer.writeFrame(frame, 'events')
writer.finish()

I think the agreement here is that frame.put should work without cppyy.gbl.std.move (and also with it in case someone is translating literally the C++ code?). I can give it a try this week, it should be easy to do

@tmadlener
Copy link
Collaborator

I am not entirely sure about whether it has to work both ways actually. I think having it work without std.move should be the main goal. In principle std::move(std::move(foo)) should be valid c++, but I am not sure whether cppyy can handle it. Maybe it does and it just works out of the box. Otherwise we just document it.

Another interesting question to clarify is the state in which the collection is in after put (mainly for documentation purposes).

Related: #326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants