CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions
LumiList.LumiList Class Reference
Inheritance diagram for LumiList.LumiList:

Public Member Functions

def __add__
 
def __and__
 
def __contains__
 
def __init__
 
def __len__
 
def __or__
 
def __str__
 
def __sub__
 
def contains
 
def filterLumis
 
def getCMSSWString
 
def getCompactList
 
def getDuplicates
 
def getLumis
 
def getRuns
 
def getVLuminosityBlockRange
 
def removeRuns
 
def selectRuns
 
def writeJSON
 

Public Attributes

 compactList
 
 duplicates
 
 filename
 
 url
 

Private Member Functions

def _getLumiParts
 

Detailed Description

Deal with lists of lumis in several different forms:
Compact list:
    {
    '1': [[1, 33], [35, 35], [37, 47], [49, 75], [77, 130], [133, 136]],
    '2':[[1,45],[50,80]]
    }
    where the first key is the run number, subsequent pairs are
    ranges of lumis within that run that are desired
Runs and lumis:
    {
    '1': [1,2,3,4,6,7,8,9,10],
    '2': [1,4,5,20]
    }
    where the first key is the run number and the list is a list of
    individual lumi sections. This form also takes a list of these objects
    which can be much faster than LumiList += LumiList
Run  lumi pairs:
    [[1,1], [1,2],[1,4], [2,1], [2,5], [1,10]]
    where each pair in the list is an individual run&lumi
CMSSW representation:
    '1:1-1:33,1:35,1:37-1:47,2:1-2:45,2:50-2:80'
    The string used by CMSSW in lumisToProcess or lumisToSkip
    is a subset of the compactList example above

Definition at line 18 of file LumiList.py.

Constructor & Destructor Documentation

def LumiList.LumiList.__init__ (   self,
  filename = None,
  lumis = None,
  runsAndLumis = None,
  runs = None,
  compactList = None,
  url = None 
)
Constructor takes filename (JSON), a list of run/lumi pairs,
or a dict with run #'s as the keys and a list of lumis as the values, or just a list of runs

Definition at line 46 of file LumiList.py.

46 
47  def __init__(self, filename = None, lumis = None, runsAndLumis = None, runs = None, compactList = None, url = None):
48  """
49  Constructor takes filename (JSON), a list of run/lumi pairs,
50  or a dict with run #'s as the keys and a list of lumis as the values, or just a list of runs
51  """
52  self.compactList = {}
53  self.duplicates = {}
54  if filename:
55  self.filename = filename
56  jsonFile = open(self.filename,'r')
57  self.compactList = json.load(jsonFile)
58  elif url:
59  self.url = url
60  jsonFile = urllib2.urlopen(url)
61  self.compactList = json.load(jsonFile)
62  elif lumis:
63  runsAndLumis = {}
64  for (run, lumi) in lumis:
65  run = str(run)
66  if run not in runsAndLumis:
67  runsAndLumis[run] = []
68  runsAndLumis[run].append(lumi)
69 
70  if isinstance(runsAndLumis, list):
71  queued = {}
72  for runLumiList in runsAndLumis:
73  for run, lumis in runLumiList.items():
74  queued.setdefault(run, []).extend(lumis)
75  runsAndLumis = queued
76 
77  if runsAndLumis:
78  for run in runsAndLumis.keys():
79  runString = str(run)
80  lastLumi = -1000
81  lumiList = runsAndLumis[run]
82  if lumiList:
83  self.compactList[runString] = []
84  self.duplicates[runString] = []
85  for lumi in sorted(lumiList):
86  if lumi == lastLumi:
87  self.duplicates[runString].append(lumi)
88  elif lumi != lastLumi + 1: # Break in lumi sequence
89  self.compactList[runString].append([lumi, lumi])
90  else:
91  nRange = len(self.compactList[runString])
92  self.compactList[runString][nRange-1][1] = lumi
93  lastLumi = lumi
94  if runs:
95  for run in runs:
96  runString = str(run)
97  self.compactList[runString] = [[1, 0xFFFFFFF]]
98 
99  if compactList:
100  for run in compactList.keys():
101  runString = str(run)
102  if compactList[run]:
103  self.compactList[runString] = compactList[run]
104 
105  # Compact each run and make it unique
106 
107  for run in self.compactList.keys():
108  newLumis = []
109  for lumi in sorted(self.compactList[run]):
110  # If the next lumi starts inside or just after the last just change the endpoint of the first
111  if newLumis and newLumis[-1][0] <= lumi[0] <= newLumis[-1][1] + 1:
112  newLumis[-1][1] = max(newLumis[-1][1], lumi[1])
113  else:
114  newLumis.append(lumi)
115  self.compactList[run] = newLumis
boost::dynamic_bitset append(const boost::dynamic_bitset<> &bs1, const boost::dynamic_bitset<> &bs2)
this method takes two bitsets bs1 and bs2 and returns result of bs2 appended to the end of bs1 ...

