CMS 3D CMS Logo

Functions | Variables
ValidationMatrix Namespace Reference

Functions

def add_to_blacklist (blacklist, pattern, target, blist_piece)
 
def call_compare_using_files (args)
 
def check_root_files (names_list)
 
def count_alive_processes (p_list)
 
def do_comparisons_threaded (options)
 
def do_html (options, hashing_flag, standalone)
 
def do_reports (indir)
 
def get_clean_fileanames (ref_samples, test_samples)
 
def get_filenames_from_pool (all_samples)
 
def get_roofiles_in_dir (directory)
 
def guess_blacklists (samples, ver1, ver2, hlt)
 
def guess_params (ref_filenames, test_filenames)
 
def name2globaltag (filename)
 
def name2run (filename)
 
def name2runskim (filename)
 
def name2sample (filename)
 
def name2version (filename)
 

Variables

 action
 —HASHING—## More...
 
 all_samples
 
 args
 
 argv
 
 default
 
 dest
 
 help
 
 hlt
 
 in_dir
 
 n_processes
 
 n_threads
 
 options
 
 out_dir
 
 parser
 
 ref_samples
 
 run
 
 stat_test
 
 test_samples
 
 test_threshold
 
 usage
 

Function Documentation

def ValidationMatrix.add_to_blacklist (   blacklist,
  pattern,
  target,
  blist_piece 
)

Definition at line 125 of file ValidationMatrix.py.

References cond::persistency.search().

Referenced by guess_blacklists().

125 def add_to_blacklist(blacklist, pattern, target, blist_piece):
126  int_pattern=pattern
127  int_pattern=pattern.strip()
128  flip_condition=False
129  if int_pattern[0]=='!':
130  int_pattern=int_pattern[1:]
131  flip_condition=True
132 
133  condition = search(int_pattern,target)!=None
134  if flip_condition:
135  condition = not condition
136 
137  if condition:
138  #print "Found %s in %s" %(pattern,target)
139  if blacklist!="": # if not the first, add a comma
140  blacklist+=","
141  blacklist+=blist_piece
142  #else:
143  #print " NOT Found %s in %s" %(pattern,target)
144  return blacklist
145 
146 #-------------------------------------------------------------------------------
147 
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:314
def add_to_blacklist(blacklist, pattern, target, blist_piece)
def ValidationMatrix.call_compare_using_files (   args)
Creates shell command to compare two files using compare_using_files.py
script and calls it.

Definition at line 272 of file ValidationMatrix.py.

References ALCARECOTkAlBeamHalo_cff.filter, guess_blacklists(), name2globaltag(), and name2version().

273  """Creates shell command to compare two files using compare_using_files.py
274  script and calls it."""
275  sample, ref_filename, test_filename, options = args
276  gt = name2globaltag(ref_filename)
277  blacklists=guess_blacklists([sample],name2version(ref_filename),name2version(test_filename),options.hlt)
278  command = " compare_using_files.py "
279  command+= "%s %s " %(ref_filename,test_filename)
280  command+= " -C -R "
281  if options.do_pngs:
282  command+= " -p "
283  command+= " -o %s_%s " %(sample, gt)
284  # Change threshold to an experimental and empirical value of 10^-5
285  command+= " --specify_run "
286  if options.stat_test in ["Bin2Bin", "BinToBin"]:
287  options.test_threshold = 0.9999
288  command+= " -t %s " %options.test_threshold
289  command+= " -s %s " %options.stat_test
290 
291  # Inspect the HLT directories
292  if options.hlt:
293  command+=" -d HLT "
294 
295  if options.hash_name:
296  command += " --hash_name "
297 
298  if options.blacklist_file:
299  command += " --use_black_file "
300 
301  if options.standalone:
302  command += " --standalone "
303  if len(blacklists[sample]) >0:
304  command+= '-B %s ' %blacklists[sample]
305  print "\nExecuting -- %s" %command
306 
307  process=call(filter(lambda x: len(x)>0,command.split(" ")))
308  return process
309 
310 
311 #--------------------------------------------------------------------------------
312 
def name2globaltag(filename)
def call_compare_using_files(args)
def name2version(filename)
def guess_blacklists(samples, ver1, ver2, hlt)
def ValidationMatrix.check_root_files (   names_list)

Definition at line 116 of file ValidationMatrix.py.

Referenced by get_clean_fileanames().

116 def check_root_files(names_list):
117  for name in names_list:
118  if not name.endswith(".root"):
119  print "File %s does not seem to be a rootfile. Please check."
120  return False
121  return True
122 
123 #-------------------------------------------------------------------------------
124 
def check_root_files(names_list)
def ValidationMatrix.count_alive_processes (   p_list)

