test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
DBSApi_cff Namespace Reference

Functions

def DictToXML
 
def FillSource
 
def GetDbsInfo
 
def loadXML
 
def serialize
 

Function Documentation

def DBSApi_cff.DictToXML (   root)

Definition at line 79 of file DBSApi_cff.py.

References parseString(), and serialize().

79 
80 def DictToXML(root):
81  from xml.dom.minidom import parseString
82  outdom = parseString(serialize(root)) #closure test to check incopatibilities, and better printing
83  return outdom.toprettyxml()
def DictToXML
Definition: DBSApi_cff.py:79
void parseString(std::string &title)
def serialize
Definition: DBSApi_cff.py:64
def DBSApi_cff.FillSource (   eventType,
  source 
)

Definition at line 40 of file DBSApi_cff.py.

References GetDbsInfo(), and mps_monitormerge.items.

40 
41 def FillSource(eventType,source):
42  import os
43  requirements = ''
44  for item in datasetDict[eventType].items():
45  requirements += item[0]+' = '+item[1]+' and '
46  requirements += 'release = %s' % os.environ['CMSSW_VERSION']
47  foundDs = GetDbsInfo('dataset', requirements)
48  selDs = ''
49  if len(foundDs) > 1:
50  print "Multiple datasets found for %s! Which one you would like to use?" % eventType
51  for ds in foundDs:
52  print "%s : %s" % (foundDs.index(ds),ds)
53  cnum = int(raw_input("\nselect Dataset: "))
54  selDs = foundDs[cnum]
55  elif len(foundDs) == 0:
56  print "Sorry! No Dataset found, exiting..."
57  return None
58  else:
59  selDs = foundDs[0]
60  requirements = 'dataset = %s' % selDs
61  files = GetDbsInfo('file', requirements)
62  for entry in files:
63  source.fileNames.append(entry)
def FillSource
Definition: DBSApi_cff.py:40
def GetDbsInfo
Definition: DBSApi_cff.py:1
def DBSApi_cff.GetDbsInfo (   toFind,
  requirements 
)

Definition at line 1 of file DBSApi_cff.py.

References parseString().

Referenced by FillSource().

1 def GetDbsInfo(toFind, requirements):
2  "Interface with the DBS API to get the whatever you want of a requirements. ALWAYS RETURN A LIST OF STRINGS"
3  from xml.dom.minidom import parseString
4  from DBSAPI.dbsApi import DbsApi
5  args = {}
6  args['url']='http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet'
7  args['version']='DBS_2_0_9'
8  args['mode']='POST'
9  api = DbsApi(args)
10  data = api.executeQuery("find %s where %s" % (toFind, requirements))
11  domresults = parseString(data)
12  dbs = domresults.getElementsByTagName('dbs')
13  result = dbs[0].getElementsByTagName('results')
14  rows=result[0].getElementsByTagName('row')
15  retList = []
16  for row in rows:
17  resultXML = row.getElementsByTagName(toFind)[0]
18  node=(resultXML.childNodes)[0] #childNodes should be a one element array
19  retList.append(str(node.nodeValue))
20  return retList
21 
22 #Matching names to real datasetNames
23 datasetDict={
24  #GEN-SIM-RECO tier
25  'ZTT' : { 'primds' : 'RelValZTT', 'tier' : 'GEN-SIM-RECO',},
26  'QCD' : { 'primds' : 'RelValQCD_FlatPt_15_3000', 'tier' : 'GEN-SIM-RECO',},
27  'ZMM' : { 'primds' : 'RelValZMM', 'tier' : 'GEN-SIM-RECO',},
28  'ZEE' : { 'primds' : 'RelValZEE', 'tier' : 'GEN-SIM-RECO',},
29  #Data
30  'RealData' : { 'primds' : 'Jet', 'tier' : 'RECO', 'dataset' : '*RelVal*'},
31  'RealMuonsData' : { 'primds' : 'Mu', 'tier' : 'RECO', 'dataset' : '*RelVal*'},
32  'RealElectronsData' : { 'primds' : 'Electron', 'tier' : 'RECO', 'dataset' : '*RelVal*'},
33  #FastSim
34  'ZTTFastSim' : { 'primds' : 'RelValZTT', 'tier' : 'GEN-SIM-DIGI-RECO','dataset' : '*FastSim*',},
35  #'FastSimQCD' : { 'primds' : 'RelValQCD_FlatPt_15_3000', 'tier' : 'GEN-SIM-DIGI-RECO','dataset' : '*FastSim*',}, NOT YET IN RELVAL CONTENT
36  #'FastSimZMM' : { 'primds' : 'RelValZMM', 'tier' : 'GEN-SIM-DIGI-RECO','dataset' : '*FastSim*',},
37  'ZEEFastSim' : { 'primds' : 'RelValZEE', 'tier' : 'GEN-SIM-DIGI-RECO','dataset' : '*FastSim*',},
38  }
39 
def GetDbsInfo
Definition: DBSApi_cff.py:1
void parseString(std::string &title)
def DBSApi_cff.loadXML (   xml,
  eventType,
  source 
)

Definition at line 84 of file DBSApi_cff.py.

References triggerExpression.parse(), and python.rootplot.root2matplotlib.replace().

84 
85 def loadXML(xml,eventType,source):
86  from xml.dom.minidom import parse
87  wrappedCont = parse(xml)
88  content = wrappedCont.getElementsByTagName('dataFiles')[0]
89  byType = content.getElementsByTagName(eventType)
90  if len(byType) == 0:
91  return None
92  fnames = byType[0].getElementsByTagName('file')
93  for fname in fnames:
94  node = (fname.childNodes)[0] #childNodes should be a one element array
95  source.fileNames.append(str(node.nodeValue).replace('\n','').replace('\t',''))
def loadXML
Definition: DBSApi_cff.py:84
Evaluator * parse(const T &text)
def DBSApi_cff.serialize (   root)

Definition at line 64 of file DBSApi_cff.py.

Referenced by DictToXML().

64 
65 def serialize(root):
66  xmlstr = ''
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)
75  else:
76  value = root[key]
77  xmlstr = '%s<%s>%s</%s>' % (xmlstr, key, value, key)
78  return xmlstr
def serialize
Definition: DBSApi_cff.py:64