ATLAS Offline Software
Classes | Functions | Variables
python.L1.Base.MenuUtils Namespace Reference

Classes

class  idgen
 

Functions

def binstr (value, width)
 
def get_smk_psk_Name (menuName)
 
def getJetWeights (triggerPythonConfig, use_fj=False)
 

Variables

 __all__
 
 log
 
 idgen
 

Function Documentation

◆ binstr()

def python.L1.Base.MenuUtils.binstr (   value,
  width 
)

Definition at line 27 of file MenuUtils.py.

27 def binstr(value, width):
28  return ''.join([str( value >> i & 1 ) for i in range( width-1, -1, -1 ) ])
29 

◆ get_smk_psk_Name()

def python.L1.Base.MenuUtils.get_smk_psk_Name (   menuName)

Definition at line 30 of file MenuUtils.py.

30 def get_smk_psk_Name(menuName):
31  import re
32  smk_psk_Name = {}
33  if "mc_prescale" in menuName:
34  form = "(.*)_(.*)_mc_prescale"
35  m = re.match(form, menuName)
36  (smkName, pskName) = m.groups()
37  pskName = pskName+"_mc"
38  elif "prescale" in menuName:
39  #eg lumi1e31_simpleL1Calib_no_prescale
40  form = "(.*)_(.*)_prescale"
41  m = re.match(form,menuName)
42  (smkName, pskName) = m.groups()
43  else:
44  #eg lumi1e31 ps set name can be "default"
45  smkName = menuName
46  pskName = "default"
47  smk_psk_Name["smkName"] = str(smkName)
48  smk_psk_Name["pskName"] = str(smkName+"_"+pskName+"_prescale")
49 
50  return smk_psk_Name
51 

◆ getJetWeights()

def python.L1.Base.MenuUtils.getJetWeights (   triggerPythonConfig,
  use_fj = False 
)

Definition at line 52 of file MenuUtils.py.

52 def getJetWeights(triggerPythonConfig, use_fj=False):
53  jw = []
54  jthr, fjthr = [], []
55  def thr2weights(thrs, factor=1.25):
56  n = len(thrs)
57  # need to skip any turned-off thresholds
58  use = []
59  for i in range(n):
60  if thrs[i]<1023:
61  use.append(1)
62  else:
63  use.append(0)
64  # allow for thresholds being out of order
65  index = order(thrs)
66  # compute weights
67  sum = 0
68  weights = [0]*n
69  for j in range(n):
70  w = 0
71  if use[index[j]]>0:
72  jnext = j + 1
73  while (jnext < n and use[index[jnext]]==0):
74  jnext = jnext + 1
75  if (jnext < n):
76  w = int( (thrs[index[j]]+thrs[index[jnext]]+1)/2.0) - sum
77  else:
78  w = int(thrs[index[j]]*factor - sum)
79  weights[index[j]]=w
80  sum += w
81  return weights
82 #
83  def order(thrs):
84  n = len(thrs)
85  thr1 = list(thrs)
86  thr2 = sorted(thrs)
87  index = []
88  for i in range(n):
89  val = thr2[i]
90  pos = thr1.index(val)
91  index.append(pos)
92  if (thr1.count(val)>1):
93  thr1[pos] = -thr1[pos]
94  return index
95 #
96  l1_thrs = triggerPythonConfig.Lvl1Thresholds()
97  jet_thresholds = l1_thrs.allThresholdsOf('JET')
98  fjet_thresholds = l1_thrs.allThresholdsOf('JF')
99  log.debug('N jet thresholds: %d (8 expected)', len(jet_thresholds))
100  log.debug('N fjet thresholds: %d (4 expected)', len(fjet_thresholds))
101  jthr = [1023]*8
102  fjthr = [1023]*4
103  jet_names, fjet_names = ['---']*8, ['---']*4
104  for j in jet_thresholds:
105  log.debug('jet threshold %s: %d', j.name, j.thresholdInGeV())
106  # jthr.append(j.thresholdInGeV())
107  jthr[j.mapping] = j.thresholdInGeV()
108  jet_names[j.mapping] = j.name
109  for j in fjet_thresholds:
110  tvalues = j.thresholdValues
111  priority = 0
112  threshold_value = 0
113  for tv in tvalues:
114  if tv.priority > priority:
115  threshold_value = tv.value
116  log.debug('fjet threshold %s: %d', j.name, threshold_value)
117  fjthr.append(threshold_value)
118  fjthr[j.mapping] = threshold_value
119  fjet_names[j.mapping] = j.name
120  #
121  s = ''
122  for j in jet_names:
123  s += '%s ' % j
124  log.debug('Jet thresholds: %s', s)
125  s = ''
126  for j in fjet_names:
127  s += '%s ' % j
128  log.debug('Fjet thresholds: %s', s)
129  if len(jthr) <= 8:
130  w = thr2weights(jthr)
131  jw = w
132  else:
133  jw = [0]*8
134  w = [0]*4
135  if use_fj:
136  if len(fjthr) <= 4:
137  w = thr2weights(fjthr)
138  jw.extend(w)
139  return jw

Variable Documentation

◆ __all__

python.L1.Base.MenuUtils.__all__
private

Definition at line 3 of file MenuUtils.py.

◆ idgen

Definition at line 23 of file MenuUtils.py.

◆ log

python.L1.Base.MenuUtils.log

Definition at line 6 of file MenuUtils.py.

CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.L1.Base.MenuUtils.get_smk_psk_Name
def get_smk_psk_Name(menuName)
Definition: MenuUtils.py:30
mc.order
order
Configure Herwig7.
Definition: mc.Herwig7_Dijet.py:12
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
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.
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.L1.Base.MenuUtils.getJetWeights
def getJetWeights(triggerPythonConfig, use_fj=False)
Definition: MenuUtils.py:52
python.L1.Base.MenuUtils.binstr
def binstr(value, width)
Definition: MenuUtils.py:27
str
Definition: BTagTrackIpAccessor.cxx:11