ATLAS Offline Software
Classes | Functions | Variables
python.ids Namespace Reference

Classes

class  DefectID
 
class  DefectIDBitfield
 
class  DefectsDBIDsNamesMixin
 

Functions

int choose_new_defect_id (Mapping[Union[str, int], Union[str, int]] existing_map, str defect_name, bool virtual=False)
 

Variables

 log
 

Function Documentation

◆ choose_new_defect_id()

int python.ids.choose_new_defect_id ( Mapping[Union[str, int], Union[str,int]]  existing_map,
str  defect_name,
bool   virtual = False 
)
Function to create a new defect ID.

We're abandoning the mapping of defect names to IDs (Oct 2012).
Hence here we just ask for the first open gap in ID numbers.
It works for virtual IDs as well, though via a bit of an edge case for
when none exist yet.

Definition at line 48 of file ids.py.

48 def choose_new_defect_id(existing_map: Mapping[Union[str, int], Union[str,int]],
49  defect_name: str, virtual: bool = False) -> int:
50  """
51  Function to create a new defect ID.
52 
53  We're abandoning the mapping of defect names to IDs (Oct 2012).
54  Hence here we just ask for the first open gap in ID numbers.
55  It works for virtual IDs as well, though via a bit of an edge case for
56  when none exist yet.
57  """
58  existing = sorted(_ for _ in six.itervalues(existing_map) if not isinstance(_, six.string_types))
59  if len(existing) == 0:
60  newid = 0
61  else:
62  newid = None
63  for i, v in enumerate(existing[1:]):
64  if v-existing[i] > 1:
65  newid = existing[i]+1
66  break
67  if newid is None:
68  newid = existing[-1] + 1
69  did = DefectID(newid)
70  did.is_virtual=virtual
71  log.debug("Chose new id: %r", did)
72  return int(did)
73 

Variable Documentation

◆ log

python.ids.log

Definition at line 3 of file ids.py.

CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
python.ids.choose_new_defect_id
int choose_new_defect_id(Mapping[Union[str, int], Union[str, int]] existing_map, str defect_name, bool virtual=False)
Definition: ids.py:48