1 from __future__
import print_function
2 import sys, os, optparse, re, json
5 SERVER_URL =
"http://pccmsdqm04.cern.ch/runregistry/xmlrpc" 7 ONLINE_DATASET =
'/Global/Online/ALL' 11 'reportSummaryContents': (
'DQM',
'reportSummary' ),
12 'CertificationContents': (
'CERT',
'CertificationSummary' ),
13 'DAQContents': (
'DAQ',
'DAQSummary' ),
14 'DCSContents': (
'DCS',
'DCSSummary' )
21 'EcalBarrel' :
'ECAL',
22 'EcalEndcap' :
'ECAL',
32 """ Method to get dataset name from the file name""" 35 d = re.search(
"(__[a-zA-Z0-9-_]+)+", file_name).
group(0)
36 d = re.sub(
"__",
"/", d)
42 """ Method to extract keys from root file and return dict """ 48 f = ROOT.TFile(file_name,
'READ')
50 root = f.GetDirectory(
"DQMData")
51 if root ==
None:
return (run_number, result)
54 for key
in root.GetListOfKeys():
55 if re.match(
"^Run [0-9]+$", key.ReadObj().GetName())
and key.IsFolder():
56 run_number =
int(re.sub(
"^Run ",
"", key.ReadObj().GetName()))
60 if run ==
None:
return (run_number, result)
62 for sub
in run.GetListOfKeys():
64 sub_name = sub.ReadObj().GetName()
65 if sub_name
not in SUBSYSTEMS:
continue 69 sub_key = SUBSYSTEMS[sub_name]
72 if not re.match(filters[0], sub_key):
75 if sub_key
not in result:
78 evInfo = sub.ReadObj().GetDirectory(
"Run summary/EventInfo")
79 if evInfo ==
None:
continue 81 for folder_name
in FOLDERS.keys():
83 folder = evInfo.GetDirectory(folder_name)
84 if folder ==
None:
continue 86 folder_id = folder_name
88 folder_id = FOLDERS[folder_name][0]
91 if not re.match(filters[1], folder_id):
94 if folder_id
not in result[sub_key]:
95 result[sub_key][folder_id] = {}
99 value_filter = filters[2]
101 writeValues(folder, result[sub_key][folder_id],
None, value_filter)
102 writeValues(evInfo, result[sub_key][folder_id], {FOLDERS[folder_name][1]:
'Summary'}, value_filter)
106 return (run_number, result)
109 """ Write values (possibly only for the keys in the keymap and filtered) from folder to map """ 110 for value
in folder.GetListOfKeys():
111 full_name = value.ReadObj().GetName()
112 if not value.IsFolder()
and re.match(
"^<.+>f=-{,1}[0-9\.]+</.+>$", full_name):
113 value_name = re.sub(
"<(?P<n>[^>]+)>.+",
"\g<n>", full_name)
114 value_numb =
float(re.sub(
"<.+>f=(?P<n>-{,1}[0-9\.]+)</.+>",
"\g<n>", full_name))
115 if keymap ==
None or value_name
in keymap:
116 if not keymap ==
None:
117 if not keymap[value_name] ==
None:
118 value_name = keymap[value_name]
119 if filter ==
None or re.match(filter, value_name):
120 if value_name
not in map:
121 map[value_name] = value_numb
124 """ Check if filter is OK """ 125 if raw_filter !=
None:
127 filter = eval(raw_filter)
128 if not isinstance(
"", type(filter[0]))
or not isinstance(
"", type(filter[1]))
or not isinstance(
"", type(filter[2])):
131 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.")
134 filter = (
'.*',
'.*',
'.*')
def getDatasetName(file_name)
S & print(S &os, JobReport::InputFile const &f)
def writeValues(folder, map, keymap=None, filter=None)
def getSummaryValues(file_name, translate, filters=None)
def checkFilter(raw_filter)