ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.BeamSpotData.BeamSpotCSV Class Reference
Inheritance diagram for python.BeamSpotData.BeamSpotCSV:
Collaboration diagram for python.BeamSpotData.BeamSpotCSV:

Public Member Functions

def __init__ (self, filename='/afs/cern.ch/user/a/atlidbs/data/69OnlineBeamspots.csv', delim=',')
 
def __del__ (self)
 
def allData (self)
 
def summary (self)
 
def initStatistics (self)
 
def __iter__ (self)
 
def next (self)
 
def __next__ (self)
 
def selectedData (self)
 
def getDataCache (self)
 
def cutSummary (self)
 

Public Attributes

 csvFile
 
 csvReader
 
 runMin
 
 runMax
 
 runList
 
 runListExclude
 
 fillMin
 
 fillMax
 
 bcidMin
 
 bcidMax
 
 lbMin
 
 lbMax
 
 timeMin
 
 timeMax
 
 statusList
 
 acqFlag
 
 grl
 
 grlIOVs
 
 previousGRLIndex
 
 iter
 
 nTot
 
 nSel
 
 selRunMin
 
 selRunMax
 
 selFillMin
 
 selFillMax
 
 selBcidMin
 
 selBcidMax
 
 selTimeMin
 
 selTimeMax
 

Detailed Description

BeamSpotContainer for beam spot information stored in online CSV files

Definition at line 1218 of file BeamSpotData.py.

Constructor & Destructor Documentation

◆ __init__()

def python.BeamSpotData.BeamSpotCSV.__init__ (   self,
  filename = '/afs/cern.ch/user/a/atlidbs/data/69OnlineBeamspots.csv',
  delim = ',' 
)

Definition at line 1221 of file BeamSpotData.py.

1221  def __init__(self, filename='/afs/cern.ch/user/a/atlidbs/data/69OnlineBeamspots.csv', delim=','):
1222  BeamSpotContainer.__init__(self)
1223  self.csvFile = open(filename, 'rb')
1224  self.csvReader = csv.DictReader(self.csvFile, delimiter=delim)
1225 

◆ __del__()

def python.BeamSpotData.BeamSpotCSV.__del__ (   self)

Definition at line 1226 of file BeamSpotData.py.

1226  def __del__(self):
1227  self.csvFile.close()
1228 

Member Function Documentation

◆ __iter__()

def python.BeamSpotData.BeamSpotContainer.__iter__ (   self)
inherited
Iterator to iterate over selected elements in the container.

Definition at line 792 of file BeamSpotData.py.

792  def __iter__(self):
793  """Iterator to iterate over selected elements in the container."""
794  self.iter = self.selectedData()
795  return self
796 

◆ __next__()

def python.BeamSpotData.BeamSpotContainer.__next__ (   self)
inherited
Return next selected element in the container.

Definition at line 801 of file BeamSpotData.py.

801  def __next__(self):
802  """Return next selected element in the container."""
803  return self.next()
804 

◆ allData()

def python.BeamSpotData.BeamSpotCSV.allData (   self)
Default generator to iterate over all data. Must be overridden by derived classes.

Reimplemented from python.BeamSpotData.BeamSpotContainer.

Definition at line 1229 of file BeamSpotData.py.

1229  def allData(self):
1230 
1231  for row in self.csvReader:
1232 
1233  bs = BeamSpotValue()
1234 
1235  bs.run = int(row['run'])
1236  bs.lbStart = int(row['firstLBN'])
1237  bs.lbEnd = int(row['lastLBN'])
1238  bs.posX = float(row['posX'])
1239  bs.posY = float(row['posY'])
1240  bs.posZ = float(row['posZ'])
1241  bs.sigmaX = float(row['sigmaX'])
1242  bs.sigmaY = float(row['sigmaY'])
1243  bs.sigmaZ = float(row['sigmaZ'])
1244  bs.tiltX = float(row['tiltX'])
1245  bs.tiltY = float(row['tiltY'])
1246  bs.status = int(row['status'])
1247 
1248  bs.posXErr = float(row['posXE'])
1249  bs.posYErr = float(row['posYE'])
1250  bs.posZErr = float(row['posZE'])
1251  bs.sigmaXErr = float(row['sigmaXE'])
1252  bs.sigmaYErr = float(row['sigmaYE'])
1253  bs.sigmaZErr = float(row['sigmaZE'])
1254  bs.tiltXErr = float(row['tiltXE'])
1255  bs.tiltYErr = float(row['tiltYE'])
1256 
1257  yield bs
1258 
1259 

