CMS 3D CMS Logo

Functions
dumpparser Namespace Reference

Functions

def parse (path, config)
 

Function Documentation

◆ parse()

def dumpparser.parse (   path,
  config 
)

Definition at line 13 of file dumpparser.py.

References genParticles_cff.map.

13 def parse(path, config):
14  logger = logging.getLogger("mpsvalidate")
15 
16  # parse pede.dump.gz
17 
18  pedeDump = mpsv_classes.PedeDumpData()
19 
20  # only recognize warning the first time
21  warningBool = False
22 
23  # save lines in list
24  try:
25  with gzip.open(path) as gzipFile:
26  dumpFile = [ l.decode() for l in gzipFile.readlines() ]
27  except IOError:
28  logger.error("PedeDump: {0} does not exist".format(path))
29  return
30 
31  for i, line in enumerate(dumpFile):
32  # Sum(Chi^2)/Sum(Ndf)
33  if ("Sum(Chi^2)/Sum(Ndf) =" in line):
34  number = []
35  number.append(list(map(float, re.findall(
36  r"[-+]?\d*\.\d+", dumpFile[i]))))
37  number.append(list(map(int, re.findall(r"[-+]?\d+", dumpFile[i + 1]))))
38  number.append(list(map(float, re.findall(
39  r"[-+]?\d*\.\d+", dumpFile[i + 2]))))
40  pedeDump.sumSteps = "{0} / ( {1} - {2} )".format(
41  number[0][0], number[1][0], number[1][1])
42  pedeDump.sumValue = number[2][0]
43 
44  # Sum(W*Chi^2)/Sum(Ndf)/<W>
45  if ("Sum(W*Chi^2)/Sum(Ndf)/<W> =" in line):
46  number = []
47  number.append(list(map(float, re.findall(
48  r"[-+]?\d*\.\d+", dumpFile[i]))))
49  number.append(list(map(int, re.findall(r"[-+]?\d+", dumpFile[i + 1]))))
50  number.append(list(map(float, re.findall(
51  r"[-+]?\d*\.\d+", dumpFile[i + 2]))))
52  number.append(list(map(float, re.findall(
53  r"[-+]?\d*\.\d+", dumpFile[i + 3]))))
54  pedeDump.sumSteps = "{0} / ( {1} - {2} ) / {3}".format(
55  number[0][0], number[1][0], number[1][1], number[2][0])
56  pedeDump.sumWValue = number[3][0]
57 
58  if ("with correction for down-weighting" in line):
59  number = list(map(float, re.findall(r"[-+]?\d*\.\d+", dumpFile[i])))
60  pedeDump.correction = number[0]
61 
62  # Peak dynamic memory allocation
63  if ("Peak dynamic memory allocation:" in line):
64  number = list(map(float, re.findall(r"[-+]?\d*\.\d+", dumpFile[i])))
65  pedeDump.memory = number[0]
66 
67  # total time
68  if ("Iteration-end" in line):
69  number = list(map(int, re.findall(r"\d+", dumpFile[i + 1])))
70  pedeDump.time = number[:3]
71 
72  # warings
73  if ("WarningWarningWarningWarning" in line and warningBool == False):
74  warningBool = True
75  j = i + 8
76  while ("Warning" not in dumpFile[j]):
77  pedeDump.warning.append(dumpFile[j])
78  j += 1
79 
80  # nrec number of records
81  if (" = number of records" in line):
82  number = list(map(int, re.findall("\\d+", dumpFile[i])))
83  pedeDump.nrec = number[0]
84 
85  # ntgb total number of parameters
86  if (" = total number of parameters" in line):
87  number = list(map(int, re.findall("\\d+", dumpFile[i])))
88  pedeDump.ntgb = number[0]
89 
90  # nvgb number of variable parameters
91  if (" = number of variable parameters" in line):
92  number = list(map(int, re.findall("\\d+", dumpFile[i])))
93  pedeDump.nvgb = number[0]
94 
95  return pedeDump
96 
vector< string > parse(string line, const string &delimiter)