ATLAS Offline Software
Classes | Functions | Variables
python.grl Namespace Reference

Classes

class  GRLGen
 

Functions

def GRL_IOV ()
 
def grl_from_dir (xmldir)
 
def load_grl_iovs_any (*files)
 
def load_grl (xml_file, IOVSet_class=IOVSet)
 
def load_grl_string (data, IOVSet_class=IOVSet)
 
def make_grl (iovset, name="unknown", version="unknown")
 
def grl_contains_run_lb (grl, runlb)
 
def grl_iovs_from_xml (*args, **kwargs)
 
def test ()
 
def _do_import_and_get_obj (grlconfmod, grlobj=None)
 
def _deep_get_grl_info (grlconf, cooltag, folder)
 
def _get_grl_info (grlconf, cooltag, folder, queue=None)
 
def _get_cool_tags_for_folder (folder)
 
def _get_list_of_grl_classes ()
 

Variables

list TAGS_TO_SUPPRESS
 

Function Documentation

◆ _deep_get_grl_info()

def python.grl._deep_get_grl_info (   grlconf,
  cooltag,
  folder 
)
private

Definition at line 21 of file GoodRunsLists/python/grl.py.

21 def _deep_get_grl_info(grlconf, cooltag, folder):
22  from CoolRunQuery.AtlRunQueryLib import AtlRunQuery, AtlRunQueryOptions
23  from CoolRunQuery.AtlRunQueryParser import ArgumentParser
24 
25 
26  config = _do_import_and_get_obj(grlconf)
27  config.setdqfolder(folder)
28  config.setdqctag(cooltag)
29  #config.setPrefix('')
30 
31  query = config.getsearchquery()
32  print (">> Calling cmd equivalent of: ")
33  print ("%s \"%s\"" % (config.querytool,query))
34 
35 
36  ap = ArgumentParser()
37  atlqueryarg = config.querytool + " " + ap.ParseArgument( query )
38  (options, args) = AtlRunQueryOptions().parse(atlqueryarg)
39 
40  #print (atlqueryarg)
41  #print (options)
42 
43 
44  proc = multiprocessing.Process(target=AtlRunQuery, args=(options,),
45  kwargs={'html':"NO", 'origQuery':query, 'loglevel':0}) # html can be "YES", "NO", "AUTO"
46  proc.start()
47  proc.join()
48  xmlfile = 'data/'+config.listname
49  #print (">> Good-run list stored as: \'%s\'" % xmlfile)
50  return xmlfile
51 
52 

◆ _do_import_and_get_obj()

def python.grl._do_import_and_get_obj (   grlconfmod,
  grlobj = None 
)
private

Definition at line 14 of file GoodRunsLists/python/grl.py.

14 def _do_import_and_get_obj(grlconfmod, grlobj = None):
15  __import__(grlconfmod)
16  m = sys.modules[grlconfmod]
17  if grlobj is None:
18  grlobj = grlconfmod.rsplit('.')[-1]
19  return m.__dict__[grlobj]()
20 

◆ _get_cool_tags_for_folder()

def python.grl._get_cool_tags_for_folder (   folder)
private

Definition at line 66 of file GoodRunsLists/python/grl.py.

66 def _get_cool_tags_for_folder(folder):
67  tagxml = urllib.urlopen('http://voatlas11.cern.ch:8080/cooldb/ATLAS_COOLPROD/ATLAS_COOLOFL_GLOBAL/COMP200/GLOBAL/DETSTATUS/%s/tags'
68  % folder)
69  xml = ET.parse(tagxml)
70  rv = []
71  for t in xml.findall('tag'):
72  text = t.text
73  lock = t.attrib.get('lock', 'unlocked')
74  description = t.attrib.get('description')
75  rv.append((text, description, lock))
76  return rv
77 
78 GRL_DIRECTORY='/afs/cern.ch/user/a/atlasdqm/grl'
79 
80 

◆ _get_grl_info()

def python.grl._get_grl_info (   grlconf,
  cooltag,
  folder,
  queue = None 
)
private

Definition at line 53 of file GoodRunsLists/python/grl.py.

53 def _get_grl_info(grlconf, cooltag, folder, queue = None):
54  sys.path.append(os.path.dirname(grlconf))
55  # grlconf is the input file
56  tmpdir = tempfile.mkdtemp()
57  os.chdir(tmpdir)
58  rfile = _deep_get_grl_info(os.path.basename(grlconf).rstrip('.py'), cooltag, folder)
59  rv = open(rfile, 'r').read()
60  os.chdir(os.environ['TMPDIR'])
61  shutil.rmtree(tmpdir)
62  #print (rv)
63  queue.put((rv, rfile))
64  return
65 