Member Function Documentation

def LumiList.LumiList.__add__ (   self,
  other 
)

Definition at line 192 of file LumiList.py.

References GlobalTag.GlobalTag.__or__(), SequenceTypes._BooleanLogicSequenceable.__or__(), and LumiList.LumiList.__or__().

Referenced by counter.Counter.__iadd__(), and average.Average.__iadd__().

193  def __add__(self, other):
194  # + is the same as |
195  return self.__or__(other)
def LumiList.LumiList.__and__ (   self,
  other 
)

Definition at line 144 of file LumiList.py.

References LumiList.LumiList.compactList.

145  def __and__(self, other): # Things in both
146  result = {}
147  aruns = set(self.compactList.keys())
148  bruns = set(other.compactList.keys())
149  for run in aruns & bruns:
150  lumiList = [] # List for this run
151  unique = [] # List for this run
152  for alumi in self.compactList[run]:
153  for blumi in other.compactList[run]:
154  if blumi[0] <= alumi[0] and blumi[1] >= alumi[1]: # blumi has all of alumi
155  lumiList.append(alumi)
156  if blumi[0] > alumi[0] and blumi[1] < alumi[1]: # blumi is part of alumi
157  lumiList.append(blumi)
158  elif blumi[0] <= alumi[0] and blumi[1] < alumi[1] and blumi[1] >= alumi[0]: # overlaps start
159  lumiList.append([alumi[0], blumi[1]])
160  elif blumi[0] > alumi[0] and blumi[1] >= alumi[1] and blumi[0] <= alumi[1]: # overlaps end
161  lumiList.append([blumi[0], alumi[1]])
162 
163 
164  if lumiList:
165  unique = [lumiList[0]]
166  for pair in lumiList[1:]:
167  if pair[0] == unique[-1][1]+1:
168  unique[-1][1] = copy.deepcopy(pair[1])
169  else:
170  unique.append(copy.deepcopy(pair))
171 
172  result[run] = unique
173  return LumiList(compactList = result)
174 
def LumiList.LumiList.__contains__ (   self,
  runTuple 
)

Definition at line 373 of file LumiList.py.

References edm::Association< C >.contains(), edm::helper::IndexRangeAssociation.contains(), FWGeometry.contains(), edm::ValueMap< T >.contains(), edm::MultiAssociation< C >.contains(), PhysicsTools::Calibration::MVAComputerContainer.contains(), and LumiList.LumiList.contains().

