ATLAS Offline Software
TriggerPeriodData.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__="Class defining data periods and access to GRLs"
6 
7 import sys
8 import xml.etree.ElementTree as ET
9 from TriggerMenuMT.TriggerAPI.TriggerEnums import TriggerPeriod
10 
12  # From https://atlas-tagservices.cern.ch/tagservices/RunBrowser/runBrowserReport/rBR_Period_Report.php?fnt=data17_13TeV
13  # period: start,end,maxlumi
14  periodMap2015 = {
15  'All' :(276262, 284484, 0)
16  }
17  periodMap2016 = {
18  'A' :(296939,300279,0),
19  'BD3' :(300345,302872,0),
20  'D4plus' :(302919,311481,0),
21  }
22  periodMap2017 = {
23  'B' :(325713,328393,15815),
24  'B1':(325713,325790,3216),
25  'B2':(326439,326439,22.4),
26  'B3':(326446,326551,7008),
27  'B4':(326657,326695,6199),
28  'B5':(326834,326945,7915),
29  'B6':(327057,327265,11202),
30  'B7':(327342,327490,14642),
31  'B8':(327582,328393,15815),
32  'C' :(329385,330470,16776),
33  'C1':(329385,329484,289),
34  'C2':(329542,329542,3422),
35  'C3':(329716,329778,7729),
36  'C4':(329780,329964,13293),
37  'C5':(330025,330203,16365),
38  'C6':(330294,330294,14993),
39  'C7':(330328,330328,7213),
40  'C8':(330470,330470,16776),
41  'D' :(330857,332304,17466),
42  'D1':(330857,330875,2.77),
43  'D2':(331019,331020,3800),
44  'D3':(331033,331239,16242),
45  'D4':(331462,331479,15952),
46  'D5':(331697,331975,16385),
47  'D6':(332303,332304,17466),
48  'E' :(332720,334779,14059),
49  'E1':(332720,332896,3485),
50  'E2':(332915,333192,9599),
51  'E3':(333367,333487,10230),
52  'E4':(333519,333650,10534),
53  'E5':(333707,333979,9515),
54  'E6':(333994,333994,14059),
55  'E7':(334264,334580,9745),
56  'E8':(334588,334779,9061),
57  'F' :(334842,335290,12070),
58  'F1':(334842,334907,10643),
59  'F2':(334960,335022,11067),
60  'F3':(335056,335082,12070),
61  'F4':(335083,335170,10520),
62  'F5':(335177,335290,10658),
63  'G' :(335302,335302,1658),
64  'G1':(335302,335302,1658),
65  'H' :(336497,336782,14165),
66  'H1':(336497,336497,306),
67  'H2':(336505,336505,4224),
68  'H3':(336506,336548,11603),
69  'H4':(336567,336782,14165),
70  'I' :(336832,337833,18456),
71  'I1':(336832,337005,16400),
72  'I2':(337052,337215,17078),
73  'I3':(337263,337833,18456),
74  'K' :(338183,340453,20614),
75  'K1':(338183,338349,15706),
76  'K2':(338377,339070,20486),
77  'K3':(339197,339197,917),
78  'K4':(339205,339205,15216),
79  'K5':(339346,339849,20614),
80  'K6':(339957,340453,15750),
81  'N' :(341257,341649,16018),
82  'N1':(341257,341294,1957),
83  'N4':(341419,341649,1590),
84  'N2':(341312,341312,16018),
85  }
86  periodMap2018 = {
87  'B':(348885,349533,20836),
88  'C':(349534,350220,21519),
89  'D':(350310,352107,20422),
90  'E':(352123,352137,18296),
91  'F':(352274,352514,19938),
92  'G' :(354107,354494,17012),
93  'G1':(354107,354174,4676 ),
94  'G2':(354176,354311,61.2 ),
95  'G3':(354309,354359,17012),
96  'G4':(354396,354396,11098),
97  'G5':(354476,354494,8.73 ),
98 
99  'I':(355261,355273,17318),
100  'J':(355331,355468,18781),
101  'K':(355529,356259,19958),
102  'L':(357050,359171,19935),
103  'M':(359191,360414,20904),
104  'N':(361635,361696,9464 ),
105  'O':(361738,363400,19822),
106  'Q':(363664,364292,19618),
107  }
108 
109  grlbase = "/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/"
110  y2018grlpath = grlbase+"data18_13TeV/20181105/data18_13TeV.periodAllYear_DetStatus-v102-pro22-04_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml"
111  y2017grlpath = grlbase+"data17_13TeV/20180619/data17_13TeV.periodAllYear_DetStatus-v99-pro22-01_Unknown_PHYS_StandardGRL_All_Good_25ns_Triggerno17e33prim.xml"
112  y2016grlpath = grlbase+"data16_13TeV/20180129/data16_13TeV.periodAllYear_DetStatus-v89-pro21-01_DQDefects-00-02-04_PHYS_StandardGRL_All_Good_25ns.xml"
113  y2015grlpath = grlbase+"data15_13TeV/20170619/data15_13TeV.periodAllYear_DetStatus-v89-pro21-02_Unknown_PHYS_StandardGRL_All_Good_25ns.xml"
114  y2017lowmugrlpath = grlbase+"data17_13TeV/20180117/data17_13TeV.periodN_DetStatus-v98-pro21-16_Unknown_PHYS_StandardGRL_All_Good_25ns_ignore_GLOBAL_LOWMU.xml"
115  y2018lowmugrlpath = grlbase+"data18_13TeV/20180830/data18_13TeV.periodG4J_MERGED_PHYS_StandardGRL_All_Good_25ns_ignore_GLOBAL_LOWMU.xml"
116  def __init__(self, period, customGRL=None):
117  self.grl = {}
118  if customGRL:
119  self.loadGRL(customGRL)
120  elif TriggerPeriod.isRunNumber(period) and period != TriggerPeriod.customGRL: #run number assume 2018
121  self.loadGRL(self.y2018grlpath)
122  elif period & TriggerPeriod.y2015:
123  self.loadGRL(self.y2015grlpath)
124  elif period & TriggerPeriod.y2016:
125  self.loadGRL(self.y2016grlpath)
126  elif period & TriggerPeriod.y2017lowmu:
127  self.loadGRL(self.y2017lowmugrlpath)
128  elif period & TriggerPeriod.y2017:
129  self.loadGRL(self.y2017grlpath)
130  elif period & TriggerPeriod.y2018lowmu:
131  self.loadGRL(self.y2018lowmugrlpath)
132  elif period & TriggerPeriod.y2018:
133  self.loadGRL(self.y2018grlpath)
134  if period != TriggerPeriod.customGRL:
135  self.skimPeriod(period)
136 
137  def loadGRL(self, grlpath):
138  if type(grlpath)==list:
139  for grl in grlpath: self.loadGRL(grl)
140  else:
141  grlroot = ET.parse(grlpath).getroot()
142  for run in grlroot.findall('NamedLumiRange/LumiBlockCollection'):
143  runNum = int(run.find('Run').text)
144  if runNum not in self.grl:
145  self.grl[runNum] = []
146  self.grl[runNum] += [(int(x.get('Start')), int(x.get('End'))) for x in run.findall('LBRange')]
147 
148  @classmethod
149  def testCustomGRL(cls, grlpath):
150  try:
151  grlroot = ET.parse(grlpath).getroot()
152  testgrl = {}
153  for run in grlroot.findall('NamedLumiRange/LumiBlockCollection'):
154  testgrl[ int(run.find('Run').text)] = [(int(x.get('Start')), int(x.get('End'))) for x in run.findall('LBRange')]
155  return any(len(lb)!=0 for lb in testgrl.values())
156  except Exception:
157  return False
158 
159  def skimPeriod(self, period):
160  if TriggerPeriod.isRunNumber(period):
161  if period in self.grl:
162  blocks = self.grl[period]
163  self.grl = {}
164  self.grl[period] = blocks
165  else:
166  self.grl = {}
167  self.grl[period] = [(0,9999)]
168  else:
169  ranges = []
170  if period & TriggerPeriod.y2015 :
171  ranges.append( self.periodMap2015['All'] )
172  if period & TriggerPeriod.y2016periodA:
173  ranges.append( self.periodMap2016['A'] )
174  if period & TriggerPeriod.y2016periodBD3:
175  ranges.append( self.periodMap2016['BD3'] )
176  if period & TriggerPeriod.y2016periodD4plus:
177  ranges.append( self.periodMap2016['D4plus'] )
178  if period & TriggerPeriod.y2017periodB1:
179  ranges.append( self.periodMap2017['B1'] )
180  if period & TriggerPeriod.y2017periodB2B4:
181  for i in range(2,4+1): ranges.append( self.periodMap2017['B%d' %i] )
182  if period & TriggerPeriod.y2017periodB5B7:
183  for i in range(5,7+1): ranges.append( self.periodMap2017['B%d' %i] )
184  if period & TriggerPeriod.y2017periodB8 :
185  ranges.append( self.periodMap2017['B8'] )
186  if period & TriggerPeriod.y2017periodC :
187  for i in range(1,8+1): ranges.append( self.periodMap2017['C%d' %i] )
188  if period & TriggerPeriod.y2017periodD1D5:
189  for i in range(1,5+1): ranges.append( self.periodMap2017['D%d' %i] )
190  if period & TriggerPeriod.y2017periodD6 :
191  ranges.append( self.periodMap2017['D6'] )
192  if period & TriggerPeriod.y2017periodEF :
193  ranges.append( self.periodMap2017['E'] )
194  ranges.append( self.periodMap2017['F'] )
195  if period & TriggerPeriod.y2017periodGHIK :
196  ranges.append( self.periodMap2017['G'] )
197  ranges.append( self.periodMap2017['H'] )
198  ranges.append( self.periodMap2017['I'] )
199  ranges.append( self.periodMap2017['K'] )
200  if period & TriggerPeriod.y2017lowmu :
201  ranges.append( self.periodMap2017['N'] )
202  if period & TriggerPeriod.y2018periodBE :
203  ranges.append( self.periodMap2018['B'] )
204  ranges.append( self.periodMap2018['C'] )
205  ranges.append( self.periodMap2018['D'] )
206  ranges.append( self.periodMap2018['E'] )
207  if period & TriggerPeriod.y2018periodFI :
208  ranges.append( self.periodMap2018['F'] )
209  ranges.append( self.periodMap2018['G1'] )
210  ranges.append( self.periodMap2018['G2'] )
211  ranges.append( self.periodMap2018['G3'] )
212  ranges.append( self.periodMap2018['I'] )
213  if period & TriggerPeriod.y2018lowmu :
214  ranges.append( self.periodMap2018['G4'] )
215  ranges.append( self.periodMap2018['J'] )
216  if period & TriggerPeriod.y2018periodKQ :
217  ranges.append( self.periodMap2018['K'] )
218  ranges.append( self.periodMap2018['L'] )
219  ranges.append( self.periodMap2018['M'] )
220  ranges.append( self.periodMap2018['N'] )
221  ranges.append( self.periodMap2018['O'] )
222  ranges.append( self.periodMap2018['Q'] )
223  for run in list(self.grl.keys()):
224  if not any([run >= x[0] and run <= x[1] for x in ranges]): self.grl.pop(run)
225 
226 def test():
227  from AthenaCommon.Logging import logging
228  log = logging.getLogger(__name__)
229  log.info(TriggerPeriodData( TriggerPeriod.y2017 ).grl)
230  log.info(TriggerPeriodData( TriggerPeriod.y2017lowmu ).grl)
231 
232 if __name__ == "__main__":
233  sys.exit(test())
234 
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.y2016grlpath
y2016grlpath
Definition: TriggerPeriodData.py:112
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.TriggerAPI.TriggerPeriodData.test
def test()
Definition: TriggerPeriodData.py:226
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.testCustomGRL
def testCustomGRL(cls, grlpath)
Definition: TriggerPeriodData.py:149
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.periodMap2016
periodMap2016
Definition: TriggerPeriodData.py:17
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.periodMap2017
periodMap2017
Definition: TriggerPeriodData.py:22
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.__init__
def __init__(self, period, customGRL=None)
Definition: TriggerPeriodData.py:116
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.y2018grlpath
y2018grlpath
Definition: TriggerPeriodData.py:110
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.skimPeriod
def skimPeriod(self, period)
Definition: TriggerPeriodData.py:159
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.y2015grlpath
y2015grlpath
Definition: TriggerPeriodData.py:113
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.periodMap2018
periodMap2018
Definition: TriggerPeriodData.py:86
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.y2017grlpath
y2017grlpath
Definition: TriggerPeriodData.py:111
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData
Definition: TriggerPeriodData.py:11
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.y2017lowmugrlpath
y2017lowmugrlpath
Definition: TriggerPeriodData.py:114
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.y2018lowmugrlpath
y2018lowmugrlpath
Definition: TriggerPeriodData.py:115
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.loadGRL
def loadGRL(self, grlpath)
Definition: TriggerPeriodData.py:137
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.grl
grl
Definition: TriggerPeriodData.py:117
python.TriggerAPI.TriggerPeriodData.TriggerPeriodData.periodMap2015
periodMap2015
Definition: TriggerPeriodData.py:14