Definition at line 267 of file ValidationMatrix.py.

References ALCARECOTkAlBeamHalo_cff.filter.

268  return len(filter(lambda p: p.returncode==None,p_list))
269 
270 #-------------------------------------------------------------------------------
271 
def count_alive_processes(p_list)
def ValidationMatrix.do_comparisons_threaded (   options)

Definition at line 313 of file ValidationMatrix.py.

References get_clean_fileanames(), get_filenames_from_pool(), guess_params(), createfilelist.int, list(), genParticles_cff.map, cond::persistency.search(), and ComparisonHelper.zip().

314 
315  n_processes= int(options.n_processes)
316 
317  ref_filenames=[]
318  test_filenames=[]
319 
320  if len(options.all_samples)>0:
321  ref_filenames,test_filenames=get_filenames_from_pool(options.all_samples)
322  else:
323  ref_filenames,test_filenames=get_clean_fileanames(options.ref_samples,options.test_samples)
324 
325  # make the paths absolute
326  ref_filenames=map(os.path.abspath,ref_filenames)
327  test_filenames=map(os.path.abspath,test_filenames)
328 
329  samples,cmssw_version1,cmssw_version2=guess_params(ref_filenames,test_filenames)
330 
331  if len(samples)==0:
332  print "No Samples found... Quitting"
333  return 0
334 
335 # blacklists=guess_blacklists(samples,cmssw_version1,cmssw_version2,options.hlt)
336 
337  # Launch the single comparisons
338  original_dir=os.getcwd()
339 
340  outdir=options.out_dir
341  if len(outdir)==0:
342  print "Creating automatic outdir:",
343  outdir="%sVS%s" %(cmssw_version1,cmssw_version2)
344  print outdir
345  if len(options.input_dir)==0:
346  print "Creating automatic indir:",
347  options.input_dir=outdir
348  print options.input_dir
349 
350  if not os.path.exists(outdir):
351  os.mkdir(outdir)
352  os.chdir(outdir)
353 
354  # adjust the number of threads
355  n_comparisons=len(ref_filenames)
356  if n_comparisons < n_processes:
357  print "Less comparisons than possible processes: reducing n processes to",
358  n_processes=n_comparisons
359  #elif n_processes/n_comparisons == 0:
360  #print "More comparisons than possible processes, can be done in N rounds: reducing n processes to",
361  #original_nprocesses=n_processes
362  #first=True
363  #n_bunches=0
364  #while first or n_processes > original_nprocesses:
365  #n_processes=n_comparisons/2
366  #if n_comparisons%2 !=0:
367  #n_processes+=1
368  #first=False
369 
370  #print n_processes
371  #print n_processes
372 
373  # Test if we treat data
374  skim_name=""
375  if search("20[01]",cmssw_version1)!=None:
376  skim_name=cmssw_version1.split("_")[-1]
377 
378  running_subprocesses=[]
379  process_counter=0
380  #print ref_filenames
381 
382  ## Compare all pairs of root files
383  pool = Pool(n_processes)
384  args_iterable = [list(args) + [options] for args in zip(samples, ref_filenames, test_filenames)]
385  pool.map(call_compare_using_files, args_iterable)
386  # move the pickles on the top, hack
387  os.system("mv */*pkl .")
388 
389  os.chdir("..")
390 #-------------------------------------------------------------------------------
def guess_params(ref_filenames, test_filenames)
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:314
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def get_filenames_from_pool(all_samples)
def get_clean_fileanames(ref_samples, test_samples)
def do_comparisons_threaded(options)
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
def ValidationMatrix.do_html (   options,
  hashing_flag,
  standalone 
)

Definition at line 419 of file ValidationMatrix.py.

References do_reports(), and directories2html.make_summary_table().

419 def do_html(options, hashing_flag, standalone):
420 
421  if options.reports:
422  print "Preparing reports for the single files..."
423  do_reports(options.input_dir)
424  # Do the summary page
425  aggregation_rules={}
426  aggregation_rules_twiki={}
427  # check which aggregation rules are to be used
428  if options.hlt:
429  print "Aggregating directories according to HLT rules"
430  aggregation_rules=definitions.aggr_pairs_dict['HLT']
431  aggregation_rules_twiki=definitions.aggr_pairs_twiki_dict['HLT']
432  else:
433  aggregation_rules=definitions.aggr_pairs_dict['reco']
434  aggregation_rules_twiki=definitions.aggr_pairs_twiki_dict['reco']
435  table_html = make_summary_table(options.input_dir,aggregation_rules,aggregation_rules_twiki, hashing_flag, standalone)
436 
437  # create summary html file
438  ofile = open("RelMonSummary.html","w")
439  ofile.write(table_html)
440  ofile.close()
441 
442 #-------------------------------------------------------------------------------
443 
def do_html(options, hashing_flag, standalone)
def make_summary_table(indir, aggregation_rules, aggregation_rules_twiki, hashing_flag, standalone_flag)
def ValidationMatrix.do_reports (   indir)