374  def __contains__ (self, runTuple):
375  return self.contains (runTuple)
376 
377 
378 
379 '''
380 # Unit test code
381 import unittest
382 import FWCore.ParameterSet.Config as cms
383 
384 class LumiListTest(unittest.TestCase):
385  """
386  _LumiListTest_
387 
388  """
389 
390  def testRead(self):
391  """
392  Test reading from JSON
393  """
394  exString = "1:1-1:33,1:35,1:37-1:47,2:49-2:75,2:77-2:130,2:133-2:136"
395  exDict = {'1': [[1, 33], [35, 35], [37, 47]],
396  '2': [[49, 75], [77, 130], [133, 136]]}
397  exVLBR = cms.VLuminosityBlockRange('1:1-1:33', '1:35', '1:37-1:47', '2:49-2:75', '2:77-2:130', '2:133-2:136')
398 
399  jsonList = LumiList(filename = 'lumiTest.json')
400  lumiString = jsonList.getCMSSWString()
401  lumiList = jsonList.getCompactList()
402  lumiVLBR = jsonList.getVLuminosityBlockRange(True)
403 
404  self.assertTrue(lumiString == exString)
405  self.assertTrue(lumiList == exDict)
406  self.assertTrue(lumiVLBR == exVLBR)
407 
408  def testList(self):
409  """
410  Test constucting from list of pairs
411  """
412 
413  listLs1 = range(1, 34) + [35] + range(37, 48)
414  listLs2 = range(49, 76) + range(77, 131) + range(133, 137)
415  lumis = zip([1]*100, listLs1) + zip([2]*100, listLs2)
416 
417  jsonLister = LumiList(filename = 'lumiTest.json')
418  jsonString = jsonLister.getCMSSWString()
419  jsonList = jsonLister.getCompactList()
420 
421  pairLister = LumiList(lumis = lumis)
422  pairString = pairLister.getCMSSWString()
423  pairList = pairLister.getCompactList()
424 
425  self.assertTrue(jsonString == pairString)
426  self.assertTrue(jsonList == pairList)
427 
428 
429  def testRuns(self):
430  """
431  Test constucting from run and list of lumis
432  """
433  runsAndLumis = {
434  1: range(1, 34) + [35] + range(37, 48),
435  2: range(49, 76) + range(77, 131) + range(133, 137)
436  }
437  runsAndLumis2 = {
438  '1': range(1, 34) + [35] + range(37, 48),
439  '2': range(49, 76) + range(77, 131) + range(133, 137)
440  }
441  blank = {
442  '1': [],
443  '2': []
444  }
445 
446  jsonLister = LumiList(filename = 'lumiTest.json')
447  jsonString = jsonLister.getCMSSWString()
448  jsonList = jsonLister.getCompactList()
449 
450  runLister = LumiList(runsAndLumis = runsAndLumis)
451  runString = runLister.getCMSSWString()
452  runList = runLister.getCompactList()
453 
454  runLister2 = LumiList(runsAndLumis = runsAndLumis2)
455  runList2 = runLister2.getCompactList()
456 
457  runLister3 = LumiList(runsAndLumis = blank)
458 
459 
460  self.assertTrue(jsonString == runString)
461  self.assertTrue(jsonList == runList)
462  self.assertTrue(runList2 == runList)
463  self.assertTrue(len(runLister3) == 0)
464 
465  def testFilter(self):
466  """
467  Test filtering of a list of lumis
468  """
469  runsAndLumis = {
470  1: range(1, 34) + [35] + range(37, 48),
471  2: range(49, 76) + range(77, 131) + range(133, 137)
472  }
473 
474  completeList = zip([1]*150, range(1, 150)) + \
475  zip([2]*150, range(1, 150)) + \
476  zip([3]*150, range(1, 150))
477 
478  smallList = zip([1]*50, range(1, 10)) + zip([2]*50, range(50, 70))
479  overlapList = zip([1]*150, range(30, 40)) + \
480  zip([2]*150, range(60, 80))
481  overlapRes = zip([1]*9, range(30, 34)) + [(1, 35)] + \
482  zip([1]*9, range(37, 40)) + \
483  zip([2]*30, range(60, 76)) + \
484  zip([2]*9, range(77, 80))
485 
486  runLister = LumiList(runsAndLumis = runsAndLumis)
487 
488  # Test a list to be filtered which is a superset of constructed list
489  filterComplete = runLister.filterLumis(completeList)
490  # Test a list to be filtered which is a subset of constructed list
491  filterSmall = runLister.filterLumis(smallList)
492  # Test a list to be filtered which is neither
493  filterOverlap = runLister.filterLumis(overlapList)
494 
495  self.assertTrue(filterComplete == runLister.getLumis())
496  self.assertTrue(filterSmall == smallList)
497  self.assertTrue(filterOverlap == overlapRes)
498 
499  def testDuplicates(self):
500  """
501  Test a list with lots of duplicates
502  """
503  result = zip([1]*100, range(1, 34) + range(37, 48))
504  lumis = zip([1]*100, range(1, 34) + range(37, 48) + range(5, 25))
505 
506  lister = LumiList(lumis = lumis)
507  self.assertTrue(lister.getLumis() == result)
508 
509  def testNull(self):
510  """
511  Test a null list
512  """
513 
514  runLister = LumiList(lumis = None)
515 
516  self.assertTrue(runLister.getCMSSWString() == '')
517  self.assertTrue(runLister.getLumis() == [])
518  self.assertTrue(runLister.getCompactList() == {})
519 
520  def testSubtract(self):
521  """
522  a-b for lots of cases
523  """
524 
525  alumis = {'1' : range(2,20) + range(31,39) + range(45,49),
526  '2' : range(6,20) + range (30,40),
527  '3' : range(10,20) + range (30,40) + range(50,60),
528  }
529  blumis = {'1' : range(1,6) + range(12,13) + range(16,30) + range(40,50) + range(33,36),
530  '2' : range(10,35),
531  '3' : range(10,15) + range(35,40) + range(45,51) + range(59,70),
532  }
533  clumis = {'1' : range(1,6) + range(12,13) + range(16,30) + range(40,50) + range(33,36),
534  '2' : range(10,35),
535  }
536  result = {'1' : range(6,12) + range(13,16) + range(31,33) + range(36,39),
537  '2' : range(6,10) + range(35,40),
538  '3' : range(15,20) + range(30,35) + range(51,59),
539  }
540  result2 = {'1' : range(6,12) + range(13,16) + range(31,33) + range(36,39),
541  '2' : range(6,10) + range(35,40),
542  '3' : range(10,20) + range (30,40) + range(50,60),
543  }
544  a = LumiList(runsAndLumis = alumis)
545  b = LumiList(runsAndLumis = blumis)
546  c = LumiList(runsAndLumis = clumis)
547  r = LumiList(runsAndLumis = result)
548  r2 = LumiList(runsAndLumis = result2)
549 
550  self.assertTrue((a-b).getCMSSWString() == r.getCMSSWString())
551  self.assertTrue((a-b).getCMSSWString() != (b-a).getCMSSWString())
552  # Test where c is missing runs from a
553  self.assertTrue((a-c).getCMSSWString() == r2.getCMSSWString())
554  self.assertTrue((a-c).getCMSSWString() != (c-a).getCMSSWString())
555  # Test empty lists
556  self.assertTrue(str(a-a) == '{}')
557  self.assertTrue(len(a-a) == 0)
558 
559  def testOr(self):
560  """
561  a|b for lots of cases
562  """
563 
564  alumis = {'1' : range(2,20) + range(31,39) + range(45,49),
565  '2' : range(6,20) + range (30,40),
566  '3' : range(10,20) + range (30,40) + range(50,60),
567  }
568  blumis = {'1' : range(1,6) + range(12,13) + range(16,30) + range(40,50) + range(39,80),
569  '2' : range(10,35),
570  '3' : range(10,15) + range(35,40) + range(45,51) + range(59,70),
571  }
572  clumis = {'1' : range(1,6) + range(12,13) + range(16,30) + range(40,50) + range(39,80),
573  '2' : range(10,35),
574  }
575  result = {'1' : range(2,20) + range(31,39) + range(45,49) + range(1,6) + range(12,13) + range(16,30) + range(40,50) + range(39,80),
576  '2' : range(6,20) + range (30,40) + range(10,35),
577  '3' : range(10,20) + range (30,40) + range(50,60) + range(10,15) + range(35,40) + range(45,51) + range(59,70),
578  }
579  a = LumiList(runsAndLumis = alumis)
580  b = LumiList(runsAndLumis = blumis)
581  c = LumiList(runsAndLumis = blumis)
582  r = LumiList(runsAndLumis = result)
583  self.assertTrue((a|b).getCMSSWString() == r.getCMSSWString())
584  self.assertTrue((a|b).getCMSSWString() == (b|a).getCMSSWString())
585  self.assertTrue((a|b).getCMSSWString() == (a+b).getCMSSWString())
586 
587  # Test list constuction (faster)
588 
589  multiple = [alumis, blumis, clumis]
590  easy = LumiList(runsAndLumis = multiple)
591  hard = a + b
592  hard += c
593  self.assertTrue(hard.getCMSSWString() == easy.getCMSSWString())
594 
595  def testAnd(self):
596  """
597  a&b for lots of cases
598  """
599 
600  alumis = {'1' : range(2,20) + range(31,39) + range(45,49),
601  '2' : range(6,20) + range (30,40),
602  '3' : range(10,20) + range (30,40) + range(50,60),
603  '4' : range(1,100),
604  }
605  blumis = {'1' : range(1,6) + range(12,13) + range(16,25) + range(25,40) + range(40,50) + range(33,36),
606  '2' : range(10,35),
607  '3' : range(10,15) + range(35,40) + range(45,51) + range(59,70),
608  '5' : range(1,100),
609  }
610  result = {'1' : range(2,6) + range(12,13) + range(16,20) + range(31,39) + range(45,49),
611  '2' : range(10,20) + range(30,35),
612  '3' : range(10,15) + range(35,40) + range(50,51)+ range(59,60),
613  }
614  a = LumiList(runsAndLumis = alumis)
615  b = LumiList(runsAndLumis = blumis)
616  r = LumiList(runsAndLumis = result)
617  self.assertTrue((a&b).getCMSSWString() == r.getCMSSWString())
618  self.assertTrue((a&b).getCMSSWString() == (b&a).getCMSSWString())
619  self.assertTrue((a|b).getCMSSWString() != r.getCMSSWString())
620 
621  def testRemoveSelect(self):
622  """
623  a-b for lots of cases
624  """
625 
626  alumis = {'1' : range(2,20) + range(31,39) + range(45,49),
627  '2' : range(6,20) + range (30,40),
628  '3' : range(10,20) + range (30,40) + range(50,60),
629  '4' : range(10,20) + range (30,80),
630  }
631 
632  result = {'2' : range(6,20) + range (30,40),
633  '4' : range(10,20) + range (30,80),
634  }
635 
636  rem = LumiList(runsAndLumis = alumis)
637  sel = LumiList(runsAndLumis = alumis)
638  res = LumiList(runsAndLumis = result)
639 
640  rem.removeRuns([1,3])
641  sel.selectRuns([2,4])
642 
643  self.assertTrue(rem.getCMSSWString() == res.getCMSSWString())
644  self.assertTrue(sel.getCMSSWString() == res.getCMSSWString())
645  self.assertTrue(sel.getCMSSWString() == rem.getCMSSWString())
646 
647  def testURL(self):
648  URL = 'https://cms-service-dqm.web.cern.ch/cms-service-dqm/CAF/certification/Collisions12/8TeV/Reprocessing/Cert_190456-195530_8TeV_08Jun2012ReReco_Collisions12_JSON.txt'
649  ll = LumiList(url=URL)
650  self.assertTrue(len(ll) > 0)
651 
652 
653  def testWrite(self):
654  alumis = {'1' : range(2,20) + range(31,39) + range(45,49),
655  '2' : range(6,20) + range (30,40),
656  '3' : range(10,20) + range (30,40) + range(50,60),
657  '4' : range(1,100),
658  }
659  a = LumiList(runsAndLumis = alumis)
660  a.writeJSON('newFile.json')
661 
662 
663 if __name__ == '__main__':
664  jsonFile = open('lumiTest.json','w')
665  jsonFile.write('{"1": [[1, 33], [35, 35], [37, 47]], "2": [[49, 75], [77, 130], [133, 136]]}')
666  jsonFile.close()
667  unittest.main()
668 '''
669 # Test JSON file
670 
671 #{"1": [[1, 33], [35, 35], [37, 47]], "2": [[49, 75], [77, 130], [133, 136]]}
def LumiList.LumiList.__len__ (   self)
Returns number of runs in list

