Beispiel #1
0
def run_sequential(systems, lbtime, run_iovs):
    result_iovs = IOVSet()

    for system in systems:
        log.info(" -- running for %s", system)
        system_result = run_one(system, lbtime, run_iovs)
        print_system_iovs(system_result)
        if system_result:
            result_iovs.extend(system_result)

    return result_iovs
Beispiel #2
0
    def merge_input_variables(self, inputs):
        """
        Merge multiple variables together for many channels.
        Takes a list of IOVSets, one for each DCSC_Variable.
        """

        result = []
        info_states = IOVSet(iov_type=GoodIOV)
        
        # Reassign inputs to be a list of dictionaries with
        # Key=channel_id and Val=IOVSet
        inputs = [iovs.by_channel for iovs in inputs]

        # set of channel ids
        all_channels = sorted(set(y for x in inputs for y in x.keys()))
        
        tally_system_states = config.opts.tally_system_states
        
        for channel in all_channels:

            # Handle one channel at a time for variable merging
            c_inputs = [x[channel] for x in inputs]
            
            # Merge "good" state across multiple variables
            result.append(self.merge_inputs(channel, *c_inputs))
            
            if tally_system_states:
                # Merge Input information across multiple variables
                info_state = self.merge_input_information(channel, *c_inputs)
                info_states.extend(info_state)

        
        if tally_system_states:
            # Print a tally of the states for the different systems
            from DQUtils.ext import tally
            def pretty(state):
                return "/".join(x[0] for x in state)
            
            chans, iovs = zip(*sorted(six.iteritems(info_states.by_channel)))
            for since, until, states in process_iovs(self.run_iovs, *iovs):
                if states[0]._is_empty:
                    # Not inside a run
                    continue
                
                statetally = tally(pretty(x.good) for x in states[1:])
                
                print(since, until, statetally)
            
        return result
Beispiel #3
0
 def calculate_result(self, inputs_by_output, global_variables):
     """
     Terrible name for a method.
     Calculate the iov extents and dead fractions for all output channels.
     In other words, the IoVs to be written to DCSOFL for this subdetector.
     """
     result = IOVSet(iov_type=DCSOFL_IOV)
     
     # loop over output channel dictionary
     for channel, input_iovs in sorted(six.iteritems(inputs_by_output)):
         these_globals = self.select_globals(channel, global_variables)
         args = channel, input_iovs, these_globals
         result.extend(self.calculate_result_for_output(*args))
         
     return result
Beispiel #4
0
def run_parallel(systems, lbtime, run_iovs, N):
    pool = Pool(N if N > 0 else len(systems))
    results = []
    for system in systems:
        result = pool.apply_async(run_one, (system, lbtime, run_iovs))
        results.append(result)

    all_results = IOVSet()
    for system, result in zip(systems, map(lambda x: x.get(), results)):
        log.info(" -- result for %s", system)
        print_system_iovs(result)
        if result:
            all_results.extend(result)

    return all_results
Beispiel #5
0
def calculate_virtual_defects(primary_iovs, evaluation_order,
                              virtual_output_channels, primary_output_channels,
                              since, until, ignore):
    """
    Returns a list of IoVs for a given query in the normal COOL order
    (sorted by channelID, then by since)
    """

    if since == None: since = 0
    if until == None: until = 2**63 - 1
    since, until = RunLumi(since), RunLumi(until)

    result = defaultdict(IOVSet)

    primary_by_channel = primary_iovs.by_channel

    # Copy desired primary channels to the result
    for primary_channel, primary_iovs in primary_by_channel.iteritems():
        if primary_channel in primary_output_channels:
            if ignore and primary_channel in ignore:
                continue
            result[primary_channel] = primary_iovs

    args = primary_by_channel, evaluation_order, since, until, ignore

    # Skip vfgen loop if there is no virtual logic to compute
    vfgen = [] if not evaluation_order else generate_virtual_defects(*args)

    for since, until, virtual_iovs in vfgen:
        if bad_iov(since, until):
            continue

        for output_name in virtual_output_channels:
            # Consider the state of each desired output for this
            # (since, until) and write it to output_iovs
            iov = virtual_iovs.get(output_name)
            if iov and iov.present:
                result[output_name].add(since, until, *iov[2:])

    # Sort them by traditional COOL sort ordering (by channelId first,
    # then by since. `iovs` are already ordered by since.)
    result_list = IOVSet()
    for channel, iovs in sorted(result.iteritems()):
        result_list.extend(iovs.solidify(DEFECT_IOV))

    return result_list
Beispiel #6
0
 def run(self, lbtime, run_iovs):
     self.evaluate_inputs(lbtime)
     result = IOVSet()
     for variable in self.variables:
         result.extend(variable.iovs)
     return result