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  "MenuPartitioning" : FlagArgs( Iterable, val_check = lambda x: len(list(filter(lambda y: y not in range(512), x)))==0 ),
45  "items" : FlagArgs( Iterable, val_check = lambda x: len(list(filter(lambda y: not isinstance(y, str), x)))==0),
46  "boards" : FlagArgs( OrderedDict, OrderedDict() ),
47  "legacyBoards" : FlagArgs( OrderedDict, OrderedDict() ),
48  "prescales" : FlagArgs( dict, dict() ),
49  "RemapThresholdsAsListed" : FlagArgs( bool, False ),
50  "CtpIdMap" : FlagArgs( dict, dict() ),
51  "ThresholdMap" : FlagArgs( dict, dict() ),
52  "ItemMap" : FlagArgs( dict, dict() ),
53  }
54 
55  def __setattr__(self, attr, value):
56  # set the object
57  object.__setattr__(self, attr, value)
58  d = L1MenuFlagsCont.__slots__[attr]
59  # check the type
60  if not isinstance(value, d.val_type):
61  raise TypeError("L1MenuFlags.%s type check failed for %r. Type needs to be '%s'" % ( attr, value, d.valtype.__name__))
62  # check the values
63  if d.val_check and not d.val_check(value):
64  raise ValueError("L1MenuFlags.%s value check failed for %r" % ( attr, value))
65 
66  if d.action:
67  d.action(value)
68  L1MenuFlagsCont.statusOn.add(attr)
69 
70  def __getattribute__(self,attr):
71  if attr in L1MenuFlagsCont.__slots__:
72  try:
73  object.__getattribute__(self,attr)
74  except AttributeError:
75  if L1MenuFlagsCont.__slots__[attr].val_default is not None:
76  object.__setattr__(self, attr, L1MenuFlagsCont.__slots__[attr].val_default)
77  return FlagWrapper(attr, object.__getattribute__(self,attr), L1MenuFlagsCont)
78  else:
79  return object.__getattribute__(self,attr)
80 
81 
82 L1MenuFlags = L1MenuFlagsCont()
83 
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:55
python.L1.Base.L1MenuFlags.L1MenuFlagsCont.__getattribute__
def __getattribute__(self, attr)
Definition: L1MenuFlags.py:70
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:224
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