1 from __future__
import print_function
3 "Interface with the DBS API to get the whatever you want of a requirements. ALWAYS RETURN A LIST OF STRINGS" 4 from xml.dom.minidom
import parseString
5 from DBSAPI.dbsApi
import DbsApi
7 args[
'url']=
'http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet' 8 args[
'version']=
'DBS_2_0_9' 11 data = api.executeQuery(
"find %s where %s" % (toFind, requirements))
12 domresults = parseString(data)
13 dbs = domresults.getElementsByTagName(
'dbs')
14 result = dbs[0].getElementsByTagName(
'results')
15 rows=result[0].getElementsByTagName(
'row')
18 resultXML = row.getElementsByTagName(toFind)[0]
19 node=(resultXML.childNodes)[0]
20 retList.append(
str(node.nodeValue))
26 'ZTT' : {
'primds' :
'RelValZTT',
'tier' :
'GEN-SIM-RECO',},
27 'QCD' : {
'primds' :
'RelValQCD_FlatPt_15_3000',
'tier' :
'GEN-SIM-RECO',},
28 'ZMM' : {
'primds' :
'RelValZMM',
'tier' :
'GEN-SIM-RECO',},
29 'ZEE' : {
'primds' :
'RelValZEE',
'tier' :
'GEN-SIM-RECO',},
31 'RealData' : {
'primds' :
'Jet',
'tier' :
'RECO',
'dataset' :
'*RelVal*'},
32 'RealMuonsData' : {
'primds' :
'Mu',
'tier' :
'RECO',
'dataset' :
'*RelVal*'},
33 'RealElectronsData' : {
'primds' :
'Electron',
'tier' :
'RECO',
'dataset' :
'*RelVal*'},
35 'ZTTFastSim' : {
'primds' :
'RelValZTT',
'tier' :
'GEN-SIM-DIGI-RECO',
'dataset' :
'*FastSim*',},
38 'ZEEFastSim' : {
'primds' :
'RelValZEE',
'tier' :
'GEN-SIM-DIGI-RECO',
'dataset' :
'*FastSim*',},
44 for item
in datasetDict[eventType].
items():
45 requirements += item[0]+
' = '+item[1]+
' and ' 46 requirements +=
'release = %s' % os.environ[
'CMSSW_VERSION']
50 print(
"Multiple datasets found for %s! Which one you would like to use?" % eventType)
52 print(
"%s : %s" % (foundDs.index(ds),ds))
53 cnum =
int(raw_input(
"\nselect Dataset: "))
55 elif len(foundDs) == 0:
56 print(
"Sorry! No Dataset found, exiting...")
60 requirements =
'dataset = %s' % selDs
63 source.fileNames.append(entry)
67 for key
in root.keys():
68 if isinstance(root[key], dict):
69 xmlstr =
'%s<%s>%s</%s>' % (xmlstr, key,
serialize(root[key]), key)
70 elif isinstance(root[key], list):
71 xmlstr =
'%s<%s>' % (xmlstr, key)
72 for item
in root[key]:
73 xmlstr =
'%s%s' % (xmlstr,
serialize(item))
74 xmlstr =
'%s</%s>' % (xmlstr, key)
77 xmlstr =
'%s<%s>%s</%s>' % (xmlstr, key, value, key)
81 from xml.dom.minidom
import parseString
83 return outdom.toprettyxml()
86 from xml.dom.minidom
import parse
87 wrappedCont =
parse(xml)
88 content = wrappedCont.getElementsByTagName(
'dataFiles')[0]
89 byType = content.getElementsByTagName(eventType)
92 fnames = byType[0].getElementsByTagName(
'file')
94 node = (fname.childNodes)[0]
vector< string > parse(string line, const string &delimiter)
def FillSource(eventType, source)
def replace(string, replacements)
def GetDbsInfo(toFind, requirements)
def loadXML(xml, eventType, source)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)