-
Notifications
You must be signed in to change notification settings - Fork 0
/
LHEfile.py
30 lines (26 loc) · 894 Bytes
/
LHEfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import ROOT as rt
class LHEfile():
def __init__(self, fileINname):
self.eventList = []
self.fileINname = fileINname
self.MaxEv = -99
def setMax(self, maxVal):
self.Max = maxVal
def readEvents(self):
fileIN = open(self.fileINname)
newEVENT = False
oneEvent = []
for line in fileIN:
if newEVENT: oneEvent.append(line)
if line.find("</event>") != -1:
# the event block ends
newEVENT = False
self.eventList.append(oneEvent)
oneEvent = []
if len(self.eventList) >= self.Max and self.Max>0: break
if line.find("<event>") != -1:
# the event block starts
newEVENT = True
oneEvent.append(line)
fileIN.close()
return self.eventList