CMS 3D CMS Logo

Functions
contentValuesLib Namespace Reference

Functions

def checkFilter (raw_filter)
 
def getDatasetName (file_name)
 
def getSummaryValues (file_name, translate, filters=None)
 
def writeValues (folder, map, keymap=None, filter=None)
 

Function Documentation

def contentValuesLib.checkFilter (   raw_filter)
Check if filter is OK 

Definition at line 122 of file contentValuesLib.py.

Referenced by contentValuesToDBS.OptionParser.__init__(), and contentValuesToRR.OptionParser.__init__().

122 def checkFilter(raw_filter):
123  """ Check if filter is OK """
124  if raw_filter != None:
125  try:
126  filter = eval(raw_filter)
127  if type("") != type(filter[0]) or type("") != type(filter[1]) or type("") != type(filter[2]):
128  raise TypeError('')
129  except:
130  print "Bad filter value ", raw_filter, ".\nFilter should be written in python tupple with 3 elements, i.e. \"('subsystem','folder','value')\". elements are in regexp format."
131  sys.exit(2)
132  else:
133  filter = ('.*', '.*', '.*')
134  return filter
135 
def checkFilter(raw_filter)
def contentValuesLib.getDatasetName (   file_name)
Method to get dataset name from the file name

Definition at line 30 of file contentValuesLib.py.

References edmIntegrityCheck.group.

Referenced by contentValuesToDBS.OptionParser.__init__(), and contentValuesToRR.OptionParser.__init__().

30 def getDatasetName(file_name):
31  """ Method to get dataset name from the file name"""
32  d = None
33  try:
34  d = re.search("(__[a-zA-Z0-9-_]+)+", file_name).group(0)
35  d = re.sub("__", "/", d)
36  except:
37  d = None
38  return d
39 
def getDatasetName(file_name)
def contentValuesLib.getSummaryValues (   file_name,
  translate,
  filters = None 
)
Method to extract keys from root file and return dict 

Definition at line 40 of file contentValuesLib.py.

References createfilelist.int, and writeValues().

Referenced by contentValuesCheck.OptionParser.__init__(), contentValuesToRR.OptionParser.__init__(), and contentValuesToDBS.OptionParser.__init__().

40 def getSummaryValues(file_name, translate, filters = None):
41  """ Method to extract keys from root file and return dict """
42  ROOT.gROOT.Reset()
43 
44  run_number = None
45  result = {}
46 
47  f = ROOT.TFile(file_name, 'READ')
48 
49  root = f.GetDirectory("DQMData")
50  if root == None: return (run_number, result)
51 
52  run = None
53  for key in root.GetListOfKeys():
54  if re.match("^Run [0-9]+$", key.ReadObj().GetName()) and key.IsFolder():
55  run_number = int(re.sub("^Run ", "", key.ReadObj().GetName()))
56  run = key.ReadObj()
57  break
58 
59  if run == None: return (run_number, result)
60 
61  for sub in run.GetListOfKeys():
62 
63  sub_name = sub.ReadObj().GetName()
64  if sub_name not in SUBSYSTEMS: continue
65 
66  sub_key = sub_name
67  if translate:
68  sub_key = SUBSYSTEMS[sub_name]
69 
70  if filters != None:
71  if not re.match(filters[0], sub_key):
72  continue
73 
74  if sub_key not in result:
75  result[sub_key] = {}
76 
77  evInfo = sub.ReadObj().GetDirectory("Run summary/EventInfo")
78  if evInfo == None: continue
79 
80  for folder_name in FOLDERS.keys():
81 
82  folder = evInfo.GetDirectory(folder_name)
83  if folder == None: continue
84 
85  folder_id = folder_name
86  if translate:
87  folder_id = FOLDERS[folder_name][0]
88 
89  if filters != None:
90  if not re.match(filters[1], folder_id):
91  continue
92 
93  if folder_id not in result[sub_key]:
94  result[sub_key][folder_id] = {}
95 
96  value_filter = None
97  if filters != None:
98  value_filter = filters[2]
99 
100  writeValues(folder, result[sub_key][folder_id], None, value_filter)
101  writeValues(evInfo, result[sub_key][folder_id], {FOLDERS[folder_name][1]: 'Summary'}, value_filter)
102 
103  f.Close()
104 
105  return (run_number, result)
106 
def writeValues(folder, map, keymap=None, filter=None)
def getSummaryValues(file_name, translate, filters=None)
def contentValuesLib.writeValues (   folder,
  map,
  keymap = None,
  filter = None 
)
Write values (possibly only for the keys in the keymap and filtered) from folder to map 

Definition at line 107 of file contentValuesLib.py.

References objects.autophobj.float.

Referenced by getSummaryValues().

107 def writeValues(folder, map, keymap = None, filter = None):
108  """ Write values (possibly only for the keys in the keymap and filtered) from folder to map """
109  for value in folder.GetListOfKeys():
110  full_name = value.ReadObj().GetName()
111  if not value.IsFolder() and re.match("^<.+>f=-{,1}[0-9\.]+</.+>$", full_name):
112  value_name = re.sub("<(?P<n>[^>]+)>.+", "\g<n>", full_name)
113  value_numb = float(re.sub("<.+>f=(?P<n>-{,1}[0-9\.]+)</.+>", "\g<n>", full_name))
114  if keymap == None or value_name in keymap:
115  if not keymap == None:
116  if not keymap[value_name] == None:
117  value_name = keymap[value_name]
118  if filter == None or re.match(filter, value_name):
119  if value_name not in map:
120  map[value_name] = value_numb
121 
def writeValues(folder, map, keymap=None, filter=None)