16 prefix,sample,cmssw_release,tier = filename[:-5].
split(
"__")[:5]
17 run=int(prefix.split(
"_")[-1][1:])
18 return run,sample,cmssw_release,tier
20 from sys
import argv,exit
43 from optparse
import OptionParser
45 parser = OptionParser(usage=
"usage: %prog file1 file2 [options]")
54 parser.add_option(
"-d",
"--dir_name",
58 help=
"The 'directory' to be checked in the DQM \n(default is %s)" %dir_name)
60 parser.add_option(
"-o",
"--outdir_name",
64 help=
"The directory where the output will be stored \n(default is %s)" %outdir_name)
66 parser.add_option(
"-p",
"--do_pngs",
70 help=
"Do the pngs of the comparison (takes 50%% of the total running time) \n(default is %s)" %
False)
72 parser.add_option(
"--no_successes",
76 help=
"Do not draw successes. Default is False.")
78 parser.add_option(
"-P",
"--pickle",
82 help=
"Pkl file of the dir structure ")
84 parser.add_option(
"--sample",
88 help=
"The name of the sample to be displayed")
90 parser.add_option(
"--metas",
94 help=
"The Metas describing the two files (separated by @@@)")
96 parser.add_option(
"-t",
"--test_threshold",
98 dest=
"test_threshold",
99 default=test_threshold,
100 help=
"Threshold for the statistical test \n(default is %s)" %test_threshold)
102 parser.add_option(
"-s",
"--stat_test",
106 help=
"Statistical test (KS or Chi2) \n(default is %s)" %stat_test)
108 parser.add_option(
"-C",
"--compare",
112 help=
"Make the comparison \n(default is %s)" %compare)
114 parser.add_option(
"-R",
"--Report",
118 help=
"Make the html report \n(default is %s)" %report)
120 parser.add_option(
"--specify_run",
124 help=
"Append the run number to the output dir for data")
127 parser.add_option(
"-B",
"--black_list",
130 default=black_list_str,
131 help=
"Blacklist elements. form is name@hierarchy_level (i.e. HLT@1) \n(default is %s)" %black_list_str)
134 parser.add_option(
"--hash_name",
138 help=
"Set if you want to minimize & hash the output HTML files.")
140 parser.add_option(
"--use_black_file",
142 dest=
"blacklist_file",
144 help=
"Use a black list file of histograms located @ /RelMon/data")
146 parser.add_option(
"--standalone",
150 help=
"Makes CSS files accessible over HTTP")
154 if os.environ.has_key(
"RELMON_SA"):
155 black_list_file=
"../data/blacklist.txt"
157 black_list_file=
"%s/src/Utilities/RelMon/data/blacklist.txt"%(os.environ[
"CMSSW_BASE"])
158 bListFile = open(black_list_file,
'r')
159 black_listed_histograms = bListFile.read()
162 histogramArray = black_listed_histograms.split("\n")
163 histogramArray.remove(
"")
165 for elem
in histogramArray:
166 tmp = elem.split(
"/")
167 tmp.insert(1,
"Run summary")
168 newarray.append((
"/").
join(tmp))
172 (options, args) = parser.parse_args()
174 if len(args)!=2
and options.compare:
175 print "Wrong number of RootFiles specified (%s)" %len(args)
179 original_pickle_name=
""
182 if os.environ.has_key(
"RELMON_SA"):
184 from dqm_interfaces
import DirID,DirWalkerFile,string2blacklist
185 from dirstructure
import Directory
188 from Utilities.RelMon.dqm_interfaces
import DirID,DirWalkerFile,string2blacklist
189 from Utilities.RelMon.dirstructure
import Directory
192 from os
import mkdir,chdir,getcwd
193 from os.path
import exists
197 rootfilename1,rootfilename2 = args
208 if options.metas==
'':
212 print "Reading meta from commandline"
213 sample1=sample2=options.sample
214 cmssw_release1,cmssw_release2=options.metas.split(
'@@@')
215 options.standalone =
True
219 print "I am puzzled. Did you choose two different samples?"
225 print "I am puzzled. Did you choose two different runs?"
229 fulldirname=options.outdir_name
230 if len(fulldirname)==0:
231 fulldirname=options.dir_name
232 if len(fulldirname)==0:
233 fulldirname=
"%s_%s_%s" %(sample1,cmssw_release1,cmssw_release2)
238 if options.blacklist_file:
245 print "Analysing Histograms located in directory %s at: " %options.dir_name
246 for filename
in rootfilename1,rootfilename2:
247 print " o %s" %filename
250 if len(black_list)>0:
251 print "We have a Blacklist:"
252 for dirid
in black_list:
259 rootfilename1,rootfilename2,
263 options.test_threshold,
264 not options.no_successes,
270 outdir_name=options.outdir_name
271 if run>1
and options.specify_run:
272 outdir_name+=
"_%s" %run
273 fulldirname+=
"_%s" %run
275 print "Output Directory will be ", outdir_name
276 options.outdir_name=outdir_name
277 if not exists(outdir_name)
and len(outdir_name )>0:
279 if len(outdir_name)>0:
287 directory=dirwalker.directory
290 directory.meta.sample1=sample1
291 directory.meta.sample2=sample2
292 directory.meta.run1=run1
293 directory.meta.run2=run2
294 directory.meta.release1=cmssw_release1
295 directory.meta.release2=cmssw_release2
296 directory.meta.tier1=tier1
297 directory.meta.tier2=tier2
300 directory.print_report(verbose=
True)
303 directory.prune(
"Run summary")
306 original_pickle_name=
"%s.pkl" %fulldirname
307 print "Pickleing the directory as %s in dir %s" %(original_pickle_name,getcwd())
308 output = open(original_pickle_name,
"w")
309 cPickle.dump(directory, output, -1)
315 if os.environ.has_key(
"RELMON_SA"):
316 from directories2html
import directory2html
317 from dirstructure
import Directory
319 from Utilities.RelMon.directories2html
import directory2html
320 from Utilities.RelMon.dirstructure
import Directory
322 from os.path
import exists
323 from os
import chdir,mkdir
327 pickle_name=options.pklfile
328 if len(options.pklfile)==0:
329 pickle_name=original_pickle_name
331 print "Reading directory from %s" %(pickle_name)
332 ifile=open(pickle_name,
"rb")
333 directory=cPickle.load(ifile)
336 if not options.compare:
337 if not os.path.exists(options.outdir_name):
338 mkdir(options.outdir_name)
340 if exists(options.outdir_name)
and len(directory.name)==0:
341 chdir(options.outdir_name)
344 print "Calculating stats for the directory..."
345 directory.calcStats()
347 print "Producing html..."
350 if not (options.report
or options.compare):
351 print "Neither comparison nor report to be executed. A typo?"
def getInfoFromFilename
https://twiki.cern.ch/twiki/bin/view/CMSPublic/RelMon
static std::string join(char **cmd)