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=defaultDict.keys()
69 print "Default bad (run,events) are:"
72 print "\nA total of %i bad events"%len(keys)
75 for i
in sys.argv[1:]:
76 if not os.path.isfile(i):
77 print "Error, file '%s' does not exist"%i
79 lines=open(i,
'r').readlines()
86 newkeys=newBadDict.keys()
91 out=open(
"badEvents.py",
'w')
94 thistime=time.strftime(
"%H:%M:%S %d %h %Y")
95 out.write(
"# File last updated on %s\n"%thistime)
96 out.write(
"# A total of %i bad events\n\n"%len(newkeys))
98 out.write(
"badEvents=[\n")
101 out.write(
"%s\n"%newBadDict[i])
103 notInOld[i]=newBadDict[i]
110 notInNew[i]=defaultDict[i]
113 print "Total bad events in new file = ",len(newkeys)
115 if len(notInOld.keys())>0:
117 print "A total of %i bad events found"%len(notInOld.keys())
118 for k
in notInOld.keys():
121 if len(notInNew.keys())>0:
123 print "A total of %i events aren't in NEW list!"%len(notInNew.keys())
124 for k
in notInNew.keys():