ATLAS Offline Software
Loading...
Searching...
No Matches
python.BeamSpotData.BeamSpotFinderNt Class Reference
Inheritance diagram for python.BeamSpotData.BeamSpotFinderNt:
Collaboration diagram for python.BeamSpotData.BeamSpotFinderNt:

Public Member Functions

 __init__ (self, fileName, treeName='BeamSpotNt', fullCorrelations=True)
 __del__ (self)
 allData (self)
 summary (self)
 initStatistics (self)
 __iter__ (self)
 next (self)
 __next__ (self)
 selectedData (self)
 getDataCache (self)
 cutSummary (self)

Public Attributes

 fileName = fileName
 treeName = treeName
 rootFile = ROOT.TFile(fileName)
 nt = self.rootFile.Get(treeName)
 fullCorrelations = fullCorrelations
int runMin = 0
int runMax = 9999999
list runList = []
list runListExclude = []
int fillMin = 0
int fillMax = 9999999
int bcidMin = 0
int bcidMax = 9999999
int lbMin = 0
int lbMax = 9999999999
int timeMin = 0
int timeMax = 2000000000
list statusList = []
 acqFlag = None
str grl = ''
 grlIOVs = None
int previousGRLIndex = 0
 iter = None
int nTot = 0
int nSel = 0
int selRunMin = 9999999
int selRunMax = 0
int selFillMin = 9999999
int selFillMax = 0
int selBcidMin = 9999999
int selBcidMax = 0
int selTimeMin = 2000000000
int selTimeMax = -1

Static Public Attributes

dict fitResultToStatusMap = {0: 0, 1: 3, 2: 0, 3: 0}
dict fitIdToStatusMap = {1: 0x38, 2: 0x40, 3: 0x10}

Private Attributes

 __del__

Detailed Description

BeamSpotContainer for ntuples created by InDetBeamSpotFinder.

Definition at line 983 of file BeamSpotData.py.

Constructor & Destructor Documentation

◆ __init__()

python.BeamSpotData.BeamSpotFinderNt.__init__ ( self,
fileName,
treeName = 'BeamSpotNt',
fullCorrelations = True )

Definition at line 994 of file BeamSpotData.py.

994 def __init__(self,fileName,treeName = 'BeamSpotNt',fullCorrelations=True):
995 BeamSpotContainer.__init__(self)
996 self.fileName = fileName
997 self.treeName = treeName
998 self.rootFile = ROOT.TFile(fileName)
999 self.nt = self.rootFile.Get(treeName)
1000 self.fullCorrelations = fullCorrelations
1001 if not self.nt:
1002 raise ValueError ('Tree %s not found in ntuple file %s' % (treeName,fileName))
1003
1004 # Register instance's __del__() with exit handler
1005 # This is needed for ROOT >= 5.28 to prevent ROOTs exit handler cleaning up the file
1006 # before we have closed/written to it. Only needed if use TFile in __del__
1007 atexit.register(self.__del__)
1008
T * Get(TFile &f, const std::string &n, const std::string &dir="", const chainmap_t *chainmap=0, std::vector< std::string > *saved=0)
get a histogram given a path, and an optional initial directory if histogram is not found,...

◆ __del__()

python.BeamSpotData.BeamSpotFinderNt.__del__ ( self)

Definition at line 1009 of file BeamSpotData.py.

1009 def __del__(self):
1010 # Prevent caling more than one (atexit/explicit del)
1011 if self.rootFile is not None:
1012 self.rootFile.Close()
1013 self.rootFile = None
1014

Member Function Documentation

◆ __iter__()

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

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

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

Reimplemented from python.BeamSpotData.BeamSpotContainer.

Definition at line 1015 of file BeamSpotData.py.

