46 Modifies `events.lhe` output file from Madgraph by doing the following:
48 - Changes photon px and py to zero and energy to pz
49 - Recalculates energy scales as an average of lepton pair transverse momentum
52 DOMTree = xml.dom.minidom.parse(self.
inFileName)
53 collection = DOMTree.documentElement
56 init = collection.getElementsByTagName(
'init')
58 13 -13 2.510000e+03 2.510000e+03 0 0 0 0 3 1
59 1.000000e+00 0.000000e+00 1.000000e+00 9999
61 init[0].firstChild.data = init_repl
65 event_header =
r'^(\s*\S*\s*\S*\s*\S*\s*)(\S*)(.*)$'
69 event_particle =
r'^(\s*)([0-9-]+)(\s+[0-9-]+\s+[0-9-]+\s+[0-9-]+\s+[0-9-]+\s+[0-9-]+\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(\s+)(\S+)(.*)$'
71 events = collection.getElementsByTagName(
'event')
72 for i, event
in enumerate(events):
75 nodes = event.getElementsByTagName(
'mgrwt')
77 parent = node.parentNode
78 parent.removeChild(node)
83 particles = re.findall(event_particle, event.firstChild.data, re.MULTILINE)
84 for particle
in particles:
85 particle = list(particle)
86 if particle[1] ==
'22':
90 particle[9] = particle[7]
92 if self.
mode ==
'Tauolapp':
94 particle[1] =
'11' if float(particle[7]) > 0.0
else '-11'
96 particle[1] =
'-11' if float(particle[7]) > 0.0
else '11'
97 new_particles.append(
''.join(particle))
98 elif particle[1]
in self.
leptons:
100 lepton_mom.append(float(particle[3]))
101 lepton_mom.append(float(particle[5]))
102 new_particles.append(
''.join(particle))
104 new_particles.append(
''.join(particle))
107 l1_px, l1_py, l2_px, l2_py = lepton_mom
108 l1_pt = math.sqrt(l1_px**2 + l1_py**2)
109 l2_pt = math.sqrt(l2_px**2 + l2_py**2)
110 energy_scale = f
'{(l1_pt + l2_pt) / 2.:.9E}'
112 header = re.search(event_header, event.firstChild.data, re.MULTILINE)
113 header = list(header.groups())
114 header[1] = energy_scale
117 event.firstChild.data =
'\n'.join([
''.join(header)] + new_particles) +
'\n'
119 event.firstChild.data =
'\n'.join([
''.join(header)] + new_particles)
122 output.write(DOMTree.toxml().
replace(
'<?xml version="1.0" ?>',
' '))
126 return StatusCode.Success