Definition at line 196 of file LumiList.py.

References LumiList.LumiList.compactList.

197  def __len__(self):
198  '''Returns number of runs in list'''
199  return len(self.compactList)
def LumiList.LumiList.__or__ (   self,
  other 
)

Definition at line 175 of file LumiList.py.

Referenced by LumiList.LumiList.__add__().

176  def __or__(self, other):
177  result = {}
178  aruns = self.compactList.keys()
179  bruns = other.compactList.keys()
180  runs = set(aruns + bruns)
181  for run in runs:
182  overlap = sorted(self.compactList.get(run, []) + other.compactList.get(run, []))
183  unique = [overlap[0]]
184  for pair in overlap[1:]:
185  if pair[0] >= unique[-1][0] and pair[0] <= unique[-1][1]+1 and pair[1] > unique[-1][1]:
186  unique[-1][1] = copy.deepcopy(pair[1])
187  elif pair[0] > unique[-1][1]:
188  unique.append(copy.deepcopy(pair))
189  result[run] = unique
190  return LumiList(compactList = result)
191 
def LumiList.LumiList.__str__ (   self)

Definition at line 216 of file LumiList.py.

References LumiList.LumiList.compactList.

217  def __str__ (self):
218  doubleBracketRE = re.compile (r']],')
219  return doubleBracketRE.sub (']],\n',
220  json.dumps (self.compactList,
221  sort_keys=True))
def LumiList.LumiList.__sub__ (   self,
  other 
)

