15 from sys
import argv,exit
16 from optparse
import OptionParser
21 dqm_server=
'https://cmsweb.cern.ch/dqm/relval'
23 cmssw_release1=
"CMSSW_5_3_0-START53_V4-v1"
24 cmssw_release2=
"CMSSW_5_3_1-START53_V5-v1"
27 test_threshold=0.00001
48 parser = OptionParser(usage=
"usage: %prog [options]")
50 parser.add_option(
"-1",
"--release1",
52 dest=
"cmssw_release1",
53 default=cmssw_release1,
54 help=
"The main CMSSW release \n(default is %s)" %cmssw_release1)
56 parser.add_option(
"-2",
"--release2",
58 dest=
"cmssw_release2",
59 default=cmssw_release2,
60 help=
"The CMSSW release for the regression \n(default is %s)" %cmssw_release2)
62 parser.add_option(
"-S",
"--sample",
66 help=
"The Sample upon which you want to run \n(default is %s)" %sample)
68 parser.add_option(
"-o",
"--outdir_name",
72 help=
"The directory where the output will be stored \n(default is %s)" %outdir_name)
74 parser.add_option(
"-D",
"--dqm_server",
78 help=
"The DQM server \n(default is %s)" %dqm_server)
80 parser.add_option(
"-a",
"--run1 ",
84 help=
"The run of the first sample to be checked \n(default is %s)" %run1)
86 parser.add_option(
"-b",
"--run2",
90 help=
"The run of the second sample to be checked \n(default is %s)" %run2)
92 parser.add_option(
"-d",
"--dir_name",
96 help=
"The 'directory' to be checked in the DQM \n(default is %s)" %dir_name)
98 parser.add_option(
"-p",
"--do_pngs",
102 help=
"EXPERIMENTAL!!! Do the pngs of the comparison (takes 50%% of the total running time) \n(default is %s)" %
False)
104 parser.add_option(
"-P",
"--pickle",
108 help=
"Pkl file of the dir structure ")
109 parser.add_option(
"-t",
"--test_threshold",
111 dest=
"test_threshold",
112 default=test_threshold,
113 help=
"Threshold for the statistical test \n(default is %s)" %test_threshold)
115 parser.add_option(
"-s",
"--stat_test",
119 help=
"Statistical test (KS or Chi2) \n(default is %s)" %stat_test)
121 parser.add_option(
"-C",
"--compare",
125 help=
"Make the comparison \n(default is %s)" %compare)
127 parser.add_option(
"-R",
"--Report",
131 help=
"Make the html report \n(default is %s)" %report)
133 parser.add_option(
"-T",
"--Tiers",
137 help=
"Data tiers (comma separated list) \n(default is %s)" %tiers)
139 parser.add_option(
"-B",
"--black_list",
142 default=black_list_str,
143 help=
"Blacklist elements. form is name@hierarchy_level (i.e. HLT@1) \n(default is %s)" %black_list_str)
145 (options, args) = parser.parse_args()
148 original_pickle_name=
""
151 if os.environ.has_key(
"RELMON_SA"):
152 from dqm_interfaces
import DirID,DQMcommunicator,DirWalkerDB
153 from dirstructure
import Directory
155 from Utilities.RelMon.dqm_interfaces
import DirID,DQMcommunicator,DirWalkerDB
156 from Utilities.RelMon.dirstructure
import Directory
160 fulldirname=options.outdir_name
161 if len(fulldirname)==0:
162 fulldirname=options.dir_name
163 if len(fulldirname)==0:
164 fulldirname=
"%s_%s_%s" %(sample1,cmssw_release1,cmssw_release2)
168 black_list_str=options.black_list
169 if len(black_list_str)>0:
170 for ele
in black_list_str.split(
","):
171 dirname,level=ele.split(
"@")
173 black_list.append(
DirID(dirname,level))
175 db_base_url=
"/data/json/archive/"
176 base1=
"%s/%s/%s/%s/DQM/" %(db_base_url,options.run1,options.sample,options.cmssw_release1)
177 base2=
"%s/%s/%s/%s/DQM/" %(db_base_url,options.run2,options.sample,options.cmssw_release2)
180 print "Analysing Histograms located in directory %s at: " %options.dir_name
181 for base
in base1,base2:
182 print " o %s (server= %s)" %(base,options.dqm_server)
193 dirwalker.do_pngs=options.do_pngs
196 dirwalker.stat_test=options.stat_test
197 dirwalker.test_threshold=options.test_threshold
200 if len(black_list)>0:
201 print "We have a Blacklist:"
202 for dirid
in black_list:
204 dirwalker.black_list=black_list
207 if not os.path.exists(options.outdir_name)
and len(options.outdir_name )>0:
208 os.mkdir(options.outdir_name)
209 if len(options.outdir_name)>0:
210 os.chdir(options.outdir_name)
218 directory=dirwalker.directory
221 directory.meta.sample=options.sample
222 directory.meta.run1=options.run1
223 directory.meta.run2=options.run2
224 directory.meta.release1=options.cmssw_release1
225 directory.meta.release2=options.cmssw_release2
227 directory.meta.tier1,directory.meta.tier2 = options.tiers.split(
",")
230 directory.print_report()
233 original_pickle_name=
"%s.pkl" %fulldirname
234 print "Pickleing the directory as %s in dir %s" %(original_pickle_name,os.getcwd())
235 output = open(original_pickle_name,
"w")
236 cPickle.dump(directory, output, -1)
241 if os.environ.has_key(
"RELMON_SA"):
242 from directories2html
import directory2html
243 from dirstructure
import Directory
245 from Utilities.RelMon.directories2html
import directory2html
246 from Utilities.RelMon.dirstructure
import Directory
248 pickle_name=options.pklfile
249 if len(options.pklfile)==0:
250 pickle_name=original_pickle_name
252 print "Reading directory from %s" %(pickle_name)
253 ifile=open(pickle_name,
"rb")
254 directory=cPickle.load(ifile)
257 if os.path.exists(options.outdir_name)
and len(directory.name)==0:
258 os.chdir(options.outdir_name)
261 print "Calculating stats for the directory..."
262 directory.calcStats()
264 print "Producing html..."
267 if not (options.report
or options.compare):
268 print "Neither comparison nor report to be executed. A typo?"