Definition at line 391 of file ValidationMatrix.py.

References ALCARECOTkAlBeamHalo_cff.filter, and createfilelist.int.

Referenced by do_html().

391 def do_reports(indir):
392  #print indir
393  os.chdir(indir)
394  pkl_list=filter(lambda x:".pkl" in x, os.listdir("./"))
395  running_subprocesses=[]
396  n_processes=int(options.n_processes)
397  process_counter=0
398  for pklfilename in pkl_list:
399  command = "compare_using_files.py "
400  command+= "-R "
401  if options.do_pngs:
402  command+= " -p "
403  command+= "-P %s " %pklfilename
404  command+= "-o %s " %pklfilename[:-4]
405  print "Executing %s" %command
406  process=call(filter(lambda x: len(x)>0,command.split(" ")))
407  process_counter+=1
408  # add it to the list
409  running_subprocesses.append(process)
410  if process_counter>=n_processes:
411  process_counter=0
412  for p in running_subprocesses:
413  #print "Waiting for %s" %p.name
414  p.wait()
415 
416  os.chdir("..")
417 
418 #-------------------------------------------------------------------------------
def ValidationMatrix.get_clean_fileanames (   ref_samples,
  test_samples 
)

Definition at line 252 of file ValidationMatrix.py.

References check_root_files(), cmsRelvalreport.exit, and genParticles_cff.map.

Referenced by do_comparisons_threaded().

252 def get_clean_fileanames(ref_samples,test_samples):
253  # Process the samples starting from the names
254  ref_filenames=map(lambda s:s.strip(),ref_samples.split(","))
255  test_filenames=map(lambda s:s.strip(),test_samples.split(","))
256 
257  if len(ref_filenames)!=len(test_filenames):
258  print "The numebr of reference and test files does not seem to be the same. Please check."
259  exit(2)
260 
261  if not (check_root_files(ref_filenames) and check_root_files(test_filenames)):
262  exit(2)
263  return ref_filenames,test_filenames
264 
265 #-------------------------------------------------------------------------------
266 
def check_root_files(names_list)
def get_clean_fileanames(ref_samples, test_samples)
def ValidationMatrix.get_filenames_from_pool (   all_samples)

Definition at line 198 of file ValidationMatrix.py.

References get_roofiles_in_dir(), utils.make_files_pairs(), and ComparisonHelper.zip().

Referenced by do_comparisons_threaded().

198 def get_filenames_from_pool(all_samples):
199 
200  # get a list of the files
201  files_list=get_roofiles_in_dir(all_samples)
202 
203  if len(files_list)==0:
204  print "Zero files found in directory %s!" %all_samples
205  return [],[]
206 
207  # Are they an even number?
208  for name in files_list:
209  print "* ",name
210  if len(files_list)%2!=0:
211  print "The numbuer of file is not even... Trying to recover a catastrophe."
212 
213  files_list=make_files_pairs(files_list)
214 
215  # Try to couple them according to their sample
216  ref_filenames=[]
217  test_filenames=[]
218  #files_list.sort(key=name2version)
219  #files_list.sort(key=name2sample)
220  #files_list.sort(key=name2run)
221  for iname in xrange(len(files_list)):
222  filename=files_list[iname]
223  if iname%2==0:
224  ref_filenames.append(filename)
225  else:
226  test_filenames.append(filename)
227 
228  print "The guess would be the following:"
229  for ref,test in zip(ref_filenames,test_filenames):
230  refbasedir=os.path.dirname(ref)
231  testbasedir=os.path.dirname(test)
232  dir_to_print=refbasedir
233  if refbasedir!=testbasedir:
234  dir_to_print="%s and %s" %(refbasedir,testbasedir)
235  print "* Directory: %s " %dir_to_print
236  refname=os.path.basename(ref)
237  testname=os.path.basename(test)
238  print " o %s" %refname
239  print " o %s" %testname
240 
241  #is_ok=ask_ok("Is that ok?")
242  #if not is_ok:
243  #print "Manual input needed then!"
244  #exit(2)
245 
246 
247  return ref_filenames,test_filenames
248 
249 
250 #-------------------------------------------------------------------------------
251 
def get_roofiles_in_dir(directory)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def get_filenames_from_pool(all_samples)
def make_files_pairs(files, verbose=True)
Definition: utils.py:561
def ValidationMatrix.get_roofiles_in_dir (   directory)

