12 from __future__
import print_function
13 from sys
import argv,exit
14 from optparse
import OptionParser
19 dqm_server=
'https://cmsweb.cern.ch/dqm/relval' 21 cmssw_release1=
"CMSSW_5_3_0-START53_V4-v1" 22 cmssw_release2=
"CMSSW_5_3_1-START53_V5-v1" 25 test_threshold=0.00001
46 parser = OptionParser(usage=
"usage: %prog [options]")
48 parser.add_option(
"-1",
"--release1",
50 dest=
"cmssw_release1",
51 default=cmssw_release1,
52 help=
"The main CMSSW release \n(default is %s)" %cmssw_release1)
54 parser.add_option(
"-2",
"--release2",
56 dest=
"cmssw_release2",
57 default=cmssw_release2,
58 help=
"The CMSSW release for the regression \n(default is %s)" %cmssw_release2)
60 parser.add_option(
"-S",
"--sample",
64 help=
"The Sample upon which you want to run \n(default is %s)" %sample)
66 parser.add_option(
"-o",
"--outdir_name",
70 help=
"The directory where the output will be stored \n(default is %s)" %outdir_name)
72 parser.add_option(
"-D",
"--dqm_server",
76 help=
"The DQM server \n(default is %s)" %dqm_server)
78 parser.add_option(
"-a",
"--run1 ",
82 help=
"The run of the first sample to be checked \n(default is %s)" %run1)
84 parser.add_option(
"-b",
"--run2",
88 help=
"The run of the second sample to be checked \n(default is %s)" %run2)
90 parser.add_option(
"-d",
"--dir_name",
94 help=
"The 'directory' to be checked in the DQM \n(default is %s)" %dir_name)
96 parser.add_option(
"-p",
"--do_pngs",
100 help=
"EXPERIMENTAL!!! Do the pngs of the comparison (takes 50%% of the total running time) \n(default is %s)" %
False)
102 parser.add_option(
"-P",
"--pickle",
106 help=
"Pkl file of the dir structure ")
107 parser.add_option(
"-t",
"--test_threshold",
109 dest=
"test_threshold",
110 default=test_threshold,
111 help=
"Threshold for the statistical test \n(default is %s)" %test_threshold)
113 parser.add_option(
"-s",
"--stat_test",
117 help=
"Statistical test (KS or Chi2) \n(default is %s)" %stat_test)
119 parser.add_option(
"-C",
"--compare",
123 help=
"Make the comparison \n(default is %s)" %compare)
125 parser.add_option(
"-R",
"--Report",
129 help=
"Make the html report \n(default is %s)" %report)
131 parser.add_option(
"-T",
"--Tiers",
135 help=
"Data tiers (comma separated list) \n(default is %s)" %tiers)
137 parser.add_option(
"-B",
"--black_list",
140 default=black_list_str,
141 help=
"Blacklist elements. form is name@hierarchy_level (i.e. HLT@1) \n(default is %s)" %black_list_str)
143 (options, args) = parser.parse_args()
146 original_pickle_name=
"" 149 if "RELMON_SA" in os.environ:
150 from dqm_interfaces
import DirID,DQMcommunicator,DirWalkerDB
151 from dirstructure
import Directory
153 from Utilities.RelMon.dqm_interfaces
import DirID,DQMcommunicator,DirWalkerDB
154 from Utilities.RelMon.dirstructure
import Directory
158 fulldirname=options.outdir_name
159 if len(fulldirname)==0:
160 fulldirname=options.dir_name
161 if len(fulldirname)==0:
162 fulldirname=
"%s_%s_%s" %(sample1,cmssw_release1,cmssw_release2)
166 black_list_str=options.black_list
167 if len(black_list_str)>0:
168 for ele
in black_list_str.split(
","):
169 dirname,level=ele.split(
"@")
171 black_list.append(
DirID(dirname,level))
173 db_base_url=
"/data/json/archive/" 174 base1=
"%s/%s/%s/%s/DQM/" %(db_base_url,options.run1,options.sample,options.cmssw_release1)
175 base2=
"%s/%s/%s/%s/DQM/" %(db_base_url,options.run2,options.sample,options.cmssw_release2)
178 print(
"Analysing Histograms located in directory %s at: " %options.dir_name)
179 for base
in base1,base2:
180 print(
" o %s (server= %s)" %(base,options.dqm_server))
191 dirwalker.do_pngs=options.do_pngs
194 dirwalker.stat_test=options.stat_test
195 dirwalker.test_threshold=options.test_threshold
198 if len(black_list)>0:
199 print(
"We have a Blacklist:")
200 for dirid
in black_list:
201 print(
" o %s" %dirid)
202 dirwalker.black_list=black_list
205 if not os.path.exists(options.outdir_name)
and len(options.outdir_name )>0:
206 os.mkdir(options.outdir_name)
207 if len(options.outdir_name)>0:
208 os.chdir(options.outdir_name)
216 directory=dirwalker.directory
219 directory.meta.sample=options.sample
220 directory.meta.run1=options.run1
221 directory.meta.run2=options.run2
222 directory.meta.release1=options.cmssw_release1
223 directory.meta.release2=options.cmssw_release2
225 directory.meta.tier1,directory.meta.tier2 = options.tiers.split(
",")
228 directory.print_report()
231 original_pickle_name=
"%s.pkl" %fulldirname
232 print(
"Pickleing the directory as %s in dir %s" %(original_pickle_name,os.getcwd()))
233 output = open(original_pickle_name,
"w")
234 cPickle.dump(directory, output, -1)
239 if "RELMON_SA" in os.environ:
240 from directories2html
import directory2html
241 from dirstructure
import Directory
243 from Utilities.RelMon.directories2html
import directory2html
244 from Utilities.RelMon.dirstructure
import Directory
246 pickle_name=options.pklfile
247 if len(options.pklfile)==0:
248 pickle_name=original_pickle_name
250 print(
"Reading directory from %s" %(pickle_name))
251 ifile=open(pickle_name,
"rb")
252 directory=cPickle.load(ifile)
255 if os.path.exists(options.outdir_name)
and len(directory.name)==0:
256 os.chdir(options.outdir_name)
259 print(
"Calculating stats for the directory...")
260 directory.calcStats()
262 print(
"Producing html...")
265 if not (options.report
or options.compare):
266 print(
"Neither comparison nor report to be executed. A typo?")
S & print(S &os, JobReport::InputFile const &f)
def directory2html(directory, hashing, standalone, depth=0)