3 from __future__
import print_function
7 import FWCore.ParameterSet.Config
as cms
8 from hcalLaserEventFilter_cfi
import hcalLaserEventFilter
10 ''' 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. 12 If no text file is provided, then the current bad events in the .py file will be displayed. 18 for i
in range(0,len(startlist),2):
22 dict[runevent]=
"%s,%s,"%(key1,key2)
26 ''' Read a new list of bad runs from an input file, and 27 creates a new list of output keys for the bad run/events. 34 temp=string.split(temp,
",")
37 temp=string.split(temp)
42 run=string.atoi(temp[0])
43 evt=string.atoi(temp[2])
45 print(
"Could not parse line '%s'"%i)
49 run=string.atoi(temp[0])
50 evt=string.atoi(temp[1])
52 print(
"Could not parse line '%s'"%i)
54 print(
"Cannot parse line! ('%s')"%i)
64 if __name__==
"__main__":
65 defaultList=hcalLaserEventFilter.BadRunEventNumbers
67 keys=sorted(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))
117 print(
"A total of %i bad events found"%len(notInOld))
118 for k
in notInOld.keys():
123 print(
"A total of %i events aren't in NEW list!"%len(notInNew))
124 for k
in notInNew.keys():
S & print(S &os, JobReport::InputFile const &f)