ATLAS Offline Software
GoodRunsListConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 from __future__ import print_function
4 
6  def __init__(self):
7  # -- run cmd options
8  self.name = "GoodRunsListConfig" # -- name set inside GRLB xml output file
9  self.querytool = "AtlRunQuery.py" # -- run query tool
10  self.listname = "default.xml" # -- name of GRL xml output file
11  self.prefix = "" # -- prefix for GRL file name
12  self.show = "" # -- show arguments for atlrunquery
13  self.dqfolder = "DEFECTS" # -- DQ folder, eg. LBSUMM, SHIFTOFL. Default by AtlRunQuery
14 
15  # -- query selections in AtlRunQuery.py
16  # -- see Database/CoolRunQuery/python/AtlRunQueryParser.py for full list
17  self.querydict = {}
18  self.querydict['partition'] = ["ATLAS"] # -- DAQ partition
19  self.querydict['ptag'] = ["data09*"] # -- projecttag: collection filename prefix
20  #self.querydict['events'] = ["1000+"] # -- number of events per run
21  self.querydict['run'] = ["140541+"] # -- run number selection range
22  #self.querydict['duration'] = ["60s+"] # -- duration of run selection
23  self.querydict['time'] = [] # -- time of run selection, eg.
24  self.querydict['detector'] = [] #['all'] # -- subdetectors turned on, eg.
25  self.querydict['streams'] = [] # -- trigger output streams, eg.
26  self.querydict['mag'] = [] #["solenoidon","toroidon"] # -- magnetic field configuration
27  self.querydict['dq'] = [] # -- selection of data quality flags
28  self.querydict['smk'] = [] # -- super master key, eg.
29  self.querydict['trigger'] = [] # -- select specific triggers available, eg.
30  self.querydict['release'] = [] # -- release used, eg: '15.1.*'
31  #self.querydict['ctag'] = ['DetStatusLBSUMM-pass1'] # -- COOL conditions tag to use, eg: 'COMCOND-HLTC-001-00'. Default = head.
32  self.querydict['db'] = ['DATA'] # -- DATA or MC
33  self.dqignore = [] # DQ defects to ignore. These will be patched into the dq querydict
34 
35 
36  def Summary(self):
37  print ('Name : %s' % (self.name))
38  print ('Tool : %s' % (self.querytool))
39  print ('File : %s' % (self.listname))
40  print ('Show : %s' % (self.show))
41  print ('DQ folder : %s' % (self.dqfolder))
42  print ('Query :')
43  print (self.getsearchquery())
44  return
45 
46 
47  def getsearchquery(self):
48  cmd = "find "
49 
50  for key in self.querydict.keys():
51  arr = self.querydict[key][:]
52  if key == 'dq':
53  if len(self.dqignore) > 0:
54  toexclude = '\\' + '\\'.join(self.dqignore)
55  else:
56  toexclude = ''
57  print ('to exclude', toexclude)
58  for i, q in enumerate(arr):
59  qsplit = q.split()
60  if len(qsplit) > 0:
61  arr[i] = ' '.join([qsplit[0] + toexclude] + qsplit[1:])
62  for selection in arr:
63  if len(selection)>0:
64  cmd += "%s %s and " % (key,selection)
65  cmd = cmd[:-4]
66 
67  if len(self.show)>0:
68  cmd += " %s" % (self.show)
69  else: cmd += " / show run and events / nodef"
70 
71  xmlstring = 'xmlfile %s:%s' % (self.listname,self.name)
72  cmd += " , %s" % (xmlstring)
73  return cmd
74 
75 
76  def getparseddqflags(self):
77  from CoolRunQuery.AtlRunQueryLib import DQSelector,AtlRunQueryOptions
78  from CoolRunQuery.AtlRunQueryParser import ArgumentParser
79 
80 
81  query = self.getsearchquery()
82  ap = ArgumentParser()
83  atlqueryarg = self.querytool + " " + ap.ParseArgument( query )
84  (options, args) = AtlRunQueryOptions().parse(atlqueryarg)
85 
86 
87  selector = DQSelector(name = 'dataquality', dq = options.dqchannels)
88  dqfolder = self.getdqfolder()
89 
90  funcArr = []
91  dqconfig = selector.selectors[dqfolder]
92  for flag in dqconfig.flags:
93  fncName = dqconfig.flagInterpreter[flag]['passFncName']
94  fncName = fncName.replace("\'","")
95  funcArr.append(fncName)
96  #funcArr = selector.selectors[dqfolder].passFncName
97  #for i in range(len(funcArr)): funcArr[i] = funcArr[i].replace("\'","")
98 
99 
100  dqchannels = options.dqchannels
101  for i in range(len(dqchannels)):
102  dqArr = dqchannels[i].split()
103  dqArr[1] = funcArr[i]
104  dqchannels[i] = ' '.join(dqArr)
105 
106  return dqchannels
107 
108 
109  def getdqfolder(self):
110  return self.dqfolder
111 
112  def setdqfolder(self,dqfolder=''):
113  if len(dqfolder)>0: self.dqfolder = dqfolder
114  for idx in range( len(self.querydict['dq']) ):
115  dqquery = self.querydict['dq'][idx].strip()
116  queryArr = dqquery.split()
117 
118  if len(queryArr)==3:
119  ctagArr = queryArr[1].split('#')
120  if len(ctagArr)==2:
121  queryArr[1] = '%s#%s' % (self.dqfolder,ctagArr[1])
122  else: queryArr[1] = self.dqfolder
123 
124  elif len(queryArr)==2:
125  queryArr.insert(1,self.dqfolder)
126  dqquery = '%s %s %s' % (queryArr[0],queryArr[1],queryArr[2])
127  self.querydict['dq'][idx] = dqquery
128  return
129 
130  def setdqctag(self,dqctag):
131  if len(dqctag)==0: return
132  for idx in range( len(self.querydict['dq']) ):
133  dqquery = self.querydict['dq'][idx].strip()
134  queryArr = dqquery.split()
135 
136  if len(queryArr)==3:
137  ctagArr = queryArr[1].split('#')
138  queryArr[1] = '%s#%s' % (ctagArr[0],dqctag)
139 
140  elif len(queryArr)==2:
141  dqfoldtag = '%s#%s' % (self.dqfolder,dqctag)
142  queryArr.insert(1,dqfoldtag)
143  dqquery = '%s %s %s' % (queryArr[0],queryArr[1],queryArr[2])
144  self.querydict['dq'][idx] = dqquery
145  return
146 
147  def setctag(self,ctag):
148  if len(ctag)>0: self.querydict['ctag'] = ctag
149 
150  def getctag(self):
151  return self.querydict.get('ctag', '')
152 
153  def setPrefix(self,newprefix):
154  self.prefix = newprefix
155  self.listname = self.prefix+self.listname
156 
python.GoodRunsListConfig.GoodRunsListConfig.__init__
def __init__(self)
Definition: GoodRunsListConfig.py:6
python.GoodRunsListConfig.GoodRunsListConfig.name
name
Definition: GoodRunsListConfig.py:8
parse
std::map< std::string, std::string > parse(const std::string &list)
Definition: egammaLayerRecalibTool.cxx:1054
python.GoodRunsListConfig.GoodRunsListConfig.setdqfolder
def setdqfolder(self, dqfolder='')
Definition: GoodRunsListConfig.py:112
python.GoodRunsListConfig.GoodRunsListConfig.show
show
Definition: GoodRunsListConfig.py:12
python.GoodRunsListConfig.GoodRunsListConfig
Definition: GoodRunsListConfig.py:5
python.GoodRunsListConfig.GoodRunsListConfig.getsearchquery
def getsearchquery(self)
Definition: GoodRunsListConfig.py:47
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.GoodRunsListConfig.GoodRunsListConfig.prefix
prefix
Definition: GoodRunsListConfig.py:11
python.GoodRunsListConfig.GoodRunsListConfig.Summary
def Summary(self)
Definition: GoodRunsListConfig.py:36
python.GoodRunsListConfig.GoodRunsListConfig.dqignore
dqignore
Definition: GoodRunsListConfig.py:33
python.GoodRunsListConfig.GoodRunsListConfig.setPrefix
def setPrefix(self, newprefix)
Definition: GoodRunsListConfig.py:153
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.GoodRunsListConfig.GoodRunsListConfig.setdqctag
def setdqctag(self, dqctag)
Definition: GoodRunsListConfig.py:130
python.GoodRunsListConfig.GoodRunsListConfig.listname
listname
Definition: GoodRunsListConfig.py:10
python.GoodRunsListConfig.GoodRunsListConfig.dqfolder
dqfolder
Definition: GoodRunsListConfig.py:13
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
python.GoodRunsListConfig.GoodRunsListConfig.setctag
def setctag(self, ctag)
Definition: GoodRunsListConfig.py:147
python.GoodRunsListConfig.GoodRunsListConfig.querydict
querydict
Definition: GoodRunsListConfig.py:17
python.GoodRunsListConfig.GoodRunsListConfig.getparseddqflags
def getparseddqflags(self)
Definition: GoodRunsListConfig.py:76
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
python.GoodRunsListConfig.GoodRunsListConfig.querytool
querytool
Definition: GoodRunsListConfig.py:9
python.GoodRunsListConfig.GoodRunsListConfig.getctag
def getctag(self)
Definition: GoodRunsListConfig.py:150
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.GoodRunsListConfig.GoodRunsListConfig.getdqfolder
def getdqfolder(self)
Definition: GoodRunsListConfig.py:109