ATLAS Offline Software
PrescaleHelper.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaCommon.Logging import logging
4 log = logging.getLogger(__name__)
5 
6 """
7 The prescaling uses a pseudo-random binary sequence generator of 24 bit width (31 bit internal)
8 
9 - Prescales are defined by a cutoff (C).
10 - Each time a random number (R) is generated.
11 - C, R are between 0 and 2**24-1
12 
13 - The trigger item is accepted if R>=C. The prescale (PS) corresponding to a cutoff C is PS = (2**24-1)/(2**24-C)
14 
15 
16 In this scheme only number that are powers of 2 can be represented
17 exactly. Effective prescales are typically non-integer. Integer
18 numbers can~t be represented exactly but have an error which grows with the
19 prescale)
20 """
21 
22 maxPrescaleCut = 0xFFFFFF # 2**24 - 1
23 
24 def getCutFromPrescale(prescale):
25  """
26  C = 2**24-(2**24-1)/PS
27 
28  PS = 1 --> C = 1
29  PS = 2 --> C = 8388609
30  PS = 10 --> C = 15099495
31  PS = 1000 --> C = 16760439
32  PS = 10000 --> C = 16775539
33  PS = 2**24-1 --> C = 2**24-1
34  """
35 
36  if prescale==0:
37  raise RuntimeError("L1 Prescale value of 0 is not allowed")
38 
39  sign = -1 if prescale<0 else 1
40  prescale = abs(prescale)
41  cut=sign * ( 0x1000000 - (0xFFFFFF/prescale) )
42  cut = round( cut )
43  if prescale > 0xFFFFFF:
44  cut=sign * (0x1000000-1)
45 
46  return int(cut)
47 
49  """
50  PS = (2**24-1)/(2**24-C)
51 
52  C = 1 --> PS = 1
53  C = 2**24-1 --> PS = 2**24-1
54  """
55 
56  if cut==0:
57  raise RuntimeError("L1 Prescale cut of 0 is not allowed, use cut=1 for a prescale value of 1")
58 
59  sign = -1 if cut<0 else 1
60  cut = abs(cut)
61  return (sign * 0xFFFFFF) / ( 0x1000000 - cut )
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
python.L1.Base.PrescaleHelper.getPrescaleFromCut
def getPrescaleFromCut(cut)
Definition: PrescaleHelper.py:48
python.L1.Base.PrescaleHelper.getCutFromPrescale
def getCutFromPrescale(prescale)
Definition: PrescaleHelper.py:24