3 from __future__
import print_function
4 from __future__
import absolute_import
5 from builtins
import range
9 import FWCore.ParameterSet.Config
as cms
10 from .hcalLaserEventFilter_cfi
import hcalLaserEventFilter
12 ''' 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. 14 If no text file is provided, then the current bad events in the .py file will be displayed. 20 for i
in range(0,len(startlist),2):
24 dict[runevent]=
"%s,%s,"%(key1,key2)
28 ''' Read a new list of bad runs from an input file, and 29 creates a new list of output keys for the bad run/events. 36 temp=string.split(temp,
",")
39 temp=string.split(temp)
44 run=string.atoi(temp[0])
45 evt=string.atoi(temp[2])
47 print(
"Could not parse line '%s'"%i)
51 run=string.atoi(temp[0])
52 evt=string.atoi(temp[1])
54 print(
"Could not parse line '%s'"%i)
56 print(
"Cannot parse line! ('%s')"%i)
66 if __name__==
"__main__":
67 defaultList=hcalLaserEventFilter.BadRunEventNumbers
69 keys=sorted(defaultDict.keys())
71 print(
"Default bad (run,events) are:")
74 print(
"\nA total of %i bad events"%len(keys))
77 for i
in sys.argv[1:]:
78 if not os.path.isfile(i):
79 print(
"Error, file '%s' does not exist"%i)
81 lines=open(i,
'r').readlines() 88 newkeys=newBadDict.keys()
93 out=open(
"badEvents.py",
'w')
96 thistime=time.strftime(
"%H:%M:%S %d %h %Y")
97 out.write(
"# File last updated on %s\n"%thistime)
98 out.write(
"# A total of %i bad events\n\n"%len(newkeys))
100 out.write(
"badEvents=[\n")
103 out.write(
"%s\n"%newBadDict[i])
105 notInOld[i]=newBadDict[i]
112 notInNew[i]=defaultDict[i]
115 print(
"Total bad events in new file = ",len(newkeys))
119 print(
"A total of %i bad events found"%len(notInOld))
120 for k
in notInOld.keys():
125 print(
"A total of %i events aren't in NEW list!"%len(notInNew))
126 for k
in notInNew.keys():
S & print(S &os, JobReport::InputFile const &f)