◆ cutSummary()

def python.BeamSpotData.BeamSpotContainer.cutSummary (   self)
inherited
Get summary of cuts made when looping over selected data.

Definition at line 894 of file BeamSpotData.py.

894  def cutSummary(self):
895  """Get summary of cuts made when looping over selected data."""
896  s = 'Cuts:\n'
897  s += ' run %7i ... %7i\n' % (self.runMin,self.runMax)
898  s += ' runList %7s\n' % str(self.runList)
899  s += ' runListExcluded %7s\n' % str(self.runListExclude)
900  s += ' fill %7i ... %7i\n' % (self.fillMin,self.fillMax)
901  s += ' bcid %7i ... %7i\n' % (self.bcidMin,self.bcidMax)
902  s += ' LB %7i ... %7i\n' % (self.lbMin,self.lbMax)
903  s += ' fit status %7s\n' % str(self.statusList)
904  s += ' %s - %s' % (time.strftime('%a %b %d %X %Z %Y',time.localtime(self.timeMin)),
905  time.strftime('%a %b %d %X %Z %Y',time.localtime(self.timeMax)))
906  s += ' acquisition flag %7s' % self.acqFlag
907  if self.grl:
908  s += ' GRL %s\n' % self.grl
909  return s
910 
911 
912 
913 ROOT.gROOT.ProcessLine(BeamSpotValue(fullCorrelations=True,addScanVars=True).getROOTStruct())

◆ getDataCache()

def python.BeamSpotData.BeamSpotContainer.getDataCache (   self)
inherited
Get a cache of all data in the form of a dict of runs, where each element
   is a dict with a BeamSpotValue for each individual lumi blocks.

Definition at line 874 of file BeamSpotData.py.

874  def getDataCache(self):
875  """Get a cache of all data in the form of a dict of runs, where each element
876  is a dict with a BeamSpotValue for each individual lumi blocks."""
877  cache = {}
878  for b in self:
879  r = b.run
880  if r not in cache:
881  cache[r] = {}
882  if b.lbEnd-b.lbStart > 500:
883  print ('WARNING: Cannot cache LB range %i ... %i for run %i' % (b.lbStart,b.lbEnd,r))
884  else:
885  for i in range(b.lbStart,b.lbEnd+1):
886  if b.status in self.statusList or not self.statusList:
887  cache[r][i] = b
888  return cache
889 

◆ initStatistics()

def python.BeamSpotData.BeamSpotContainer.initStatistics (   self)
inherited

Definition at line 776 of file BeamSpotData.py.

776  def initStatistics(self):
777  self.nTot = 0
778  self.nSel = 0
779  self.selRunMin = 9999999
780  self.selRunMax = 0
781  self.selFillMin = 9999999
782  self.selFillMax = 0
783  self.selBcidMin = 9999999
784  self.selBcidMax = 0
785  self.selTimeMin = 2000000000
786  self.selTimeMax = -1
787 

◆ next()

def python.BeamSpotData.BeamSpotContainer.next (   self)
inherited
Return next selected element in the container.

Definition at line 797 of file BeamSpotData.py.

797  def next(self):
798  """Return next selected element in the container."""
799  return next(self.iter)
800 

◆ selectedData()

def python.BeamSpotData.BeamSpotContainer.selectedData (   self)
inherited
Generator to iterate over selected elements in the container.

Definition at line 809 of file BeamSpotData.py.

