ATLAS Offline Software
L1MenuFlags.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 __doc__="Level 1 specific configuration for L1 Run 3"
4 
5 from .Limits import Limits
6 from collections import OrderedDict
7 from collections.abc import Iterable
8 
9 
11  """
12  this is to support the old functionality of calling and setting statusOn for flags
13  """
14  def __init__(self, name, value, cls):
15  self.name = name
16  self.value = value
17  self.cls = cls
18  def __call__(self):
19  return self.value
20  def statusOn(self):
21  return self.name in self.cls.statusOn
22  def setStatusOn(self, on = True):
23  if on:
24  self.cls.statusOn.add(self.name)
25  else:
26  self.cls.statusOn.remove(self.name)
27 
29 
30  class FlagArgs:
31  def __init__( self, val_type, val_default = None, val_check = None, action = None ):
32  self.val_type = val_type
33  self.val_default = val_default
34  self.val_check = val_check
35  self.action = action
36 
37  statusOn = set()
38 
39  __slots__ = {
40  "MenuSetup" : FlagArgs( str ),
41  "CTPVersion" : FlagArgs( int, 4, val_check = lambda x: x in range(5), action = lambda x: Limits.setLimits(x) ),
42  "BunchGroupPartitioning" : FlagArgs( Iterable, val_check = lambda x: len(list(filter(lambda y: y not in range(16), x)))==0 ),
43  "BunchGroupNames" : FlagArgs( Iterable, val_check = lambda x: len(list(filter(lambda y: not isinstance(y, str), x)))==0),
44  "items" : FlagArgs( Iterable, val_check = lambda x: len(list(filter(lambda y: not isinstance(y, str), x)))==0),
45  "boards" : FlagArgs( OrderedDict, OrderedDict() ),
46  "legacyBoards" : FlagArgs( OrderedDict, OrderedDict() ),
47  "prescales" : FlagArgs( dict, dict() ),
48  "RemapThresholdsAsListed" : FlagArgs( bool, False ),
49  "CtpIdMap" : FlagArgs( dict, dict() ),
50  "ThresholdMap" : FlagArgs( dict, dict() ),
51  "ItemMap" : FlagArgs( dict, dict() ),
52  }
53 
54  def __setattr__(self, attr, value):
55  # set the object
56  object.__setattr__(self, attr, value)
57  d = L1MenuFlagsCont.__slots__[attr]
58  # check the type
59  if not isinstance(value, d.val_type):
60  raise TypeError("L1MenuFlags.%s type check failed for %r. Type needs to be '%s'" % ( attr, value, d.valtype.__name__))
61  # check the values
62  if d.val_check and not d.val_check(value):
63  raise ValueError("L1MenuFlags.%s value check failed for %r" % ( attr, value))
64 
65  if d.action:
66  d.action(value)
67  L1MenuFlagsCont.statusOn.add(attr)
68 
69  def __getattribute__(self,attr):
70  if attr in L1MenuFlagsCont.__slots__:
71  try:
72  object.__getattribute__(self,attr)
73  except AttributeError:
74  if L1MenuFlagsCont.__slots__[attr].val_default is not None:
75  object.__setattr__(self, attr, L1MenuFlagsCont.__slots__[attr].val_default)
76  return FlagWrapper(attr, object.__getattribute__(self,attr), L1MenuFlagsCont)
77  else:
78  return object.__getattribute__(self,attr)
79 
80 
81 L1MenuFlags = L1MenuFlagsCont()
82 
python.L1.Base.L1MenuFlags.FlagWrapper.name
name
Definition: L1MenuFlags.py:15
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.__setattr__
def __setattr__(self, attr, value)
Definition: L1MenuFlags.py:54
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.__getattribute__
def __getattribute__(self, attr)
Definition: L1MenuFlags.py:69
python.L1.Base.L1MenuFlags.FlagWrapper.setStatusOn
def setStatusOn(self, on=True)
Definition: L1MenuFlags.py:22
python.L1.Base.L1MenuFlags.FlagWrapper
Definition: L1MenuFlags.py:10
covarianceTool.filter
filter
Definition: covarianceTool.py:514
python.L1.Base.L1MenuFlags.FlagWrapper.value
value
Definition: L1MenuFlags.py:16
python.L1.Base.L1MenuFlags.L1MenuFlagsCont
Definition: L1MenuFlags.py:28
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.FlagArgs.val_type
val_type
Definition: L1MenuFlags.py:32
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.L1.Base.L1MenuFlags.FlagWrapper.statusOn
def statusOn(self)
Definition: L1MenuFlags.py:20
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.FlagArgs.val_default
val_default
Definition: L1MenuFlags.py:33
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.FlagArgs.action
action
Definition: L1MenuFlags.py:35
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.L1.Base.L1MenuFlags.FlagWrapper.__init__
def __init__(self, name, value, cls)
Definition: L1MenuFlags.py:14
python.L1.Base.L1MenuFlags.FlagWrapper.cls
cls
Definition: L1MenuFlags.py:17
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.FlagArgs.val_check
val_check
Definition: L1MenuFlags.py:34
python.L1.Base.L1MenuFlags.FlagWrapper.__call__
def __call__(self)
Definition: L1MenuFlags.py:18
pickleTool.object
object
Definition: pickleTool.py:30
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.FlagArgs
Definition: L1MenuFlags.py:30
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.FlagArgs.__init__
def __init__(self, val_type, val_default=None, val_check=None, action=None)
Definition: L1MenuFlags.py:31