ATLAS Offline Software
dq_defect_translate_defects.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 def copyfunc(indb, outdb, func_iov, func_output, runends):
4  '''
5  indb = input database
6  outdb = output database
7  func_iov = function that takes a DB connection and returns some IOVs
8  (includes folder/channel selection and any filtering)
9  func_output = takes IOVs and writes them to the output DB connection
10  '''
11  iovs = func_iov(indb)
12  iovs = truncate_iovs_to_runs(iovs, runends)
13  iovs = filter(lambda x: not(x.until.lumi-x.since.lumi == 0), iovs)
14  print('There are %d IOVs to process' % len(iovs))
15 
17  for i, iov in enumerate(iovs):
18  func_output(outdb, iov)
19  if i % 100 == 1:
20  print('IOV', i)
21 
22 def truncate_iovs_to_runs(iovs, runends):
23  for iov in iovs:
24  if iov.since.run not in runends:
25  print('Missing run', iov.since.run, 'from EOR_Params')
26 
27  return filter(None,
28  [iov.intersect(runends[iov.since.run])
29  for iov in iovs if iov.since.run in runends])
30 
32  from DQUtils.db import fetch_iovs
33  eor_params = fetch_iovs('EOR_Params',
34  with_channel=False, what=[])
35  runends = {}
36  for iov in eor_params:
37  runends[iov.since.run] = iov
38  return runends
39 
40 def dq_code_filter(foldername, tag, channel, codes):
41  from DQUtils.db import fetch_iovs
42  def dq_code_filter_internals(indb):
43  folder = indb.getFolder(foldername)
44  iovs = fetch_iovs(folder, channels=[channel], tag=tag)
45  iovs = [iov for iov in iovs if iov.Code in codes]
46  return iovs
47  return dq_code_filter_internals
48 
49 def defect_output(channel):
50  def defect_output_internals(outdb, iov):
51  db = outdb
52  db.insert(channel, iov.since, iov.until,
53  (iov.Comment if 'Comment' in dir(iov) else 'Automatic'),
54  'sys:copy')
55  return defect_output_internals
56 
58  from DQUtils.db import fetch_iovs
59  folder = indb.getFolder('/TDAQ/RunCtrl/DataTakingMode')
60  iovs = fetch_iovs(folder, channels=[0])
61 
62  return filter(None, [iov for iov in iovs if iov.ReadyForPhysics == 0])
63 
64 if __name__ == '__main__':
65  from DQUtils.db import Databases
66  from DQDefects import DefectsDB
67 
68  TRIPLES = [
69  ('ATLTOR', [-1], 'GLOBAL_TOROID_OFF'),
70  ('ATLTOR', [1], 'GLOBAL_TOROID_RAMPING'),
71  ('ATLSOL', [-1], 'GLOBAL_SOLENOID_OFF'),
72  ('ATLSOL', [1], 'GLOBAL_SOLENOID_RAMPING'),
73  ('PIX0', [-1], 'PIXEL_LAYER0_DISABLED'),
74  ('PIXB', [-1], 'PIXEL_BARREL_DISABLED'),
75  ('PIXEA', [-1], 'PIXEL_ENDCAPS_DISABLED'),
76  ('PIXEC', [-1], 'PIXEL_ENDCAPS_DISABLED'),
77  ('PIX0', [-1, 0, 1, 2], 'PIXEL_LAYER0_2010NONGREEN'),
78  ('PIXB', [-1, 0, 1, 2], 'PIXEL_BARREL_2010NONGREEN'),
79  ('PIXEA', [-1, 0, 1, 2], 'PIXEL_ENDCAPA_2010NONGREEN'),
80  ('PIXEC', [-1, 0, 1, 2], 'PIXEL_ENDCAPC_2010NONGREEN'),
81  ('SCTB', [-1], 'SCT_GLOBAL_DISABLED'),
82  ('SCTEA', [-1], 'SCT_GLOBAL_DISABLED'),
83  ('SCTEC', [-1], 'SCT_GLOBAL_DISABLED'),
84  ('SCTB', [-1, 0, 1, 2], 'SCT_SCTB_2010NONGREEN'),
85  ('SCTEA', [-1, 0, 1, 2], 'SCT_SCTEA_2010NONGREEN'),
86  ('SCTEC', [-1, 0, 1, 2], 'SCT_SCTEC_2010NONGREEN'),
87  ('TRTTR', [-1, 0, 1, 2], 'TRT_TRTTR_2010NONGREEN'),
88  ('ATLGL', [1], 'GLOBAL_NOTCONSIDERED'),
89  ('RCOPS', [-1, 0, 1, 2], 'GLOBAL_RCOPS_2010NONGREEN'),
90  ('TILBA', [-1], 'TILE_LBA_DISABLED'),
91  ('TILBC', [-1], 'TILE_LBC_DISABLED'),
92  ('TIEBA', [-1], 'TILE_EBA_DISABLED'),
93  ('TIEBC', [-1], 'TILE_EBC_DISABLED'),
94  ('TILBA', [-1,0,1,2], 'TILE_LBA_2010NONGREEN'),
95  ('TILBC', [-1,0,1,2], 'TILE_LBC_2010NONGREEN'),
96  ('TIEBA', [-1,0,1,2], 'TILE_EBA_2010NONGREEN'),
97  ('TIEBC', [-1,0,1,2], 'TILE_EBC_2010NONGREEN'),
98  ('ALFA', [-1], 'ALFA_DISABLED'),
99  ('MBTSA', [-1], 'MBTS_A_DISABLED'),
100  ('MBTSC', [-1], 'MBTS_C_DISABLED'),
101  ('LCDA', [-1,0,1,2], 'LCD_LCDA_2010NONGREEN'),
102  ('LCDC', [-1,0,1,2], 'LCD_LCDC_2010NONGREEN'),
103  ('LUMI', [-1,0,1,2], 'LUMI_LUMI_2010NONGREEN'),
104  ('LUMIONL', [-1,0,1,2], 'LUMI_LUMIONL_2010NONGREEN'),
105  ('IDBS', [1], 'ID_BS_2010RED'),
106  ('IDBS', [2], 'ID_BS_2010YELLOW'),
107  ('IDVX', [-1,0,1,2], 'ID_VX_2010NONGREEN'),
108  ('IDGL', [-1,0,1,2], 'ID_GL_2010NONGREEN'),
109  ('IDAL', [-1,0,1,2], 'ID_AL_2010NONGREEN'),
110  ('L1CTP', [1], 'TRIG_L1_CTP_CLOCK'),
111  ('EIDCR', [-1,0,1,2], 'EGAMMA_EIDCR_2010NONGREEN'),
112  ('EMBA', [-1,0,1,2], 'LAR_EMBA_2010NONGREEN'),
113  ('EMBC', [-1,0,1,2], 'LAR_EMBC_2010NONGREEN'),
114  ('EMECA', [-1,0,1,2], 'LAR_EMECA_2010NONGREEN'),
115  ('EMECC', [-1,0,1,2], 'LAR_EMECC_2010NONGREEN'),
116  ('HECA', [-1,0,1,2], 'LAR_HECA_2010NONGREEN'),
117  ('HECC', [-1,0,1,2], 'LAR_HECC_2010NONGREEN'),
118  ('FCALA', [-1,0,1,2], 'LAR_FCALA_2010NONGREEN'),
119  ('FCALC', [-1,0,1,2], 'LAR_FCALC_2010NONGREEN'),
120  ('MDTBA', [-1,0,1,2], 'MS_MDT_BA_2010NONGREEN'),
121  ('MDTBC', [-1,0,1,2], 'MS_MDT_BC_2010NONGREEN'),
122  ('MDTEA', [-1,0,1,2], 'MS_MDT_EA_2010NONGREEN'),
123  ('MDTEC', [-1,0,1,2], 'MS_MDT_EC_2010NONGREEN'),
124  ('RPCBA', [-1,0,1,2], 'MS_RPC_BA_2010NONGREEN'),
125  ('RPCBC', [-1,0,1,2], 'MS_RPC_BC_2010NONGREEN'),
126  ('CSCEA', [-1,0,1,2], 'MS_CSC_EA_2010NONGREEN'),
127  ('CSCEC', [-1,0,1,2], 'MS_CSC_EC_2010NONGREEN'),
128  ('TGCEA', [-1,0,1,2], 'MS_TGC_EA_2010NONGREEN'),
129  ('TGCEC', [-1,0,1,2], 'MS_TGC_EC_2010NONGREEN'),
130  ('ZDC', [-1,0,1,2], 'ZDC_2010NONGREEN'),
131  ('TRTB', [-1,0,1,2], 'TRT_TRTB_2010NONGREEN'),
132  ('TRTEA', [-1,0,1,2], 'TRT_TRTEA_2010NONGREEN'),
133  ('TRTEC', [-1,0,1,2], 'TRT_TRTEC_2010NONGREEN'),
134  ('L1CAL', [-1,0,1,2], 'TRIG_L1_CAL_2010NONGREEN'),
135  ('TRBJT', [-1,0,1,2], 'TRIG_HLT_BJT_2010NONGREEN'),
136  ('TRBPH', [-1,0,1,2], 'TRIG_HLT_BPH_2010NONGREEN'),
137  ('TRCAL', [-1,0,1,2], 'TRIG_HLT_CAL_2010NONGREEN'),
138  ('TRELE', [-1,0,1,2], 'TRIG_HLT_ELE_2010NONGREEN'),
139  ('TRGAM', [-1,0,1,2], 'TRIG_HLT_GAM_2010NONGREEN'),
140  ('TRIDT', [-1,0,1,2], 'TRIG_HLT_IDT_2010NONGREEN'),
141  ('TRJET', [-1,0,1,2], 'TRIG_HLT_JET_2010NONGREEN'),
142  ('TRMBI', [-1,0,1,2], 'TRIG_HLT_MBI_2010NONGREEN'),
143  ('TRMET', [-1,0,1,2], 'TRIG_HLT_MET_2010NONGREEN'),
144  ('TRMUO', [-1,0,1,2], 'TRIG_HLT_MUO_2010NONGREEN'),
145  ('TRTAU', [-1,0,1,2], 'TRIG_HLT_TAU_2010NONGREEN'),
146  ('TRCOS', [-1,0,1,2], 'TRIG_HLT_COS_2010NONGREEN'),
147  ('TAUB', [-1,0,1,2], 'TAU_B_2010NONGREEN'),
148  ('TAUCR', [-1,0,1,2], 'TAU_CR_2010NONGREEN'),
149  ('TAUE', [-1,0,1,2], 'TAU_E_2010NONGREEN'),
150  ('BTGLIFE', [-1,0,1,2], 'BTAG_BTGLIFE_2010NONGREEN'),
151  ('BTGSOFTE', [-1,0,1,2], 'BTAG_BTGSOFTE_2010NONGREEN'),
152  ('BTGSOFTM', [-1,0,1,2], 'BTAG_BTGSOFTM_2010NONGREEN'),
153  ('MMUIDVX', [-1,0,1,2], 'MCP_MMUIDVX_2010NONGREEN'),
154  ]
155 
156  runends = get_runends()
157  outdb = DefectsDB('defectstest.db/COMP200', read_only=False)
158  with outdb.storage_buffer:
159  for trip in TRIPLES:
160  print(trip)
161  copyfunc(Databases.get_instance('COOLOFL_GLOBAL/COMP200'),
162  outdb,
163  dq_code_filter('/GLOBAL/DETSTATUS/LBSUMM',
164  'DetStatusLBSUMM-repro05-01', trip[0], trip[1]),
165  defect_output(trip[2]), runends)
166  copyfunc(Databases.get_instance('COOLOFL_GLOBAL/COMP200'),
167  outdb,
168  dq_code_filter('/GLOBAL/DETSTATUS/LBSUMM',
169  'DetStatusLBSUMM-pass1-analysis-2010J-01', trip[0], trip[1]),
170  defect_output(trip[2]), runends)
171 
172 
173  copyfunc(Databases.get_instance('COOLONL_TDAQ/COMP200'),
174  outdb,
175  atlas_notready_filter,
176  defect_output('GLOBAL_NOTREADY'), runends)
dq_defect_translate_defects.dq_code_filter
def dq_code_filter(foldername, tag, channel, codes)
Definition: dq_defect_translate_defects.py:40
dq_defect_translate_defects.get_runends
def get_runends()
Definition: dq_defect_translate_defects.py:31
dq_defect_translate_defects.copyfunc
def copyfunc(indb, outdb, func_iov, func_output, runends)
Definition: dq_defect_translate_defects.py:3
python.db.fetch_iovs
def fetch_iovs(folder_name, since=None, until=None, channels=None, tag="", what="all", max_records=-1, with_channel=True, loud=False, database=None, convert_time=False, named_channels=False, selection=None, runs=None, with_time=False, unicode_strings=False)
Definition: DQUtils/python/db.py:67
covarianceTool.filter
filter
Definition: covarianceTool.py:514
dq_defect_translate_defects.defect_output
def defect_output(channel)
Definition: dq_defect_translate_defects.py:49
beamspotman.dir
string dir
Definition: beamspotman.py:623
dq_defect_translate_defects.atlas_notready_filter
def atlas_notready_filter(indb)
Definition: dq_defect_translate_defects.py:57
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
dq_defect_translate_defects.truncate_iovs_to_runs
def truncate_iovs_to_runs(iovs, runends)
Definition: dq_defect_translate_defects.py:22