◆ _get_list_of_grl_classes()

def python.grl._get_list_of_grl_classes ( )
private

Definition at line 88 of file GoodRunsLists/python/grl.py.

89  rl = []
90  def walker(rl, d, children):
91  for child in children:
92  if child[-3:] == '.py' and child != '__init__.py':
93  fullpath = os.path.join(d, child)
94  classname = fullpath.replace(GRL_DIRECTORY, '')[:-3].lstrip('/').replace('/', '.')
95  rl.append((fullpath, classname))
96  os.path.walk(GRL_DIRECTORY, walker, rl)
97  return rl
98 

◆ grl_contains_run_lb()

def python.grl.grl_contains_run_lb (   grl,
  runlb 
)

Definition at line 84 of file DQUtils/python/grl.py.

84 def grl_contains_run_lb(grl, runlb):
85  # takes IOVSet of GRL_IOV, says whether runlb is in it
86  # runlb can be RunLumi type or tuple pair
87  if isinstance(runlb, RunLumiType):
88  runlb_ = runlb
89  else:
90  runlb_ = RunLumi(*runlb)
91  return any(_.contains_point(runlb_) for _ in grl)
92 
93 # Deprecated alias

◆ grl_from_dir()

def python.grl.grl_from_dir (   xmldir)
Loads valid IOV ranges if they appear in any grl file whose name ends with ".xml"

Definition at line 16 of file DQUtils/python/grl.py.

16 def grl_from_dir(xmldir):
17  """
18  Loads valid IOV ranges if they appear in any grl file whose name ends with ".xml"
19  """
20  return load_grl_iovs_any(*(pjoin(xmldir, f)
21  for f in listdir(xmldir) if f.endswith(".xml")))
22 

◆ GRL_IOV()

def python.grl.GRL_IOV ( )

Definition at line 13 of file DQUtils/python/grl.py.

13 def GRL_IOV():
14  "Represent a good run region"
15 

◆ grl_iovs_from_xml()

def python.grl.grl_iovs_from_xml ( args,
**  kwargs 
)

Definition at line 94 of file DQUtils/python/grl.py.

94 def grl_iovs_from_xml(*args, **kwargs):
95  from warnings import warn
96  warn("grl_iovs_from_xml was renamed to load_grl", DeprecationWarning)
97  return load_grl(*args, **kwargs)
98 

◆ load_grl()

def python.grl.load_grl (   xml_file,
  IOVSet_class = IOVSet 
)

Definition at line 38 of file DQUtils/python/grl.py.

38 def load_grl(xml_file, IOVSet_class=IOVSet):
39  with open(xml_file, "rb") as fd:
40  return load_grl_string(fd.read(), IOVSet_class)
41 

◆ load_grl_iovs_any()

def python.grl.load_grl_iovs_any ( files)
Use IOV ranges from the input `files` xmls if the lumirange is set in any file

Definition at line 23 of file DQUtils/python/grl.py.

23 def load_grl_iovs_any(*files):
24  """
25  Use IOV ranges from the input `files` xmls if the lumirange is set in any file
26  """
27  grl_iovsets = [grl_iovs_from_xml(f) for f in files]
28 
29  assert all(i.ordered for i in grl_iovsets)
30 
31  result = IOVSet()
32  for since, until, grl_states in process_iovs(*grl_iovsets):
33  if any(grl_states):
34  result.add(since, until)
35 
36  return result.solidify(GRL_IOV)
37 

◆ load_grl_string()

def python.grl.load_grl_string (   data,
  IOVSet_class = IOVSet 
)

Definition at line 42 of file DQUtils/python/grl.py.

42 def load_grl_string(data, IOVSet_class=IOVSet):
43  xml = cElementTree.fromstring(data)
44  result = []
45 
46  for lbc in xml.iter('LumiBlockCollection'):
47  run = int(lbc.find('Run').text)
48  for lbr in lbc.findall('LBRange'):
49  since, until = int(lbr.get('Start')), int(lbr.get('End')) + 1
50 
51  result.append((RunLumi(run, since), RunLumi(run, until)))
52 
53  return IOVSet_class(map(GRL_IOV._make, sorted(result)))
54 

◆ make_grl()

def python.grl.make_grl (   iovset,
  name = "unknown",
  version = "unknown" 
)

Definition at line 55 of file DQUtils/python/grl.py.

