示例#1
0
    def _obtainQCDNormalizationSystHistograms(self, shapeHisto, dsetMgr, plotName, luminosity, normDataSrc, normEWKSrc):
        msg = "Obtaining region transition systematics"
        self.Print(ShellStyles.HighlightStyle() + msg + ShellStyles.NormalStyle(), True)

        myPlotSignalRegionShape = dataDrivenQCDCount.DataDrivenQCDShape(dsetMgr=dsetMgr,
                                                                        dsetLabelData="Data",
                                                                        dsetLabelEwk="EWK",
                                                                        histoName=plotName,
                                                                        dataPath=normDataSrc+"QCDNormalizationSignal",
                                                                        ewkPath=normEWKSrc+"QCDNormalizationSignal",
                                                                        luminosity=luminosity,
                                                                        optionUseInclusiveNorm=False,
                                                                        verbose=True)

        myPlotControlRegionShape = dataDrivenQCDCount.DataDrivenQCDShape(dsetMgr=dsetMgr,
                                                                         dsetLabelData="Data",
                                                                         dsetLabelEwk="EWK",
                                                                         histoName=plotName,
                                                                         dataPath=normDataSrc+"QCDNormalizationControl",
                                                                         ewkPath=normEWKSrc+"QCDNormalizationControl",
                                                                         luminosity=luminosity,
                                                                         optionUseInclusiveNorm=False,
                                                                         verbose=True)


        myPlotRegionTransitionSyst = metSyst.SystematicsForMetShapeDifference(myPlotSignalRegionShape, 
                                                                              myPlotControlRegionShape, 
                                                                              shapeHisto, 
                                                                              moduleInfoString=self._moduleInfoString,
                                                                              quietMode=True)
        myPlotSignalRegionShape.delete()
        myPlotControlRegionShape.delete()
        # Store up and down variations
        #hUp = aux.Clone(myPlotRegionTransitionSyst.getUpHistogram(), "QCDfactMgrSystQCDSystUp%d"%i)
        #hUp.SetTitle(plotName+"systQCDUp")
        #self._QCDNormalizationSystPlots.append(hUp)
        #self._QCDNormalizationSystPlotLabels.append(hUp.GetTitle())
        #hDown = aux.Clone(myPlotRegionTransitionSyst.getDownHistogram(), "QCDfactMgrSystQCDSystDown%d"%i)
        #hDown.SetTitle(plotName+"systQCDDown")
        #self._QCDNormalizationSystPlots.append(hDown)
        #self._QCDNormalizationSystPlotLabels.append(hDown.GetTitle())
        # Store source histograms
        hNum = aux.Clone(myPlotRegionTransitionSyst.getCombinedSignalRegionHistogram(), "QCDfactMgrSystQCDSystNumerator")
        hNum.SetTitle(plotName+"systQCDNumerator")
        self._QCDNormalizationSystPlots.append(hNum)
        self._QCDNormalizationSystPlotLabels.append(hNum.GetTitle())
        hDenom = aux.Clone(myPlotRegionTransitionSyst.getCombinedCtrlRegionHistogram(), "QCDfactMgrSystQCDSystDenominator")
        hDenom.SetTitle(plotName+"systQCDDenominator")
        self._QCDNormalizationSystPlots.append(hDenom)
        self._QCDNormalizationSystPlotLabels.append(hDenom.GetTitle())
        # Free memory
        myPlotRegionTransitionSyst.delete()
