ATLAS Offline Software
TriggerEnums.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 __author__ = 'Javier Montejo'
4 __version__="$Revision: 2.0 $"
5 __doc__="Enumerations for trigger types and periods"
6 
7 from enum import IntEnum
8 
9 class TriggerType(IntEnum):
10  el_single = 1 << 0
11  el_multi = 1 << 1
12  mu_single = 1 << 2
13  mu_multi = 1 << 3
14  j_single = 1 << 4
15  j_multi = 1 << 5
16  bj_single = 1 << 6
17  bj_multi = 1 << 7
18  tau_single = 1 << 8
19  tau_multi = 1 << 9
20  g_single = 1 << 10
21  g_multi = 1 << 11
22  xe = 1 << 12
23  ht = 1 << 13
24  mu_bphys = 1 << 14
25  exotics = 1 << 15
26  afp = 1 << 16
27 
28  el = el_single | el_multi
29  mu = mu_single | mu_multi
30  j = j_single | j_multi
31  bj = bj_single | bj_multi
32  tau = tau_single| tau_multi
33  g = g_single | g_multi
34 
35  ALL = el | mu | j | bj | tau | g | xe | ht | mu_bphys | exotics | afp
36  UNDEFINED = 0
37 
38  @classmethod
39  def toStr(cls, val):
40  out = []
41  for e in cls:
42  if val == e.value: return e.name # perfect matches returned as-is
43  if bin(e.value).count('1')!=1: continue # will only express in terms of fundamental types
44  if e.value & val: out += [e.name]
45  if not out: return "undefined"
46  return "|".join(out)
47 
48 
49 class TriggerPeriod(IntEnum):
50  customGRL = 0
51  y2015 = 1 << 0
52  y2016periodA = 1 << 1
53  y2016periodBD3 = 1 << 2
54  y2016periodD4plus = 1 << 3
55  y2017periodB1 = 1 << 4
56  y2017periodB2B4 = 1 << 5
57  y2017periodB5B7 = 1 << 6
58  y2017periodB8 = 1 << 7
59  y2017periodC = 1 << 8
60  y2017periodD1D5 = 1 << 9
61  y2017periodD6 = 1 << 10
62  y2017periodEF = 1 << 11
63  y2017periodGHIK = 1 << 12
64  y2017lowmu = 1 << 13
65  y2018periodBE = 1 << 14
66  y2018periodFI = 1 << 15
67  y2018lowmu = 1 << 16
68  y2018periodKQ = 1 << 17
69 
70  runNumber = 1 << 18 #Can't get higher than this, enters the run number domain
71  future1p8e34 = 1 << 19
72  future2e34 = 1 << 20
73 
74  y2017periodB = y2017periodB1 | y2017periodB2B4 | y2017periodB5B7 | y2017periodB8
75  y2017periodD = y2017periodD1D5 | y2017periodD6
76  y2017periodAll = y2017periodB | y2017periodC | y2017periodD | y2017periodEF | y2017periodGHIK #low-mu period is not considered
77  y2018 = y2018periodBE | y2018periodFI | y2018periodKQ #low-mu period is not considered
78  y2017 = y2017periodAll
79  y2016 = y2016periodA | y2016periodBD3 | y2016periodD4plus
80  future = future1p8e34 | future2e34
81 
82  def isBasePeriod(self):
83  return TriggerPeriod.isRunNumber(self) or all([self & x == 0 or self & x == self for x in TriggerPeriod])
84 
85  @classmethod
86  def isRunNumber(cls, number):
87  try:
88  number = int(number)
89  except ValueError:
90  return False
91  return (number==0 or (number > TriggerPeriod.runNumber and number < TriggerPeriod.runNumber*2))
92 
93  @classmethod
94  def basePeriods(cls):
95  return [x for x in TriggerPeriod if x.isBasePeriod()]
96 
97  @classmethod
98  def toName(cls, p):
99  return p if TriggerPeriod.isRunNumber(p) else p.name
100 
101  @classmethod
102  def fromName(cls, p):
103  return p if TriggerPeriod.isRunNumber(p) else TriggerPeriod[p]
104 
106  ''' List of LBs to be skipped.
107  Usually due to accidental prescales that will be taken into account in future GRLs or via reduced luminosity.
108  Users can modify this if needed, but hopefully there is no need ;)
109  '''
110  # Run number: [(LB start, LB end), ...] both inclusive
111  exceptions = {
112  276262: [(72 , 75 )], #toroid off keys
113  281317: [(116, 118)], #toroid off keys
114  299055: [(650, 700)], #Toroid was going down, turned muons off
115  301932: [(233, 234)], #Accidentaly moved to MuScan prescales
116  302831: [(4 , 10 )], #toroid off keys
117  336506: [(212, 260)], #Regular muscan but the defect is not in sync with the switch of keys
118  341294: [(137, 156)], #Standby keys
119  355650: [(117, 117)], #Last LB of emittance scan
120  357283: [(117, 117)], #Last LB of emittance scan
121  359623: [(129, 129)], #Last LB of emittance scan
122  }
123 
125  ''' Pairs of triggers that have been renamed at some point
126  The code will complete each other so that each contains
127  luminosity of both
128  Assumes that they are orthogonal, i.e. they haven't run both at the same time
129  '''
130  pairs = [
131  ("HLT_mu20_mu8noL1_e9_lhvloose_nod0","HLT_e9_lhvloose_nod0_mu20_mu8noL1"),
132  ("HLT_mu20_mu8noL1_e9_lhvloose_nod0_L1EM8VH_MU20","HLT_e9_lhvloose_nod0_mu20_mu8noL1_L1EM8VH_MU20"),
133  ("HLT_mu20_mu8noL1_e9_lhvloose_nod0_L1EM7_MU20","HLT_e9_lhvloose_nod0_mu20_mu8noL1_L1EM7_MU20"),
134  ]
135 
136 if __name__ == "__main__":
137  from AthenaCommon.Logging import logging
138  log = logging.getLogger(__name__)
139  log.info(TriggerPeriod.y2015.isBasePeriod() )
140  log.info(TriggerPeriod.y2017.isBasePeriod() )
141  log.info(TriggerPeriod.basePeriods() )
python.TriggerAPI.TriggerEnums.TriggerType.toStr
def toStr(cls, val)
Definition: TriggerEnums.py:39
python.TriggerAPI.TriggerEnums.TriggerRenaming
Definition: TriggerEnums.py:124
python.TriggerAPI.TriggerEnums.TriggerPeriod.basePeriods
def basePeriods(cls)
Definition: TriggerEnums.py:94
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:67
python.TriggerAPI.TriggerEnums.TriggerPeriod
Definition: TriggerEnums.py:49
python.TriggerAPI.TriggerEnums.LBexceptions
Definition: TriggerEnums.py:105
bin
Definition: BinsDiffFromStripMedian.h:43
python.TriggerAPI.TriggerEnums.TriggerPeriod.isBasePeriod
def isBasePeriod(self)
Definition: TriggerEnums.py:82
python.TriggerAPI.TriggerEnums.TriggerType
Definition: TriggerEnums.py:9
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
python.TriggerAPI.TriggerEnums.TriggerPeriod.fromName
def fromName(cls, p)
Definition: TriggerEnums.py:102
python.TriggerAPI.TriggerEnums.TriggerPeriod.toName
def toName(cls, p)
Definition: TriggerEnums.py:98
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.TriggerAPI.TriggerEnums.TriggerPeriod.isRunNumber
def isRunNumber(cls, number)
Definition: TriggerEnums.py:86