CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 123 of file contentValuesLib.py.

References print().

124 def checkFilter(raw_filter):
125  """ Check if filter is OK """
126  if raw_filter != None:
127  try:
128  filter = eval(raw_filter)
129  if not isinstance("", type(filter[0])) or not isinstance("", type(filter[1])) or not isinstance("", type(filter[2])):
130  raise TypeError('')
131  except:
132  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  sys.exit(2)
134  else:
135  filter = ('.*', '.*', '.*')
136  return filter
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def contentValuesLib.getDatasetName (   file_name)
Method to get dataset name from the file name

Definition at line 31 of file contentValuesLib.py.

References watchdog.group.

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

References writeValues().

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

Referenced by getSummaryValues().

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

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

Definition at line 7 of file contentValuesLib.py.

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

Definition at line 5 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 17 of file contentValuesLib.py.