CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes
dqm_interfaces.DQMcommunicator Class Reference
Inheritance diagram for dqm_interfaces.DQMcommunicator:

Public Member Functions

def __init__
 
def cd
 
def get_common_runs
 
def get_data
 
def get_dataset_runs
 
def get_datasets_list
 
def get_RelVal_CMSSW_versions
 
def get_root_objects
 
def get_root_objects_list
 
def get_root_objects_list_recursive
 
def get_root_objects_names_list_recursive
 
def get_root_objects_recursive
 
def get_runs_list
 
def get_samples
 
def ls
 
def ls_url
 
def open_url
 

Public Attributes

 DQMpwd
 
 ident
 
 is_private
 
 oldDQMpwd
 
 opener
 
 prevDQMpwd
 
 server
 

Static Public Attributes

string base_dir = '/data/json/archive/'
 

Detailed Description

Communicate with the DQM Document server

Definition at line 52 of file dqm_interfaces.py.

Constructor & Destructor Documentation

def dqm_interfaces.DQMcommunicator.__init__ (   self,
  server,
  is_private = False,
  ident = "DQMToJson/1.0 python/%d.%d.%d" % version_info[:3] 
)

Definition at line 63 of file dqm_interfaces.py.

63 
64  ident="DQMToJson/1.0 python/%d.%d.%d" % version_info[:3]):
65  self.ident = ident
66  self.server = server
67  self.is_private = is_private
68  self.DQMpwd=DQMcommunicator.base_dir
69  self.prevDQMpwd=self.DQMpwd
70  self.opener=None
71  if not self.is_private:
self.opener=build_opener(X509CertOpen())

Member Function Documentation

def dqm_interfaces.DQMcommunicator.cd (   self,
  args 
)

Definition at line 156 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.oldDQMpwd, and dqm_interfaces.DQMcommunicator.server.

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), and dqm_interfaces.DirWalkerFile.walk().

157  def cd(self, *args):
158  len_args=len(args)
159  full_url=""
160  if len_args!=1 and len_args!=3:
161  raise(InvalidNumberOfArguments("3 or 1 args expected!"))
162  if len_args==3:
163  dataset, run, folder = args
164  full_url='%s/data/json/archive/%s/%s/%s' % (self.server, dataset, run, folder)
165  if len_args==1:
166  folder=args[0]
167  if folder==self.DQMpwd:
168  full_url=self.DQMpwd
169  elif folder=="..":
170  full_url=self.DQMpwd[:self.DQMpwd.rfind("/")]
171  elif folder=="-":
172  full_url=self.oldDQMpwd
173  elif folder=="":
174  full_url=DQMcommunicator.base_dir
175  else:
176  full_url=self.DQMpwd+"/"+folder
177 
178  full_url=full_url.replace(' ','%20')
179  #print "cd: "+full_url
180 
181  self.oldDQMpwd=self.DQMpwd
182  self.DQMpwd=full_url
183  #print "In %s" %self.DQMpwd
def dqm_interfaces.DQMcommunicator.get_common_runs (   self,
  dataset_string1,
  dataset_string2 
)

Definition at line 239 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_runs_list().

240  def get_common_runs(self,dataset_string1,dataset_string2):
241  set1=set(self.get_runs_list(dataset_string1))
242  set2=set(self.get_runs_list(dataset_string2))
243  set1.intersection_update(set2)
244  return list (set2)
def dqm_interfaces.DQMcommunicator.get_data (   self,
  full_url 
)

Definition at line 89 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.open_url(), and SiPixelLorentzAngle_cfi.read.

Referenced by dqm_interfaces.DQMcommunicator.get_samples(), and dqm_interfaces.DQMcommunicator.ls_url().

89 
90  def get_data(self, full_url):
91  #print "getting data from %s" %full_url
92  data = self.open_url(full_url).read()
93 
94  data = sub("-inf", '0', data)
95  data = sub("\s+inf", '0', data)
96  data = sub("\s+nan", '0', data)
97  data = sub('""(CMSSW.*?)""', '"\\1"', data)
98 
99  return data
def dqm_interfaces.DQMcommunicator.get_dataset_runs (   self,
  dataset_string 
)

Definition at line 231 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_datasets_list(), and dqm_interfaces.DQMcommunicator.get_runs_list().

