15 from optparse
import OptionParser
21 from subprocess
import call,PIPE
22 from multiprocessing
import Pool
28 if os.environ.has_key(
"RELMON_SA"):
29 import definitions
as definitions
30 from dqm_interfaces
import DirWalkerFile,string2blacklist,DirWalkerFile_thread_wrapper
31 from dirstructure
import Directory
32 from directories2html
import directory2html,make_summary_table
33 from utils
import ask_ok, unpickler, make_files_pairs
36 from Utilities.RelMon.dqm_interfaces
import DirWalkerFile,string2blacklist,DirWalkerFile_thread_wrapper
37 from Utilities.RelMon.dirstructure
import Directory
38 from Utilities.RelMon.directories2html
import directory2html,make_summary_table
39 from Utilities.RelMon.utils
import ask_ok, unpickler, make_files_pairs
45 namebase=os.path.basename(filename)
46 return namebase.split(
"__")[1]
49 namebase=os.path.basename(filename)
50 return namebase.split(
"__")[2]
53 namebase=os.path.basename(filename)
54 return namebase.split(
"__")[0].
split(
"_")[2]
61 skim = skim[:skim.rfind(
'-v')]
62 return "%s_%s"%(run,skim)
68 if len(ref_filenames)*len(test_filenames)==0:
69 print "Empty reference and test filenames lists!"
76 for ref, test
in zip(
map(os.path.basename,ref_filenames),
map(os.path.basename,test_filenames)):
83 print " ## sample 1: %s vs sample 2: %s"%(ref_sample, test_sample)
85 if ref_sample!=test_sample:
86 print "Files %s and %s do not seem to be relative to the same sample." %(ref, test)
90 if search(
"20[01]",ref_version)!=
None:
91 ref_sample+=ref_version.split(
"_")[-1]
92 samples.append(ref_sample)
95 ref_versions.append(ref_version)
96 test_versions.append(test_version)
99 ref_versions=
list(set(ref_versions))
100 test_versions=
list(set(test_versions))
107 cmssw_version1=ref_versions[0]
108 cmssw_version2=test_versions[0]
110 return samples,cmssw_version1,cmssw_version2
116 for name
in names_list:
117 if not name.endswith(
".root"):
118 print "File %s does not seem to be a rootfile. Please check."
126 int_pattern=pattern.strip()
128 if int_pattern[0]==
'!':
129 int_pattern=int_pattern[1:]
132 condition =
search(int_pattern,target)!=
None
134 condition =
not condition
140 blacklist+=blist_piece
148 """Build a blacklist for each sample accordind to a set of rules
151 for sample
in samples:
152 blacklists[sample]=
"FED@1,AlcaBeamMonitor@1,HLT@1,AlCaReco@1"
156 blacklists[sample]+=
",AlCaEcalPi0@2"
157 if not search(
"2010+|2011+",ver1):
158 print "We are treating MC files for the HLT"
159 for pattern,blist
in definitions.hlt_mc_pattern_blist_pairs:
160 blacklists[sample]=
add_to_blacklist(blacklists[sample],pattern,sample,blist)
162 print "We are treating Data files for the HLT"
167 if not search(
"2010+|2011+",ver1):
168 print "We are treating MC files"
170 for pattern,blist
in definitions.mc_pattern_blist_pairs:
171 blacklists[sample]=
add_to_blacklist(blacklists[sample],pattern,sample,blist)
177 print "We are treating Data files:"
178 blacklists[sample]+=
",By__Lumi__Section@-1,AlCaReco@1"
179 for pattern,blist
in definitions.data_pattern_blist_pairs:
190 files_list =
filter(
lambda s: s.endswith(
".root"), os.listdir(directory))
191 files_list_path=
map(
lambda s: os.path.join(directory,s), files_list)
193 return files_list_path
202 if len(files_list)==0:
203 print "Zero files found in directory %s!" %all_samples
207 for name
in files_list:
209 if len(files_list)%2!=0:
210 print "The numbuer of file is not even... Trying to recover a catastrophe."
220 for iname
in xrange(len(files_list)):
221 filename=files_list[iname]
223 ref_filenames.append(filename)
225 test_filenames.append(filename)
227 print "The guess would be the following:"
228 for ref,test
in zip(ref_filenames,test_filenames):
229 refbasedir=os.path.dirname(ref)
230 testbasedir=os.path.dirname(test)
231 dir_to_print=refbasedir
232 if refbasedir!=testbasedir:
233 dir_to_print=
"%s and %s" %(refbasedir,testbasedir)
234 print "* Directory: %s " %dir_to_print
235 refname=os.path.basename(ref)
236 testname=os.path.basename(test)
237 print " o %s" %refname
238 print " o %s" %testname
246 return ref_filenames,test_filenames
253 ref_filenames=
map(
lambda s:s.strip(),ref_samples.split(
","))
254 test_filenames=
map(
lambda s:s.strip(),test_samples.split(
","))
256 if len(ref_filenames)!=len(test_filenames):
257 print "The numebr of reference and test files does not seem to be the same. Please check."
262 return ref_filenames,test_filenames
267 return len(
filter(
lambda p: p.returncode==
None,p_list))
272 """Creates shell command to compare two files using compare_using_files.py
273 script and calls it."""
274 sample, ref_filename, test_filename, options = args
276 command =
" compare_using_files.py "
277 command+=
"%s %s " %(ref_filename,test_filename)
281 command+=
" -o %s " %sample
283 command+=
" --specify_run "
284 command+=
" -t %s " %options.test_threshold
285 command+=
" -s %s " %options.stat_test
291 if options.hash_name:
292 command +=
" --hash_name "
294 if options.blacklist_file:
295 command +=
" --use_black_file "
297 if options.standalone:
298 command +=
" --standalone "
299 if len(blacklists[sample]) >0:
300 command+=
'-B %s ' %blacklists[sample]
301 print "\nExecuting -- %s" %command
303 process=call(
filter(
lambda x: len(x)>0,command.split(
" ")))
311 n_processes= int(options.n_processes)
316 if len(options.all_samples)>0:
322 ref_filenames=
map(os.path.abspath,ref_filenames)
323 test_filenames=
map(os.path.abspath,test_filenames)
325 samples,cmssw_version1,cmssw_version2=
guess_params(ref_filenames,test_filenames)
328 print "No Samples found... Quitting"
334 original_dir=os.getcwd()
336 outdir=options.out_dir
338 print "Creating automatic outdir:",
339 outdir=
"%sVS%s" %(cmssw_version1,cmssw_version2)
341 if len(options.input_dir)==0:
342 print "Creating automatic indir:",
343 options.input_dir=outdir
344 print options.input_dir
346 if not os.path.exists(outdir):
351 n_comparisons=len(ref_filenames)
352 if n_comparisons < n_processes:
353 print "Less comparisons than possible processes: reducing n processes to",
354 n_processes=n_comparisons
371 if search(
"20[01]",cmssw_version1)!=
None:
372 skim_name=cmssw_version1.split(
"_")[-1]
374 running_subprocesses=[]
379 pool = Pool(n_processes)
380 args_iterable = [
list(args) + [options]
for args
in zip(samples, ref_filenames, test_filenames)]
381 pool.map(call_compare_using_files, args_iterable)
383 os.system(
"mv */*pkl .")
390 pkl_list=
filter(
lambda x:
".pkl" in x, os.listdir(
"./"))
391 running_subprocesses=[]
392 n_processes=int(options.n_processes)
394 for pklfilename
in pkl_list:
395 command =
"compare_using_files.py "
399 command+=
"-P %s " %pklfilename
400 command+=
"-o %s " %pklfilename[:-4]
401 print "Executing %s" %command
402 process=call(
filter(
lambda x: len(x)>0,command.split(
" ")))
405 running_subprocesses.append(process)
406 if process_counter>=n_processes:
408 for p
in running_subprocesses:
415 def do_html(options, hashing_flag, standalone):
418 print "Preparing reports for the single files..."
422 aggregation_rules_twiki={}
425 print "Aggregating directories according to HLT rules"
426 aggregation_rules=definitions.aggr_pairs_dict[
'HLT']
427 aggregation_rules_twiki=definitions.aggr_pairs_twiki_dict[
'HLT']
429 aggregation_rules=definitions.aggr_pairs_dict[
'reco']
430 aggregation_rules_twiki=definitions.aggr_pairs_twiki_dict[
'reco']
431 table_html =
make_summary_table(options.input_dir,aggregation_rules,aggregation_rules_twiki, hashing_flag, standalone)
434 ofile = open(
"RelMonSummary.html",
"w")
435 ofile.write(table_html)
440 if __name__ ==
"__main__":
452 test_threshold=0.00001
457 parser = OptionParser(usage=
"usage: %prog [options]")
459 parser.add_option(
"-R",
"--ref_samples ",
463 help=
"The samples that act as reference (comma separated list)")
465 parser.add_option(
"-T",
"--test_samples",
468 default=test_samples,
469 help=
"The samples to be tested (comma separated list)")
471 parser.add_option(
"-a",
"--all_samples",
475 help=
"EXPERIMENTAL: Try to sort all samples selected (wildacrds) and organise a comparison")
477 parser.add_option(
"-o",
"--out_dir",
481 help=
"The outdir other than <Version1>VS<Version2>")
483 parser.add_option(
"-p",
"--do_pngs",
487 help=
"EXPERIMENTAL!!! Do the pngs of the comparison (takes 50%% of the total running time) \n(default is %s)" %
False)
489 parser.add_option(
"-r",
"--run ",
493 help=
"The run to be checked \n(default is %s)" %run)
495 parser.add_option(
"-t",
"--test_threshold",
497 dest=
"test_threshold",
498 default=test_threshold,
499 help=
"Threshold for the statistical test \n(default is %s)" %test_threshold)
501 parser.add_option(
"-s",
"--stat_test",
505 help=
"Statistical test (KS or Chi2) \n(default is %s)" %stat_test)
507 parser.add_option(
"-N",
"--numberOfProcesses",
511 help=
"Number of parallel processes to be run. Be Polite! \n(default is %s)" %n_processes)
513 parser.add_option(
"--HLT",
517 help=
"Analyse HLT histograms\n(default is %s)" %hlt)
519 parser.add_option(
"-i",
"--input_dir",
523 help=
"Input directory for html creation \n(default is %s)" %in_dir)
525 parser.add_option(
"--reports",
529 help=
"Do the reports for the pickles \n(default is %s)" %in_dir)
531 parser.add_option(
"--hash_name",
535 help=
"Set if you want to minimize & hash the output HTML files.")
537 parser.add_option(
"--use_black_file",
539 dest=
"blacklist_file",
541 help=
"Use a black list file of histograms located @ /RelMon/data")
543 parser.add_option(
"--standalone",
547 help=
"Define that using RelMon in standalone method. Makes CSS files accessible over HTTP")
549 (options, args) = parser.parse_args()
551 if len(options.test_samples)*len(options.ref_samples)+len(options.all_samples)==0
and len(options.input_dir)==0:
552 print "No samples given as input."
556 if len(options.all_samples)>0
or (len(options.ref_samples)*len(options.test_samples)>0):
558 if len(options.input_dir)>0:
559 do_html(options, options.hash_name, options.standalone)
def get_filenames_from_pool
def count_alive_processes
def do_comparisons_threaded
def call_compare_using_files
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run