809  def selectedData(self):
810  """Generator to iterate over selected elements in the container."""
811  self.initStatistics()
812 
813  self.previousGRLIndex = 0
814 
815  for b in self.allData():
816  self.nTot +=1
817  if b.run<self.runMin: continue
818  if b.run>self.runMax: continue
819  if self.runList and b.run not in self.runList: continue
820  if self.runListExclude and b.run in self.runListExclude: continue
821  if b.fill<self.fillMin: continue
822  if b.fill>self.fillMax: continue
823  if b.bcid<self.bcidMin: continue
824  if b.bcid>self.bcidMax: continue
825  if b.lbStart<self.lbMin: continue
826  if b.lbEnd-1>self.lbMax: continue # lbEnd is exclusive
827  if b.timeStart<self.timeMin: continue
828  if b.timeEnd>self.timeMax: continue
829  if self.statusList and b.status not in self.statusList: continue
830  #if self.acqFlag is not None and b.acquisitionFlag != self.acqFlag: continue
831 
832  if self.grl:
833  # Check if in GRL
834  from DQUtils.sugar import RANGEIOV_VAL, RunLumi
835  from DQUtils import IOVSet
836 
837  # Get IoVs from GRL
838  if self.grlIOVs is None:
839  self.grlIOVs = IOVSet.from_grl(self.grl)
840 
841  idx = self.previousGRLIndex
842 
843  # Get current IoV
844  test_iov = RANGEIOV_VAL(RunLumi(b.run, b.lbStart), RunLumi(b.run, b.lbEnd)) # COOL convention, ie lbEnd is exclusive
845 
846  # Search for IoV in GRL IoVs
847  for i, iov in enumerate(self.grlIOVs[idx:]):
848  if (test_iov.since >= iov.since and test_iov.until <= iov.until):
849  self.previousGRLIndex = idx + i
850  break
851  else:
852  # Only if don't break -> IOV not found so skip
853  continue
854 
855 
856  self.nSel += 1
857  self.selRunMin = min(self.selRunMin,b.run)
858  self.selRunMax = max(self.selRunMax,b.run)
859  self.selFillMin = min(self.selFillMin,b.fill)
860  self.selFillMax = max(self.selFillMax,b.fill)
861  self.selBcidMin = min(self.selBcidMin,b.bcid)
862  self.selBcidMax = max(self.selBcidMax,b.bcid)
863  self.selTimeMin = min(self.selTimeMin,b.timeStart)
864  self.selTimeMax = max(self.selTimeMax,b.timeEnd)
865  yield b
866  print ('\n%i entries selected out of total of %i entries in ntuple:' % (self.nSel,self.nTot))
867  print ('... runs %6i - %6i' % (self.selRunMin,self.selRunMax))
868  print ('... fills %6i - %6i' % (self.selFillMin,self.selFillMax))
869  print ('... bcids %6i - %6i' % (self.selBcidMin,self.selBcidMax))
870  print ('... %s - %s' % (time.strftime('%a %b %d %X %Z %Y',time.localtime(self.selTimeMin)),
871  time.strftime('%a %b %d %X %Z %Y',time.localtime(self.selTimeMax))))
872  print()
873 

◆ summary()

def python.BeamSpotData.BeamSpotCSV.summary (   self)
Get one-line info of Ntuple. Should be overridden by derived classes.

Reimplemented from python.BeamSpotData.BeamSpotContainer.

Definition at line 1260 of file BeamSpotData.py.

1260  def summary(self):
1261  s = 'CSV file %s:\n' % self.filename
1262  s += ' %s ntuple\n' % (self.__class__.__name__)
1263  return s
1264 
1265 # Test code for modules

Member Data Documentation

◆ acqFlag

python.BeamSpotData.BeamSpotContainer.acqFlag
inherited

Definition at line 765 of file BeamSpotData.py.

◆ bcidMax

python.BeamSpotData.BeamSpotContainer.bcidMax
inherited

Definition at line 759 of file BeamSpotData.py.

◆ bcidMin

python.BeamSpotData.BeamSpotContainer.bcidMin
inherited

Definition at line 758 of file BeamSpotData.py.

◆ csvFile

python.BeamSpotData.BeamSpotCSV.csvFile

Definition at line 1223 of file BeamSpotData.py.

◆ csvReader

python.BeamSpotData.BeamSpotCSV.csvReader

Definition at line 1224 of file BeamSpotData.py.

◆ fillMax

python.BeamSpotData.BeamSpotContainer.fillMax
inherited

Definition at line 757 of file BeamSpotData.py.

◆ fillMin

python.BeamSpotData.BeamSpotContainer.fillMin
inherited

