3 from DCSCalculator2.lib 
import DCSC_Subdetector_DefectsOnly, DCSC_Defect_Global_Variable, connect_adjacent_iovs_defect
 
    4 from DCSCalculator2.variable 
import DefectIOV
 
    5 from DQUtils 
import process_iovs
 
    6 from DQUtils.sugar 
import IOVSet, RunLumi
 
    7 from DQUtils.iov_truncator 
import truncate_to_atlas_runs
 
    8 from logging 
import getLogger
 
   14     Overloads calculate_good_iovs 
   16     input_db = 
'COOLONL_TDAQ/CONDBR2' 
   17     timewise_folder = 
False 
   26         for since, until, (state,) 
in events:
 
   29                 if state.ReadyForPhysics == 1:
 
   32                 yield DefectIOV(since, until, 
'GLOBAL_NOTREADY', 
True,
 
   33                                 comment=
'ReadyForPhysics not set')
 
   37     Overloads calculate_good_iovs & quantize 
   38     Latter because this is a strange COOL folder that is timewise but already quantized 
   41     input_db = 
'COOLOFL_TRIGGER/CONDBR2' 
   42     fetch_args = dict(tag=
"OflLumiAcct-Run3-003")
 
   43     deadfraction_threshold = 0.9
 
   52         for since, until, (state,) 
in events:
 
   53             if state.Run == 0 
or state.Run 
is None: 
continue 
   55                 if state.LiveFraction 
is None:
 
   57                     log.warning(
'WARNING: LiveFraction is "None" for %d %d', state.Run, state.LumiBlock)
 
   59                     deadfrac = 1-state.LiveFraction
 
   63                                 RunLumi(state.Run, state.LumiBlock+1), 
 
   65                                 comment=
'Average live fraction %.1f%%' % ((1-deadfrac)*100))
 
   71         for since, until, (state,) 
in events:
 
   72             if state 
is not None and state.Run 
is not None:
 
   73                 deadfrac = 1-state.LiveFraction
 
   77                 if state.Run == 0 
and counter <counter_max:
 
   78                     log.error(
'ERROR: Wrong run number in LumiAccounting; here is the IOV: ')
 
   87     Overloads calculate_good_iovs & quantize 
   88     Latter because this is a strange COOL folder that is timewise but already quantized 
   91     input_db = 
'COOLONL_TDAQ/CONDBR2' 
   97         events = 
process_iovs(_ 
for _ 
in iovs 
if _.channel == 1 
and _.ScanningIP != 0)
 
   99         for since, until, (state,) 
in events:
 
  101             if state 
is not None and state.RunLB 
is not None:
 
  102                 thisrun = state.RunLB >>32
 
  104                 if thisrun == 0: 
continue 
  105                 thisLB = state.RunLB & 0xffffffff
 
  108                                 'LUMI_EMITTANCESCAN', 
True,
 
  109                                 comment=
'Emittance scan' 
  115 class Global(DCSC_Subdetector_DefectsOnly):
 
  120         TDAQ_Ready(
'/TDAQ/RunCtrl/DataTakingMode', 
lambda x: 
True),
 
  122         TDAQ_Busy(
'/TRIGGER/OFLLUMI/LumiAccounting', 
lambda x: 
True),
 
  129     def run(self, lbtime, run_iovs):
 
  130         self.evaluate_inputs(lbtime)
 
  132                           for var 
in self.variables), []))