示例#2
0
    def _obtainShapeHistograms(self, i, dataPath, ewkPath, dsetMgr, plotName, luminosity, normFactors):
        self.Verbose("_obtainShapeHistograms()", True)

        if self._verbose:
            self.PrintShapeInputSummary(dataPath, ewkPath, dsetMgr, plotName, luminosity, normFactors)

        self.Verbose("Obtain the (pre-normFactor) shape %s as \"DataDrivenQCDShape\" type object" % (plotName), True) 
        myShape = dataDrivenQCDCount.DataDrivenQCDShape(dsetMgr, "Data", "EWK", plotName, dataPath, ewkPath, luminosity, self._useInclusiveNorm, self._verbose)
        
        if self._verbose:
            msg = "Printing TH1s (before NormFactors) of \"Data\", \"Data-Driven QCD\", \"EWK\",  and \"Bin-by\Bin Purity\" and \"Integrated Purity\""
            self.Print(msg, True)
            PrintTH1Info(myShape.getIntegratedDataHisto())
            PrintTH1Info(myShape.getIntegratedDataDrivenQCDHisto()) #Data-EWK. NormFactor not applied
            PrintTH1Info(myShape.getIntegratedEwkHisto())
            PrintTH1Info(myShape.getPurityHisto())  # Splitted-bin (disabled for Inclusive mode)
            PrintTH1Info(myShape.getIntegratedPurityForShapeHisto())        
            self.PrintShapePuritySummary(myShape)
        
        self.Verbose("Obtain the (post-normFactor) shape %s as \"QCDInvertedShape\" type object (Takes \"DataDrivenQCDShape\" type object as argument)" % (plotName), True)
        moduleInfo = self._moduleInfoString + "_" + plotName
        myPlot= QCDInvertedShape(myShape, moduleInfo, normFactors, optionUseInclusiveNorm=self._useInclusiveNorm)
        myPlot.PrintSettings(printHistos=self._verbose, verbose=self._verbose)

        # Define histogram name as will be written in the ROOT file
        self.Verbose("%sDefining the name of histogram objects, as they will appear in the ROOT file%s" % (ShellStyles.WarningStyle(), ShellStyles.NormalStyle()), True)
        hName  = plotName + "%d" %i
        hTitle = plotName.replace("CRSelections", "AllSelections").replace("Baseline_", "").replace("Inverted_", "")#FIXME: not elegant!

        # DataDriven
        myShape.delete()
        myPlotHisto = aux.Clone(myPlot.getResultShape(), "ctrlPlotShapeInManager")
        myPlot.delete()
        myPlotHisto.SetName(hName)
        myPlotHisto.SetTitle(hTitle)
        self._shapePlots.append(myPlotHisto)
        self._shapePlotLabels.append(myPlotHisto.GetTitle())# this is the name the object will have in the ROOT file

        # MC EWK
        hName  = plotName + "%d_MCEWK" %i
        myPlotMCEWKHisto = aux.Clone(myPlot.getResultMCEWK(), "ctrlPlotMCEWKInManager")
        myPlotMCEWKHisto.SetName(hName) 
        myPlotMCEWKHisto.SetTitle(hTitle + "_MCEWK")
        self._shapePlots.append(myPlotMCEWKHisto)
        self._shapePlotLabels.append(myPlotMCEWKHisto.GetTitle())# this is the name the object will have in the ROOT file

        # Purity
        hName  = plotName + "%d_Purity" %i
        #self.Print("myPlot.getResultPurity().GetName() = %s" % myPlot.getResultPurity().GetName(), True)
        #self.Print("myPlot.getResultPurity().GetIntegral() = %s" % myPlot.getResultPurity().Integral(), True)

        myPlotPurityHisto = aux.Clone(myPlot.getResultPurity(), "ctrlPlotPurityInManager")
        myPlotPurityHisto.SetName(hName)
        myPlotPurityHisto.SetTitle(hTitle + "_Purity")
        self._shapePlots.append(myPlotPurityHisto)
        self._shapePlotLabels.append(myPlotPurityHisto.GetTitle())# this is the name the object will have in the ROOT file
        return myPlotHisto
    def _obtainShapeHistograms(self, i, dataPath, ewkPath, dsetMgr, plotName, luminosity, normFactors):
        Verbose("_obtainShapeHistograms()", True)

        if self._verbose:
            self.PrintShapeInputSummary(dataPath, ewkPath, dsetMgr, plotName, luminosity, normFactors)
        
        Verbose("Obtain the (pre-normFactor) shape %s as \"DataDrivenQCDShape\" type object" % (plotName), True) 
        myShape = dataDrivenQCDCount.DataDrivenQCDShape(dsetMgr, "Data", "EWK", plotName, dataPath, ewkPath, luminosity, self._useInclusiveNorm) #pre-normFactor

        if self._verbose:
            msg = "Printing TH1s (before NormFactors) of \"Data\", \"Data-Driven QCD\", \"EWK\",  and \"Bin-by\Bin Purity\" and \"Integrated Purity\""
            Print(msg, True)
            PrintTH1Info(myShape.getIntegratedDataHisto())
            PrintTH1Info(myShape.getIntegratedDataDrivenQCDHisto()) #Data-EWK. NormFactor not applied
            PrintTH1Info(myShape.getIntegratedEwkHisto())
            PrintTH1Info(myShape.getPurityHisto())
            PrintTH1Info(myShape.getIntegratedPurityForShapeHisto())

        if self._verbose:
            self.PrintShapePuritySummary(myShape)
        
        Verbose("Obtain the (post-normFactor) shape %s as \"QCDInvertedShape\" type object (Takes \"DataDrivenQCDShape\" type object as argument)" % (plotName), True)
        moduleInfo = self._moduleInfoString + "_" + plotName
        myPlot     = QCDInvertedShape(myShape, moduleInfo, normFactors, optionUseInclusiveNorm=self._useInclusiveNorm)
        myPlot.PrintSettings(printHistos=self._verbose, verbose=self._verbose)

        myShape.delete()
        myPlotHisto = aux.Clone(myPlot.getResultShape(), "ctrlPlotShapeInManager")
        myPlot.delete()
        myPlotHisto.SetName(plotName+"%d"%i)
        myPlotHisto.SetTitle(plotName)
        self._shapePlots.append(myPlotHisto)
        self._shapePlotLabels.append(plotName)

        # MC EWK and purity
        myPlotMCEWKHisto = aux.Clone(myPlot.getResultMCEWK(), "ctrlPlotMCEWKInManager")
        myPlotMCEWKHisto.SetName(plotName+"%d_MCEWK"%i)
        myPlotMCEWKHisto.SetTitle(plotName+"_MCEWK")
        self._shapePlots.append(myPlotMCEWKHisto)
        self._shapePlotLabels.append(myPlotMCEWKHisto.GetTitle())
        myPlotPurityHisto = aux.Clone(myPlot.getResultPurity(), "ctrlPlotPurityInManager")
        myPlotPurityHisto.SetName(plotName+"%d_Purity"%i)
        myPlotPurityHisto.SetTitle(plotName+"_Purity")
        self._shapePlots.append(myPlotPurityHisto)
        self._shapePlotLabels.append(myPlotPurityHisto.GetTitle())
        return myPlotHisto