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

[question] Hierarchical model #677

Open
remenska opened this issue Jan 6, 2016 · 1 comment
Open

[question] Hierarchical model #677

remenska opened this issue Jan 6, 2016 · 1 comment

Comments

@remenska
Copy link
Contributor

remenska commented Jan 6, 2016

Hi,
I'm wondering if this is at all possible with rootpy; I have an existing python data model (sketch below), which i want to convert/migrate to a rootpy one:

class ReconstructedPosition(object):
    x 
    y 
    ....

class Peak(object):
    area
    detector
    ...
    reconstructed_positions = list(ReconstructedPosition)

class Event(object):
    event_number
    dataset_name 
    ...
    peaks = list(Peak)  

From the examples, I see the only possible "hierarchical" modeling is by passsing .prefix()/.suffix(), but this essentially flattens the model, as the attributes are copied over.
The user_object example would be a good start (except that generating C++ code is ugly), but then I would need somethng like ObjectArrayCol or stl.vector to model the collection of peaks, etc.

Is it possible at all to make this kind of truly hierarchical structure with rootpy in a clean way?

Thanks upfront!

@ndawe
Copy link
Member

ndawe commented Jan 8, 2016

Hmm... Handling nested structure like this with TreeModel is currently not implemented, unless, like you say, you use stl.vector and structs.

The hierarchical nature of TreeModel is really in the sense that you can define a basic object like a FourVector and extend that in subclasses for separate types of particles (for example), as well as mixing classes through multiple inheritance.

Any list of something is probably best implemented as a vector in the TTree. This is what I've used in various TreeModels, but it always feels more finicky than it should.

I agree that implementing something to automatically map such a nested structure to the appropriate vectors (possibly nested vectors) would be very useful.

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

No branches or pull requests

2 participants