1 from __future__
import print_function
2 from __future__
import absolute_import
3 import FWCore.ParameterSet.Config
as cms
7 ''' Removes the specified flag from the Severity Level Computer, 8 and returns the revised Computer.''' 15 for i
in range(len(sevLevelComputer.SeverityLevels)):
16 Flags=sevLevelComputer.SeverityLevels[i].RecHitFlags.value()
21 ChanStat=sevLevelComputer.SeverityLevels[i].ChannelStatus.value()
23 if len(Flags)==0
and ChanStat==[
'']:
27 sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags
31 if (removeSeverity>-1):
32 sevLevelComputer.SeverityLevels.remove(sevLevelComputer.SeverityLevels[removeSeverity])
34 return sevLevelComputer
38 print(
"Severity Level Computer Levels and associated flags/Channel Status values:")
39 for i
in SLComp.SeverityLevels:
40 print(
"\t Level = %i"%i.Level.value())
41 print(
"\t\t RecHit Flags = %s"%i.RecHitFlags.value())
42 print(
"\t\t Channel Status = %s"%i.ChannelStatus.value())
47 def AddFlag(sevLevelComputer,flag="UserDefinedBit0",severity=10,verbose=True):
48 ''' Adds specified flag to severity level computer using specified severity level. 49 If flag already exists at another severity level, it is removed from that level. 56 for i
in sevLevelComputer.SeverityLevels:
57 for j
in i.RecHitFlags.value():
60 allowedflags.append(j)
63 if flag
not in allowedflags
and verbose:
66 print(
"###################################################")
67 print(
"\nWARNING!!!!!! You are adding a flag \n\t'%s' \nthat is not defined in the Severity Level Computer!"%flag)
68 print(
"This can be EXCEPTIONALLY dangerous if you do not \nknow what you are doing!\n")
69 print(
"Proceed with EXTREME caution!\n")
71 print(
"###################################################")
75 for i
in range(len(sevLevelComputer.SeverityLevels)):
76 Level=sevLevelComputer.SeverityLevels[i].Level.value()
77 Flags=sevLevelComputer.SeverityLevels[i].RecHitFlags.value()
84 sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags
91 ChanStat=sevLevelComputer.SeverityLevels[i].ChannelStatus.value()
93 if len(Flags)==0
and ChanStat==[
'']:
96 sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags
99 if (removeSeverity>-1):
100 sevLevelComputer.SeverityLevels.remove(sevLevelComputer.SeverityLevels[removeSeverity])
104 if (AddedSeverity==
False):
105 sevLevelComputer.SeverityLevels.append(cms.PSet(Level=cms.int32(severity),
106 RecHitFlags=cms.vstring(flag),
107 ChannelStatus=cms.vstring(
"")))
108 return sevLevelComputer
114 if __name__==
"__main__":
115 from .
import hcalRecAlgoESProd_cfi
as ES
117 ES.hcalRecAlgos=
AddFlag(ES.hcalRecAlgos,flag=
"HOBit",severity=5)
def RemoveFlag(sevLevelComputer, flag="HFLongShort")
def AddFlag(sevLevelComputer, flag="UserDefinedBit0", severity=10, verbose=True)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)