CMS 3D CMS Logo

Functions | Variables
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)
 

Variables

 FOLDERS
 
 ONLINE_DATASET
 
 SERVER_URL
 
 SUBSYSTEMS
 

Function Documentation

◆ checkFilter()

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

Definition at line 123 of file contentValuesLib.py.

References print().

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 not isinstance("", type(filter[0])) or not isinstance("", type(filter[1])) or not isinstance("", 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
136 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def checkFilter(raw_filter)

◆ getDatasetName()

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 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
40 
def getDatasetName(file_name)

◆ getSummaryValues()

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 createfilelist.int, and writeValues().

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)
107 
def writeValues(folder, map, keymap=None, filter=None)
def getSummaryValues(file_name, translate, filters=None)

◆ writeValues()

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.

References nano_mu_digi_cff.float.

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

Variable Documentation

◆ FOLDERS

contentValuesLib.FOLDERS

Definition at line 10 of file contentValuesLib.py.

◆ ONLINE_DATASET

contentValuesLib.ONLINE_DATASET

Definition at line 7 of file contentValuesLib.py.

◆ SERVER_URL

contentValuesLib.SERVER_URL

Definition at line 5 of file contentValuesLib.py.

◆ SUBSYSTEMS

contentValuesLib.SUBSYSTEMS

Definition at line 17 of file contentValuesLib.py.