Definition at line 116 of file LumiList.py.

References LumiList.LumiList.compactList.

117  def __sub__(self, other): # Things from self not in other
118  result = {}
119  for run in sorted(self.compactList.keys()):
120  alumis = sorted(self.compactList[run])
121  blumis = sorted(other.compactList.get(run, []))
122  alist = [] # verified part
123  for alumi in alumis:
124  tmplist = [alumi[0], alumi[1]] # may be part
125  for blumi in blumis:
126  if blumi[0] <= tmplist[0] and blumi[1] >= tmplist[1]: # blumi has all of alumi
127  tmplist = []
128  break # blumi is has all of alumi
129  if blumi[0] > tmplist[0] and blumi[1] < tmplist[1]: # blumi is part of alumi
130  alist.append([tmplist[0], blumi[0]-1])
131  tmplist = [blumi[1]+1, tmplist[1]]
132  elif blumi[0] <= tmplist[0] and blumi[1] < tmplist[1] and blumi[1]>=tmplist[0]: # overlaps start
133  tmplist = [blumi[1]+1, tmplist[1]]
134  elif blumi[0] > tmplist[0] and blumi[1] >= tmplist[1] and blumi[0]<=tmplist[1]: # overlaps end
135  alist.append([tmplist[0], blumi[0]-1])
136  tmplist = []
137  break
138  if tmplist:
139  alist.append(tmplist)
140  result[run] = alist
141 
142  return LumiList(compactList = result)
143 
def LumiList.LumiList._getLumiParts (   self)
private
Turn compactList into a list of the format
[ 'R1:L1', 'R2:L2-R2:L3' ] which is used by getCMSSWString and getVLuminosityBlockRange

