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 20 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 48 of file LumiList.py.

48 
49  def __init__(self, filename = None, lumis = None, runsAndLumis = None, runs = None, compactList = None, url = None):
50  """
51  Constructor takes filename (JSON), a list of run/lumi pairs,
52  or a dict with run #'s as the keys and a list of lumis as the values, or just a list of runs
53  """
54  self.compactList = {}
55  self.duplicates = {}
56  if filename:
57  self.filename = filename
58  jsonFile = open(self.filename,'r')
59  self.compactList = json.load(jsonFile)
60  elif url:
61  self.url = url
62  jsonFile = urllib2.urlopen(url)
63  self.compactList = json.load(jsonFile)
64  elif lumis:
65  runsAndLumis = {}
66  for (run, lumi) in lumis:
67  run = str(run)
68  if not runsAndLumis.has_key(run):
69  runsAndLumis[run] = []
70  runsAndLumis[run].append(lumi)
71 
72  if isinstance(runsAndLumis, list):
73  queued = {}
74  for runLumiList in runsAndLumis:
75  for run, lumis in runLumiList.items():
76  queued.setdefault(run, []).extend(lumis)
77  runsAndLumis = queued
78 
79  if runsAndLumis:
80  for run in runsAndLumis.keys():
81  runString = str(run)
82  lastLumi = -1000
83  lumiList = runsAndLumis[run]
84  if lumiList:
85  self.compactList[runString] = []
86  self.duplicates[runString] = []
87  for lumi in sorted(lumiList):
88  if lumi == lastLumi:
89  self.duplicates[runString].append(lumi)
90  elif lumi != lastLumi + 1: # Break in lumi sequence
91  self.compactList[runString].append([lumi, lumi])
92  else:
93  nRange = len(self.compactList[runString])
94  self.compactList[runString][nRange-1][1] = lumi
95  lastLumi = lumi
96  if runs:
97  for run in runs:
98  runString = str(run)
99  self.compactList[runString] = [[1, 0xFFFFFFF]]
100 
101  if compactList:
102  for run in compactList.keys():
103  runString = str(run)
104  if compactList[run]:
105  self.compactList[runString] = compactList[run]
106 

Member Function Documentation

def LumiList.LumiList.__add__ (   self,
  other 
)

Definition at line 183 of file LumiList.py.

References LumiList.LumiList.__or__().

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

Definition at line 135 of file LumiList.py.

References LumiList.LumiList.compactList, and runtimedef.set().

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

Definition at line 364 of file LumiList.py.

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

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

References LumiList.LumiList.compactList.

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

Definition at line 166 of file LumiList.py.

References runtimedef.set().

Referenced by LumiList.LumiList.__add__().

167  def __or__(self, other):
168  result = {}
169  aruns = self.compactList.keys()
170  bruns = other.compactList.keys()
171  runs = set(aruns + bruns)
172  for run in runs:
173  overlap = sorted(self.compactList.get(run, []) + other.compactList.get(run, []))
174  unique = [overlap[0]]
175  for pair in overlap[1:]:
176  if pair[0] >= unique[-1][0] and pair[0] <= unique[-1][1]+1 and pair[1] > unique[-1][1]:
177  unique[-1][1] = copy.deepcopy(pair[1])
178  elif pair[0] > unique[-1][1]:
179  unique.append(copy.deepcopy(pair))
180  result[run] = unique
181  return LumiList(compactList = result)
182 
void set(const std::string &name, int value)
set the flag, with a run-time name
def LumiList.LumiList.__str__ (   self)

Definition at line 207 of file LumiList.py.

References LumiList.LumiList.compactList.

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

Definition at line 107 of file LumiList.py.

References LumiList.LumiList.compactList.

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

References LumiList.LumiList.compactList.

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

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

Referenced by LumiList.LumiList.__contains__().

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

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

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

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

Definition at line 213 of file LumiList.py.

References LumiList.LumiList.compactList.

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

Definition at line 220 of file LumiList.py.

References LumiList.LumiList.duplicates.

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

Definition at line 227 of file LumiList.py.

References LumiList.LumiList.compactList.

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

Definition at line 243 of file LumiList.py.

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

Definition at line 281 of file LumiList.py.

References LumiList.LumiList._getLumiParts().

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

Definition at line 303 of file LumiList.py.

References LumiList.LumiList.compactList.

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

Definition at line 315 of file LumiList.py.

References LumiList.LumiList.compactList.

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

Definition at line 294 of file LumiList.py.

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

Member Data Documentation

LumiList.LumiList.compactList

Definition at line 53 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 54 of file LumiList.py.

Referenced by LumiList.LumiList.getDuplicates().

LumiList.LumiList.filename

Definition at line 56 of file LumiList.py.

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

LumiList.LumiList.url

Definition at line 60 of file LumiList.py.