File indexing completed on 2024-11-26 02:34:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 from sys import argv,exit
0013 from optparse import OptionParser
0014 import cPickle
0015 import os
0016
0017
0018 dqm_server='https://cmsweb.cern.ch/dqm/relval'
0019
0020 cmssw_release1="CMSSW_5_3_0-START53_V4-v1"
0021 cmssw_release2="CMSSW_5_3_1-START53_V5-v1"
0022
0023 stat_test="Chi2"
0024 test_threshold=0.00001
0025
0026 sample = "RelValZMM"
0027
0028 run1="1"
0029 run2="1"
0030
0031 dir_name="00 Shift"
0032 outdir_name=""
0033
0034 do_pngs=False
0035
0036 compare=False
0037 report=False
0038
0039 black_list_str=""
0040
0041 tiers="DQM,DQM"
0042
0043
0044
0045 parser = OptionParser(usage="usage: %prog [options]")
0046
0047 parser.add_option("-1","--release1",
0048 action="store",
0049 dest="cmssw_release1",
0050 default=cmssw_release1,
0051 help="The main CMSSW release \n(default is %s)" %cmssw_release1)
0052
0053 parser.add_option("-2","--release2",
0054 action="store",
0055 dest="cmssw_release2",
0056 default=cmssw_release2,
0057 help="The CMSSW release for the regression \n(default is %s)" %cmssw_release2)
0058
0059 parser.add_option("-S","--sample",
0060 action="store",
0061 dest="sample",
0062 default=sample,
0063 help="The Sample upon which you want to run \n(default is %s)" %sample)
0064
0065 parser.add_option("-o","--outdir_name",
0066 action="store",
0067 dest="outdir_name",
0068 default=outdir_name,
0069 help="The directory where the output will be stored \n(default is %s)" %outdir_name)
0070
0071 parser.add_option("-D","--dqm_server",
0072 action="store",
0073 dest="dqm_server",
0074 default=dqm_server,
0075 help="The DQM server \n(default is %s)" %dqm_server)
0076
0077 parser.add_option("-a","--run1 ",
0078 action="store",
0079 dest="run1",
0080 default=run1,
0081 help="The run of the first sample to be checked \n(default is %s)" %run1)
0082
0083 parser.add_option("-b","--run2",
0084 action="store",
0085 dest="run2",
0086 default=run2,
0087 help="The run of the second sample to be checked \n(default is %s)" %run2)
0088
0089 parser.add_option("-d","--dir_name",
0090 action="store",
0091 dest="dir_name",
0092 default=dir_name,
0093 help="The 'directory' to be checked in the DQM \n(default is %s)" %dir_name)
0094
0095 parser.add_option("-p","--do_pngs",
0096 action="store_true",
0097 dest="do_pngs",
0098 default=False,
0099 help="EXPERIMENTAL!!! Do the pngs of the comparison (takes 50%% of the total running time) \n(default is %s)" %False)
0100
0101 parser.add_option("-P","--pickle",
0102 action="store",
0103 dest="pklfile",
0104 default="",
0105 help="Pkl file of the dir structure ")
0106 parser.add_option("-t","--test_threshold",
0107 action="store",
0108 dest="test_threshold",
0109 default=test_threshold,
0110 help="Threshold for the statistical test \n(default is %s)" %test_threshold)
0111
0112 parser.add_option("-s","--stat_test",
0113 action="store",
0114 dest="stat_test",
0115 default=stat_test,
0116 help="Statistical test (KS or Chi2) \n(default is %s)" %stat_test)
0117
0118 parser.add_option("-C","--compare",
0119 action="store_true",
0120 dest="compare",
0121 default=compare,
0122 help="Make the comparison \n(default is %s)" %compare)
0123
0124 parser.add_option("-R","--Report",
0125 action="store_true",
0126 dest="report",
0127 default=report,
0128 help="Make the html report \n(default is %s)" %report)
0129
0130 parser.add_option("-T","--Tiers",
0131 action="store",
0132 dest="tiers",
0133 default=tiers,
0134 help="Data tiers (comma separated list) \n(default is %s)" %tiers)
0135
0136 parser.add_option("-B","--black_list",
0137 action="store",
0138 dest="black_list",
0139 default=black_list_str,
0140 help="Blacklist elements. form is name@hierarchy_level (i.e. HLT@1) \n(default is %s)" %black_list_str)
0141
0142 (options, args) = parser.parse_args()
0143
0144
0145 original_pickle_name=""
0146 if options.compare:
0147
0148 if "RELMON_SA" in os.environ:
0149 from dqm_interfaces import DirID,DQMcommunicator,DirWalkerDB
0150 from dirstructure import Directory
0151 else:
0152 from Utilities.RelMon.dqm_interfaces import DirID,DQMcommunicator,DirWalkerDB
0153 from Utilities.RelMon.dirstructure import Directory
0154
0155
0156
0157 fulldirname=options.outdir_name
0158 if len(fulldirname)==0:
0159 fulldirname=options.dir_name
0160 if len(fulldirname)==0:
0161 fulldirname="%s_%s_%s" %(sample1,cmssw_release1,cmssw_release2)
0162
0163
0164 black_list=[]
0165 black_list_str=options.black_list
0166 if len(black_list_str)>0:
0167 for ele in black_list_str.split(","):
0168 dirname,level=ele.split("@")
0169 level=int(level)
0170 black_list.append(DirID(dirname,level))
0171
0172 db_base_url="/data/json/archive/"
0173 base1="%s/%s/%s/%s/DQM/" %(db_base_url,options.run1,options.sample,options.cmssw_release1)
0174 base2="%s/%s/%s/%s/DQM/" %(db_base_url,options.run2,options.sample,options.cmssw_release2)
0175
0176
0177 print("Analysing Histograms located in directory %s at: " %options.dir_name)
0178 for base in base1,base2:
0179 print(" o %s (server= %s)" %(base,options.dqm_server))
0180
0181
0182 comm1 = DQMcommunicator(server=options.dqm_server)
0183 comm2 = DQMcommunicator(server=options.dqm_server)
0184
0185
0186 directory=Directory(options.dir_name)
0187 dirwalker=DirWalkerDB(comm1,comm2,base1,base2,directory)
0188
0189
0190 dirwalker.do_pngs=options.do_pngs
0191
0192
0193 dirwalker.stat_test=options.stat_test
0194 dirwalker.test_threshold=options.test_threshold
0195
0196
0197 if len(black_list)>0:
0198 print("We have a Blacklist:")
0199 for dirid in black_list:
0200 print(" o %s" %dirid)
0201 dirwalker.black_list=black_list
0202
0203
0204 if not os.path.exists(options.outdir_name) and len(options.outdir_name )>0:
0205 os.mkdir(options.outdir_name)
0206 if len(options.outdir_name)>0:
0207 os.chdir(options.outdir_name)
0208
0209
0210 dirwalker.start()
0211
0212 dirwalker.join()
0213
0214
0215 directory=dirwalker.directory
0216
0217
0218 directory.meta.sample=options.sample
0219 directory.meta.run1=options.run1
0220 directory.meta.run2=options.run2
0221 directory.meta.release1=options.cmssw_release1
0222 directory.meta.release2=options.cmssw_release2
0223
0224 directory.meta.tier1,directory.meta.tier2 = options.tiers.split(",")
0225
0226
0227 directory.print_report()
0228
0229
0230 original_pickle_name="%s.pkl" %fulldirname
0231 print("Pickleing the directory as %s in dir %s" %(original_pickle_name,os.getcwd()))
0232 output = open(original_pickle_name,"w")
0233 cPickle.dump(directory, output, -1)
0234 output.close()
0235
0236
0237 if options.report:
0238 if "RELMON_SA" in os.environ:
0239 from directories2html import directory2html
0240 from dirstructure import Directory
0241 else:
0242 from Utilities.RelMon.directories2html import directory2html
0243 from Utilities.RelMon.dirstructure import Directory
0244
0245 pickle_name=options.pklfile
0246 if len(options.pklfile)==0:
0247 pickle_name=original_pickle_name
0248
0249 print("Reading directory from %s" %(pickle_name))
0250 ifile=open(pickle_name,"rb")
0251 directory=cPickle.load(ifile)
0252 ifile.close()
0253
0254 if os.path.exists(options.outdir_name) and len(directory.name)==0:
0255 os.chdir(options.outdir_name)
0256
0257
0258 print("Calculating stats for the directory...")
0259 directory.calcStats()
0260
0261 print("Producing html...")
0262 directory2html(directory)
0263
0264 if not (options.report or options.compare):
0265 print("Neither comparison nor report to be executed. A typo?")
0266