def GetRootHistos(datasetsMgr, histoList, regions, binLabels): # Definition hPathDict = GetHistoPathDict(histoList, printList=False) rhDict = {} # For-loop: All Control Regions (CR) for region in regions: # For-loop: All bins for binLabel in binLabels: # Define labels lIncl = "%s-%s" % (region, binLabel) lGenB = "%s-%s-%s" % (region, binLabel, "EWKGenuineB") lFakeB = "%s-%s-%s" % (region, binLabel, "EWKFakeB") # Get the desired histograms pIncl = plots.DataMCPlot(datasetsMgr, hPathDict[lIncl]) pGenB = plots.DataMCPlot(datasetsMgr, hPathDict[lGenB]) pFakeB = plots.DataMCPlot(datasetsMgr, hPathDict[lFakeB]) # Clone and Save the root histograms rhDict["Data-" + lIncl] = pIncl.histoMgr.getHisto( "Data").getRootHisto().Clone("Data-" + lIncl) rhDict["EWK-" + lGenB] = pGenB.histoMgr.getHisto( "EWK").getRootHisto().Clone("EWK-" + lGenB) rhDict["EWK-" + lFakeB] = pFakeB.histoMgr.getHisto( "EWK").getRootHisto().Clone("EWK-" + lFakeB) if opts.useMC: rhDict["QCD-" + lIncl] = pIncl.histoMgr.getHisto( "QCD").getRootHisto().Clone("QCD-" + lIncl) # Add EWKFakeB (MC) to QCD (MC) to get FakeB (= QCD_inclusive + EWK_fakeB) rhDict["FakeB-" + lIncl] = rhDict["QCD-" + lIncl].Clone("FakeB-" + lIncl) rhDict["FakeB-" + lIncl].Add(rhDict["EWK-" + lFakeB], +1) else: # Subtract EWKGenuineB (MC) from Data to get FakeB (= Data - EWK_genuineB) rhDict["FakeB-" + lIncl] = rhDict["Data-" + lIncl].Clone("FakeB-" + lIncl) rhDict["FakeB-" + lIncl].Add(rhDict["EWK-" + lGenB], -1) # For debugging: if 0: for k in rhDict: if "FakeB" not in k: continue fakeBResult.PrintTH1Info(rhDict[k]) return rhDict
def GetRootHistos(datasetsMgr, histoList): hPathDict = GetHistoPathDict(histoList, printList=False) rhDict = {} # For-loop: All histograms for h in histoList: inclu, genuB, fakeB = GetHistoLabelTriplet(h) pIncl = plots.DataMCPlot(datasetsMgr, hPathDict[inclu]) pGenB = plots.DataMCPlot(datasetsMgr, hPathDict[genuB]) pFakeB = plots.DataMCPlot(datasetsMgr, hPathDict[fakeB]) # Define mapping keys: "Datasets-Region-Bin-Triplet" key1 = "Data-%s" % (inclu) key2 = "EWKGenuineB-%s" % (genuB) key3 = "EWKFakeB-%s" % (fakeB) key4 = "FakeB-%s" % (inclu) # Clone and Save the root histograms rhDict[key1] = pIncl.histoMgr.getHisto("Data").getRootHisto().Clone( "Data-" + h) rhDict[key2] = pGenB.histoMgr.getHisto("EWK").getRootHisto().Clone( "EWKGenuineB-" + h) rhDict[key3] = pFakeB.histoMgr.getHisto("EWK").getRootHisto().Clone( "EWKFakeB-" + h) rhDict[key4] = pIncl.histoMgr.getHisto("Data").getRootHisto().Clone( "FakeB-" + h) rhDict[key4].Add(rhDict[key2], -1) # For debugging: if 0: for k in rhDict: if "FakeB" not in k: continue fakeBResult.PrintTH1Info(rhDict[k]) return rhDict
def buildModule(self, dataPath, ewkPath, normFactors, calculateQCDNormalizationSyst, normDataSrc=None, normEWKSrc=None): # Create containers for results self.Verbose("Create containers for results", True) myModule = pseudoMultiCrabCreator.PseudoMultiCrabModule( self._dsetMgr, self._era, self._searchMode, self._optimizationMode, self._systematicVariation, opts.analysisNameSaveAs, opts.verbose) self.Verbose("Obtain results from the results manager", True) self._nominalResult = fakeBResult.FakeBResultManager( dataPath, ewkPath, self._dsetMgr, self._luminosity, self.getModuleInfoString(), normFactors, calculateQCDNormalizationSyst, opts.normDataSrc, opts.normEwkSrc, self._opts.useInclusiveNorm, keyList=["AllSelections"], verbose=opts.verbose) self.Verbose( "Add all plots to be written in the peudo-dataset beind created", True) myModule.addPlots(self._nominalResult.getShapePlots(), self._nominalResult.getShapePlotLabels()) self._outputCreator.addModule(myModule) return
def buildTransferFactorVarSystModule(self, dataPath, ewkPath, normFactors): #Up, normFactorsDown): ''' This function re-calculates all histograms as normal and stores them into folders with extensions: "Hplus2tbAnalysis_<opts.searchMode>_<opts.era>_SystVarTransferFactorUp" "Hplus2tbAnalysis_<opts.searchMode>_<opts.era>_SystVarTransferFactorDown" The difference is that instead of using the nominal Transfer Factors (TF) for a given FakeB measurement bin (e.g. ldg b-jet eta) it does it using an up/down variation of it: TF_Up = TF + Error TF_Down = TF - Error where the error values and errors of the TFs are calculated in FakeBNormalization.py using the CalculateTransferFactor() method of FakeBNormalizationManager class object. The error in this case is calculated by using error propagation: TF = CR1/CR2 TF_Error = ErrorPropagationForDivision(TF) = sqrt((sigmaA/b)**2 + (a/(b**2)*sigmaB)**2) where: A = Integral of CR1 histogram (from ROOT) sigmaA = Integral Error for CR1 histogram (from ROOT) ''' # Up variation of Transfer Factors print #Print(ShellStyles.HighlightAltStyle() + "TF+Error Variation" + ShellStyles.NormalStyle() , True) Print( ShellStyles.HighlightAltStyle() + "Extra Module: SystVarTransferFactorPlus" + ShellStyles.NormalStyle(), False) mySystModulePlus = pseudoMultiCrabCreator.PseudoMultiCrabModule( self._dsetMgr, self._era, self._searchMode, self._optimizationMode, "SystVarTransferFactorUp", #self._systematicVariation opts.analysisNameSaveAs, opts.verbose) self._transferFactorPlusResult = fakeBResult.FakeBResultManager( dataPath, ewkPath, self._dsetMgr, self._luminosity, self.getModuleInfoString(), normFactors["SystVarUp"], optionDoFakeBNormalisationSyst=False, optionUseInclusiveNorm=self._opts.useInclusiveNorm, keyList=["AllSelections"], verbose=opts.verbose) # Up variation of Transfer Factors (3x) print Print( ShellStyles.HighlightAltStyle() + "Extra Module: SystVarTransferFactor3xPlus" + ShellStyles.NormalStyle(), False) mySystModule3xPlus = pseudoMultiCrabCreator.PseudoMultiCrabModule( self._dsetMgr, self._era, self._searchMode, self._optimizationMode, "SystVarTransferFactor3xUp", #self._systematicVariation opts.analysisNameSaveAs, opts.verbose) # Create new list with TF + 3xError self._transferFactorPlusResult3x = fakeBResult.FakeBResultManager( dataPath, ewkPath, self._dsetMgr, self._luminosity, self.getModuleInfoString(), normFactors["SystVar3xUp"], optionDoFakeBNormalisationSyst=False, optionUseInclusiveNorm=self._opts.useInclusiveNorm, keyList=["AllSelections"], verbose=opts.verbose) # Add the plots mySystModulePlus.addPlots( self._transferFactorPlusResult.getShapePlots(), self._transferFactorPlusResult.getShapePlotLabels()) mySystModule3xPlus.addPlots( self._transferFactorPlusResult3x.getShapePlots(), self._transferFactorPlusResult3x.getShapePlotLabels()) # Save "_SystVarTransferFactorUp" folder to pseudo-dataset pseudo-multicrab self._outputCreator.addModule(mySystModulePlus) self._outputCreator.addModule(mySystModule3xPlus) # Down variation of Transfer Factors print Print( ShellStyles.HighlightAltStyle() + "Extra Module: SystVarTransferFactorMinus" + ShellStyles.NormalStyle(), False) mySystModuleMinus = pseudoMultiCrabCreator.PseudoMultiCrabModule( self._dsetMgr, self._era, self._searchMode, self._optimizationMode, "SystVarTransferFactorDown", opts.analysisNameSaveAs, opts.verbose) self._transferFactorMinusResult = fakeBResult.FakeBResultManager( dataPath, ewkPath, self._dsetMgr, self._luminosity, self.getModuleInfoString(), normFactors["SystVarDown"], optionDoFakeBNormalisationSyst=False, optionUseInclusiveNorm=self._opts.useInclusiveNorm, keyList=["AllSelections"], verbose=opts.verbose) # Down variation of Transfer Factors (3x) print Print( ShellStyles.HighlightAltStyle() + "Extra Module: SystVarTransferFactor3xMinus" + ShellStyles.NormalStyle(), False) mySystModule3xMinus = pseudoMultiCrabCreator.PseudoMultiCrabModule( self._dsetMgr, self._era, self._searchMode, self._optimizationMode, "SystVarTransferFactor3xDown", opts.analysisNameSaveAs, opts.verbose) self._transferFactorMinusResult3x = fakeBResult.FakeBResultManager( dataPath, ewkPath, self._dsetMgr, self._luminosity, self.getModuleInfoString(), normFactors["SystVar3xDown"], optionDoFakeBNormalisationSyst=False, optionUseInclusiveNorm=self._opts.useInclusiveNorm, keyList=["AllSelections"], verbose=opts.verbose) # Add the plots mySystModuleMinus.addPlots( self._transferFactorMinusResult.getShapePlots(), self._transferFactorMinusResult.getShapePlotLabels()) mySystModule3xMinus.addPlots( self._transferFactorMinusResult3x.getShapePlots(), self._transferFactorMinusResult3x.getShapePlotLabels()) # Save "_SystVarTransferFactorDown" folder to pseudo-dataset pseudo-multicrab self._outputCreator.addModule(mySystModuleMinus) self._outputCreator.addModule(mySystModule3xMinus) return