def initialize_name_mapping(self): from DQUtils.db import Databases, get_channel_ids_names f = Databases.get_folder("/TDAQ/EnabledResources/ATLAS/PIXEL/Modules", "COOLONL_TDAQ") cids, cnames, cmap = get_channel_ids_names(f) self.name_mapping = dict(zip(cids, cnames)) self.name_mapping_initialized = True
def generate_table(folder, channel, since, until): cool_folder = Databases.get_folder(folder) channelid = cool_folder.channelId(channel) cs = cool.ChannelSelection(channelid, channelid) print "Totals for channel '%s' in folder '%s'" % (channel, folder) iovs, info_runs = fetch_fixedup_folder_information(folder, since, until, cs) table = generate_lb_count_table(folder, iovs, info_runs) pprint_table(table, header_loc=2)
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
def test(): def filter_hello(line): if line.startswith("Data source lookup using"): return True print "Before with block.." with silence(filter_hello): from DQUtils.db import Databases f = Databases.get_folder("DQMFONL") print "Sensible stuff!" print "f =", f print "I am after the silence block"
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'
def make_sct_mapping(): """ Generate a mapping for the channelids in /SCT/DCS/HV to DCSOFL output channel ids. The highest two bits can be used to determine the system. (see `subdets`) """ from DQUtils.db import Databases from DQUtils.channel_mapping import get_channel_ids_names f = Databases.get_folder("/SCT/DCS/HV", "COOLOFL_DCS/CONDBR2") cids, cnames, cmap = get_channel_ids_names(f) mapping = {} subdets = {0: 114, 1: 111, 2: 115} for cid in cids: # The highest-two bits of cid specify which DQ region we're in output_subdet = subdets[(cid >> 25) & 0x3] mapping.setdefault(output_subdet, []).append(cid) return mapping
('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)
db = DefectsDB(opts.db, read_only=False, tag=opts.defecttag) primary_names = DetStatusNames() with db.storage_buffer: print 'Populating old primary flags' ## for defect in primary_names.allNames(): ## #print defect ## try: ## print db.new_virtual_defect(0, defect, defect, ''), defect ## except DefectExistsError: ## if opts.ignoreold: ## print 'Defect', defect, 'already exists; ignoring' ## else: ## raise folder = Databases.get_folder(opts.origpridb, read_only=True) ids, names, cdict = get_channel_ids_names(folder) for defect in names: if defect in DEPRECATED_PRIMARY_FLAGS: print 'Skipping', defect, 'as it is deprecated' continue #print defect, folder.channelDescription(cdict[defect]) try: print db.new_virtual_defect(defect, defect, ''), defect except DefectExistsError: if opts.ignoreold: print 'Defect', defect, 'already exists; ignoring' else: raise print 'Populating old virtual flags'
def clear_lookup_line(): Databases.get_folder("SHIFTOFL") stdout.write("\x1B[A\x1B[K")