12 from __future__
import print_function
14 prefix,sample,cmssw_release,tier = filename[:-5].
split(
"__")[:5]
15 run=
int(prefix.split(
"_")[-1][1:])
16 return run,sample,cmssw_release,tier
18 from sys
import argv,exit
41 from optparse
import OptionParser
43 parser = OptionParser(usage=
"usage: %prog file1 file2 [options]")
52 parser.add_option(
"-d",
"--dir_name",
56 help=
"The 'directory' to be checked in the DQM \n(default is %s)" %dir_name)
58 parser.add_option(
"-o",
"--outdir_name",
62 help=
"The directory where the output will be stored \n(default is %s)" %outdir_name)
64 parser.add_option(
"-p",
"--do_pngs",
68 help=
"Do the pngs of the comparison (takes 50%% of the total running time) \n(default is %s)" %
False)
70 parser.add_option(
"--no_successes",
74 help=
"Do not draw successes. Default is False.")
76 parser.add_option(
"-P",
"--pickle",
80 help=
"Pkl file of the dir structure ")
82 parser.add_option(
"--sample",
86 help=
"The name of the sample to be displayed")
88 parser.add_option(
"--metas",
92 help=
"The Metas describing the two files (separated by @@@)")
94 parser.add_option(
"-t",
"--test_threshold",
96 dest=
"test_threshold",
97 default=test_threshold,
98 help=
"Threshold for the statistical test \n(default is %s)" %test_threshold)
100 parser.add_option(
"-s",
"--stat_test",
104 help=
"Statistical test (KS or Chi2) \n(default is %s)" %stat_test)
106 parser.add_option(
"-C",
"--compare",
110 help=
"Make the comparison \n(default is %s)" %compare)
112 parser.add_option(
"-R",
"--Report",
116 help=
"Make the html report \n(default is %s)" %report)
118 parser.add_option(
"--specify_run",
122 help=
"Append the run number to the output dir for data")
125 parser.add_option(
"-B",
"--black_list",
128 default=black_list_str,
129 help=
"Blacklist elements. form is name@hierarchy_level (i.e. HLT@1) \n(default is %s)" %black_list_str)
132 parser.add_option(
"--hash_name",
136 help=
"Set if you want to minimize & hash the output HTML files.")
138 parser.add_option(
"--use_black_file",
140 dest=
"blacklist_file",
142 help=
"Use a black list file of histograms located @ /RelMon/data")
144 parser.add_option(
"--standalone",
148 help=
"Makes CSS files accessible over HTTP")
152 if "RELMON_SA" in os.environ:
153 black_list_file=
"../data/blacklist.txt" 155 black_list_file=
"%s/src/Utilities/RelMon/data/blacklist.txt"%(os.environ[
"CMSSW_BASE"])
156 bListFile = open(black_list_file,
'r') black_listed_histograms = bListFile.read() 159 histogramArray = black_listed_histograms.split("\n")
160 histogramArray.remove(
"")
162 for elem
in histogramArray:
163 tmp = elem.split(
"/")
164 tmp.insert(1,
"Run summary")
165 newarray.append((
"/").
join(tmp))
169 (options, args) = parser.parse_args()
171 if len(args)!=2
and options.compare:
172 print(
"Wrong number of RootFiles specified (%s)" %len(args))
176 original_pickle_name=
"" 179 if "RELMON_SA" in os.environ:
181 from dqm_interfaces
import DirID,DirWalkerFile,string2blacklist
182 from dirstructure
import Directory
185 from Utilities.RelMon.dqm_interfaces
import DirID,DirWalkerFile,string2blacklist
186 from Utilities.RelMon.dirstructure
import Directory
189 from os
import mkdir,chdir,getcwd
190 from os.path
import exists
194 rootfilename1,rootfilename2 = args
205 if options.metas==
'':
209 print(
"Reading meta from commandline")
210 sample1=sample2=options.sample
211 cmssw_release1,cmssw_release2=options.metas.split(
'@@@')
212 options.standalone =
True 216 print(
"I am puzzled. Did you choose two different samples?")
222 print(
"I am puzzled. Did you choose two different runs?")
226 fulldirname=options.outdir_name
227 if len(fulldirname)==0:
228 fulldirname=options.dir_name
229 if len(fulldirname)==0:
230 fulldirname=
"%s_%s_%s" %(sample1,cmssw_release1,cmssw_release2)
235 if options.blacklist_file:
242 print(
"Analysing Histograms located in directory %s at: " %options.dir_name)
243 for filename
in rootfilename1,rootfilename2:
244 print(
" o %s" %filename)
247 if len(black_list)>0:
248 print(
"We have a Blacklist:")
249 for dirid
in black_list:
250 print(
" o %s" %dirid)
256 rootfilename1,rootfilename2,
260 options.test_threshold,
261 not options.no_successes,
267 outdir_name=options.outdir_name
268 if run>1
and options.specify_run:
269 outdir_name+=
"_%s" %run
270 fulldirname+=
"_%s" %run
272 print(
"Output Directory will be ", outdir_name)
273 options.outdir_name=outdir_name
274 if not exists(outdir_name)
and len(outdir_name )>0:
276 if len(outdir_name)>0:
284 directory=dirwalker.directory
287 directory.meta.sample1=sample1
288 directory.meta.sample2=sample2
289 directory.meta.run1=run1
290 directory.meta.run2=run2
291 directory.meta.release1=cmssw_release1
292 directory.meta.release2=cmssw_release2
293 directory.meta.tier1=tier1
294 directory.meta.tier2=tier2
297 directory.print_report(verbose=
True)
300 directory.prune(
"Run summary")
303 original_pickle_name=
"%s.pkl" %fulldirname
304 print(
"Pickleing the directory as %s in dir %s" %(original_pickle_name,getcwd()))
305 output = open(original_pickle_name,
"wb")
306 pickle.dump(directory, output, -1)
312 if "RELMON_SA" in os.environ:
313 from directories2html
import directory2html
314 from dirstructure
import Directory
316 from Utilities.RelMon.directories2html
import directory2html
317 from Utilities.RelMon.dirstructure
import Directory
319 from os.path
import exists
320 from os
import chdir,mkdir
324 pickle_name=options.pklfile
325 if len(options.pklfile)==0:
326 pickle_name=original_pickle_name
328 print(
"Reading directory from %s" %(pickle_name))
329 ifile=open(pickle_name,
"rb")
330 directory=pickle.load(ifile)
333 if not options.compare:
334 if not os.path.exists(options.outdir_name):
335 mkdir(options.outdir_name)
337 if exists(options.outdir_name)
and len(directory.name)==0:
338 chdir(options.outdir_name)
341 print(
"Calculating stats for the directory...")
342 directory.calcStats()
344 print(
"Producing html...")
347 if not (options.report
or options.compare):
348 print(
"Neither comparison nor report to be executed. A typo?")
351
def getInfoFromFilename(filename)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def split(sequence, size)
def directory2html(directory, hashing, standalone, depth=0)
static std::string join(char **cmd)
def string2blacklist(black_list_str)