CMS 3D CMS Logo

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