Example #1
0
def test_coracool():

    folder_path = "/SCT/DAQ/Configuration/Module"

    database = Databases.get_instance("COOLONL_SCT/COMP200")
    folder = database.getFolder(folder_path)

    #print "Total:", folder.countObjects(0, 2**63-1, cool.ChannelSelection())

    if not "<coracool>" in folder.description():
        print "%s is not a coracool folder" % folder.fullPath()
        return

    #x = fetch_objects("LBLB", (142391,0), (142391,0xFFFF), what=[], with_channel=False)
    #print "Expected count:", len(x)

    # Run 142391 timestamps
    #since, until = 1260878894897166135, 1260879303912307635
    run = 142391
    #run = 90415

    since, until, dummy = fetch_lb_timestamps((run, 0), (run, 2**32 - 1))

    #since, until = 0, 2**63-1
    since, until = 1221973544491128285, 1221995264779751560

    variables = ["group", "id"]

    record = namedtuple("coracool_record", "since until channel elements")
    element = namedtuple("element", " ".join(variables))

    start = time()

    objects = browse_coracool(database, folder_path, since, until,
                              cool.ChannelSelection(), "", variables, record,
                              element)

    elapsed = time() - start
    print "Took %.2f to browse_coracool" % elapsed

    print len(objects)
    #pprint(objects[:10])

    bad = [x for x in objects if any(el.group == -1 for el in x.elements)]
    print len(bad)

    #pprint(bad)

    ip()

    return
Example #2
0
def test_update_virtual_defect():

    ddb = DefectsDB(TEST_DATABASE, read_only=False)

    # Create two defects
    create_defect_type(ddb, 0)
    create_defect_type(ddb, 1)
    create_defect_type(ddb, 2)

    ddb.insert("DQD_TEST_DEFECT_0", 0, 100, "", "")
    ddb.insert("DQD_TEST_DEFECT_1", 100, 200, "", "")
    ddb.insert("DQD_TEST_DEFECT_2", 200, 300, "", "")

    defects_tag = ddb.new_defects_tag("dqd-test", "New iov tag")

    # Make a virtual defect whose result is the combination of the above
    ddb.new_virtual_defect("DQD_TEST_VIRTUAL_DEFECT", "",
                           "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_1")

    original_tag = ddb.new_logics_tag()
    original_htag = ddb.new_hierarchical_tag(defects_tag, original_tag)

    ddb.update_virtual_defect("DQD_TEST_VIRTUAL_DEFECT",
                              "DQD_TEST_DEFECT_0 DQD_TEST_DEFECT_2")

    new_tag = ddb.new_logics_tag()
    new_htag = ddb.new_hierarchical_tag(defects_tag, new_tag)

    what = {"channels": ["DQD_TEST_VIRTUAL_DEFECT"]}

    orig_iovs = DefectsDB(TEST_DATABASE, tag=original_htag).retrieve(**what)
    new_iovs = DefectsDB(TEST_DATABASE, tag=new_htag).retrieve(**what)
    head_iovs = DefectsDB(TEST_DATABASE).retrieve(**what)

    assert head_iovs == new_iovs
    assert head_iovs != orig_iovs

    assert len(head_iovs) == 2
    assert (head_iovs[0].since, head_iovs[0].until) == (0, 100)
    assert (head_iovs[1].since, head_iovs[1].until) == (200, 300)

    from DQUtils.db import Databases
    db3 = Databases.get_instance(TEST_DATABASE, read_only=True)
    pfs = db3.getFolderSet('/GLOBAL/DETSTATUS')
    assert pfs.tagDescription(
        new_htag) != '', 'Hierarchical tag description not created'
        ('TRCOS', [-1, 0, 1, 2], 'TRIG_HLT_COS_2010NONGREEN'),
        ('TAUB', [-1, 0, 1, 2], 'TAU_B_2010NONGREEN'),
        ('TAUCR', [-1, 0, 1, 2], 'TAU_CR_2010NONGREEN'),
        ('TAUE', [-1, 0, 1, 2], 'TAU_E_2010NONGREEN'),
        ('BTGLIFE', [-1, 0, 1, 2], 'BTAG_BTGLIFE_2010NONGREEN'),
        ('BTGSOFTE', [-1, 0, 1, 2], 'BTAG_BTGSOFTE_2010NONGREEN'),
        ('BTGSOFTM', [-1, 0, 1, 2], 'BTAG_BTGSOFTM_2010NONGREEN'),
        ('MMUIDVX', [-1, 0, 1, 2], 'MCP_MMUIDVX_2010NONGREEN'),
    ]

    runends = get_runends()
    outdb = DefectsDB('defectstest.db/COMP200', read_only=False)
    with outdb.storage_buffer:
        for trip in TRIPLES:
            print trip
            copyfunc(
                Databases.get_instance('COOLOFL_GLOBAL/COMP200'), outdb,
                dq_code_filter('/GLOBAL/DETSTATUS/LBSUMM',
                               'DetStatusLBSUMM-repro05-01', trip[0], trip[1]),
                defect_output(trip[2]), runends)
            copyfunc(
                Databases.get_instance('COOLOFL_GLOBAL/COMP200'), outdb,
                dq_code_filter('/GLOBAL/DETSTATUS/LBSUMM',
                               'DetStatusLBSUMM-pass1-analysis-2010J-01',
                               trip[0], trip[1]), defect_output(trip[2]),
                runends)

        copyfunc(Databases.get_instance('COOLONL_TDAQ/COMP200'), outdb,
                 atlas_notready_filter, defect_output('GLOBAL_NOTREADY'),
                 runends)