CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
RemoveAddSevLevel Namespace Reference

Functions

def AddFlag
 
def PrintLevels
 
def RemoveFlag
 

Function Documentation

def RemoveAddSevLevel.AddFlag (   sevLevelComputer,
  flag = "UserDefinedBit0",
  severity = 10,
  verbose = True 
)
Adds specified flag to severity level computer using specified severity level.
    If flag already exists at another severity level, it is removed from that level.

Definition at line 47 of file RemoveAddSevLevel.py.

References print(), PrintLevels(), sistrip::SpyUtilities.range(), and RemoveFlag().

47 
48 def AddFlag(sevLevelComputer,flag="UserDefinedBit0",severity=10,verbose=True):
49  ''' Adds specified flag to severity level computer using specified severity level.
50  If flag already exists at another severity level, it is removed from that level.
51  '''
52 
53  AddedSeverity=False
54  removeSeverity=-1
55 
56  allowedflags=[]
57  for i in sevLevelComputer.SeverityLevels:
58  for j in i.RecHitFlags.value():
59  if j=="":
60  continue
61  allowedflags.append(j)
62 
63  #print "Allowed flags = ",allowedflags
64  if flag not in allowedflags and verbose:
65  print("\n\n")
66  for j in range(0,3):
67  print("###################################################")
68  print("\nWARNING!!!!!! You are adding a flag \n\t'%s' \nthat is not defined in the Severity Level Computer!"%flag)
69  print("This can be EXCEPTIONALLY dangerous if you do not \nknow what you are doing!\n")
70  print("Proceed with EXTREME caution!\n")
71  for j in range(0,3):
72  print("###################################################")
73  print("\n\n")
74 
75  #Loop over severity Levels
76  for i in range(len(sevLevelComputer.SeverityLevels)):
77  Level=sevLevelComputer.SeverityLevels[i].Level.value()
78  Flags=sevLevelComputer.SeverityLevels[i].RecHitFlags.value()
79  if Level==severity: # Found the specified level
80  if (Flags==['']):
81  Flags=[flag] # Create new vector for this flag
82  else:
83  if flag not in Flags: # don't need to add flag if it's already there
84  Flags.append(flag) # append flag to existing vector
85  sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags # Set new RecHitFlags vector
86  AddedSeverity=True
87  else: # Found some other level; be sure to remove flag from it
88  if flag not in Flags:
89  continue
90  else:
91  Flags.remove(flag)
92  ChanStat=sevLevelComputer.SeverityLevels[i].ChannelStatus.value()
93  # Removing flag leaves nothing else: need to remove this level completely
94  if len(Flags)==0 and ChanStat==['']:
95  removeSeverity=i
96  else:
97  sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags
98 
99  # Remove any newly-empty levels
100  if (removeSeverity>-1):
101  sevLevelComputer.SeverityLevels.remove(sevLevelComputer.SeverityLevels[removeSeverity])
102 
103  # No existing severity level for specified severity was found;
104  # add a new one
105  if (AddedSeverity==False):
106  sevLevelComputer.SeverityLevels.append(cms.PSet(Level=cms.int32(severity),
107  RecHitFlags=cms.vstring(flag),
108  ChannelStatus=cms.vstring("")))
109  return sevLevelComputer
110 
111 
const uint16_t range(const Frame &aFrame)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def RemoveAddSevLevel.PrintLevels (   SLComp)

Definition at line 37 of file RemoveAddSevLevel.py.

References print().

Referenced by AddFlag().

37 
38 def PrintLevels(SLComp):
39  print("Severity Level Computer Levels and associated flags/Channel Status values:")
40  for i in SLComp.SeverityLevels:
41  print("\t Level = %i"%i.Level.value())
42  print("\t\t RecHit Flags = %s"%i.RecHitFlags.value())
43  print("\t\t Channel Status = %s"%i.ChannelStatus.value())
44  print()
45  return
46 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def RemoveAddSevLevel.RemoveFlag (   sevLevelComputer,
  flag = "HFLongShort" 
)
Removes the specified flag from the Severity Level Computer,
and returns the revised Computer.

Definition at line 6 of file RemoveAddSevLevel.py.

References sistrip::SpyUtilities.range().

Referenced by AddFlag().

6 
7 def RemoveFlag(sevLevelComputer,flag="HFLongShort"):
8  ''' Removes the specified flag from the Severity Level Computer,
9  and returns the revised Computer.'''
10 
11  removeSeverity=-1 # Track which Severity Level has been modified
12 
13 
14 
15  # Loop over all levels
16  for i in range(len(sevLevelComputer.SeverityLevels)):
17  Flags=sevLevelComputer.SeverityLevels[i].RecHitFlags.value()
18  if flag not in Flags: # Flag not present for this level
19  continue
20  #Remove flag
21  Flags.remove(flag)
22  ChanStat=sevLevelComputer.SeverityLevels[i].ChannelStatus.value()
23  # Check to see if Severity Level no longer contains any useful information
24  if len(Flags)==0 and ChanStat==['']:
25  removeSeverity=i
26  else:
27  # Set revised list of flags for this severity level
28  sevLevelComputer.SeverityLevels[i].RecHitFlags=Flags
29  break
30 
31  # Removing flag results in empty severity level; remove it
32  if (removeSeverity>-1):
33  sevLevelComputer.SeverityLevels.remove(sevLevelComputer.SeverityLevels[removeSeverity])
34 
35  return sevLevelComputer
36 
const uint16_t range(const Frame &aFrame)