ATLAS Offline Software
Loading...
Searching...
No Matches
python.AtlCoolLib.RangeList Class Reference
Collaboration diagram for python.AtlCoolLib.RangeList:

Public Member Functions

 __init__ (self, start, end)
 vetoRange (self, start, end)
 getAllowedRanges (self, start, end)
 __str__ (self)

Protected Member Functions

 _remove (self, idx)
 _insert (self, idx, start, end)

Protected Attributes

list _starts = [start]
list _ends = [end]

Detailed Description

Hold a list of IOVs (start/end pairs) which are good, allowing parts
of list to be vetoed. start/end interpreted in COOL convention

Definition at line 394 of file AtlCoolLib.py.

Constructor & Destructor Documentation

◆ __init__()

python.AtlCoolLib.RangeList.__init__ ( self,
start,
end )

Definition at line 397 of file AtlCoolLib.py.

397 def __init__(self,start,end):
398 "Initalise RangeList with given start and end (end=1 after last valid)"
399 self._starts=[start]
400 self._ends=[end]
401

Member Function Documentation

◆ __str__()

python.AtlCoolLib.RangeList.__str__ ( self)

Definition at line 436 of file AtlCoolLib.py.

436 def __str__(self):
437 "Print representation of range as list of [x,y] allowed values"
438 rep=''
439 for i in range(0,len(self._starts)):
440 rep+='[%i,%i] ' % (self._starts[i],self._ends[i])
441 return rep
442

◆ _insert()

python.AtlCoolLib.RangeList._insert ( self,
idx,
start,
end )
protected

Definition at line 448 of file AtlCoolLib.py.

448 def _insert(self,idx,start,end):
449 "Put a new entry at idx, moving others to make space"
450 self._starts.insert(idx,start)
451 self._ends.insert(idx,end)
452

◆ _remove()

python.AtlCoolLib.RangeList._remove ( self,
idx )
protected

Definition at line 443 of file AtlCoolLib.py.

443 def _remove(self,idx):
444 "Remove the entry at idx"
445 self._starts[idx:]=self._starts[1+idx:]
446 self._ends[idx:]=self._ends[1+idx:]
447

◆ getAllowedRanges()

python.AtlCoolLib.RangeList.getAllowedRanges ( self,
start,
end )
Return a list of tuples giving the allowed (start,end) within the
specified (start,end)

Definition at line 427 of file AtlCoolLib.py.

427 def getAllowedRanges(self,start,end):
428 """Return a list of tuples giving the allowed (start,end) within the
429 specified (start,end)"""
430 result=[]
431 for ix in range(0,len(self._starts)):
432 if (self._ends[ix]>start and self._starts[ix]<end):
433 result+=[(max(self._starts[ix],start),min(self._ends[ix],end))]
434 return result
435
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41

◆ vetoRange()

python.AtlCoolLib.RangeList.vetoRange ( self,
start,
end )

Definition at line 402 of file AtlCoolLib.py.

402 def vetoRange(self,start,end):
403 "Veto part of the original range, splitting it if needed"
404 if (start>=end): return
405 if (len(self._starts)==0): return
406 ix=0
407 while (ix<len(self._starts) and end>self._starts[ix]):
408 if (end>=self._starts[ix]):
409 if (start<=self._starts[ix] and end>=self._ends[ix]):
410 # remove whole interval
411 self._remove(ix)
412 ix-=1
413 elif (start<=self._starts[ix] and end<self._ends[ix]):
414 # remove front of stored interval
415 self._starts[ix]=end
416 elif (start<=self._ends[ix] and end>=self._ends[ix]):
417 # remove back of stored interval
418 self._ends[ix]=start
419 elif (start>self._starts[ix] and end<self._ends[ix]):
420 # have to split the stored interval
421 oldend=self._ends[ix]
422 self._ends[ix]=start
423 self._insert(ix+1,end,oldend)
424 ix+=1
425 ix+=1
426

Member Data Documentation

◆ _ends

list python.AtlCoolLib.RangeList._ends = [end]
protected

Definition at line 400 of file AtlCoolLib.py.

◆ _starts

python.AtlCoolLib.RangeList._starts = [start]
protected

Definition at line 399 of file AtlCoolLib.py.


The documentation for this class was generated from the following file: