Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:18:51

0001 #!/usr/bin/env python
0002 
0003 from __future__ import print_function
0004 import sys, os, urllib
0005 
0006 
0007 base_url = "https://cmsweb.cern.ch/dqm/offline/start"
0008 
0009 # maps from type to subdirectory
0010 
0011 
0012 knownDatasets = {
0013     "photonJet" : { "dqmdir" : "Photon Summary" },
0014     
0015     "zee" : { "dqmdir" : "Zee Preselection", },
0016 
0017     "wen" : { "dqmdir" : "Wenu Preselection" },
0018 } 
0019 
0020 #----------------------------------------------------------------------
0021 
0022 def fixDataSetTier(dataset):
0023     """ makes sure that the data tier of the given data set is
0024     GEN-SIM-RECO (which is what seems to be used in DQM).
0025 
0026     Also supports datasets without any data tier.
0027     """
0028 
0029     if dataset.startswith('/'):
0030         dataset = dataset[1:]
0031 
0032     if dataset.endswith('/'):
0033         dataset = dataset[:-1]
0034     
0035     parts = dataset.split("/")
0036 
0037     if len(parts) < 2 or len(parts) > 3:
0038         raise Exception("expected at two or three parts (found " + str(len(parts)) + ") separated by '/' for dataset '" + dataset +"'")
0039 
0040     if len(parts) == 2:
0041         # data tier missing
0042         parts.append("GEN-SIM-RECO")
0043     else:
0044         # replace the last part
0045         parts[-1] = "GEN-SIM-RECO"
0046 
0047     return "/" + "/".join(parts)
0048 
0049 
0050 #----------------------------------------------------------------------
0051 # main
0052 #----------------------------------------------------------------------
0053 from optparse import OptionParser
0054 
0055 parser = OptionParser("""
0056 
0057   usage: %prog [options] reference_dataset [ new_dataset ]
0058 
0059 
0060   If only one dataset is given, links to the corresponding relval
0061   plots in the offline DQM are printed.
0062 
0063   If two datasets are given, links to overlay plots are printed.
0064 
0065   Note that the datasets used in DQM seem to have the data tier
0066   (third part) GEN-SIM-RECO. This program will replace any
0067   existing data tier by this value. You may also specify
0068   a dataset without data tier (e.g. /RelValWE/CMSSW_3_8_0-START38_V7-v1 )
0069   and this program will append the required data tier.
0070 
0071 """)
0072 
0073 (options, ARGV) = parser.parse_args()
0074 
0075 if len(ARGV) < 1 or len(ARGV) > 2:
0076     parser.print_help()
0077     sys.exit(1)
0078 
0079 
0080 ref_dataset = fixDataSetTier(ARGV.pop(0))
0081 
0082 if len(ARGV) > 0:
0083     new_dataset = fixDataSetTier(ARGV.pop(0))
0084 else:
0085     new_dataset = None
0086 
0087 # example from another validation report:
0088 # https://cmsweb.cern.ch/dqm/offline/start?workspace=HLT;root=HLT/HLTJETMET/ValidationReport;size=L;runnr=0;dataset=/RelValTTbar/CMSSW_3_8_0-MC_38Y_V7-v1/GEN-SIM-RECO;referenceshow=all;referencepos=overlay;referenceobj1=other::/RelValTTbar/CMSSW_3_8_0_pre8-MC_38Y_V6-v1/GEN-SIM-RECO
0089 
0090 # there seems not to be a standard URL encoding scheme used here...
0091 
0092 for analysisType in knownDatasets.keys():
0093 
0094     dqmdir = knownDatasets[analysisType]['dqmdir']
0095 
0096     parameters = {
0097         "workspace":      "HLT",
0098         "root":           "HLT/HLTEgammaValidation/" + dqmdir,
0099         "size":           "L",
0100         "runnr":          0,
0101         "dataset":        ref_dataset,
0102         "referenceshow":  "all",
0103         "referencepos":   "overlay",
0104         }
0105 
0106     if new_dataset != None:
0107         parameters["referenceobj1"] = "other::" + new_dataset
0108 
0109 
0110     print("analysis: " + analysisType)
0111     print()
0112     print("          " + base_url + "?" + ";".join([ x + "=" + urllib.quote(str(parameters[x])) for x in parameters.keys() ]))
0113 
0114     print()
0115     print()
0116