ATLAS Offline Software
dcsc_muons_show_bad_for_variable.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 from DQUtils import fetch_iovs, IOVSet, process_iovs
4 from DQUtils.channel_mapping import list_to_channelselection
5 
6 from DCSCalculator2.lib import DCSC_Global_Variable
7 
8 def pretty_range(r):
9  a, b = r
10  if a == b:
11  return "%i" % a
12  return "%i..%i" % r
13 
14 def pretty_ranges(channels):
15  channels = list_to_channelselection(channels, as_list=True, convert_channel=None)
16  return ", ".join(pretty_range(r) for r in channels)
17 
18 def show_variable_info(lbtime, Subdetector):
19  subdetector = Subdetector()
20  for variable in subdetector.variables:
21  print "Processing variable:", variable.folder_name
22  good_iovs = variable.calculate_good_iovs(lbtime, subdetector).iovs
23 
24  chans, iovs = good_iovs.chans_iovsets
25 
26  if isinstance(variable, DCSC_Global_Variable):
27 
28  for since, until, states in process_iovs(*iovs):
29  channels = [(state.channel, state.Code) for state in states
30  if state and state.Code < 3]
31 
32  print since, until, pretty_ranges(channels)
33  else:
34 
35  for since, until, states in process_iovs(*iovs):
36  channels = [state.channel for state in states
37  if state and not state.good]
38  print since, until, pretty_ranges(channels)
39 
40 def main():
41  from DCSCalculator2.subdetectors import MDT
42 
43  lbtime = fetch_iovs("LBTIME", (177540, 0))
44 
45  print "lbtime =", lbtime
46 
47  show_variable_info(lbtime, MDT)
48 
49 if __name__ == "__main__":
50  main()
dcsc_muons_show_bad_for_variable.main
def main()
Definition: dcsc_muons_show_bad_for_variable.py:40
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
dcsc_muons_show_bad_for_variable.pretty_range
def pretty_range(r)
Definition: dcsc_muons_show_bad_for_variable.py:8
dcsc_muons_show_bad_for_variable.show_variable_info
def show_variable_info(lbtime, Subdetector)
Definition: dcsc_muons_show_bad_for_variable.py:18
python.events.process_iovs
def process_iovs(*iovsets)
Definition: events.py:30
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.channel_mapping.list_to_channelselection
def list_to_channelselection(list_, convert_channel=convert_channel, as_list=False)
Definition: channel_mapping.py:42
dcsc_muons_show_bad_for_variable.pretty_ranges
def pretty_ranges(channels)
Definition: dcsc_muons_show_bad_for_variable.py:14