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 not runsAndLumis.has_key(run):
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 

Member Function Documentation

def LumiList.LumiList.__add__ (   self,
  other 
)

Definition at line 181 of file LumiList.py.

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

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

182  def __add__(self, other):
183  # + is the same as |
184  return self.__or__(other)
def LumiList.LumiList.__and__ (   self,
  other 
)

Definition at line 133 of file LumiList.py.

References LumiList.LumiList.compactList.

134  def __and__(self, other): # Things in both
135  result = {}
136  aruns = set(self.compactList.keys())
137  bruns = set(other.compactList.keys())
138  for run in aruns & bruns:
139  lumiList = [] # List for this run
140  unique = [] # List for this run
141  for alumi in self.compactList[run]:
142  for blumi in other.compactList[run]:
143  if blumi[0] <= alumi[0] and blumi[1] >= alumi[1]: # blumi has all of alumi
144  lumiList.append(alumi)
145  if blumi[0] > alumi[0] and blumi[1] < alumi[1]: # blumi is part of alumi
146  lumiList.append(blumi)
147  elif blumi[0] <= alumi[0] and blumi[1] < alumi[1] and blumi[1] >= alumi[0]: # overlaps start
148  lumiList.append([alumi[0], blumi[1]])
149  elif blumi[0] > alumi[0] and blumi[1] >= alumi[1] and blumi[0] <= alumi[1]: # overlaps end
150  lumiList.append([blumi[0], alumi[1]])
151 
152 
153  if lumiList:
154  unique = [lumiList[0]]
155  for pair in lumiList[1:]:
156  if pair[0] == unique[-1][1]+1:
157  unique[-1][1] = copy.deepcopy(pair[1])
158  else:
159  unique.append(copy.deepcopy(pair))
160 
161  result[run] = unique
162  return LumiList(compactList = result)
163 
def LumiList.LumiList.__contains__ (   self,
  runTuple 
)

Definition at line 362 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().

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

References LumiList.LumiList.compactList.

186  def __len__(self):
187  '''Returns number of runs in list'''
188  return len(self.compactList)
def LumiList.LumiList.__or__ (   self,
  other 
)

Definition at line 164 of file LumiList.py.

Referenced by LumiList.LumiList.__add__().

165  def __or__(self, other):
166  result = {}
167  aruns = self.compactList.keys()
168  bruns = other.compactList.keys()
169  runs = set(aruns + bruns)
170  for run in runs:
171  overlap = sorted(self.compactList.get(run, []) + other.compactList.get(run, []))
172  unique = [overlap[0]]
173  for pair in overlap[1:]:
174  if pair[0] >= unique[-1][0] and pair[0] <= unique[-1][1]+1 and pair[1] > unique[-1][1]:
175  unique[-1][1] = copy.deepcopy(pair[1])
176  elif pair[0] > unique[-1][1]:
177  unique.append(copy.deepcopy(pair))
178  result[run] = unique
179  return LumiList(compactList = result)
180 
def LumiList.LumiList.__str__ (   self)

Definition at line 205 of file LumiList.py.

References LumiList.LumiList.compactList.

206  def __str__ (self):
207  doubleBracketRE = re.compile (r']],')
208  return doubleBracketRE.sub (']],\n',
209  json.dumps (self.compactList,
210  sort_keys=True))
def LumiList.LumiList.__sub__ (   self,
  other 
)

Definition at line 105 of file LumiList.py.

References LumiList.LumiList.compactList.

106  def __sub__(self, other): # Things from self not in other
107  result = {}
108  for run in sorted(self.compactList.keys()):
109  alumis = sorted(self.compactList[run])
110  blumis = sorted(other.compactList.get(run, []))
111  alist = [] # verified part
112  for alumi in alumis:
113  tmplist = [alumi[0], alumi[1]] # may be part
114  for blumi in blumis:
115  if blumi[0] <= tmplist[0] and blumi[1] >= tmplist[1]: # blumi has all of alumi
116  tmplist = []
117  break # blumi is has all of alumi
118  if blumi[0] > tmplist[0] and blumi[1] < tmplist[1]: # blumi is part of alumi
119  alist.append([tmplist[0], blumi[0]-1])
120  tmplist = [blumi[1]+1, tmplist[1]]
121  elif blumi[0] <= tmplist[0] and blumi[1] < tmplist[1] and blumi[1]>=tmplist[0]: # overlaps start
122  tmplist = [blumi[1]+1, tmplist[1]]
123  elif blumi[0] > tmplist[0] and blumi[1] >= tmplist[1] and blumi[0]<=tmplist[1]: # overlaps end
124  alist.append([tmplist[0], blumi[0]-1])
125  tmplist = []
126  break
127  if tmplist:
128  alist.append(tmplist)
129  result[run] = alist
130 
131  return LumiList(compactList = result)
132 
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 248 of file LumiList.py.

References LumiList.LumiList.compactList.

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

249  def _getLumiParts(self):
250  """
251  Turn compactList into a list of the format
252  [ 'R1:L1', 'R2:L2-R2:L3' ] which is used by getCMSSWString and getVLuminosityBlockRange
253  """
254 
255  parts = []
256  runs = self.compactList.keys()
257  runs.sort(key=int)
258  for run in runs:
259  lumis = self.compactList[run]
260  for lumiPair in sorted(lumis):
261  if lumiPair[0] == lumiPair[1]:
262  parts.append("%s:%s" % (run, lumiPair[0]))
263  else:
264  parts.append("%s:%s-%s:%s" %
265  (run, lumiPair[0], run, lumiPair[1]))
266  return parts
267 
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 327 of file LumiList.py.

Referenced by LumiList.LumiList.__contains__().

