def addEntry(self, mass, title, evaluationRange, hSignal, hQCD, hEmbedded,
              hEWKfake):
     # Obtain event counts
     mySignal = self._evaluate(evaluationRange, hSignal)
     myQCD = self._evaluate(evaluationRange, hQCD)
     myEmbedded = self._evaluate(evaluationRange, hEmbedded)
     myEWKfake = self._evaluate(evaluationRange, hEWKfake)
     # Produce output
     myOutput = "%s, mass=%d, range=%d-%d\n" % (
         title, mass, evaluationRange[0], evaluationRange[1])
     myOutput += "  signal: %f +- %f\n" % (mySignal.value(),
                                           mySignal.uncertainty())
     myOutput += "  QCD: %f +- %f\n" % (myQCD.value(), myQCD.uncertainty())
     myOutput += "  EWKtau: %f +- %f\n" % (myEmbedded.value(),
                                           myEmbedded.uncertainty())
     myOutput += "  EWKfake: %f +- %f\n" % (myEWKfake.value(),
                                            myEWKfake.uncertainty())
     myExpected = Count(0.0, 0.0)
     myExpected.add(myQCD)
     myExpected.add(myEmbedded)
     myExpected.add(myEWKfake)
     myOutput += "  Total expected: %f +- %f\n" % (myExpected.value(),
                                                   myExpected.uncertainty())
     mySignal.divide(myExpected)
     myOutput += "  signal/expected: %f +- %f\n" % (mySignal.value(),
                                                    mySignal.uncertainty())
     myOutput += "\n"
     self._output += myOutput
    def getMinimumPurity(self):
        '''
        Return the minimum QCD purity as a Count object
        '''
        myMinPurity = 0.0
        myMinPurityUncert = 0.0
        nData = 0.0
        nEwk = 0.0

        # For-loop: All data
        for i in range(0, len(self._dataList)):
            # For-loop: All bins
            for j in range(0, self._dataList[i].GetNbinsX() + 2):
                nData += self._dataList[i].GetBinContent(j)
                nEwk += self._ewkList[i].GetBinContent(j)
        myPurity = 0.0
        myUncert = 0.0
        if (nData > 0.0):
            # Assume binomial error
            myPurity = (nData - nEwk) / nData
            myUncert = sqrt(myPurity * (1.0 - myPurity) / nData)
            if myPurity < myMinPurity:
                myMinPurity = myPurity
                myMinPurityUncert = myUncert
        return Count(myMinPurity, myMinPurityUncert)
Exemplo n.º 3
0
 def _evaluate(self,evaluationRange,h):
     myResult = 0.0
     myError = 0.0
     for i in range(1,h.GetNbinsX()+1):
         if (h.GetXaxis().GetBinLowEdge(i) >= evaluationRange[0] and
             h.GetXaxis().GetBinUpEdge(i) <= evaluationRange[1]):
             myResult += h.GetBinContent(i)
             myError += pow(h.GetBinError(i),2)
     return Count(myResult,sqrt(myError))
Exemplo n.º 4
0
 def getIntegratedPurity(self):
     nData = 0.0
     nEwk = 0.0
     for i in range(0, len(self._dataList)):
         for j in range(0, self._dataList[i].GetNbinsX()+2):
             nData += self._dataList[i].GetBinContent(j)
             nEwk += self._ewkList[i].GetBinContent(j)
     myPurity = 0.0
     myUncert = 0.0
     if (nData > 0.0):
         myPurity = (nData - nEwk) / nData
         myUncert = sqrt(myPurity * (1.0-myPurity) / nData) # Assume binomial error
     return Count(myPurity, myUncert)
 def getShapeByUnfoldedBin(self, unfoldedBinIndex, h):
     self._initialize(h)
     myResult = []
     myMin = 0
     myMax = h.GetNbinsX()
     if h.GetNbinsX() != 1:
         # Include under- and overflow bin
         myMin -= 1
         myMax += 1
     for i in range(myMin, myMax):
         myValue = h.GetBinContent(i + 1, unfoldedBinIndex + 1)
         myUncertainty = h.GetBinError(i + 1, unfoldedBinIndex + 1)
         myResult.append(Count(myValue, myUncertainty))
     return myResult
 def addEntry(self,mass,title,evaluationRange,hSignal,hQCD,hEmbedded,hEWKfake):
     # Obtain event counts
     mySignal = self._evaluate(evaluationRange,hSignal)
     myQCD = self._evaluate(evaluationRange,hQCD)
     myEmbedded = self._evaluate(evaluationRange,hEmbedded)
     myEWKfake = self._evaluate(evaluationRange,hEWKfake)
     # Produce output
     myOutput = "%s, mass=%d, range=%d-%d\n"%(title,mass,evaluationRange[0],evaluationRange[1])
     myOutput += "  signal: %f +- %f\n"%(mySignal.value(),mySignal.uncertainty())
     myOutput += "  QCD: %f +- %f\n"%(myQCD.value(),myQCD.uncertainty())
     myOutput += "  EWKtau: %f +- %f\n"%(myEmbedded.value(),myEmbedded.uncertainty())
     myOutput += "  EWKfake: %f +- %f\n"%(myEWKfake.value(),myEWKfake.uncertainty())
     myExpected = Count(0.0, 0.0)
     myExpected.add(myQCD)
     myExpected.add(myEmbedded)
     myExpected.add(myEWKfake)
     myOutput += "  Total expected: %f +- %f\n"%(myExpected.value(),myExpected.uncertainty())
     mySignal.divide(myExpected)
     myOutput += "  signal/expected: %f +- %f\n"%(mySignal.value(),mySignal.uncertainty())
     myOutput += "\n"
     self._output += myOutput
 def getContractedShapeForBin(self, factorisationAxisToKeep,
                              factorisationBin, h):
     self._initialize(h)
     myResult = []
     myMin = 0
     myMax = h.GetNbinsX()
     if h.GetNbinsX() != 1:
         # Include under- and overflow bin
         myMin -= 1
         myMax += 1
     for i in range(myMin, myMax):
         myValue = self._contractionRecursionForBin([],
                                                    factorisationAxisToKeep,
                                                    factorisationBin, h, i)
         myUncertainty = sqrt(
             self._contractionRecursionUncertaintyForBin(
                 [], factorisationAxisToKeep, factorisationBin, h, i))
         myResult.append(Count(myValue, myUncertainty))
     return myResult
 def getShapeForBin(self, factorisationBinIndexList, h):
     self._initialize(h)
     # Check that binning dimension is correct
     if len(self._binCount) != len(factorisationBinIndexList):
         raise Exception(
             "Error in UnfoldedHistogramReader::getEventCountForBin(): You asked for %d dimensions, but the histogram has %d dimensions (the dimension needs to be the same)!"
             % (len(factorisationBinIndexList), len(self._binCount)))
     myResult = []
     myMin = 0
     myMax = h.GetNbinsX()
     if h.GetNbinsX() != 1:
         # Include under- and overflow bin
         myMin -= 1
         myMax += 1
     myUnfoldedBin = self._convertBinIndexListToUnfoldedIndex(
         factorisationBinIndexList) + 1
     for i in range(myMin, myMax):
         myValue = h.GetBinContent(i + 1, myUnfoldedBin)
         myUncertainty = h.GetBinError(i + 1, myUnfoldedBin)
         myResult.append(Count(myValue, myUncertainty))
     return myResult