232  def get_dataset_runs(self,dataset_string):
233  dataset_runs={}
234  for dataset in self.get_datasets_list(dataset_string):
235  dataset_runs[dataset]=self.get_runs_list(dataset)
236  return dataset_runs
def dqm_interfaces.DQMcommunicator.get_datasets_list (   self,
  dataset_string = "" 
)

Definition at line 197 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_samples(), and python.multivaluedict.map().

Referenced by dqm_interfaces.DQMcommunicator.get_dataset_runs(), and dqm_interfaces.DQMcommunicator.get_RelVal_CMSSW_versions().

198  def get_datasets_list(self, dataset_string=""):
199  samples_list=self.get_samples(dataset_string)
200  datasets_list=[]
201  for sample in samples_list:
202  temp_datasets_list = map(lambda item:item["dataset"] ,sample['items'])
203  for temp_dataset in temp_datasets_list:
204  if not temp_dataset in datasets_list:
205  datasets_list.append(temp_dataset)
206  return datasets_list
def dqm_interfaces.DQMcommunicator.get_RelVal_CMSSW_versions (   self,
  query 
)
Get the available cmssw versions for the relvals.

Definition at line 209 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_datasets_list(), and list().

210  def get_RelVal_CMSSW_versions(self,query):
211  """Get the available cmssw versions for the relvals.
212  """
213  relvals_list=self.get_datasets_list(query)
214  # The samples are of the form /RelValTHISISMYFAVOURITECHANNEL/CMSSW_VERSION/GEN-SIM-WHATEVER-RECO
215  cmssw_versions_with_duplicates=map (lambda x: x.split("/")[2],relvals_list)
216  return list(set(cmssw_versions_with_duplicates))
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def dqm_interfaces.DQMcommunicator.get_root_objects (   self,
  url = "" 
)

Definition at line 261 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.DQMpwd, ROOTData.literal2root(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, dqm_interfaces.DQMcommunicator.ls(), EcalDeadCellTriggerPrimitiveFilter.ls, and dqm_interfaces.DQMcommunicator.server.

262  def get_root_objects(self, url=""):
263  if len(url)==0:
264  url=self.DQMpwd
265  else:
266  url=self.server+"/"+url
267  url = url.replace(" ","%20")
268  objects={}
269  for name,description in self.ls(url,True).items():
270  if "dir" not in description["type"] and "ROOT" in description["kind"]:
271  objects[name]=literal2root(description["obj_as_string"],description["type"])
272  return objects
def literal2root
Definition: ROOTData.py:52
def dqm_interfaces.DQMcommunicator.get_root_objects_list (   self,
  url = "" 
)

Definition at line 247 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.DQMpwd, ROOTData.literal2root(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, dqm_interfaces.DQMcommunicator.ls(), and EcalDeadCellTriggerPrimitiveFilter.ls.

248  def get_root_objects_list(self, url=""):
249  if len(url)==0:
250  url=self.DQMpwd
251  else:
252  url="/"+url
253  url = url.replace(" ","%20")
254  objects=[]
255  for name,description in self.ls(url,True).items():
256  if "dir" not in description["type"] and "ROOT" in description["kind"]:
257  objects.append(literal2root(description["obj_as_string"],description["type"]))
258  return objects
def literal2root
Definition: ROOTData.py:52
def dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive (   self,
  url = "" 
)

Definition at line 275 of file dqm_interfaces.py.

References TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), DQMStore::IBooker.cd(), DQMStore::IGetter.cd(), DQMStore.cd(), python.rootplot.utilities.RootFile.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), ROOTData.literal2root(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, dqm_interfaces.DQMcommunicator.ls(), and EcalDeadCellTriggerPrimitiveFilter.ls.

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive().

276  def get_root_objects_list_recursive(self, url=""):
277  null_url = (len(url)==0)
278  if len(url)==0:
279  url=self.DQMpwd
280  else:
281  url="/"+url
282  url = url.replace(" ","%20")
283  if not null_url:
284  self.cd(url)
285  objects=[]
286  for name,description in self.ls("",True).items():
287  if "dir" in description["type"]:
288  objects+=self.get_root_objects_list_recursive(name)
289  self.cd("..")
290  elif "ROOT" in description["kind"]:
291  objects.append(literal2root(description["obj_as_string"],description["type"]))
292  if not null_url:
293  self.cd("..")
294  return objects
def literal2root
Definition: ROOTData.py:52
def dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive (   self,
  url = "",
  present_url = "" 
)

Definition at line 297 of file dqm_interfaces.py.

References TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), DQMStore::IBooker.cd(), DQMStore::IGetter.cd(), DQMStore.cd(), python.rootplot.utilities.RootFile.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, dqm_interfaces.DQMcommunicator.ls(), and EcalDeadCellTriggerPrimitiveFilter.ls.

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive().

