1 import FWCore.ParameterSet.Config
as cms
5 ''' Removes the specified flag from the Severity Level Computer, 6 and returns the revised Computer.''' 13 for i
in range(len(sevLevelComputer.SeverityLevels)):
14 Flags=sevLevelComputer.SeverityLevels[i].RecHitFlags.value()
19 ChanStat=sevLevelComputer.SeverityLevels[i].ChannelStatus.value()
21 if len(Flags)==0
and ChanStat==[
'']:
25 sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags
29 if (removeSeverity>-1):
30 sevLevelComputer.SeverityLevels.remove(sevLevelComputer.SeverityLevels[removeSeverity])
32 return sevLevelComputer
36 print "Severity Level Computer Levels and associated flags/Channel Status values:" 37 for i
in SLComp.SeverityLevels:
38 print "\t Level = %i"%i.Level.value()
39 print "\t\t RecHit Flags = %s"%i.RecHitFlags.value()
40 print "\t\t Channel Status = %s"%i.ChannelStatus.value()
45 def AddFlag(sevLevelComputer,flag="UserDefinedBit0",severity=10):
46 ''' Adds specified flag to severity level computer using specified severity level. 47 If flag already exists at another severity level, it is removed from that level. 54 for i
in sevLevelComputer.SeverityLevels:
55 for j
in i.RecHitFlags.value():
58 allowedflags.append(j)
61 if flag
not in allowedflags:
64 print "###################################################" 65 print "\nWARNING!!!!!! You are adding a flag \n\t'%s' \nthat is not defined in the Severity Level Computer!"%flag
66 print "This can be EXCEPTIONALLY dangerous if you do not \nknow what you are doing!\n" 67 print "Proceed with EXTREME caution!\n" 69 print "###################################################" 73 for i
in range(len(sevLevelComputer.SeverityLevels)):
74 Level=sevLevelComputer.SeverityLevels[i].Level.value()
75 Flags=sevLevelComputer.SeverityLevels[i].RecHitFlags.value()
82 sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags
90 if len(Flags)==0
and ChanStat==[
'']:
93 sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags
96 if (removeSeverity>-1):
97 sevLevelComputer.SeverityLevels.remove(sevLevelComputer.SeverityLevels[removeSeverity])
101 if (AddedSeverity==
False):
102 sevLevelComputer.SeverityLevels.append(cms.PSet(Level=cms.int32(severity),
103 RecHitFlags=cms.vstring(flag),
104 ChannelStatus=cms.vstring(
"")))
105 return sevLevelComputer
111 if __name__==
"__main__":
112 import hcalRecAlgoESProd_cfi
as ES
114 ES.hcalRecAlgos=
AddFlag(ES.hcalRecAlgos,flag=
"HOBit",severity=5)
def RemoveFlag(sevLevelComputer, flag="HFLongShort")
def AddFlag(sevLevelComputer, flag="UserDefinedBit0", severity=10)