1015 def allData(self):
1016 for j in range(self.nt.GetEntries()):
1017 self.nt.GetEntry(j)
1018 bs = BeamSpotValue(self.fullCorrelations)
1019 #try:
1020 # bs.status = BeamSpotFinderNt.fitIdToStatusMap[self.nt.fitID]+BeamSpotFinderNt.fitResultToStatusMap[self.nt.fitStatus]
1021 #except Exception:
1022 # bs.status = 0
1023 # print ("ERROR: can't translate (fitID,fitStatus) = (%i,%i) into status word" % (self.nt.fitID,self.nt.fitStatus))
1024 bs.run = self.nt.run
1025 try:
1026 bs.bcid = self.nt.bcid
1027 except Exception:
1028 pass
1029 bs.lbStart = self.nt.lumiStart
1030 bs.lbEnd = self.nt.lumiStart+self.nt.lumiRange
1031 bs.nEvents = self.nt.nEvents
1032 try:
1033 bs.nValid = self.nt.nValid
1034 except Exception:
1035 pass
1036 try:
1037 bs.nVtxAll = self.nt.nVtxAll
1038 except Exception:
1039 pass
1040 try:
1041 bs.nVtxPrim = self.nt.nVtxPrim
1042 except Exception:
1043 pass
1044 bs.posX = self.nt.xc
1045 bs.posY = self.nt.yc
1046 bs.posZ = self.nt.z
1047 bs.sigmaX = self.nt.sx
1048 bs.sigmaY = self.nt.sy
1049 bs.sigmaZ = self.nt.sz
1050 bs.tiltX = self.nt.ax
1051 bs.tiltY = self.nt.ay
1052 bs.rhoXY = self.nt.rhoxy
1053 bs.k = self.nt.k
1054 bs.posXErr = sqrt(self.nt.xcxc)
1055 bs.posYErr = sqrt(self.nt.ycyc)
1056 bs.posZErr = sqrt(self.nt.zz)
1057 bs.sigmaXErr = sqrt(self.nt.sxsx)
1058 bs.sigmaYErr = sqrt(self.nt.sysy)
1059 bs.sigmaZErr = sqrt(self.nt.szsz)
1060 bs.tiltXErr = sqrt(self.nt.axax)
1061 bs.tiltYErr = sqrt(self.nt.ayay)
1062 bs.rhoXYErr = sqrt(self.nt.rhoxyrhoxy)
1063 bs.kErr = sqrt(self.nt.kk)
1064 bs.covSxSy = self.nt.sxsy
1065 bs.covSxRhoXY = self.nt.sxrhoxy
1066 bs.covSyRhoXY = self.nt.syrhoxy
1067
1068 bs.covXY = self.nt.x0y0
1069 bs.covXZ = self.nt.x0z
1070 bs.covXSx = self.nt.x0sx
1071 bs.covXSy = self.nt.x0sy
1072 bs.covXSz = self.nt.x0sz
1073 bs.covXTiltX = self.nt.x0ax
1074 bs.covXTiltY = self.nt.x0ay
1075 bs.covXRhoXY = self.nt.x0rhoxy
1076 bs.covXk = self.nt.x0k
1077
1078 bs.covYZ = self.nt.y0z
1079 bs.covYSx = self.nt.y0sx
1080 bs.covYSy = self.nt.y0sy
1081 bs.covYSz = self.nt.y0sz
1082 bs.covYTiltX = self.nt.y0ax
1083 bs.covYTiltY = self.nt.y0ay
1084 bs.covYRhoXY = self.nt.y0rhoxy
1085 bs.covYk = self.nt.y0k
1086
1087 bs.covZSx = self.nt.zsx
1088 bs.covZSy = self.nt.zsy
1089 bs.covZSz = self.nt.zsz
1090 bs.covZTiltX = self.nt.zax
1091 bs.covZTiltY = self.nt.zay
1092 bs.covZRhoXY = self.nt.zrhoxy
1093 bs.covZk = self.nt.zk
1094
1095 bs.covTiltXTiltY = self.nt.axay
1096 bs.covTiltXSx = self.nt.axsx
1097 bs.covTiltXSy = self.nt.axsy
1098 bs.covTiltXSz = self.nt.axsz
1099 bs.covTiltXRhoXY = self.nt.axrhoxy
1100 bs.covTiltXk = self.nt.axk
1101
1102 bs.covTiltYSx = self.nt.aysx
1103 bs.covTiltYSy = self.nt.aysy
1104 bs.covTiltYSz = self.nt.aysz
1105 bs.covTiltYRhoXY = self.nt.ayrhoxy
1106 bs.covTiltYk = self.nt.ayk
1107
1108 bs.covSxSz = self.nt.sxsz
1109 bs.covSxk = self.nt.sxk
1110
1111 bs.covSySz = self.nt.sysz
1112 bs.covSyk = self.nt.syk
1113
1114 bs.covSzRhoXY = self.nt.szrhoxy
1115 bs.covSzk = self.nt.szk
1116
1117 bs.covRhoXYk = self.nt.rhoxyk
1118
1119 yield bs
1120
TGraphErrors * GetEntries(TH2F *histo)

◆ cutSummary()

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

◆ getDataCache()

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

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

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

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
void print(char *figname, TCanvas *c1)
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41

◆ summary()

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

Reimplemented from python.BeamSpotData.BeamSpotContainer.

Definition at line 1121 of file BeamSpotData.py.

1121 def summary(self):
1122 s = '%s:\n' % (self.fileName)
1123 s += ' %s ntuple in tree %s\n' % (self.__class__.__name__,self.treeName)
1124 s += ' %i entries\n' % (self.nt.GetEntries())
1125 return s
1126
1127

Member Data Documentation

◆ __del__

python.BeamSpotData.BeamSpotFinderNt.__del__
private

Definition at line 1007 of file BeamSpotData.py.

◆ acqFlag

python.BeamSpotData.BeamSpotContainer.acqFlag = None
inherited

Definition at line 765 of file BeamSpotData.py.

◆ bcidMax

int python.BeamSpotData.BeamSpotContainer.bcidMax = 9999999
inherited

Definition at line 759 of file BeamSpotData.py.

◆ bcidMin

int python.BeamSpotData.BeamSpotContainer.bcidMin = 0
inherited

Definition at line 758 of file BeamSpotData.py.

◆ fileName

python.BeamSpotData.BeamSpotFinderNt.fileName = fileName

Definition at line 996 of file BeamSpotData.py.