298  def get_root_objects_names_list_recursive(self, url="",present_url=""):
299  null_url = (len(url)==0)
300  if (not null_url):
301  if len(present_url)==0:
302  present_url=url
303  else:
304  present_url+="_%s"%url
305  if len(url)==0:
306  url=self.DQMpwd
307  else:
308  url="/"+url
309  url = url.replace(" ","%20")
310  if not null_url:
311  self.cd(url)
312  objects_names=[]
313  for name,description in self.ls("",False).items():
314  if "dir" in description["type"]:
315  objects_names+=self.get_root_objects_names_list_recursive(name,present_url)
316  self.cd("..")
317  elif "ROOT" in description["kind"]:
318  objects_names.append("%s_%s"%(present_url,name))
319  if not null_url:
320  self.cd("..")
321  return objects_names
def dqm_interfaces.DQMcommunicator.get_root_objects_recursive (   self,
  url = "",
  present_url = "" 
)

Definition at line 324 of file dqm_interfaces.py.

References TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), DQMStore::IBooker.cd(), DQMStore::IGetter.cd(), DQMStore.cd(), python.rootplot.utilities.RootFile.cd(), dqm_interfaces.DQMcommunicator.DQMpwd, dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), ROOTData.literal2root(), ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, dqm_interfaces.DQMcommunicator.ls(), and EcalDeadCellTriggerPrimitiveFilter.ls.

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects_recursive().

325  def get_root_objects_recursive(self, url="",present_url=""):
326  null_url = (len(url)==0)
327  if (not null_url):
328  if len(present_url)==0:
329  present_url=url
330  else:
331  present_url+="_%s"%url
332  if len(url)==0:
333  url=self.DQMpwd
334  else:
335  url="/"+url
336  url = url.replace(" ","%20")
337  #if not null_url:
338  self.cd(url)
339  objects={}
340  for name,description in self.ls("",True).items():
341  if "dir" in description["type"]:
342  objects.update(self.get_root_objects_recursive(name,present_url))
343  self.cd("..")
344  elif "ROOT" in description["kind"]:
345  objects["%s_%s"%(present_url,name)]=literal2root(description["obj_as_string"],description["type"])
346  #if not null_url:
347  self.cd("..")
348  return objects
349 
350 #-------------------------------------------------------------------------------
def literal2root
Definition: ROOTData.py:52
def dqm_interfaces.DQMcommunicator.get_runs_list (   self,
  dataset_string 
)

Definition at line 219 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_samples(), and python.multivaluedict.map().

Referenced by dqm_interfaces.DQMcommunicator.get_common_runs(), and dqm_interfaces.DQMcommunicator.get_dataset_runs().

220  def get_runs_list(self, dataset_string):
221  slash="/"
222  while(dataset_string.endswith(slash) or dataset_string.beginswith(slash)):
223  dataset_string=dataset_string.strip("/")
224  samples_list=self.get_samples(dataset_string)
225  runlist=[]
226  # Get all the runs in all the items which are in every sample
227  map( lambda sample: map (lambda item: runlist.append(item['run']), sample['items']), samples_list)
228  return runlist
def dqm_interfaces.DQMcommunicator.get_samples (   self,
  samples_string = "*" 
)
A sample contains, among the other things, a data type, a dataset name 
and a run.

Definition at line 186 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_data(), and dqm_interfaces.DQMcommunicator.server.

Referenced by dqm_interfaces.DQMcommunicator.get_datasets_list(), and dqm_interfaces.DQMcommunicator.get_runs_list().

187  def get_samples(self, samples_string="*"):
188  """
189  A sample contains, among the other things, a data type, a dataset name
190  and a run.
191  """
192  full_url='%s/data/json/samples?match=%s' % (self.server, samples_string)
193  samples_dict=eval(self.get_data(full_url))
194  return samples_dict["samples"]
def dqm_interfaces.DQMcommunicator.ls (   self,
  url = '',
  fetch_root = False 
)

