6 import FWCore.ParameterSet.Config
as cms
7 from hcalLaserEventFilter_cfi
import hcalLaserEventFilter
9 ''' Program reads existing bad run/event list from hcalLaserEventFilter_cfi.py, and an (optional) new list from a text file. If a text file is specified, this is assumed to be the desired new bad list, and its output will be sent to badEvents.py in the form needed by the cfi file. 11 If no text file is provided, then the current bad events in the .py file will be displayed. 17 for i
in range(0,len(startlist),2):
21 dict[runevent]=
"%s,%s,"%(key1,key2)
25 ''' Read a new list of bad runs from an input file, and 26 creates a new list of output keys for the bad run/events. 33 temp=string.split(temp,
",")
36 temp=string.split(temp)
41 run=string.atoi(temp[0])
42 evt=string.atoi(temp[2])
44 print "Could not parse line '%s'"%i
48 run=string.atoi(temp[0])
49 evt=string.atoi(temp[1])
51 print "Could not parse line '%s'"%i
53 print "Cannot parse line! ('%s')"%i
63 if __name__==
"__main__":
64 defaultList=hcalLaserEventFilter.BadRunEventNumbers
66 keys=sorted(defaultDict.keys())
68 print "Default bad (run,events) are:" 71 print "\nA total of %i bad events"%len(keys)
74 for i
in sys.argv[1:]:
75 if not os.path.isfile(i):
76 print "Error, file '%s' does not exist"%i
78 lines=open(i,
'r').readlines() 85 newkeys=newBadDict.keys()
90 out=open(
"badEvents.py",
'w')
93 thistime=time.strftime(
"%H:%M:%S %d %h %Y")
94 out.write(
"# File last updated on %s\n"%thistime)
95 out.write(
"# A total of %i bad events\n\n"%len(newkeys))
97 out.write(
"badEvents=[\n")
100 out.write(
"%s\n"%newBadDict[i])
102 notInOld[i]=newBadDict[i]
109 notInNew[i]=defaultDict[i]
112 print "Total bad events in new file = ",len(newkeys)
116 print "A total of %i bad events found"%len(notInOld)
117 for k
in notInOld.keys():
122 print "A total of %i events aren't in NEW list!"%len(notInNew)
123 for k
in notInNew.keys():