Definition at line 756 of file BeamSpotData.py.

◆ grl

python.BeamSpotData.BeamSpotContainer.grl
inherited

Definition at line 766 of file BeamSpotData.py.

◆ grlIOVs

python.BeamSpotData.BeamSpotContainer.grlIOVs
inherited

Definition at line 767 of file BeamSpotData.py.

◆ iter

python.BeamSpotData.BeamSpotContainer.iter
inherited

Definition at line 771 of file BeamSpotData.py.

◆ lbMax

python.BeamSpotData.BeamSpotContainer.lbMax
inherited

Definition at line 761 of file BeamSpotData.py.

◆ lbMin

python.BeamSpotData.BeamSpotContainer.lbMin
inherited

Definition at line 760 of file BeamSpotData.py.

◆ nSel

python.BeamSpotData.BeamSpotContainer.nSel
inherited

Definition at line 778 of file BeamSpotData.py.

◆ nTot

python.BeamSpotData.BeamSpotContainer.nTot
inherited

Definition at line 777 of file BeamSpotData.py.

◆ previousGRLIndex

python.BeamSpotData.BeamSpotContainer.previousGRLIndex
inherited

Definition at line 768 of file BeamSpotData.py.

◆ runList

python.BeamSpotData.BeamSpotContainer.runList
inherited

Definition at line 754 of file BeamSpotData.py.

◆ runListExclude

python.BeamSpotData.BeamSpotContainer.runListExclude
inherited

Definition at line 755 of file BeamSpotData.py.

◆ runMax

python.BeamSpotData.BeamSpotContainer.runMax
inherited

Definition at line 753 of file BeamSpotData.py.

◆ runMin

python.BeamSpotData.BeamSpotContainer.runMin
inherited

Definition at line 752 of file BeamSpotData.py.

◆ selBcidMax

python.BeamSpotData.BeamSpotContainer.selBcidMax
inherited

Definition at line 784 of file BeamSpotData.py.

◆ selBcidMin

python.BeamSpotData.BeamSpotContainer.selBcidMin
inherited

Definition at line 783 of file BeamSpotData.py.

◆ selFillMax

python.BeamSpotData.BeamSpotContainer.selFillMax
inherited

Definition at line 782 of file BeamSpotData.py.

◆ selFillMin

python.BeamSpotData.BeamSpotContainer.selFillMin
inherited

Definition at line 781 of file BeamSpotData.py.

◆ selRunMax

python.BeamSpotData.BeamSpotContainer.selRunMax
inherited

Definition at line 780 of file BeamSpotData.py.

◆ selRunMin

python.BeamSpotData.BeamSpotContainer.selRunMin
inherited

Definition at line 779 of file BeamSpotData.py.

◆ selTimeMax

python.BeamSpotData.BeamSpotContainer.selTimeMax
inherited

Definition at line 786 of file BeamSpotData.py.

◆ selTimeMin

python.BeamSpotData.BeamSpotContainer.selTimeMin
inherited

Definition at line 785 of file BeamSpotData.py.

◆ statusList

python.BeamSpotData.BeamSpotContainer.statusList
inherited

Definition at line 764 of file BeamSpotData.py.

◆ timeMax

python.BeamSpotData.BeamSpotContainer.timeMax
inherited

Definition at line 763 of file BeamSpotData.py.

◆ timeMin

python.BeamSpotData.BeamSpotContainer.timeMin
inherited

Definition at line 762 of file BeamSpotData.py.


The documentation for this class was generated from the following file:
max
#define max(a, b)
Definition: cfImp.cxx:41
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.sugar.iovtype.RANGEIOV_VAL
def RANGEIOV_VAL()
Definition: iovtype.py:153
python.Bindings.__iter__
__iter__
Definition: Control/AthenaPython/python/Bindings.py:783
python.sugar.runlumi.RunLumi
RunLumi
Definition: runlumi.py:131
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
min
#define min(a, b)
Definition: cfImp.cxx:40
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
python.AthDsoLogger.__del__
def __del__(self)
Definition: AthDsoLogger.py:82
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83
SCT_Monitoring::summary
@ summary
Definition: SCT_MonitoringNumbers.h:65