Definition at line 142 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.DQMpwd, join(), and dqm_interfaces.DQMcommunicator.ls_url().

Referenced by dqm_interfaces.DQMcommunicator.get_root_objects(), dqm_interfaces.DQMcommunicator.get_root_objects_list(), dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), and dqm_interfaces.DirWalkerFile.walk().

143  def ls(self, url='', fetch_root=False):
144  if len(url)==0:
145  url=join(self.DQMpwd,url)
146 
147  form_folder={}
148 
149  if fetch_root:
150  url='%s?rootcontent=1'%url
151  form_folder=self.ls_url(url)
152 
153  return form_folder
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def dqm_interfaces.DQMcommunicator.ls_url (   self,
  url 
)

Definition at line 102 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.get_data(), and dqm_interfaces.DQMcommunicator.server.

Referenced by dqm_interfaces.DQMcommunicator.ls().

103  def ls_url(self, url):
104  url=url.replace(" ","%20")
105  url=self.server+url
106  #print "listing "+url
107  form_folder={}
108  raw_folder=None
109  try:
110  raw_folder=eval(self.get_data(url))
111  except:
112  print "Retrying.."
113  for ntrials in xrange(5):
114  try:
115  if ntrials!=0:
116  sleep(2)
117  #raw_folder=loads(self.get_data(url))
118  raw_folder=eval(self.get_data(url))
119  break
120  except:
121  print "Could not fetch %s. Retrying" %url
122 
123  #raw_folder=loads(self.get_data(url))
124  for content_dict in raw_folder["contents"]:
125  if content_dict.has_key("subdir"):
126  form_folder[content_dict["subdir"]]={"type":'dir'}
127  elif content_dict.has_key("obj"):
128  properties=content_dict["properties"]
129  obj_name=content_dict["obj"]
130  obj_type=properties["type"]
131  obj_kind=properties["kind"]
132  obj_as_string=''
133  if content_dict.has_key("rootobj"):
134  obj_as_string=content_dict["rootobj"]
135  form_folder[obj_name]={'type':obj_type,'obj_as_string':obj_as_string,"kind":obj_kind}
136  #for k,v in form_folder.items():
137  #print "* %s --> %s" %(k,v["type"])
138 
139  return form_folder
def dqm_interfaces.DQMcommunicator.open_url (   self,
  url 
)

Definition at line 74 of file dqm_interfaces.py.

References dqm_interfaces.DQMcommunicator.ident, and dqm_interfaces.DQMcommunicator.is_private.

Referenced by dqm_interfaces.DQMcommunicator.get_data().

74 
75  def open_url(self,url):
76  url=url.replace(' ','%20')
77  datareq = Request(url)
78  datareq.add_header('User-agent', self.ident)
79  url_obj=0
80  if not self.is_private:
81  url_obj=self.opener.open(datareq)
82  #url_obj=build_opener(X509CertOpen()).open(datareq)
83  else:
84  url_obj=urlopen(datareq)
85 
86  return url_obj

Member Data Documentation

string dqm_interfaces.DQMcommunicator.base_dir = '/data/json/archive/'
static

Definition at line 58 of file dqm_interfaces.py.

dqm_interfaces.DQMcommunicator.DQMpwd

Definition at line 67 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.cd(), dqm_interfaces.DQMcommunicator.get_root_objects(), dqm_interfaces.DQMcommunicator.get_root_objects_list(), dqm_interfaces.DQMcommunicator.get_root_objects_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_names_list_recursive(), dqm_interfaces.DQMcommunicator.get_root_objects_recursive(), and dqm_interfaces.DQMcommunicator.ls().

dqm_interfaces.DQMcommunicator.ident

Definition at line 64 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.open_url().

dqm_interfaces.DQMcommunicator.is_private

Definition at line 66 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.open_url().

dqm_interfaces.DQMcommunicator.oldDQMpwd

Definition at line 180 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.cd().

dqm_interfaces.DQMcommunicator.opener

Definition at line 69 of file dqm_interfaces.py.

dqm_interfaces.DQMcommunicator.prevDQMpwd

Definition at line 68 of file dqm_interfaces.py.

dqm_interfaces.DQMcommunicator.server

Definition at line 65 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DQMcommunicator.cd(), dqm_interfaces.DQMcommunicator.get_root_objects(), dqm_interfaces.DQMcommunicator.get_samples(), and dqm_interfaces.DQMcommunicator.ls_url().