Definition at line 189 of file ValidationMatrix.py.

References ALCARECOTkAlBeamHalo_cff.filter, and genParticles_cff.map.

Referenced by get_filenames_from_pool().

189 def get_roofiles_in_dir(directory):
190  print directory
191  files_list = filter(lambda s: s.endswith(".root"), os.listdir(directory))
192  files_list_path=map(lambda s: os.path.join(directory,s), files_list)
193 
194  return files_list_path
195 
196 #-------------------------------------------------------------------------------
197 
def get_roofiles_in_dir(directory)
def ValidationMatrix.guess_blacklists (   samples,
  ver1,
  ver2,
  hlt 
)
Build a blacklist for each sample accordind to a set of rules

Definition at line 148 of file ValidationMatrix.py.

References add_to_blacklist(), and cond::persistency.search().

Referenced by call_compare_using_files().

148 def guess_blacklists(samples,ver1,ver2,hlt):
149  """Build a blacklist for each sample accordind to a set of rules
150  """
151  blacklists={}
152  for sample in samples:
153  blacklists[sample]="FED@1,AlcaBeamMonitor@1,HLT@1,AlCaReco@1"
154 
155  # HLT
156  if hlt: #HLT
157  blacklists[sample]+=",AlCaEcalPi0@2"
158  if not search("2010+|2011+|2012+|2015+",ver1):
159  print "We are treating MC files for the HLT"
160  for pattern,blist in definitions.hlt_mc_pattern_blist_pairs:
161  blacklists[sample]=add_to_blacklist(blacklists[sample],pattern,sample,blist)
162  else:
163  print "We are treating Data files for the HLT"
164  # at the moment it does not make sense since hlt is ran already
165 
166  else: #RECO
167  #Monte Carlo
168  if not search("2010+|2011+|2012+",ver1):
169  print "We are treating MC files"
170 
171  for pattern,blist in definitions.mc_pattern_blist_pairs:
172  blacklists[sample]=add_to_blacklist(blacklists[sample],pattern,sample,blist)
173 # print "MC RECO"
174  #print blacklists[sample]
175 
176  # Data
177  else:
178  print "We are treating Data files:"
179  blacklists[sample]+=",By__Lumi__Section@-1,AlCaReco@1"
180  for pattern,blist in definitions.data_pattern_blist_pairs:
181  blacklists[sample]=add_to_blacklist(blacklists[sample],pattern,ver1,blist)
182 # print "DATA RECO: %s %s %s -->%s" %( ver1, pattern, blist, blacklists[sample])
183 
184 
185  return blacklists
186 
187 #-------------------------------------------------------------------------------
188 
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:314
def guess_blacklists(samples, ver1, ver2, hlt)
def add_to_blacklist(blacklist, pattern, target, blist_piece)
def ValidationMatrix.guess_params (   ref_filenames,
  test_filenames 
)

Definition at line 67 of file ValidationMatrix.py.

References list(), genParticles_cff.map, name2sample(), name2version(), cond::persistency.search(), and ComparisonHelper.zip().

Referenced by do_comparisons_threaded().

67 def guess_params(ref_filenames,test_filenames):
68 
69  if len(ref_filenames)*len(test_filenames)==0:
70  print "Empty reference and test filenames lists!"
71  return [],"",""
72 
73  samples=[]
74  ref_versions=[]
75  test_versions=[]
76 
77  for ref, test in zip(map(os.path.basename,ref_filenames),map(os.path.basename,test_filenames)):
78 
79  ref_sample=name2sample(ref)
80  ref_version=name2version(ref)
81  test_sample=name2sample(test)
82  test_version=name2version(test)
83 
84  print " ## sample 1: %s vs sample 2: %s"%(ref_sample, test_sample)
85 
86  if ref_sample!=test_sample:
87  print "Files %s and %s do not seem to be relative to the same sample." %(ref, test)
88  # exit(2)
89 
90  # Slightly modify for data
91  if search("20[01]",ref_version)!=None:
92  ref_sample+=ref_version.split("_")[-1]
93  samples.append(ref_sample)
94 
95  # append the versions
96  ref_versions.append(ref_version)
97  test_versions.append(test_version)
98 
99  # Check if ref and test versions are always the same.
100  ref_versions=list(set(ref_versions))
101  test_versions=list(set(test_versions))
102 
103  #for versions in ref_versions,test_versions:
104  #if len(versions)!=1:
105  #print "More than one kind of CMSSW version selected (%s)" %versions
106  #exit(2)
107 
108  cmssw_version1=ref_versions[0]
109  cmssw_version2=test_versions[0]
110 
111  return samples,cmssw_version1,cmssw_version2
112 
113 
114 #-------------------------------------------------------------------------------
115 
def guess_params(ref_filenames, test_filenames)
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:314
def name2sample(filename)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def name2version(filename)
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
def ValidationMatrix.name2globaltag (   filename)

