Skip to content

Conversation

@tmadlener
Copy link
Collaborator

BEGINRELEASENOTES

  • Add an extract method to the Frame to allow removing existing collections from a Frame.

ENDRELEASENOTES

This has a lot of sharp edges, but it might be useful for some tasks.

@paulgessinger FYI

@jmcarcell
Copy link
Member

This looks complicated, what's the use case? I think it only makes sense when the collection has not been written, so when the Frame has been used as temporary storage for the collections? But then any other container could be used.

@paulgessinger
Copy link
Contributor

paulgessinger commented Oct 9, 2025

I would like to use this to filter collections. My use case is that I would eg like to process particles and only keep some of them, while patching up simulated hits.

Currently, I have no way to do that while retaining the rest of the content of a frame from an input file to an output file.

In practice, I would like to read a frame from a file, remove a number of collections while keeping the rest intact, modifying it, then put it back into that same frame, and finally write it to an output file.

This is current not possible I think.

@jmcarcell
Copy link
Member

jmcarcell commented Oct 10, 2025

I think two ways exist that may not be optimal:

  • Create subset collections with only the particles and the hits that you want (good if you keep most of the original contents, as the difference in size wouldn't be that big compared to dropping the original collection, no need to worry about relations)
  • Create a new collection (I think this is what you do and then you want to drop the original). Note that this has the problem that any relation pointing to the ones you want to drop will not be valid anymore, so dropping the existing one and replacing it with the new one downstream is not that easy.

Unless size is a big concern, option 1 works and you don't have to worry about the relations. Maybe we could discuss having something for either filtering or removing collections.

@paulgessinger
Copy link
Contributor

paulgessinger commented Oct 10, 2025

Size is exactly what this is about. I have files where I need to strip the vast majority of particles to get that under control.

I don't think either of these options work with the current API @jmcarcell, if want to keep all collections I'm not explicitly touching

  • If I read a frame with all collections to write that out to my target file, without this PR I can't modify any of the collections I do want to filer.
  • If I read a frame with all collections, I can't copy over all of the other collections that I'm not touching, without knowing their names and types ahead of time (there's no way to copy a CollectionBase* form one frame to another)

Your option 1 requires me to overwrite the modified collection into the output frame, which I don't believe I can.

I could possibly read an event from a frame with only the collections I want, and then again with all collections except the ones that I don't want, but from what I understand from @tmadlener this will have some impact on the relationships.

So this PR is a compromise that allows me to manipulate a frame partially.

@tmadlener tmadlener changed the title Add the possibility to extract collections from a Frame [wip] Add the possibility to extract collections from a Frame Oct 14, 2025
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 this pull request may close these issues.

3 participants