Definition at line 259 of file LumiList.py.

References LumiList.LumiList.compactList.

Referenced by LumiList.LumiList.getCMSSWString(), and LumiList.LumiList.getVLuminosityBlockRange().

260  def _getLumiParts(self):
261  """
262  Turn compactList into a list of the format
263  [ 'R1:L1', 'R2:L2-R2:L3' ] which is used by getCMSSWString and getVLuminosityBlockRange
264  """
265 
266  parts = []
267  runs = self.compactList.keys()
268  runs.sort(key=int)
269  for run in runs:
270  lumis = self.compactList[run]
271  for lumiPair in sorted(lumis):
272  if lumiPair[0] == lumiPair[1]:
273  parts.append("%s:%s" % (run, lumiPair[0]))
274  else:
275  parts.append("%s:%s-%s:%s" %
276  (run, lumiPair[0], run, lumiPair[1]))
277  return parts
278 
def LumiList.LumiList.contains (   self,
  run,
  lumiSection = None 
)
returns true if the run, lumi section passed in is contained
in this lumiList.  Input can be either:
- a single tuple of (run, lumi),
- separate run and lumi numbers
- a single run number (returns true if any lumi sections exist)

Definition at line 338 of file LumiList.py.

References LumiList.LumiList.compactList.

Referenced by LumiList.LumiList.__contains__().

