ATLAS Offline Software
Limits.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 """
4 This temporarily holds CTP sizes
5 """
6 
7 from AthenaCommon.Logging import logging
8 log = logging.getLogger(__name__)
9 
10 class Access(type):
11  """Metaclass to implement __getattr__ for class variables"""
12  def __getattr__(cls, key):
13  if cls.ctpDataFormat is None:
14  raise RuntimeError("CTP version has not been set, you need to call Limits.setLimits(CTPVersion) before you can use the limits")
15 
16  if hasattr(cls.ctpDataFormat, key):
17  return getattr( cls.ctpDataFormat, key)
18  elif hasattr(cls.l1common, key):
19  return getattr( cls.l1common, key)
20  else:
21  raise AttributeError("Neither class 'CTPdataformat' nor class 'L1Common' have an attribute '%s'" % key)
22 
23  def __str__(cls):
24  if cls.ctpDataFormat is None:
25  return "None"
26 
27  s = "CTP DataFormat version %i\n" % cls.CTPVersion
28  varnames = ['MaxTrigItems', 'NumBunchgroups', 'NumRndmTriggers']
29  for varname in varnames:
30  s += " %s = %r\n" % (varname, getattr( cls.ctpDataFormat, varname))
31  s += "L1Common version %i\n" % cls.L1CommonVersion
32  varnames = ['MUON_bitnum','EM_bitnum', 'TAU_bitnum', 'JET_bitnum', 'JE_bitnum', 'JB_bitnum', 'JF_bitnum', 'TE_bitnum', 'XE_bitnum', 'XS_bitnum',
33  'MBTS_bitnum', 'MBTSSI_bitnum', 'NIM_bitnum', 'ZDC_bitnum', 'TRT_bitnum', 'BCM_bitnum', 'BCMCMB_bitnum', 'LUCID_bitnum', 'CALREQ_bitnum',
34  'MUON_cable', 'EM_cable', 'TAU_cable', 'JET_cable', 'JE_cable', 'JB_cable', 'JF_cable', 'TE_cable', 'XE_cable', 'XS_cable', 'MBTS_cable',
35  'MBTSSI_cable', 'NIM_cable', 'ZDC_cable', 'TRT_cable', 'BCM_cable', 'BCMCMB_cable', 'LUCID_cable', 'CALREQ_cable']
36  for varname in varnames:
37  s += " %s = %r\n" % (varname, getattr( cls.l1common, varname))
38  return s
39 
40 
41 
42 class Limits(object, metaclass=Access):
43 
44  CTPVersion = None
45  L1CommonVersion = None
46 
47  ctpDataFormat = None
48  l1common = None
49 
50  @staticmethod
51  def getCTPdataformat(version):
52  module = __import__('CTPfragment.CTPdataformat_v%i' % version, globals(), locals(), ['CTPdataformat_v%i' % version], 0)
53  return getattr(module, "CTPdataformat_v%i" % version)
54 
55  @staticmethod
56  def getL1Common(version):
57  module = __import__('L1Common.L1Common_v%i' % version, globals(), locals(), ['L1Common_v%i' % version], 0)
58  return getattr(module, "L1Common_v%i" % version)
59 
60  @staticmethod
61  def setLimits(CTPVersion, verbose = False):
62  Limits.CTPVersion = CTPVersion
63  Limits.L1CommonVersion = 0 if CTPVersion <= 3 else 1
64  #print "Setting limits for CTP version %i and L1Common Version %i" % (Limits.CTPVersion, Limits.L1CommonVersion)
65  Limits.ctpDataFormat = Limits.getCTPdataformat( Limits.CTPVersion )
66  Limits.l1common = Limits.getL1Common( Limits.L1CommonVersion )
67  if verbose:
68  log.debug(Limits)
69 
70 
71 
72 
74  # Maximum values for calo thresholds to disable that threshold
75  ClusterOff = 255
76  IsolationOff = 63
77  JetOff = 1023
78  EtSumOff = 32767
79  EtMissOff = 32767
80  JetEtOff = 13286
81 
python.L1.Base.Limits.Limits.getCTPdataformat
def getCTPdataformat(version)
Definition: Limits.py:51
python.L1.Base.Limits.Limits.setLimits
def setLimits(CTPVersion, verbose=False)
Definition: Limits.py:61
python.L1.Base.Limits.CaloLimits
Definition: Limits.py:73
python.L1.Base.Limits.Limits
Definition: Limits.py:42
python.L1.Base.Limits.Access.__getattr__
def __getattr__(cls, key)
Definition: Limits.py:12
python.L1.Base.Limits.Access
Definition: Limits.py:10
python.L1.Base.Limits.Limits.getL1Common
def getL1Common(version)
Definition: Limits.py:56
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
pickleTool.object
object
Definition: pickleTool.py:30
python.L1.Base.Limits.Access.__str__
def __str__(cls)
Definition: Limits.py:23