Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:41

0001 # -*- coding: utf-8 -*-
0002 """
0003 Created on Mon Feb 21 12:38:26 2011
0004 
0005 @author: -
0006 """
0007 
0008 functionNumber = 0
0009 value = []
0010 error = []
0011 
0012 inputFile = open("FitParameters.txt",'r')
0013 
0014 totalFits = 0
0015 for line in inputFile:
0016     if "Fitting with resolution, scale, bgr function" in line:
0017         totalFits += 1
0018 # print "totalFits = ", totalFits
0019 
0020 inputFile = open("FitParameters.txt",'r')
0021 actualFit = 0
0022 for line in inputFile:
0023     if "Fitting with resolution, scale, bgr function" in line and actualFit == totalFits-1:
0024         functionNumber = line.split("# ")[1].split(" ")[0]
0025         # print "functionNumber =", functionNumber
0026         actualFit += 1
0027     elif "Fitting with resolution, scale, bgr function" in line:
0028         actualFit += 1
0029         # print "actualFit = ", actualFit
0030     if "Results of the fit: parameter" in line and actualFit == totalFits:
0031         valueAndError = line.split("value")[1].split(" ")[1].split("+-")
0032         value.append(valueAndError[0])
0033         error.append(valueAndError[1])
0034         # print "value = ", valueAndError
0035         # print valueAndError[0], "+-", valueAndError[1]
0036         
0037     if "Scale" in line and actualFit == totalFits:
0038         break
0039 
0040 values = ""
0041 errors = ""
0042 errorParameters = ""
0043 prepend = ""
0044 for i in range(len(value)):
0045     values += prepend+str(value[i])
0046     errors += prepend+str(error[i])
0047     errorParameters += prepend+"1"
0048     prepend = ", "
0049 
0050 print "values = ", values
0051 print "errors = ", errors
0052     
0053 cfgFile = open("ErrorsPropagationAnalyzer_cfg.py", 'r')
0054 outputCfgFile = open("Errors_cfg.py", 'w')
0055 for line in cfgFile:
0056     if "ResolFitType = " in line:
0057         outputCfgFile.write(line.replace("cms.int32(20)","cms.int32("+functionNumber+")"))
0058     elif "Parameters = cms.vdouble()," in line:
0059         outputCfgFile.write(line.replace("Parameters = cms.vdouble(),","Parameters = cms.vdouble("+values+"),"))
0060     elif "Errors = cms.vdouble()," in line:
0061         outputCfgFile.write(line.replace("Errors = cms.vdouble(),","Errors = cms.vdouble("+errors+"),"))
0062     elif "ErrorFactors = cms.vint32()," in line:
0063         outputCfgFile.write(line.replace("ErrorFactors = cms.vint32(),", "ErrorFactors = cms.vint32("+errorParameters+"),"))
0064     else:
0065         outputCfgFile.write( line )
0066     # print line