CMS 3D CMS Logo

utils.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from __future__ import absolute_import
3 ################################################################################
4 # RelMon: a tool for automatic Release Comparison
5 # https://twiki.cern.ch/twiki/bin/view/CMSPublic/RelMon
6 #
7 #
8 #
9 # Danilo Piparo CERN - danilo.piparo@cern.ch
10 #
11 ################################################################################
12 
13 
14 from builtins import range
15 import array
16 import os
17 import re
18 import sys
19 from cPickle import load
20 from os.path import dirname,basename,join,isfile
21 from threading import Thread
22 from time import asctime
23 
24 theargv=sys.argv
25 sys.argv=[]
26 from ROOT import *
27 import ROOT
28 ROOT.gErrorIgnoreLevel=1001
29 ROOT.gROOT.SetBatch(True)
30 sys.argv=theargv
31 
32 from urllib2 import Request,build_opener,urlopen
33 
34 if "RELMON_SA" in os.environ:
35  from .definitions import *
36  from .authentication import X509CertOpen
37  from .utils import __file__ as this_module_name
38 else:
39  from Utilities.RelMon.definitions import *
40  from Utilities.RelMon.authentication import X509CertOpen
41  from Utilities.RelMon.utils import __file__ as this_module_name
42 
43 #ROOT.gErrorIgnoreLevel=1001
44 
45 
46 _log_level=10
47 def logger(msg_level,message):
48  if msg_level>=_log_level:
49  print("[%s] %s" %(asctime(),message))
50 
51 #-------------------------------------------------------------------------------
52 def setTDRStyle():
53  this_dir=dirname(this_module_name)
54  this_dir_one_up=this_dir[:this_dir.rfind("/")+1]
55  #this_dir_two_up=this_dir_one_up[:this_dir_one_up.rfind("/")+1]
56  style_file=''
57  if "RELMON_SA" in os.environ:
58  style_file=this_dir_one_up+"data/tdrstyle_mod.C"
59  else:
60  style_file="%s/src/Utilities/RelMon/data/tdrstyle_mod.C"%(os.environ["CMSSW_BASE"])
61  try:
62  gROOT.ProcessLine(".L %s" %style_file)
63  gROOT.ProcessLine("setTDRStyle()")
64  except:
65  "Print could not set the TDR style. File %s not found?" %style_file
66 
67 
68 #-------------------------------------------------------------------------------
69 def literal2root (literal,rootType):
70  bitsarray = array.array('B')
71  bitsarray.fromstring(literal.decode('hex'))
72 
73  tbuffer=0
74  try:
75  tbuffer = TBufferFile(TBufferFile.kRead, len(bitsarray), bitsarray, False,0)
76  except:
77  print("could not transform to object array:")
78  print([ i for i in bitsarray ])
79 
80  # replace a couple of shortcuts with the real root class name
81  if rootType == 'TPROF':
82  rootType = 'TProfile'
83  if rootType == 'TPROF2D':
84  rootType = 'TProfile2D'
85 
86  root_class=eval(rootType+'.Class()')
87 
88  return tbuffer.ReadObject(root_class)
89 
90 #-------------------------------------------------------------------------------
91 
92 def getNbins(h):
93  """
94  To be used in loops on bin number with range()
95  For each dimension there are GetNbinsX()+2 bins including underflow
96  and overflow, and range() loops starts from 0. So the total number
97  of bins as upper limit of a range() loop already includes the next
98  to last value needed.
99  """
100  biny=h.GetNbinsY()
101  if biny>1: biny+=2
102  binz=h.GetNbinsZ()
103  if binz>1:binz+=2
104  return (h.GetNbinsX()+2)*(biny)*(binz)
105 
106 #-------------------------------------------------------------------------------
107 
108 
110  def __init__(self,threshold):
111  self.name=""
112  self.h1=None
113  self.h2=None
114  self.threshold=float(threshold)
115  self.rank=-1
116  self.is_init=False
117 
118  def set_operands(self,h1,h2):
119  self.h1=h1
120  self.h2=h2
121 
122  def get_rank(self):
123  if not self.is_init:
124  if self.rank < 0:
125  type1=type(self.h1)
126  type2=type(self.h2)
127  if (type1 != type2):
128  logger(1,"*** ERROR: object types in comparison don't match: %s!=%s" %(type1,type2))
129  self.rank=test_codes["DIFF_TYPES"]
130  elif not self.h2.InheritsFrom("TH1"):
131  logger(1,"*** ERROR: object type is not histogram but a %s" %(type1))
132  self.rank=test_codes["NO_HIST"]
133  # if histos are empty
134  #elif self.h1.InheritsFrom("TH2") and not "BinToBin" in self.name:
135  ## 2D!
136  #return test_codes["2D"]
137  else:
138  is_empty1=is_empty(self.h1)
139  is_empty2=is_empty(self.h2)
140  are_empty=is_empty1 and is_empty2
141  one_empty=is_empty1 or is_empty2
142 
143  Nbins1= getNbins(self.h1)
144  Nbins2= getNbins(self.h2)
145 
146  if are_empty:
147  #return -103
148  # Conversation with JeanRoch and David 5 April
149  return 1
150  elif one_empty:
151  # Due conversation with Giovanni on 2015-09-10
152  return 0
153 
154  # if histos have different number of bins
155  if Nbins1!=Nbins2:
156  return test_codes["DIFF_BIN"]
157 
158  self.rank=self.do_test()
159  self.is_init=True
160  return self.rank
161 
162  def get_status(self):
163  status = SUCCESS
164  if self.get_rank()<0:
165  status=NULL
166  logger(0,"+++ Test %s FAILED: rank is %s and threshold is %s ==> %s" %(self.name, self.rank, self.threshold, status))
167  elif self.get_rank() < self.threshold:
168  status=FAIL
169  logger(0,"+++ Test %s: rank is %s and threshold is %s ==> %s" %(self.name, self.rank, self.threshold, status))
170  return status
171 
172  def do_test(self):
173  pass
174 
175 #-------------------------------------------------------------------------------
176 
177 def is_empty(h):
178  for i in range(0,getNbins(h)):
179  if h.GetBinContent(i)!=0: return False
180  return True
181  #return h.GetSumOfWeights()==0
182 
183 #-------------------------------------------------------------------------------
184 
185 def is_sparse(h):
186  filled_bins=0.
187  nbins=h.GetNbinsX()
188  for ibin in range(0,nbins+2):
189  if h.GetBinContent(ibin)>0:
190  filled_bins+=1
191  #print "%s %s --> %s" %(filled_bins,nbins,filled_bins/nbins)
192  if filled_bins/nbins < .5:
193  return True
194  else:
195  return False
196 
197 #-------------------------------------------------------------------------------
198 
200  def __init__(self, threshold):
201  StatisticalTest.__init__(self,threshold)
202  self.name="KS"
203 
204  def do_test(self):
205 
206  # Calculate errors if not there...
207  for h in self.h1,self.h2:
208  w2s=h.GetSumw2()
209  if w2s.GetSize()==0:
210  h.Sumw2()
211 
212  ## If errors are 0:
213  #zero_errors=True
214  #for h in self.h1,self.h2:
215  #for ibin in xrange(Nbins1):
216  #if h.GetBinError(ibin+1) >0:
217  #zero_errors=False
218  #break
219  #if zero_errors:
220  #return test_codes["ZERO_ERR"]
221 
222  return self.h1.KolmogorovTest(self.h2)
223 
224 #-------------------------------------------------------------------------------
225 import array
226 def profile2histo(profile):
227  if not profile.InheritsFrom("TH1"):
228  return profile
229 
230  bin_low_edges=[]
231  n_bins=profile.GetNbinsX()
232 
233  for ibin in range(1,n_bins+2):
234  bin_low_edges.append(profile.GetBinLowEdge(ibin))
235  bin_low_edges=array.array('f',bin_low_edges)
236  histo=TH1F(profile.GetName(),profile.GetTitle(),n_bins,bin_low_edges)
237  for ibin in range(0,n_bins+2):
238  histo.SetBinContent(ibin,profile.GetBinContent(ibin))
239  histo.SetBinError(ibin,profile.GetBinError(ibin))
240 
241  return histo
242 #-------------------------------------------------------------------------------
243 
245  def __init__(self, threshold):
246  StatisticalTest.__init__(self,threshold)
247  self.name="Chi2"
248 
249  def check_filled_bins(self,min_filled):
250  nbins=self.h1.GetNbinsX()
251  n_filled_l=[]
252  for h in self.h1,self.h2:
253  nfilled=0.
254  for ibin in range(0,nbins+2):
255  if h.GetBinContent(ibin)>0:
256  nfilled+=1
257  n_filled_l.append(nfilled)
258  return len([x for x in n_filled_l if x>=min_filled] )>0
259 
260  def absval(self):
261  nbins=getNbins(self.h1)
262  binc=0
263  for i in range(0,nbins):
264  for h in self.h1,self.h2:
265  binc=h.GetBinContent(i)
266  if binc<0:
267  h.SetBinContent(i,-1*binc)
268  if h.GetBinError(i)==0 and binc!=0:
269  #print "Histo ",h.GetName()," Bin:",i,"-Content:",h.GetBinContent(i)," had zero error"
270  h.SetBinContent(i,0)
271 
272  def check_histograms(self, histogram):
273  if histogram.InheritsFrom("TProfile") or (histogram.GetEntries()!=histogram.GetSumOfWeights()):
274  return 'W'
275  else:
276  return 'U'
277 
278  def do_test(self):
279  self.absval()
280  if self.check_filled_bins(3):
281  #if self.h1.InheritsFrom("TProfile") or (self.h1.GetEntries()!=self.h1.GetSumOfWeights()):
282  # chi2=self.h1.Chi2Test(self.h2,'WW')
283  # #if chi2==0: print "DEBUG",self.h1.GetName(),"Chi2 is:", chi2
284  # return chi2
285  #else:
286  # return self.h1.Chi2Test(self.h2,'UU')
287  hist1 = self.check_histograms(self.h1)
288  hist2 = self.check_histograms(self.h2)
289  if hist1 =='W' and hist2 =='W': ##in case
290  chi2 = self.h1.Chi2Test(self.h2,'WW') ## the both histograms are weighted
291  return chi2
292  elif hist1 == 'U' and hist2 == 'U':
293  chi2 = self.h1.Chi2Test(self.h2,'UU') ##the both histograms are unweighted
294  return chi2
295  elif hist1 == 'U' and hist2 == 'W':
296  chi2 = self.h1.Chi2Test(self.h2,'UW') ## 1st histogram is unweighted, 2nd weighted
297  return chi2
298  elif hist1 == 'W' and hist2 == 'U':
299  chi2 = self.h2.Chi2Test(self.h1,'UW') ## 1 is wieghted, 2nd unweigthed. so flip order to make a UW comparison
300  return chi2
301  else:
302  return 1
303  #return test_codes["FEW_BINS"]
304 
305 #-------------------------------------------------------------------------------
306 
308  """The bin to bin comparison builds a fake pvalue. It is 0 if the number of
309  bins is different. It is % of corresponding bins otherwhise.
310  A threshold of 1 is needed to require a 1 to 1 correspondance between
311  hisograms.
312  """
313  def __init__(self, threshold=1):
314  StatisticalTest.__init__(self, threshold)
315  self.name='BinToBin'
316  self.epsilon= 0.000001
317 
319  if self.h1.GetNbinsX() != self.h2.GetNbinsX() \
320  or self.h1.GetNbinsY() != self.h2.GetNbinsY() \
321  or self.h1.GetNbinsZ() != self.h2.GetNbinsZ() \
322  or abs(self.h1.GetXaxis().GetXmin() - self.h2.GetXaxis().GetXmin()) >self.epsilon \
323  or abs(self.h1.GetYaxis().GetXmin() - self.h2.GetYaxis().GetXmin()) >self.epsilon \
324  or abs(self.h1.GetZaxis().GetXmin() - self.h2.GetZaxis().GetXmin()) >self.epsilon \
325  or abs(self.h1.GetXaxis().GetXmax() - self.h2.GetXaxis().GetXmax()) >self.epsilon \
326  or abs(self.h1.GetYaxis().GetXmax() - self.h2.GetYaxis().GetXmax()) >self.epsilon \
327  or abs(self.h1.GetZaxis().GetXmax() - self.h2.GetZaxis().GetXmax()) >self.epsilon:
328  return False
329  return True
330 
331  def do_test(self):
332  # fist check that binning matches
333  if not self.checkBinningMatches():
334  return test_codes["DIFF_BIN"]
335  # then do the real check
336  equal = 1
337  nbins = getNbins(self.h1)
338  n_ok_bins=0.0
339  for ibin in range(0, nbins):
340  h1bin=self.h1.GetBinContent(ibin)
341  h2bin=self.h2.GetBinContent(ibin)
342  bindiff=h1bin-h2bin
343 
344  binavg=.5*(h1bin+h2bin)
345 
346  if binavg==0 or abs(bindiff) < self.epsilon:
347  n_ok_bins+=1
348  #print("Bin %ibin: bindiff %s" %(ibin,bindiff))
349  else:
350  print("Bin %ibin: bindiff %s" %(ibin,bindiff))
351 
352  #if abs(bindiff)!=0 :
353  #print "Bin %ibin: bindiff %s" %(ibin,bindiff)
354 
355  rank=n_ok_bins/nbins
356 
357  if rank!=1:
358  print("Histogram %s differs: nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins))
359 
360  return rank
361 
362 #-------------------------------------------------------------------------------
363 
365  """The bin to bin comparison builds a fake pvalue. It is 0 if the number of
366  bins is different. It is % of corresponding bins otherwhise.
367  A threshold of 1 is needed to require a 1 to 1 correspondance between
368  hisograms.
369  """
370  def __init__(self, threshold=1):
371  StatisticalTest.__init__(self, threshold)
372  self.name='BinToBin1percent'
373  self.epsilon= 0.000001
374  self.tolerance= 0.01
375 
377  if self.h1.GetNbinsX() != self.h2.GetNbinsX() \
378  or self.h1.GetNbinsY() != self.h2.GetNbinsY() \
379  or self.h1.GetNbinsZ() != self.h2.GetNbinsZ() \
380  or abs(self.h1.GetXaxis().GetXmin() - self.h2.GetXaxis().GetXmin()) >self.epsilon \
381  or abs(self.h1.GetYaxis().GetXmin() - self.h2.GetYaxis().GetXmin()) >self.epsilon \
382  or abs(self.h1.GetZaxis().GetXmin() - self.h2.GetZaxis().GetXmin()) >self.epsilon \
383  or abs(self.h1.GetXaxis().GetXmax() - self.h2.GetXaxis().GetXmax()) >self.epsilon \
384  or abs(self.h1.GetYaxis().GetXmax() - self.h2.GetYaxis().GetXmax()) >self.epsilon \
385  or abs(self.h1.GetZaxis().GetXmax() - self.h2.GetZaxis().GetXmax()) >self.epsilon:
386  return False
387  return True
388 
389  def do_test(self):
390  # fist check that binning matches
391  if not self.checkBinningMatches():
392  return test_codes["DIFF_BIN"]
393  # then do the real check
394  equal = 1
395  nbins = getNbins(self.h1)
396  n_ok_bins=0.0
397  for ibin in range(0,nbins):
398  ibin+=1
399  h1bin=self.h1.GetBinContent(ibin)
400  h2bin=self.h2.GetBinContent(ibin)
401  bindiff=h1bin-h2bin
402 
403  binavg=.5*(h1bin+h2bin)
404 
405  if binavg==0 or 100*abs(bindiff)/binavg < self.tolerance:
406  n_ok_bins+=1
407  #print "Bin %i bin: bindiff %s" %(ibin,bindiff)
408  else:
409  print("-->Bin %i bin: bindiff %s (%s - %s )" %(ibin,bindiff,h1bin,h2bin))
410 
411  #if abs(bindiff)!=0 :
412  #print "Bin %ibin: bindiff %s" %(ibin,bindiff)
413 
414  rank=n_ok_bins/nbins
415 
416  if rank!=1:
417  print("%s nok: %s ntot: %s" %(self.h1.GetName(),n_ok_bins,nbins))
418 
419  return rank
420 #-------------------------------------------------------------------------------
421 Statistical_Tests={"KS":KS,
422  "Chi2":Chi2,
423  "BinToBin":BinToBin,
424  "BinToBin1percent":BinToBin1percent,
425  "Bin2Bin":BinToBin,
426  "b2b":BinToBin,}
427 #-------------------------------------------------------------------------------
428 
429 def ask_ok(prompt, retries=4, complaint='yes or no'):
430  while True:
431  ok = raw_input(prompt)
432  if ok in ('y', 'ye', 'yes'):
433  return True
434  if ok in ('n', 'no'):
435  return False
436  retries = retries - 1
437  if retries < 0:
438  raise IOError('refusenik user')
439  print(complaint)
440 
441 #-------------------------------------------------------------------------------
442 
443 class unpickler(Thread):
444  def __init__(self,filename):
445  Thread.__init__(self)
446  self.filename=filename
447  self.directory=""
448 
449  def run(self):
450  print("Reading directory from %s" %(self.filename))
451  ifile=open(self.filename,"rb")
452  self.directory=load(ifile)
453  ifile.close()
454 
455 #-------------------------------------------------------------------------------
456 
457 def wget(url):
458  """ Fetch the WHOLE file, not in bunches... To be optimised.
459  """
460  opener=build_opener(X509CertOpen())
461  datareq = Request(url)
462  datareq.add_header('authenticated_wget', "The ultimate wgetter")
463  bin_content=None
464  try:
465  filename=basename(url)
466  print("Checking existence of file %s on disk..."%filename)
467  if not isfile("./%s"%filename):
468  bin_content=opener.open(datareq).read()
469  else:
470  print("File %s exists, skipping.." %filename)
471  except ValueError:
472  print("Error: Unknown url %s" %url)
473 
474  if bin_content!=None:
475  ofile = open(filename, 'wb')
476  ofile.write(bin_content)
477  ofile.close()
478 
479 #-------------------------------------------------------------------------------
480 ##----------------- Make files pairs: RelValData utils --------------------
481 
483  """Returns unique relvaldata ID for a given file."""
484  run_id = re.search('R\d{9}', file)
485  run = re.search('_RelVal_([\w\d]*)-v\d__', file)
486  if not run:
487  run = re.search('GR_R_\d*_V\d*C?_([\w\d]*)-v\d__', file)
488  if run_id and run:
489  return (run_id.group(), run.group(1))
490  return None
491 
493  """Returns tuple (CMSSW release, GR_R version) for specified RelValData file."""
494  cmssw_release = re.findall('(CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?)-', file)
495  gr_r_version = re.findall('-(GR_R_\d*_V\d*\w?)(?:_RelVal)?_', file)
496  if not gr_r_version:
497  gr_r_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-(\w*)_RelVal_', file)
498  if cmssw_release and gr_r_version:
499  return (cmssw_release[0], gr_r_version[0])
500 
502  """Returns tuple (CMSSW version, run version) for specified file."""
503  cmssw_version = re.findall('DQM_V(\d*)_', file)
504  run_version = re.findall('_RelVal_[\w\d]*-v(\d)__', file)
505  if not run_version:
506  run_version = re.findall('GR_R_\d*_V\d*C?_[\w\d]*-v(\d)__', file)
507  if cmssw_version and run_version:
508  return (int(cmssw_version[0]), int(run_version[0]))
509 
511  """Returns file with maximum version at a) beggining of the file,
512  e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max."""
513  max_file = files[0]
514  max_v = get_relvaldata_version(files[0])
515  for file in files:
516  file_v = get_relvaldata_version(file)
517  if file_v[1] > max_v[1] or ((file_v[1] == max_v[1]) and (file_v[0] > max_v[0])):
518  max_file = file
519  max_v = file_v
520  return max_file
521 
522 ##------------------- Make files pairs: RelVal utils ---------------------
524  """Returns tuple (CMSSW version, run version) for specified file."""
525  cmssw_version = re.findall('DQM_V(\d*)_', file)
526  run_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-[\w\d]*_V\d*\w?(?:_[\w\d]*)?-v(\d*)__', file)
527  if cmssw_version and run_version:
528  return (int(cmssw_version[0]), int(run_version[0]))
529 
531  """Returns file with maximum version at a) beggining of the file,
532  e.g. DQM_V000M b) at the end of run, e.g. _run2012-vM. M has to be max."""
533  max_file = files[0]
534  max_v = get_relval_version(files[0])
535  for file in files:
536  file_v = get_relval_version(file)
537  if file_v[1] > max_v[1] or ((file_v[1] == max_v[1]) and (file_v[0] > max_v[0])):
538  max_file = file
539  max_v = file_v
540  return max_file
541 
543  cmssw_release = re.findall('(CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?)-', file)
544  gr_r_version = re.findall('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-([\w\d]*)_V\d*\w?(_[\w\d]*)?-v', file)
545  if cmssw_release and gr_r_version:
546  if "PU" in gr_r_version[0][0] and not "FastSim" in file:
547  __gt = re.sub('^[^_]*_', "", gr_r_version[0][0])
548  __process_string = gr_r_version[0][1]
549  return (__gt, __process_string)
550  elif "PU" in gr_r_version[0][0] and "FastSim" in file: #a check for FastSimPU samples
551  return (cmssw_release[0], "PU_") #with possibly different GT's
552  return (cmssw_release[0], gr_r_version[0])
553 
554 def get_relval_id(file):
555  """Returns unique relval ID (dataset name) for a given file."""
556  dataset_name = re.findall('R\d{9}__([\w\D]*)__CMSSW_', file)
557  __process_string = re.search('CMSSW_\d*_\d*_\d*(?:_[\w\d]*)?-([\w\d]*)_V\d*\w?(_[\w\d]*)?-v', file)
558  _ps = ""
559  if __process_string:
560  if "PU" in __process_string.group(1) and not "FastSim" in file:
561  _ps = re.search('^[^_]*_', __process_string.group(1)).group()
562  elif "PU" in __process_string.group(1) and "FastSim" in file:
563  return dataset_name[0]+"_", _ps ##some testing is needed
564  return dataset_name[0], _ps
565 
566 ##------------------------- Make files pairs --------------------------
567 def is_relvaldata(files):
568  is_relvaldata_re = re.compile('_RelVal_')
569  return any([is_relvaldata_re.search(filename) for filename in files])
570 
571 def make_files_pairs(files, verbose=True):
572  ## Select functions to use
573  if is_relvaldata(files):
574  is_relval_data = True
575  get_cmssw_version = get_relvaldata_cmssw_version
576  get_id = get_relvaldata_id
577  get_max_version = get_relvaldata_max_version
578  # print 'Pairing Data RelVal files.'
579  else:
580  is_relval_data = False
581  get_cmssw_version = get_relval_cmssw_version
582  get_id = get_relval_id
583  get_max_version = get_relval_max_version
584  # print 'Pairing Monte Carlo RelVal files.'
585 
586  ## Divide files into groups
587  versions_files = dict()
588  for file in files:
589  version = get_cmssw_version(file)
590  if version in versions_files:
591  versions_files[version].append(file)
592  else:
593  versions_files[version] = [file]
594 
595  ## Print the division into groups
596  if verbose:
597  print('\nFound versions:')
598  for version in versions_files:
599  print('%s: %d files' % (str(version), len(versions_files[version])))
600 
601  if len(versions_files) <= 1:
602  print('\nFound too little versions, there is nothing to pair. Exiting...\n')
603  exit()
604 
605  ## Select two biggest groups.
606  versions = versions_files.keys()
607  sizes = [len(value) for value in versions_files.values()]
608  v1 = versions[sizes.index(max(sizes))]
609  versions.remove(v1)
610  sizes.remove(max(sizes))
611  v2 = versions[sizes.index(max(sizes))]
612 
613  ## Print two biggest groups.
614  if verbose:
615  print('\nPairing %s (%d files) and %s (%d files)' % (str(v1),
616  len(versions_files[v1]), str(v2), len(versions_files[v2])))
617 
618  ## Pairing two versions
619  print('\nGot pairs:')
620  pairs = []
621  for unique_id in set([get_id(file) for file in versions_files[v1]]):
622  if is_relval_data:
623  dataset_re = re.compile(unique_id[0]+'_')
624  run_re = re.compile(unique_id[1])
625  c1_files = [file for file in versions_files[v1] if dataset_re.search(file) and run_re.search(file)]
626  c2_files = [file for file in versions_files[v2] if dataset_re.search(file) and run_re.search(file)]
627  else:
628  dataset_re = re.compile(unique_id[0]+'_')
629  ps_re = re.compile(unique_id[1])
630  ##compile a PU re and search also for same PU
631  c1_files = [file for file in versions_files[v1] if dataset_re.search(file) and ps_re.search(file)]
632  c2_files = [file for file in versions_files[v2] if dataset_re.search(file) and ps_re.search(file)]
633 
634  if len(c1_files) > 0 and len(c2_files) > 0:
635  first_file = get_max_version(c1_files)
636  second_file = get_max_version(c2_files)
637  print('%s\n%s\n' % (first_file, second_file))
638  pairs.extend((first_file, second_file))
639  if verbose:
640  print("Paired and got %d files.\n" % len(pairs))
641  return pairs
def wget(url)
Definition: utils.py:457
def checkBinningMatches(self)
Definition: utils.py:376
def get_status(self)
Definition: utils.py:162
def checkBinningMatches(self)
Definition: utils.py:318
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def do_test(self)
Definition: utils.py:278
def get_relvaldata_version(file)
Definition: utils.py:501
def __init__(self, threshold)
Definition: utils.py:110
def is_sparse(h)
Definition: utils.py:185
def absval(self)
Definition: utils.py:260
def get_rank(self)
Definition: utils.py:122
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def check_filled_bins(self, min_filled)
Definition: utils.py:249
def get_relval_version(file)
-------------—— Make files pairs: RelVal utils ---------------——
Definition: utils.py:523
def do_test(self)
Definition: utils.py:172
def ask_ok(prompt, retries=4, complaint='yes or no')
Definition: utils.py:429
def set_operands(self, h1, h2)
Definition: utils.py:118
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def profile2histo(profile)
Definition: utils.py:226
def __init__(self, threshold)
Definition: utils.py:245
Definition: logger.py:1
def get_relval_id(file)
Definition: utils.py:554
def __init__(self, filename)
Definition: utils.py:444
def __init__(self, threshold=1)
Definition: utils.py:313
def do_test(self)
Definition: utils.py:389
def is_relvaldata(files)
----------------------— Make files pairs -----------------------—
Definition: utils.py:567
def getNbins(h)
Definition: utils.py:92
def is_empty(h)
Definition: utils.py:177
def make_files_pairs(files, verbose=True)
Definition: utils.py:571
def load(fileName)
Definition: svgfig.py:547
rank
2D! return test_codes["2D"]
Definition: utils.py:115
def check_histograms(self, histogram)
Definition: utils.py:272
def setTDRStyle()
Definition: utils.py:52
def run(self)
Definition: utils.py:449
def get_relvaldata_id(file)
-----------—— Make files pairs: RelValData utils --------------——
Definition: utils.py:482
def __init__(self, threshold)
Definition: utils.py:200
def __init__(self, threshold=1)
Definition: utils.py:370
def get_relval_max_version(files)
Definition: utils.py:530
#define str(s)
def literal2root(literal, rootType)
Definition: utils.py:69
def do_test(self)
Definition: utils.py:331
def logger(msg_level, message)
Definition: utils.py:47
def do_test(self)
Definition: utils.py:204
def get_relvaldata_cmssw_version(file)
Definition: utils.py:492
def get_relval_cmssw_version(file)
Definition: utils.py:542
def get_relvaldata_max_version(files)
Definition: utils.py:510