339  def contains (self, run, lumiSection = None):
340  '''
341  returns true if the run, lumi section passed in is contained
342  in this lumiList. Input can be either:
343  - a single tuple of (run, lumi),
344  - separate run and lumi numbers
345  - a single run number (returns true if any lumi sections exist)
346  '''
347  if lumiSection is None:
348  # if this is an integer or a string, see if the run exists
349  if isinstance (run, int) or isinstance (run, str):
350  return str(run) in self.compactList
351  # if we're here, then run better be a tuple or list
352  try:
353  lumiSection = run[1]
354  run = run[0]
355  except:
356  raise RuntimeError("Improper format for run '%s'" % run)
357  lumiRangeList = self.compactList.get( str(run) )
358  if not lumiRangeList:
359  # the run isn't there, so no need to look any further
360  return False
361  for lumiRange in lumiRangeList:
362  # we want to make this as found if either the lumiSection
363  # is inside the range OR if the lumi section is greater
364  # than or equal to the lower bound of the lumi range and
365  # the upper bound is 0 (which means extends to the end of
366  # the run)
367  if lumiRange[0] <= lumiSection and \
368  (0 == lumiRange[1] or lumiSection <= lumiRange[1]):
369  # got it
370  return True
371  return False
372 
def LumiList.LumiList.filterLumis (   self,
  lumiList 
)
Return a list of lumis that are in compactList.
lumilist is of the simple form
[(run1,lumi1),(run1,lumi2),(run2,lumi1)]

Definition at line 200 of file LumiList.py.

201  def filterLumis(self, lumiList):
202  """
203  Return a list of lumis that are in compactList.
204  lumilist is of the simple form
205  [(run1,lumi1),(run1,lumi2),(run2,lumi1)]
206  """
207  filteredList = []
208  for (run, lumi) in lumiList:
209  runsInLumi = self.compactList.get(str(run), [[0, -1]])
210  for (first, last) in runsInLumi:
211  if lumi >= first and lumi <= last:
212  filteredList.append((run, lumi))
213  break
214  return filteredList
215 
def LumiList.LumiList.getCMSSWString (   self)
Turn compactList into a list of the format
R1:L1,R2:L2-R2:L3 which is acceptable to CMSSW LumiBlockRange variable

Definition at line 279 of file LumiList.py.

References LumiList.LumiList._getLumiParts(), and join().

280  def getCMSSWString(self):
281  """
282  Turn compactList into a list of the format
283  R1:L1,R2:L2-R2:L3 which is acceptable to CMSSW LumiBlockRange variable
284  """
285 
286  parts = self._getLumiParts()
287  output = ','.join(parts)
288  return str(output)
289 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def LumiList.LumiList.getCompactList (   self)
Return the compact list representation

Definition at line 222 of file LumiList.py.

References LumiList.LumiList.compactList.

223  def getCompactList(self):
224  """
225  Return the compact list representation
226  """
227  return self.compactList
228 
def LumiList.LumiList.getDuplicates (   self)
Return the list of duplicates found during construction as a LumiList

Definition at line 229 of file LumiList.py.

References LumiList.LumiList.duplicates.

230  def getDuplicates(self):
231  """
232  Return the list of duplicates found during construction as a LumiList
233  """
234  return LumiList(runsAndLumis = self.duplicates)
235 
def LumiList.LumiList.getLumis (   self)
Return the list of pairs representation

Definition at line 236 of file LumiList.py.