◆ fillMax

int python.BeamSpotData.BeamSpotContainer.fillMax = 9999999
inherited

Definition at line 757 of file BeamSpotData.py.

◆ fillMin

int python.BeamSpotData.BeamSpotContainer.fillMin = 0
inherited

Definition at line 756 of file BeamSpotData.py.

◆ fitIdToStatusMap

dict python.BeamSpotData.BeamSpotFinderNt.fitIdToStatusMap = {1: 0x38, 2: 0x40, 3: 0x10}
static

Definition at line 992 of file BeamSpotData.py.

◆ fitResultToStatusMap

dict python.BeamSpotData.BeamSpotFinderNt.fitResultToStatusMap = {0: 0, 1: 3, 2: 0, 3: 0}
static

Definition at line 991 of file BeamSpotData.py.

◆ fullCorrelations

python.BeamSpotData.BeamSpotFinderNt.fullCorrelations = fullCorrelations

Definition at line 1000 of file BeamSpotData.py.

◆ grl

str python.BeamSpotData.BeamSpotContainer.grl = ''
inherited

Definition at line 766 of file BeamSpotData.py.

◆ grlIOVs

python.BeamSpotData.BeamSpotContainer.grlIOVs = None
inherited

Definition at line 767 of file BeamSpotData.py.

◆ iter

python.BeamSpotData.BeamSpotContainer.iter = None
inherited

Definition at line 771 of file BeamSpotData.py.

◆ lbMax

int python.BeamSpotData.BeamSpotContainer.lbMax = 9999999999
inherited

Definition at line 761 of file BeamSpotData.py.

◆ lbMin

int python.BeamSpotData.BeamSpotContainer.lbMin = 0
inherited

Definition at line 760 of file BeamSpotData.py.

◆ nSel

python.BeamSpotData.BeamSpotContainer.nSel = 0
inherited

Definition at line 778 of file BeamSpotData.py.

◆ nt

python.BeamSpotData.BeamSpotFinderNt.nt = self.rootFile.Get(treeName)

Definition at line 999 of file BeamSpotData.py.

◆ nTot

python.BeamSpotData.BeamSpotContainer.nTot = 0
inherited

Definition at line 777 of file BeamSpotData.py.

◆ previousGRLIndex

int python.BeamSpotData.BeamSpotContainer.previousGRLIndex = 0
inherited

Definition at line 768 of file BeamSpotData.py.

◆ rootFile

python.BeamSpotData.BeamSpotFinderNt.rootFile = ROOT.TFile(fileName)

Definition at line 998 of file BeamSpotData.py.

◆ runList

list python.BeamSpotData.BeamSpotContainer.runList = []
inherited

Definition at line 754 of file BeamSpotData.py.

◆ runListExclude

list python.BeamSpotData.BeamSpotContainer.runListExclude = []
inherited

Definition at line 755 of file BeamSpotData.py.

◆ runMax

int python.BeamSpotData.BeamSpotContainer.runMax = 9999999
inherited

Definition at line 753 of file BeamSpotData.py.

◆ runMin

int python.BeamSpotData.BeamSpotContainer.runMin = 0
inherited

Definition at line 752 of file BeamSpotData.py.

◆ selBcidMax

python.BeamSpotData.BeamSpotContainer.selBcidMax = 0
inherited

Definition at line 784 of file BeamSpotData.py.

◆ selBcidMin

python.BeamSpotData.BeamSpotContainer.selBcidMin = 9999999
inherited

Definition at line 783 of file BeamSpotData.py.

◆ selFillMax

python.BeamSpotData.BeamSpotContainer.selFillMax = 0
inherited

Definition at line 782 of file BeamSpotData.py.

◆ selFillMin

python.BeamSpotData.BeamSpotContainer.selFillMin = 9999999
inherited

Definition at line 781 of file BeamSpotData.py.

◆ selRunMax

python.BeamSpotData.BeamSpotContainer.selRunMax = 0
inherited

Definition at line 780 of file BeamSpotData.py.

◆ selRunMin

python.BeamSpotData.BeamSpotContainer.selRunMin = 9999999
inherited

Definition at line 779 of file BeamSpotData.py.

◆ selTimeMax

python.BeamSpotData.BeamSpotContainer.selTimeMax = -1
inherited

Definition at line 786 of file BeamSpotData.py.

◆ selTimeMin

python.BeamSpotData.BeamSpotContainer.selTimeMin = 2000000000
inherited

Definition at line 785 of file BeamSpotData.py.

◆ statusList

list python.BeamSpotData.BeamSpotContainer.statusList = []
inherited

Definition at line 764 of file BeamSpotData.py.

◆ timeMax

int python.BeamSpotData.BeamSpotContainer.timeMax = 2000000000
inherited

Definition at line 763 of file BeamSpotData.py.

◆ timeMin

int python.BeamSpotData.BeamSpotContainer.timeMin = 0
inherited

Definition at line 762 of file BeamSpotData.py.

◆ treeName

python.BeamSpotData.BeamSpotFinderNt.treeName = treeName

Definition at line 997 of file BeamSpotData.py.


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