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 47 of file ids.py.

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

Variable Documentation

◆ log

python.ids.log

Definition at line 3 of file ids.py.

DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
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:47