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")
148 if os.environ.has_key(
"RELMON_SA"):
149 black_list_file=
"../data/blacklist.txt"
151 black_list_file=
"%s/src/Utilities/RelMon/data/blacklist.txt"%(os.environ[
"CMSSW_BASE"])
152 bListFile = open(black_list_file,
'r')
153 black_listed_histograms = bListFile.read()
156 histogramArray = black_listed_histograms.split("\n")
157 histogramArray.remove(
"")
159 for elem
in histogramArray:
160 tmp = elem.split(
"/")
161 tmp.insert(1,
"Run summary")
162 newarray.append((
"/").
join(tmp))
166 (options, args) = parser.parse_args()
168 if len(args)!=2
and options.compare:
169 print "Wrong number of RootFiles specified (%s)" %len(args)
173 original_pickle_name=
""
176 if os.environ.has_key(
"RELMON_SA"):
178 from dqm_interfaces
import DirID,DirWalkerFile,string2blacklist
179 from dirstructure
import Directory
182 from Utilities.RelMon.dqm_interfaces
import DirID,DirWalkerFile,string2blacklist
183 from Utilities.RelMon.dirstructure
import Directory
186 from os
import mkdir,chdir,getcwd
187 from os.path
import exists
191 rootfilename1,rootfilename2 = args
202 if options.metas==
'':
206 print "Reading meta from commandline"
207 sample1=sample2=options.sample
208 cmssw_release1,cmssw_release2=options.metas.split(
'@@@')
212 print "I am puzzled. Did you choose two different samples?"
218 print "I am puzzled. Did you choose two different runs?"
222 fulldirname=options.outdir_name
223 if len(fulldirname)==0:
224 fulldirname=options.dir_name
225 if len(fulldirname)==0:
226 fulldirname=
"%s_%s_%s" %(sample1,cmssw_release1,cmssw_release2)
231 if options.blacklist_file:
238 print "Analysing Histograms located in directory %s at: " %options.dir_name
239 for filename
in rootfilename1,rootfilename2:
240 print " o %s" %filename
243 if len(black_list)>0:
244 print "We have a Blacklist:"
245 for dirid
in black_list:
252 rootfilename1,rootfilename2,
256 options.test_threshold,
257 not options.no_successes,
263 outdir_name=options.outdir_name
264 if run>1
and options.specify_run:
265 outdir_name+=
"_%s" %run
266 fulldirname+=
"_%s" %run
268 print "Output Directory will be ", outdir_name
269 options.outdir_name=outdir_name
270 if not exists(outdir_name)
and len(outdir_name )>0:
272 if len(outdir_name)>0:
280 directory=dirwalker.directory
283 directory.meta.sample=sample
284 directory.meta.run1=run1
285 directory.meta.run2=run2
286 directory.meta.release1=cmssw_release1
287 directory.meta.release2=cmssw_release2
288 directory.meta.tier1=tier1
289 directory.meta.tier2=tier2
292 directory.print_report(verbose=
True)
295 directory.prune(
"Run summary")
298 original_pickle_name=
"%s.pkl" %fulldirname
299 print "Pickleing the directory as %s in dir %s" %(original_pickle_name,getcwd())
300 output = open(original_pickle_name,
"w")
301 cPickle.dump(directory, output, -1)
307 if os.environ.has_key(
"RELMON_SA"):
308 from directories2html
import directory2html
309 from dirstructure
import Directory
311 from Utilities.RelMon.directories2html
import directory2html
312 from Utilities.RelMon.dirstructure
import Directory
314 from os.path
import exists
315 from os
import chdir,mkdir
319 pickle_name=options.pklfile
320 if len(options.pklfile)==0:
321 pickle_name=original_pickle_name
323 print "Reading directory from %s" %(pickle_name)
324 ifile=open(pickle_name,
"rb")
325 directory=cPickle.load(ifile)
328 if not options.compare:
329 if not os.path.exists(options.outdir_name):
330 mkdir(options.outdir_name)
332 if exists(options.outdir_name)
and len(directory.name)==0:
333 chdir(options.outdir_name)
336 print "Calculating stats for the directory..."
337 directory.calcStats()
339 print "Producing html..."
342 if not (options.report
or options.compare):
343 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)
void set(const std::string &name, int value)
set the flag, with a run-time name