test
CMS 3D CMS Logo

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

Functions

def checkFilter
 
def getDatasetName
 
def getSummaryValues
 
def writeValues
 

Variables

dictionary FOLDERS
 
string ONLINE_DATASET = '/Global/Online/ALL'
 
string SERVER_URL = "http://pccmsdqm04.cern.ch/runregistry/xmlrpc"
 
dictionary SUBSYSTEMS
 

Function Documentation

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

Definition at line 122 of file contentValuesLib.py.

123 def checkFilter(raw_filter):
124  """ Check if filter is OK """
125  if raw_filter != None:
126  try:
127  filter = eval(raw_filter)
128  if type("") != type(filter[0]) or type("") != type(filter[1]) or type("") != type(filter[2]):
129  raise TypeError('')
130  except:
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."
132  sys.exit(2)
133  else:
134  filter = ('.*', '.*', '.*')
135  return filter
def contentValuesLib.getDatasetName (   file_name)
Method to get dataset name from the file name

Definition at line 30 of file contentValuesLib.py.

References watchdog.group.

30 
31 def getDatasetName(file_name):
32  """ Method to get dataset name from the file name"""
33  d = None
34  try:
35  d = re.search("(__[a-zA-Z0-9-_]+)+", file_name).group(0)
36  d = re.sub("__", "/", d)
37  except:
38  d = None
39  return d
tuple group
Definition: watchdog.py:82
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 writeValues().

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

Referenced by getSummaryValues().

108 def writeValues(folder, map, keymap = None, filter = None):
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

Variable Documentation

dictionary contentValuesLib.FOLDERS
Initial value:
1 = {
2  'reportSummaryContents': ( 'DQM', 'reportSummary' ),
3  'CertificationContents': ( 'CERT', 'CertificationSummary' ),
4  'DAQContents': ( 'DAQ', 'DAQSummary' ),
5  'DCSContents': ( 'DCS', 'DCSSummary' )
6 }

Definition at line 9 of file contentValuesLib.py.

string contentValuesLib.ONLINE_DATASET = '/Global/Online/ALL'

Definition at line 6 of file contentValuesLib.py.

string contentValuesLib.SERVER_URL = "http://pccmsdqm04.cern.ch/runregistry/xmlrpc"

Definition at line 4 of file contentValuesLib.py.

dictionary contentValuesLib.SUBSYSTEMS
Initial value:
1 = {
2  'CSC' : 'CSC',
3  'DT' : 'DT',
4  'ES' : 'ES',
5  'EcalBarrel' : 'ECAL',
6  'EcalEndcap' : 'ECAL',
7  'Hcal' : 'HCAL',
8  'L1T' : 'L1T',
9  'L1TEMU' : 'L1T',
10  'Pixel' : 'PIX',
11  'RPC' : 'RPC',
12  'SiStrip' : 'STRIP'
13 }

Definition at line 16 of file contentValuesLib.py.