A utility class for averaging beam spot data.
Definition at line 590 of file BeamSpotData.py.
◆ __init__()
def python.BeamSpotData.BeamSpotAverage.__init__ |
( |
|
self, |
|
|
|
varList = None , |
|
|
|
weightedAverage = True |
|
) |
| |
Definition at line 593 of file BeamSpotData.py.
593 def __init__(self,varList=None,weightedAverage=True):
595 self.varList = varList
597 self.varList = [
'posX',
'posY',
'posZ',
'sigmaX',
'sigmaY',
'sigmaZ',
'tiltX',
'tiltY',
'rhoXY',
'k']
598 self.weightedAverage = weightedAverage
599 self.sumw = numpy.zeros(len(self.varList))
600 self.sumwx = numpy.zeros(len(self.varList))
601 self.sumwxx = numpy.zeros(len(self.varList))
602 self.sumwwee = numpy.zeros(len(self.varList))
604 self.sum = numpy.zeros(len(self.varList))
605 self.sumx = numpy.zeros(len(self.varList))
606 self.sumxx = numpy.zeros(len(self.varList))
◆ add()
def python.BeamSpotData.BeamSpotAverage.add |
( |
|
self, |
|
|
|
b |
|
) |
| |
Add elements of BeamSpotValue b to average.
Definition at line 633 of file BeamSpotData.py.
634 """Add elements of BeamSpotValue b to average."""
635 if self.lumiData
is not None:
637 if b.lbEnd <= b.lbStart:
638 print (
'ERROR: Illegal luminosity block range: [%i,%i]' % (b.lbStart,b.lbEnd))
640 for lb
in range(b.lbStart,b.lbEnd):
642 lumi += self.lumiData[b.run][lb]
644 print (
'ERROR: missing luminosity information for run %i LB %i (in [%i,%i]) - weight set to zero!!' % (b.run,lb,b.lbStart,b.lbEnd))
646 for i
in range(len(self.varList)):
647 parName = self.varList[i]
648 val = getattr(b,parName)
649 valErr = getattr(b,parName+
'Err')
652 self.sumxx[i] += val*val
653 if self.lumiData
is None:
658 print (
'WARNING: Divison by zero for parameter %s (val = %f valErr = %f)\n' % (parName,val,valErr))
663 self.sumwx[i] += w*val
664 self.sumwxx[i] += w*val*val
665 self.sumwwee[i] += w*w*valErr*valErr
◆ average()
def python.BeamSpotData.BeamSpotAverage.average |
( |
|
self | ) |
|
Definition at line 667 of file BeamSpotData.py.
668 self.rms = numpy.sqrt(self.sumxx/self.sum - self.sumx*self.sumx/self.sum/self.sum)
669 if self.weightedAverage:
670 if self.lumiData
is None:
671 self.ave = self.sumwx/self.sumw
672 self.err = 1./numpy.sqrt(self.sumw)
674 self.ave = self.sumwx/self.sumw
675 self.err = numpy.sqrt(self.sumwwee)/self.sumw
677 self.ave = self.sumx/self.sum
678 self.err = self.rms/numpy.sqrt(self.sum)
◆ getIndex()
def python.BeamSpotData.BeamSpotAverage.getIndex |
( |
|
self, |
|
|
|
varName |
|
) |
| |
Definition at line 680 of file BeamSpotData.py.
680 def getIndex(self, varName):
681 for i
in range(len(self.varList)):
682 if self.varList[i]==varName:
◆ readLumiData()
def python.BeamSpotData.BeamSpotAverage.readLumiData |
( |
|
self, |
|
|
|
lumiCalcNtupleName |
|
) |
| |
Read iLumiCalc.exe ntuple with luminosity data, store data in self.lumiData dict.
Definition at line 610 of file BeamSpotData.py.
610 def readLumiData(self,lumiCalcNtupleName):
611 """Read iLumiCalc.exe ntuple with luminosity data, store data in self.lumiData dict."""
612 lumiFile = ROOT.TFile(lumiCalcNtupleName)
613 lumiNt = lumiFile.Get(
'LumiMetaData')
614 print (
'Reading',lumiNt.GetEntries(),
'entries from luminosity ntuple',lumiCalcNtupleName)
616 for j
in range(lumiNt.GetEntries()):
620 lumi = lumiNt.IntLumi
622 self.lumiData[run][lb] = lumi
624 self.lumiData[run] = {}
625 self.lumiData[run][lb] = lumi
627 for (run,lbdict)
in self.lumiData.
items():
628 for (lb,lumi)
in lbdict.items():
630 print (
'... total luminosity = %6.1f / pb' % (lumiSum/1.E6))
◆ ave
python.BeamSpotData.BeamSpotAverage.ave |
◆ err
python.BeamSpotData.BeamSpotAverage.err |
◆ lumiData
python.BeamSpotData.BeamSpotAverage.lumiData |
◆ nWarnings
python.BeamSpotData.BeamSpotAverage.nWarnings |
◆ rms
python.BeamSpotData.BeamSpotAverage.rms |
◆ sum
python.BeamSpotData.BeamSpotAverage.sum |
◆ sumw
python.BeamSpotData.BeamSpotAverage.sumw |
◆ sumwwee
python.BeamSpotData.BeamSpotAverage.sumwwee |
◆ sumwx
python.BeamSpotData.BeamSpotAverage.sumwx |
◆ sumwxx
python.BeamSpotData.BeamSpotAverage.sumwxx |
◆ sumx
python.BeamSpotData.BeamSpotAverage.sumx |
◆ sumxx
python.BeamSpotData.BeamSpotAverage.sumxx |
◆ varList
python.BeamSpotData.BeamSpotAverage.varList |
◆ weightedAverage
python.BeamSpotData.BeamSpotAverage.weightedAverage |
The documentation for this class was generated from the following file: