12 from sys
import argv,exit
13 from optparse
import OptionParser
18 dqm_server=
'https://cmsweb.cern.ch/dqm/relval'
20 cmssw_release1=
"CMSSW_5_3_0-START53_V4-v1"
21 cmssw_release2=
"CMSSW_5_3_1-START53_V5-v1"
24 test_threshold=0.00001
45 parser = OptionParser(usage=
"usage: %prog [options]")
47 parser.add_option(
"-1",
"--release1",
49 dest=
"cmssw_release1",
50 default=cmssw_release1,
51 help=
"The main CMSSW release \n(default is %s)" %cmssw_release1)
53 parser.add_option(
"-2",
"--release2",
55 dest=
"cmssw_release2",
56 default=cmssw_release2,
57 help=
"The CMSSW release for the regression \n(default is %s)" %cmssw_release2)
59 parser.add_option(
"-S",
"--sample",
63 help=
"The Sample upon which you want to run \n(default is %s)" %sample)
65 parser.add_option(
"-o",
"--outdir_name",
69 help=
"The directory where the output will be stored \n(default is %s)" %outdir_name)
71 parser.add_option(
"-D",
"--dqm_server",
75 help=
"The DQM server \n(default is %s)" %dqm_server)
77 parser.add_option(
"-a",
"--run1 ",
81 help=
"The run of the first sample to be checked \n(default is %s)" %run1)
83 parser.add_option(
"-b",
"--run2",
87 help=
"The run of the second sample to be checked \n(default is %s)" %run2)
89 parser.add_option(
"-d",
"--dir_name",
93 help=
"The 'directory' to be checked in the DQM \n(default is %s)" %dir_name)
95 parser.add_option(
"-p",
"--do_pngs",
99 help=
"EXPERIMENTAL!!! Do the pngs of the comparison (takes 50%% of the total running time) \n(default is %s)" %
False)
101 parser.add_option(
"-P",
"--pickle",
105 help=
"Pkl file of the dir structure ")
106 parser.add_option(
"-t",
"--test_threshold",
108 dest=
"test_threshold",
109 default=test_threshold,
110 help=
"Threshold for the statistical test \n(default is %s)" %test_threshold)
112 parser.add_option(
"-s",
"--stat_test",
116 help=
"Statistical test (KS or Chi2) \n(default is %s)" %stat_test)
118 parser.add_option(
"-C",
"--compare",
122 help=
"Make the comparison \n(default is %s)" %compare)
124 parser.add_option(
"-R",
"--Report",
128 help=
"Make the html report \n(default is %s)" %report)
130 parser.add_option(
"-T",
"--Tiers",
134 help=
"Data tiers (comma separated list) \n(default is %s)" %tiers)
136 parser.add_option(
"-B",
"--black_list",
139 default=black_list_str,
140 help=
"Blacklist elements. form is name@hierarchy_level (i.e. HLT@1) \n(default is %s)" %black_list_str)
142 (options, args) = parser.parse_args()
145 original_pickle_name=
""
148 if "RELMON_SA" in os.environ:
149 from dqm_interfaces
import DirID,DQMcommunicator,DirWalkerDB
150 from dirstructure
import Directory
152 from Utilities.RelMon.dqm_interfaces
import DirID,DQMcommunicator,DirWalkerDB
153 from Utilities.RelMon.dirstructure
import Directory
157 fulldirname=options.outdir_name
158 if len(fulldirname)==0:
159 fulldirname=options.dir_name
160 if len(fulldirname)==0:
161 fulldirname=
"%s_%s_%s" %(sample1,cmssw_release1,cmssw_release2)
165 black_list_str=options.black_list
166 if len(black_list_str)>0:
167 for ele
in black_list_str.split(
","):
168 dirname,level=ele.split(
"@")
170 black_list.append(
DirID(dirname,level))
172 db_base_url=
"/data/json/archive/"
173 base1=
"%s/%s/%s/%s/DQM/" %(db_base_url,options.run1,options.sample,options.cmssw_release1)
174 base2=
"%s/%s/%s/%s/DQM/" %(db_base_url,options.run2,options.sample,options.cmssw_release2)
177 print "Analysing Histograms located in directory %s at: " %options.dir_name
178 for base
in base1,base2:
179 print " o %s (server= %s)" %(base,options.dqm_server)
190 dirwalker.do_pngs=options.do_pngs
193 dirwalker.stat_test=options.stat_test
194 dirwalker.test_threshold=options.test_threshold
197 if len(black_list)>0:
198 print "We have a Blacklist:"
199 for dirid
in black_list:
201 dirwalker.black_list=black_list
204 if not os.path.exists(options.outdir_name)
and len(options.outdir_name )>0:
205 os.mkdir(options.outdir_name)
206 if len(options.outdir_name)>0:
207 os.chdir(options.outdir_name)
215 directory=dirwalker.directory
218 directory.meta.sample=options.sample
219 directory.meta.run1=options.run1
220 directory.meta.run2=options.run2
221 directory.meta.release1=options.cmssw_release1
222 directory.meta.release2=options.cmssw_release2
224 directory.meta.tier1,directory.meta.tier2 = options.tiers.split(
",")
227 directory.print_report()
230 original_pickle_name=
"%s.pkl" %fulldirname
231 print "Pickleing the directory as %s in dir %s" %(original_pickle_name,os.getcwd())
232 output = open(original_pickle_name,
"w")
233 cPickle.dump(directory, output, -1)
238 if "RELMON_SA" in os.environ:
239 from directories2html
import directory2html
240 from dirstructure
import Directory
242 from Utilities.RelMon.directories2html
import directory2html
243 from Utilities.RelMon.dirstructure
import Directory
245 pickle_name=options.pklfile
246 if len(options.pklfile)==0:
247 pickle_name=original_pickle_name
249 print "Reading directory from %s" %(pickle_name)
250 ifile=open(pickle_name,
"rb")
251 directory=cPickle.load(ifile)
254 if os.path.exists(options.outdir_name)
and len(directory.name)==0:
255 os.chdir(options.outdir_name)
258 print "Calculating stats for the directory..."
259 directory.calcStats()
261 print "Producing html..."
264 if not (options.report
or options.compare):
265 print "Neither comparison nor report to be executed. A typo?"