Definition at line 61 of file ValidationMatrix.py.

References split.

Referenced by call_compare_using_files().

61 def name2globaltag(filename):
62  namebase = os.path.basename(filename)
63  return namebase.split("__")[2].split("-")[1] #returns GT from file basename
64 
65 #-------------------------------------------------------------------------------
66 
def name2globaltag(filename)
double split
Definition: MVATrainer.cc:139
def ValidationMatrix.name2run (   filename)

Definition at line 49 of file ValidationMatrix.py.

References split.

Referenced by name2runskim().

49 def name2run(filename):
50  namebase=os.path.basename(filename)
51  return namebase.split("__")[0].split("_")[2]
52 
def name2run(filename)
double split
Definition: MVATrainer.cc:139
def ValidationMatrix.name2runskim (   filename)

Definition at line 53 of file ValidationMatrix.py.

References name2run(), name2version(), and split.

53 def name2runskim(filename):
54  run=name2run(filename)
55  skim=name2version(filename).split("_")[-1]
56  # remove skim version
57  if "-v" in skim:
58  skim = skim[:skim.rfind('-v')]
59  return "%s_%s"%(run,skim)
60 
def name2run(filename)
def name2version(filename)
def name2runskim(filename)
double split
Definition: MVATrainer.cc:139
def ValidationMatrix.name2sample (   filename)

Definition at line 41 of file ValidationMatrix.py.

Referenced by guess_params().

41 def name2sample(filename):
42  namebase=os.path.basename(filename)
43  return namebase.split("__")[1]
44 
def name2sample(filename)
def ValidationMatrix.name2version (   filename)

Definition at line 45 of file ValidationMatrix.py.

Referenced by call_compare_using_files(), guess_params(), and name2runskim().

45 def name2version(filename):
46  namebase=os.path.basename(filename)
47  return namebase.split("__")[2]
48 
def name2version(filename)

Variable Documentation

ValidationMatrix.action

—HASHING—##

– USE CSS files in web access, for stand-alone usage –##

–Blacklist File –##

Definition at line 464 of file ValidationMatrix.py.

ValidationMatrix.all_samples

Definition at line 449 of file ValidationMatrix.py.

ValidationMatrix.args

Definition at line 553 of file ValidationMatrix.py.

ValidationMatrix.argv

Definition at line 23 of file ValidationMatrix.py.

ValidationMatrix.default

Definition at line 466 of file ValidationMatrix.py.

ValidationMatrix.dest

Definition at line 465 of file ValidationMatrix.py.

ValidationMatrix.help

Definition at line 467 of file ValidationMatrix.py.

ValidationMatrix.hlt
ValidationMatrix.in_dir

Definition at line 452 of file ValidationMatrix.py.

ValidationMatrix.n_processes

Definition at line 450 of file ValidationMatrix.py.

ValidationMatrix.n_threads

Definition at line 453 of file ValidationMatrix.py.

ValidationMatrix.options

Definition at line 553 of file ValidationMatrix.py.

ValidationMatrix.out_dir

Definition at line 451 of file ValidationMatrix.py.

Referenced by HtrXmlPattern.HtrXmlPattern().

ValidationMatrix.parser

Definition at line 461 of file ValidationMatrix.py.

ValidationMatrix.ref_samples

Definition at line 447 of file ValidationMatrix.py.

ValidationMatrix.run

Definition at line 454 of file ValidationMatrix.py.

ValidationMatrix.stat_test

Definition at line 455 of file ValidationMatrix.py.

ValidationMatrix.test_samples

Definition at line 448 of file ValidationMatrix.py.

ValidationMatrix.test_threshold

Definition at line 456 of file ValidationMatrix.py.

ValidationMatrix.usage

Definition at line 461 of file ValidationMatrix.py.