328  def contains (self, run, lumiSection = None):
329  '''
330  returns true if the run, lumi section passed in is contained
331  in this lumiList. Input can be either:
332  - a single tuple of (run, lumi),
333  - separate run and lumi numbers
334  - a single run number (returns true if any lumi sections exist)
335  '''
336  if lumiSection is None:
337  # if this is an integer or a string, see if the run exists
338  if isinstance (run, int) or isinstance (run, str):
339  return self.compactList.has_key( str(run) )
340  # if we're here, then run better be a tuple or list
341  try:
342  lumiSection = run[1]
343  run = run[0]
344  except:
345  raise RuntimeError, "Improper format for run '%s'" % run
346  lumiRangeList = self.compactList.get( str(run) )
347  if not lumiRangeList:
348  # the run isn't there, so no need to look any further
349  return False
350  for lumiRange in lumiRangeList:
351  # we want to make this as found if either the lumiSection
352  # is inside the range OR if the lumi section is greater
353  # than or equal to the lower bound of the lumi range and
354  # the upper bound is 0 (which means extends to the end of
355  # the run)
356  if lumiRange[0] <= lumiSection and \
357  (0 == lumiRange[1] or lumiSection <= lumiRange[1]):
358  # got it
359  return True
360  return False
361 
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 189 of file LumiList.py.

190  def filterLumis(self, lumiList):
191  """
192  Return a list of lumis that are in compactList.
193  lumilist is of the simple form
194  [(run1,lumi1),(run1,lumi2),(run2,lumi1)]
195  """
196  filteredList = []
197  for (run, lumi) in lumiList:
198  runsInLumi = self.compactList.get(str(run), [[0, -1]])
199  for (first, last) in runsInLumi:
200  if lumi >= first and lumi <= last:
201  filteredList.append((run, lumi))
202  break
203  return filteredList
204 
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 268 of file LumiList.py.

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

269  def getCMSSWString(self):
270  """
271  Turn compactList into a list of the format
272  R1:L1,R2:L2-R2:L3 which is acceptable to CMSSW LumiBlockRange variable
273  """
274 
275  parts = self._getLumiParts()
276  output = ','.join(parts)
277  return str(output)
278 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def LumiList.LumiList.getCompactList (   self)
Return the compact list representation

Definition at line 211 of file LumiList.py.

References LumiList.LumiList.compactList.

212  def getCompactList(self):
213  """
214  Return the compact list representation
215  """
216  return self.compactList
217 
def LumiList.LumiList.getDuplicates (   self)
Return the list of duplicates found during construction as a LumiList

Definition at line 218 of file LumiList.py.

References LumiList.LumiList.duplicates.

219  def getDuplicates(self):
220  """
221  Return the list of duplicates found during construction as a LumiList
222  """
223  return LumiList(runsAndLumis = self.duplicates)
224 
def LumiList.LumiList.getLumis (   self)
Return the list of pairs representation

Definition at line 225 of file LumiList.py.

References LumiList.LumiList.compactList.

226  def getLumis(self):
227  """
228  Return the list of pairs representation
229  """
230  theList = []
231  runs = self.compactList.keys()
232  runs.sort(key=int)
233  for run in runs:
234  lumis = self.compactList[run]
235  for lumiPair in sorted(lumis):
236  for lumi in range(lumiPair[0], lumiPair[1]+1):
237  theList.append((int(run), lumi))
238 
239  return theList
240 
def LumiList.LumiList.getRuns (   self)
return the sorted list of runs contained

Definition at line 241 of file LumiList.py.

242  def getRuns(self):
243  '''
244  return the sorted list of runs contained
245  '''
246  return sorted (self.compactList.keys())
247 
def LumiList.LumiList.getVLuminosityBlockRange (   self,
  tracked = False 
)
Turn compactList into an (optionally tracked) VLuminosityBlockRange

Definition at line 279 of file LumiList.py.

References LumiList.LumiList._getLumiParts().

280  def getVLuminosityBlockRange(self, tracked = False):
281  """
282  Turn compactList into an (optionally tracked) VLuminosityBlockRange
283  """
284 
285  import FWCore.ParameterSet.Config as cms
286  parts = self._getLumiParts()
287  if tracked:
288  return cms.VLuminosityBlockRange(parts)
289  else:
290  return cms.untracked.VLuminosityBlockRange(parts)
291 
def getVLuminosityBlockRange
Definition: LumiList.py:279
def LumiList.LumiList.removeRuns (   self,
  runList 
)
removes runs from runList from collection

Definition at line 301 of file LumiList.py.

References LumiList.LumiList.compactList.

302  def removeRuns (self, runList):
303  '''
304  removes runs from runList from collection
305  '''
306  for run in runList:
307  run = str(run)
308  if self.compactList.has_key (run):
309  del self.compactList[run]
310 
311  return
312 
def LumiList.LumiList.selectRuns (   self,
  runList 
)
Selects only runs from runList in collection

Definition at line 313 of file LumiList.py.

References LumiList.LumiList.compactList.

314  def selectRuns (self, runList):
315  '''
316  Selects only runs from runList in collection
317  '''
318  runsToDelete = []
319  for run in self.compactList.keys():
320  if int(run) not in runList and run not in runList:
321  runsToDelete.append(run)
322 
323  for run in runsToDelete:
324  del self.compactList[run]
325 
326  return
def LumiList.LumiList.writeJSON (   self,
  fileName 
)
Write out a JSON file representation of the object

Definition at line 292 of file LumiList.py.

293  def writeJSON(self, fileName):
294  """
295  Write out a JSON file representation of the object
296  """
297  jsonFile = open(fileName,'w')
298  jsonFile.write("%s\n" % self)
299  jsonFile.close()
300 

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.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().

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.

Referenced by rrapi.RRApi.get().