Skip to content

Commit

Permalink
initial attempt to interface LheEvent #177
Browse files Browse the repository at this point in the history
  • Loading branch information
jacanchaplais committed May 31, 2024
1 parent c9934e2 commit 4e99283
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
34 changes: 34 additions & 0 deletions graphicle/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,40 @@
DataType = ty.TypeVar("DataType")


class LheEventInterface(ty.Protocol):
"""Interface for a generic Les Houches event.
:group: base
.. versionadded:: 0.4.0
"""

@property
def pdg(self) -> IntVector:
"""PDG ID codes."""
...

@property
def pmu(self) -> AnyVector:
"""Four-momenta."""
...

@property
def color(self) -> AnyVector:
"""Color codes."""
...

@property
def helicity(self) -> HalfIntVector:
"""Spin / helicity."""
...

@property
def status(self) -> HalfIntVector:
"""Les Houches specific status codes."""
...


class EventInterface(ty.Protocol):
"""Defines the interface for a generic event object expected by
graphicle's routines. Attributes are stored as numpy arrays, with
Expand Down
8 changes: 7 additions & 1 deletion graphicle/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,13 @@ def copy(self) -> "ParticleSet":
return _composite_copy(self)

@classmethod
def from_madgraph_table(cls, event_table: str) -> "ParticleSet":
def from_lhe_event(cls, event: base.LheEventInterface) -> "ParticleSet":
prop_names = ("pdg", "pmu", "color", "helicity", "status")
data = cls(**{name: getattr(event, name) for name in prop_names})
return data

@classmethod
def _from_lhe_event(cls, event_table: str) -> "ParticleSet":
schema = {
"pdg": 0,
"color": 4,
Expand Down

0 comments on commit 4e99283

Please sign in to comment.