55 def make_grl(iovset, name="unknown", version="unknown"):
56  assert len(iovset.channels) <= 1
57 
58  from datetime import datetime
59  from textwrap import dedent
60 
61  result = [dedent("""
62  <?xml version="1.0" ?>
63  <!DOCTYPE LumiRangeCollection
64  SYSTEM 'http://atlas-runquery.cern.ch/LumiRangeCollection.dtd'>
65  <!-- Good-runs-list created by DQUtils on {time} -->
66  <LumiRangeCollection>
67  <NamedLumiRange>
68  <Name>{name}</Name>
69  <Version>{version}</Version>""".format(
70  name=name, version=version,
71  time=datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))).strip()]
72 
73  for run, iovs in sorted(iovset.by_run.items()):
74  result.append(" <LumiBlockCollection>")
75  result.append(" <Run>%i</Run>" % run)
76  for iov in iovs:
77  arg = iov.since.lumi, iov.until.lumi-1
78  result.append(' <LBRange Start="%i" End="%i"/>' % arg)
79  result.append(" </LumiBlockCollection>")
80  result.append(" </NamedLumiRange>")
81  result.append("</LumiRangeCollection>")
82  return "\n".join(result)
83 

◆ test()

def python.grl.test ( )

Definition at line 99 of file DQUtils/python/grl.py.

99 def test():
100  path = "/afs/cern.ch/user/b/beate/public/DQAna/StableBeams-periodC1.xml"
101  iovs = grl_iovs_from_xml(path)
102 
103  from pprint import pprint
104  pprint(iovs)
105 

Variable Documentation

◆ TAGS_TO_SUPPRESS

list python.grl.TAGS_TO_SUPPRESS
Initial value:
1 = ['DetStatusLBSumm_m4initial',
2  'DetStatusLBSumm-cos08-01',
3  'DetStatusLBSumm-cos09-01',
4  'DetStatusLBSumm-cos08-02',
5  'COMP200_OFL',
6  'DetStatusLBSumm_RECP']

Definition at line 81 of file GoodRunsLists/python/grl.py.

read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition: openCoraCool.cxx:569
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.grl.load_grl
def load_grl(xml_file, IOVSet_class=IOVSet)
Definition: DQUtils/python/grl.py:38
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1040
python.dummyaccess.listdir
def listdir(dirname)
Definition: dummyaccess.py:6
python.grl.load_grl_string
def load_grl_string(data, IOVSet_class=IOVSet)
Definition: DQUtils/python/grl.py:42
python.grl.test
def test()
Definition: DQUtils/python/grl.py:99
python.sugar.runlumi.RunLumi
RunLumi
Definition: runlumi.py:131
python.grl.load_grl_iovs_any
def load_grl_iovs_any(*files)
Definition: DQUtils/python/grl.py:23
python.grl._do_import_and_get_obj
def _do_import_and_get_obj(grlconfmod, grlobj=None)
Definition: GoodRunsLists/python/grl.py:14
python.grl.grl_iovs_from_xml
def grl_iovs_from_xml(*args, **kwargs)
Definition: DQUtils/python/grl.py:94
python.events.process_iovs
def process_iovs(*iovsets)
Definition: events.py:30
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
python.grl._get_cool_tags_for_folder
def _get_cool_tags_for_folder(folder)
Definition: GoodRunsLists/python/grl.py:66
python.grl.grl_from_dir
def grl_from_dir(xmldir)
Definition: DQUtils/python/grl.py:16
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.grl._get_list_of_grl_classes
def _get_list_of_grl_classes()
Definition: GoodRunsLists/python/grl.py:88
ReadBadBitsFromCool.warn
warn
Definition: ReadBadBitsFromCool.py:43
Trk::open
@ open
Definition: BinningType.h:40
Cut::all
@ all
Definition: SUSYToolsAlg.cxx:64
python.grl.make_grl
def make_grl(iovset, name="unknown", version="unknown")
Definition: DQUtils/python/grl.py:55
python.grl._deep_get_grl_info
def _deep_get_grl_info(grlconf, cooltag, folder)
Definition: GoodRunsLists/python/grl.py:21
python.grl.grl_contains_run_lb
def grl_contains_run_lb(grl, runlb)
Definition: DQUtils/python/grl.py:84
python.grl.GRL_IOV
def GRL_IOV()
Definition: DQUtils/python/grl.py:13
python.grl._get_grl_info
def _get_grl_info(grlconf, cooltag, folder, queue=None)
Definition: GoodRunsLists/python/grl.py:53