コード例 #1
0
    def __init__(self, event, isgen):
        lines = event.split("\n")

        self.weights = {}
        for line in lines:
            if "<wgt" not in line: continue
            match = re.match("<wgt id='(.*)'>([0-9+Ee.-]*)</wgt>", line)
            if match: self.weights[match.group(1)] = float(match.group(2))

        lines = [
            line for line in lines if not (
                "<" in line or ">" in line or not line.split("#")[0].strip())
        ]
        nparticles, _, weight, _, _, _ = lines[0].split()

        nparticles = int(nparticles)
        self.weight = float(weight)
        if nparticles != len(lines) - 1:
            raise ValueError(
                "Wrong number of particles! Should be {}, have {}".format(
                    nparticles,
                    len(lines) - 1))

        daughters, associated, mothers = (
            SimpleParticleCollection_t(_)
            for _ in self.extracteventparticles(lines[1:], isgen))
        if not list(mothers): mothers = None
        self.daughters, self.associated, self.mothers, self.isgen = self.inputevent = InputEvent(
            daughters, associated, mothers, isgen)
コード例 #2
0
 def __new__(cls, event, isgen):
     lines = event.split("\n")
     lines = [
         line for line in lines
         if not ("<event>" in line or "</event>" in line
                 or not line.split("#")[0].strip())
     ]
     nparticles, _, _, _, _, _ = lines[0].split()
     nparticles = int(nparticles)
     if nparticles != len(lines) - 1:
         raise ValueError(
             "Wrong number of particles! Should be {}, have {}".replace(
                 nparticles,
                 len(lines) - 1))
     daughters, associated, mothers = (
         SimpleParticleCollection_t(_)
         for _ in cls.extracteventparticles(lines[1:], isgen))
     return super(LHEEvent, cls).__new__(cls, daughters, associated,
                                         mothers, isgen)