References LumiList.LumiList.compactList.

237  def getLumis(self):
238  """
239  Return the list of pairs representation
240  """
241  theList = []
242  runs = self.compactList.keys()
243  runs.sort(key=int)
244  for run in runs:
245  lumis = self.compactList[run]
246  for lumiPair in sorted(lumis):
247  for lumi in range(lumiPair[0], lumiPair[1]+1):
248  theList.append((int(run), lumi))
249 
250  return theList
251 
def LumiList.LumiList.getRuns (   self)
return the sorted list of runs contained

Definition at line 252 of file LumiList.py.

253  def getRuns(self):
254  '''
255  return the sorted list of runs contained
256  '''
257  return sorted (self.compactList.keys())
258 
def LumiList.LumiList.getVLuminosityBlockRange (   self,
  tracked = False 
)
Turn compactList into an (optionally tracked) VLuminosityBlockRange

Definition at line 290 of file LumiList.py.

References LumiList.LumiList._getLumiParts().

291  def getVLuminosityBlockRange(self, tracked = False):
292  """
293  Turn compactList into an (optionally tracked) VLuminosityBlockRange
294  """
295 
296  import FWCore.ParameterSet.Config as cms
297  parts = self._getLumiParts()
298  if tracked:
299  return cms.VLuminosityBlockRange(parts)
300  else:
301  return cms.untracked.VLuminosityBlockRange(parts)
302 
def getVLuminosityBlockRange
Definition: LumiList.py:290
def LumiList.LumiList.removeRuns (   self,
  runList 
)
removes runs from runList from collection

Definition at line 312 of file LumiList.py.

References LumiList.LumiList.compactList.

313  def removeRuns (self, runList):
314  '''
315  removes runs from runList from collection
316  '''
317  for run in runList:
318  run = str(run)
319  if run in self.compactList:
320  del self.compactList[run]
321 
322  return
323 
def LumiList.LumiList.selectRuns (   self,
  runList 
)
Selects only runs from runList in collection

Definition at line 324 of file LumiList.py.

References LumiList.LumiList.compactList.

325  def selectRuns (self, runList):
326  '''
327  Selects only runs from runList in collection
328  '''
329  runsToDelete = []
330  for run in self.compactList.keys():
331  if int(run) not in runList and run not in runList:
332  runsToDelete.append(run)
333 
334  for run in runsToDelete:
335  del self.compactList[run]
336 
337  return
def LumiList.LumiList.writeJSON (   self,
  fileName 
)
Write out a JSON file representation of the object

Definition at line 303 of file LumiList.py.

304  def writeJSON(self, fileName):
305  """
306  Write out a JSON file representation of the object
307  """
308  jsonFile = open(fileName,'w')
309  jsonFile.write("%s\n" % self)
310  jsonFile.close()
311 

Member Data Documentation

LumiList.LumiList.compactList

Definition at line 51 of file LumiList.py.

Referenced by LumiList.LumiList.__and__(), LumiList.LumiList.__len__(), LumiList.LumiList.__str__(), LumiList.LumiList.__sub__(), LumiList.LumiList._getLumiParts(), LumiList.LumiList.contains(), LumiList.LumiList.getCompactList(), LumiList.LumiList.getLumis(), LumiList.LumiList.removeRuns(), and LumiList.LumiList.selectRuns().

LumiList.LumiList.duplicates

Definition at line 52 of file LumiList.py.

Referenced by LumiList.LumiList.getDuplicates(), edmIntegrityCheck.IntegrityCheck.report(), edmIntegrityCheck.IntegrityCheck.structured(), and edmIntegrityCheck.IntegrityCheck.test().

LumiList.LumiList.filename

Definition at line 54 of file LumiList.py.

Referenced by cuy.ValElement.__init__(), python.rootplot.rootmath.Target.__repr__(), Vispa.Plugins.ConfigEditor.ConfigDataAccessor.ConfigDataAccessor.properties(), and utils.unpickler.run().

LumiList.LumiList.url

Definition at line 58 of file LumiList.py.