Skip to content

Commit

Permalink
doc: document new tolhe function
Browse files Browse the repository at this point in the history
  • Loading branch information
APN-Pucky committed Feb 20, 2024
1 parent f9fb807 commit ec337d5
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion src/pylhe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ def __init__(
self._graph = None

def tolhe(self, rwgt=True, weights=False):
""" """
"""
Return the event as a string in LHE format.
Args:
rwgt (bool): Include the weights in the 'rwgt' format.
weights (bool): Include the weights in the 'weights' format.
Returns:
str: The event as a string in LHE format.
"""
sweights = ""
if rwgt:
if self.weights:
Expand Down Expand Up @@ -154,6 +163,12 @@ def __init__(self, **kwargs):
setattr(self, k, v)

def tolhe(self):
"""
Return the event info as a string in LHE format.
Returns:
str: The event info as a string in LHE format.
"""
return "{:3d} {:6d} {: 15.10e} {: 15.10e} {: 15.10e} {: 15.10e}".format(
*[int(getattr(self, f)) for f in self.fieldnames[:2]],
*[getattr(self, f) for f in self.fieldnames[2:]],
Expand Down Expand Up @@ -194,6 +209,12 @@ def fromstring(cls, string):
return cls(**dict(zip(cls.fieldnames, map(float, string.split()))))

def tolhe(self):
"""
Return the particle as a string in LHE format.
Returns:
str: The particle as a string in LHE format.
"""
return "{:5d} {:3d} {:3d} {:3d} {:3d} {:3d} {: 15.8e} {: 15.8e} {: 15.8e} {: 15.8e} {: 15.8e} {: 10.4e} {: 10.4e}".format(
*[int(getattr(self, f)) for f in self.fieldnames[:6]],
*[getattr(self, f) for f in self.fieldnames[6:]],
Expand All @@ -216,6 +237,12 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def tolhe(self):
"""
Return the init block as a string in LHE format.
Returns:
str: The init block as a string in LHE format.
"""
# weightgroups to xml
root = ET.Element("initrwgt")
for k, v in self["weightgroup"].items():
Expand Down Expand Up @@ -279,6 +306,12 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def tolhe(self):
"""
Return the init info block as a string in LHE format.
Returns:
str: The init info block as a string in LHE format.
"""
return (
" {: 6d} {: 6d} {: 14.7e} {: 14.7e} {: 5d} {: 5d} {: 5d} {: 5d} {: 5d} {: 5d}"
).format(
Expand Down Expand Up @@ -308,6 +341,12 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def tolhe(self):
"""
Return the process info block as a string in LHE format.
Returns:
str: The process info block as a string in LHE format.
"""
return ("{: 14.7e} {: 14.7e} {: 14.7e} {: 5d}").format(
self["xSection"], self["error"], self["unitWeight"], int(self["procId"])
)
Expand Down

0 comments on commit ec337d5

Please sign in to comment.