Example #1
0
    def pix_color_to_defect_translator(flag_iovs):
        from DCSCalculator2.consts import GREEN
        from DCSCalculator2.variable import DefectIOV
        from DQUtils import process_iovs
        rv = []

        defect_mapping = {
            101: "PIXEL_BARREL_STANDBY",
            102: "PIXEL_LAYER0_STANDBY",
            103: "PIXEL_IBL_STANDBY",
            104: "PIXEL_ENDCAPA_STANDBY",
            105: "PIXEL_ENDCAPC_STANDBY"
        }

        for since, until, states in process_iovs(
                *flag_iovs.by_channel.values()):
            #print states
            for state in states:
                if state.Code != GREEN:
                    badfrac = 'Standby module fraction: ' + str(state.deadFrac)
                    rv.append(
                        DefectIOV(since=since,
                                  until=until,
                                  channel=defect_mapping[state.channel],
                                  present=True,
                                  comment=badfrac))
        return rv
    def tdaq_busy_generator(self, iovs):
        events = process_iovs(iovs)
        counter = 0

        for since, until, (state, ) in events:
            if state.Run == 0: continue
            #print state
            if state is not None:
                deadfrac = 1 - state.LiveFraction
                if deadfrac < self.deadfraction_threshold:
                    continue
                yield DefectIOV(RunLumi(state.Run, state.LumiBlock),
                                RunLumi(state.Run, state.LumiBlock + 1),
                                'GLOBAL_BUSY',
                                True,
                                comment='Average live fraction %.1f%%' %
                                ((1 - deadfrac) * 100))
                counter += 1

        counter_max = counter
        counter = 0
        #print counter_max
        events = process_iovs(iovs)
        for since, until, (state, ) in events:
            if state is not None:
                deadfrac = 1 - state.LiveFraction
                if deadfrac < self.deadfraction_threshold:
                    continue
            #print state.Run
                counter += 1
                if state.Run == 0 and counter < counter_max:
                    print 'ERROR: Wrong run number in LumiAccounting; here is the IOV: '
                    print state
                    #print list(iovs)
                    continue
Example #3
0
    def beamspot_generator(self, iovs):
        state = iovs.select_channels(0)
        events = process_iovs(iovs)
        for since, until, (state,) in events:
            if state is not None:
                #print since, until, state.status
                if state.status == 7 or state.status is None:
                    continue

                yield DefectIOV(since, until, 'TRIG_HLT_IDT_BSPOT_INVALID_STATUS', True,
                                comment='Bad online beamspot status')
Example #4
0
    def emittance_generator(self, iovs):
        events = process_iovs(iovs)

        for since, until, (state, ) in events:
            #print state, state.RunLB & 0xffffffff if state.RunLB else 0
            if state is not None and state.RunLB is not None:
                thisrun = state.RunLB >> 32
                # pseudo-LB and not to be trusted
                if thisrun == 0: continue
                thisLB = state.RunLB & 0xffffffff
                yield DefectIOV(RunLumi(thisrun, thisLB),
                                RunLumi(thisrun, thisLB + 1),
                                'LUMI_EMITTANCESCAN',
                                True,
                                comment='Emittance scan')
Example #5
0
    def tdaq_ready_generator(self, iovs):
        #state = iovs.select_channels(0)

        events = process_iovs(iovs)

        for since, until, (state, ) in events:

            if state is not None:
                if state.ReadyForPhysics == 1:
                    continue

                yield DefectIOV(since,
                                until,
                                'GLOBAL_NOTREADY',
                                True,
                                comment='ReadyForPhysics not set')
Example #6
0
    def magnet_iov_generator(self, iovs, system, measured_channel,
                             desired_channel, tolerance):

        measured_iovs = iovs.select_channels(measured_channel)
        desired_iovs = iovs.select_channels(desired_channel)

        events = process_iovs(measured_iovs, desired_iovs)

        for since, until, (measured, desired) in events:

            # 28-05-2015: excluding empty 'desired' value, because how do we make
            # a decision without an expectation? Should debug this some more, as
            # the issue came up in 2015 run 253014.
            if measured is not None and desired is not None and not desired._is_empty:
                # NOTE: if measured is 'empty', this is always true
                if measured.value <= tolerance:
                    # Magnet off
                    defect = system + '_OFF'

                elif abs(measured.value - desired.value) <= tolerance:
                    if ((system == 'GLOBAL_SOLENOID'
                         and abs(desired.value - 7730.) > tolerance)
                            or (system == 'GLOBAL_TOROID'
                                and abs(desired.value - 20400.) > tolerance)):
                        # Magnet has non-nominal current
                        defect = system + '_NOTNOMINAL'
                    else:
                        defect = None
                else:
                    # Magnet is ramping
                    defect = system + '_RAMPING'

                if defect is None:
                    continue

                mcurrent = '%.1f' % measured.value if measured.value is not None else 'None'
                scurrent = '%.1f' % desired.value if desired.value is not None else 'None'
                yield DefectIOV(
                    since,
                    until,
                    defect,
                    True,
                    comment='Measured current: %s, Set current: %s' %
                    (mcurrent, scurrent))
Example #7
0
 def sct_color_to_defect_translator(flag_iovs):
     defectmap = {111: 'B', 114: 'EA', 115: 'EC'}
     from DCSCalculator2.consts import GREEN
     from DCSCalculator2.variable import DefectIOV
     from DQUtils import process_iovs
     rv = []
     for since, until, states in process_iovs(
             *flag_iovs.by_channel.values()):
         if any(state.Code != GREEN for state in states):
             # This line of code is awful!
             badfrac = 'Bad fractions: ' + ', '.join(
                 '%s %.3f' % (defectmap[state.channel], state.deadFrac)
                 for state in sorted(states, key=lambda x: x.channel))
             rv.append(
                 DefectIOV(since=since,
                           until=until,
                           channel='SCT_GLOBAL_STANDBY',
                           present=True,
                           comment=badfrac))
     return rv
Example #8
0
    def tdaq_busy_generator(self, iovs):
        events = process_iovs(iovs)
        counter = 0

        for since, until, (state, ) in events:
            if state.Run == 0 or state.Run is None: continue
            if state is not None:
                if state.LiveFraction is None:
                    deadfrac = 1
                    log.warning('WARNING: LiveFraction is "None" for %d %d',
                                state.Run, state.LumiBlock)
                else:
                    deadfrac = 1 - state.LiveFraction
                if deadfrac < self.deadfraction_threshold:
                    continue
                yield DefectIOV(RunLumi(state.Run, state.LumiBlock),
                                RunLumi(state.Run, state.LumiBlock + 1),
                                'GLOBAL_BUSY',
                                True,
                                comment='Average live fraction %.1f%%' %
                                ((1 - deadfrac) * 100))
                counter += 1

        counter_max = counter
        counter = 0
        events = process_iovs(iovs)
        for since, until, (state, ) in events:
            if state is not None and state.Run is not None:
                deadfrac = 1 - state.LiveFraction
                if deadfrac < self.deadfraction_threshold:
                    continue
                counter += 1
                if state.Run == 0 and counter < counter_max:
                    log.error(
                        'ERROR: Wrong run number in LumiAccounting; here is the IOV: '
                    )
                    log.error(state)
                    continue