3 __author__  = 
'Javier Montejo' 
    4 __version__=
"$Revision: 2.0 $" 
    5 __doc__=
"Class defining data periods and access to GRLs" 
    8 import xml.etree.ElementTree 
as ET
 
    9 from TriggerMenuMT.TriggerAPI.TriggerEnums 
import TriggerPeriod
 
   15         'All' :(276262, 284484, 0)
 
   18         'A' :(296939,300279,0),
 
   19         'BD3' :(300345,302872,0),
 
   20         'D4plus' :(302919,311481,0),
 
   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),
 
   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 ),
 
   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),
 
  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" 
  120         elif TriggerPeriod.isRunNumber(period) 
and period != TriggerPeriod.customGRL: 
 
  122         elif period & TriggerPeriod.y2015: 
 
  124         elif period & TriggerPeriod.y2016: 
 
  126         elif period & TriggerPeriod.y2017lowmu: 
 
  128         elif period & TriggerPeriod.y2017: 
 
  130         elif period & TriggerPeriod.y2018lowmu: 
 
  132         elif period & TriggerPeriod.y2018: 
 
  134         if period != TriggerPeriod.customGRL:
 
  138         if type(grlpath)==list:
 
  139             for grl 
in grlpath: self.
loadGRL(grl)
 
  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')]
 
  151             grlroot = ET.parse(grlpath).getroot()
 
  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())
 
  160         if TriggerPeriod.isRunNumber(period):
 
  161             if period 
in self.
grl:
 
  162                 blocks = self.
grl[period]
 
  164                 self.
grl[period] = blocks
 
  167                 self.
grl[period] = [(0,9999)]
 
  170             if period & TriggerPeriod.y2015     :
 
  172             if period & TriggerPeriod.y2016periodA:
 
  174             if period & TriggerPeriod.y2016periodBD3:
 
  176             if period & TriggerPeriod.y2016periodD4plus:
 
  178             if period & TriggerPeriod.y2017periodB1:
 
  180             if period & TriggerPeriod.y2017periodB2B4:
 
  182             if period & TriggerPeriod.y2017periodB5B7:
 
  184             if period & TriggerPeriod.y2017periodB8    :
 
  186             if period & TriggerPeriod.y2017periodC     :
 
  188             if period & TriggerPeriod.y2017periodD1D5:
 
  190             if period & TriggerPeriod.y2017periodD6    :
 
  192             if period & TriggerPeriod.y2017periodEF    :
 
  195             if period & TriggerPeriod.y2017periodGHIK  :
 
  200             if period & TriggerPeriod.y2017lowmu       :
 
  202             if period & TriggerPeriod.y2018periodBE    :
 
  207             if period & TriggerPeriod.y2018periodFI    :
 
  213             if period & TriggerPeriod.y2018lowmu       :
 
  216             if period & TriggerPeriod.y2018periodKQ   :
 
  224                 if not any([run >= x[0] 
and run <= x[1] 
for x 
in ranges]): self.
grl.pop(run)
 
  227     from AthenaCommon.Logging 
import logging
 
  228     log = logging.getLogger(__name__)
 
  232 if __name__ == 
"__main__":