1 import sys, os, optparse, re, json
4 SERVER_URL =
"http://pccmsdqm04.cern.ch/runregistry/xmlrpc" 6 ONLINE_DATASET =
'/Global/Online/ALL' 10 'reportSummaryContents': (
'DQM',
'reportSummary' ),
11 'CertificationContents': (
'CERT',
'CertificationSummary' ),
12 'DAQContents': (
'DAQ',
'DAQSummary' ),
13 'DCSContents': (
'DCS',
'DCSSummary' )
20 'EcalBarrel' :
'ECAL',
21 'EcalEndcap' :
'ECAL',
31 """ Method to get dataset name from the file name""" 34 d = re.search(
"(__[a-zA-Z0-9-_]+)+", file_name).
group(0)
35 d = re.sub(
"__",
"/", d)
41 """ Method to extract keys from root file and return dict """ 47 f = ROOT.TFile(file_name,
'READ')
49 root = f.GetDirectory(
"DQMData")
50 if root ==
None:
return (run_number, result)
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()))
59 if run ==
None:
return (run_number, result)
61 for sub
in run.GetListOfKeys():
63 sub_name = sub.ReadObj().GetName()
64 if sub_name
not in SUBSYSTEMS:
continue 68 sub_key = SUBSYSTEMS[sub_name]
71 if not re.match(filters[0], sub_key):
74 if sub_key
not in result:
77 evInfo = sub.ReadObj().GetDirectory(
"Run summary/EventInfo")
78 if evInfo ==
None:
continue 80 for folder_name
in FOLDERS.keys():
82 folder = evInfo.GetDirectory(folder_name)
83 if folder ==
None:
continue 85 folder_id = folder_name
87 folder_id = FOLDERS[folder_name][0]
90 if not re.match(filters[1], folder_id):
93 if folder_id
not in result[sub_key]:
94 result[sub_key][folder_id] = {}
98 value_filter = filters[2]
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)
105 return (run_number, result)
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
123 """ Check if filter is OK """ 124 if raw_filter !=
None:
126 filter = eval(raw_filter)
127 if type(
"") != type(filter[0])
or type(
"") != type(filter[1])
or type(
"") != type(filter[2]):
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." 133 filter = (
'.*',
'.*',
'.*')
def getDatasetName(file_name)
def writeValues(folder, map, keymap=None, filter=None)
def getSummaryValues(file_name, translate, filters=None)
def checkFilter(raw_filter)