Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-10-25 04:54:49

0001 ##########################################################################
0002 # Parse the pede.dump.gz file and returns a pedeDump object with the
0003 # parsed information of the file.
0004 ##
0005 
0006 import gzip
0007 import logging
0008 import re
0009 
0010 import Alignment.MillePedeAlignmentAlgorithm.mpsvalidate.classes as mpsv_classes
0011 
0012 
0013 def parse(path, config):
0014     logger = logging.getLogger("mpsvalidate")
0015     
0016     # parse pede.dump.gz
0017 
0018     pedeDump = mpsv_classes.PedeDumpData()
0019 
0020     # only recognize warning the first time
0021     warningBool = False
0022 
0023     # save lines in list
0024     try:
0025         with gzip.open(path) as gzipFile:
0026             dumpFile = [ l.decode() for l in gzipFile.readlines() ]
0027     except IOError:
0028         logger.error("PedeDump: {0} does not exist".format(path))
0029         return
0030 
0031     for i, line in enumerate(dumpFile):
0032         # Sum(Chi^2)/Sum(Ndf)
0033         if ("Sum(Chi^2)/Sum(Ndf) =" in line):
0034             number = []
0035             number.append(list(map(float, re.findall(
0036                 r"[-+]?\d*\.\d+", dumpFile[i]))))
0037             number.append(list(map(int, re.findall(r"[-+]?\d+", dumpFile[i + 1]))))
0038             number.append(list(map(float, re.findall(
0039                 r"[-+]?\d*\.\d+", dumpFile[i + 2]))))
0040             pedeDump.sumSteps = "{0} / ( {1} - {2} )".format(
0041                 number[0][0], number[1][0], number[1][1])
0042             pedeDump.sumValue = number[2][0]
0043 
0044         # Sum(W*Chi^2)/Sum(Ndf)/<W>
0045         if ("Sum(W*Chi^2)/Sum(Ndf)/<W> =" in line):
0046             number = []
0047             number.append(list(map(float, re.findall(
0048                 r"[-+]?\d*\.\d+", dumpFile[i]))))
0049             number.append(list(map(int, re.findall(r"[-+]?\d+", dumpFile[i + 1]))))
0050             number.append(list(map(float, re.findall(
0051                 r"[-+]?\d*\.\d+", dumpFile[i + 2]))))
0052             number.append(list(map(float, re.findall(
0053                 r"[-+]?\d*\.\d+", dumpFile[i + 3]))))
0054             pedeDump.sumSteps = "{0} / ( {1} - {2} ) / {3}".format(
0055                 number[0][0], number[1][0], number[1][1], number[2][0])
0056             pedeDump.sumWValue = number[3][0]
0057 
0058         if ("with correction for down-weighting" in line):
0059             number = list(map(float, re.findall(r"[-+]?\d*\.\d+", dumpFile[i])))
0060             pedeDump.correction = number[0]
0061 
0062         # Peak dynamic memory allocation
0063         if ("Peak dynamic memory allocation:" in line):
0064             number = list(map(float, re.findall(r"[-+]?\d*\.\d+", dumpFile[i])))
0065             pedeDump.memory = number[0]
0066 
0067         # total time
0068         if ("Iteration-end" in line):
0069             number = list(map(int, re.findall(r"\d+", dumpFile[i + 1])))
0070             pedeDump.time = number[:3]
0071 
0072         # warings
0073         if ("WarningWarningWarningWarning" in line and warningBool == False):
0074             warningBool = True
0075             j = i + 8
0076             while ("Warning" not in dumpFile[j]):
0077                 pedeDump.warning.append(dumpFile[j])
0078                 j += 1
0079 
0080         # nrec number of records
0081         if (" = number of records" in line):
0082             number = list(map(int, re.findall("\d+", dumpFile[i])))
0083             pedeDump.nrec = number[0]
0084 
0085         # ntgb total number of parameters
0086         if (" = total number of parameters" in line):
0087             number = list(map(int, re.findall("\d+", dumpFile[i])))
0088             pedeDump.ntgb = number[0]
0089 
0090         # nvgb number of variable parameters
0091         if (" = number of variable parameters" in line):
0092             number = list(map(int, re.findall("\d+", dumpFile[i])))
0093             pedeDump.nvgb = number[0]
0094 
0095     return pedeDump