def main(): # Adjust paths such that this script can be run inside the first embedding trial directory dirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.dirEmbs[1:]] # Create the dataset objects datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb+"Counters", normalizeMCByLuminosity=True) datasetsEmb.forEach(plots.mergeRenameReorderForDataMC) datasetsEmb.setLumiFromData() # Remove W+3jets datasetsEmb.remove(filter(lambda name: "W3Jets" in name, datasetsEmb.getAllDatasetNames())) # Add EWK+tt scaled down with BR(t->H+) (EWKScaled) def addSignal(datasetMgr): xsect.setHplusCrossSectionsToBR(datasetMgr, br_tH=signal_br_tH, br_Htaunu=1) plots.mergeWHandHH(datasetMgr) ttjets2 = datasetMgr.getDataset("TTJets").deepCopy() ttjets2.setName("TTJets2") ttjets2.setCrossSection(ttjets2.getCrossSection() - datasetMgr.getDataset("TTToHplus_M120").getCrossSection()) datasetMgr.append(ttjets2) datasetMgr.merge("EWKnoTT", ["WJets", "DYJetsToLL", "SingleTop", "Diboson"], keepSources=True) datasetMgr.merge("EWKScaled", ["EWKnoTT", "TTJets2"]) datasetMgr.merge("EWKMC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"]) datasetsEmb.forEach(addSignal) tauEmbedding.normalize=True tauEmbedding.era = "Run2011A" doCounters(datasetsEmb)
def main(): # Adjust paths such that this script can be run inside the first embedding trial directory dirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.dirEmbs[1:]] # Create the dataset objects datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb + "Counters", normalizeMCByLuminosity=True) # Remove signal and W+3jets datasets datasetsEmb.remove( filter(lambda name: "HplusTB" in name, datasetsEmb.getAllDatasetNames())) datasetsEmb.remove( filter(lambda name: "TTToHplus" in name, datasetsEmb.getAllDatasetNames())) datasetsEmb.remove( filter(lambda name: "W3Jets" in name, datasetsEmb.getAllDatasetNames())) datasetsEmb.forEach(plots.mergeRenameReorderForDataMC) datasetsEmb.setLumiFromData() # Apply TDR style style = tdrstyle.TDRStyle() histograms.cmsTextMode = histograms.CMSMode.NONE tauEmbedding.normalize = True tauEmbedding.era = "Run2011A" doCounters(datasetsEmb) # Remove QCD for plots datasetsEmb.remove(["QCD_Pt20_MuEnriched"]) histograms.createLegend.moveDefaults(dx=-0.04, dh=-0.05) doPlots(datasetsEmb)
def main(): tauDirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.tauDirEmbs[1:]] tauDirSig = "../"+tauEmbedding.tauDirSig datasetsEmb = tauEmbedding.DatasetsMany(tauDirEmbs, analysisEmb+"Counters", normalizeMCByLuminosity=True) datasetsSig = dataset.getDatasetsFromMulticrabCfg(cfgfile=tauDirSig+"/multicrab.cfg", counters=analysisSig+"Counters") datasetsSig.updateNAllEventsToPUWeighted() datasetsEmb.forEach(plots.mergeRenameReorderForDataMC) #datasetsEmb.setLumiFromData() datasetsEmb.lumi = 5049 plots.mergeRenameReorderForDataMC(datasetsSig) def mergeEWK(datasets): datasets.merge("EWKMC", ["WJets", "TTJets"], keepSources=True) #datasets.merge("EWKMC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"], keepSources=True) #mergeEWK(datasetsSig) #datasetsEmb.forEach(mergeEWK) #plots._legendLabels["EWKMC"] = "EWK" style = tdrstyle.TDRStyle() histograms.createLegend.setDefaults(y1=0.93, y2=0.75, x1=0.52, x2=0.93) tauEmbedding.normalize = True tauEmbedding.era = "Run2011A" def dop(datasetName): # doPlots(datasetsEmb, datasetsSig, datasetName) doCounters(datasetsEmb, datasetsSig, datasetName) print "%s done" % datasetName dop("TTJets")
def main(): dirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.dirEmbs[1:]] dirSig = "../" + tauEmbedding.dirSig # dirEmbs = dirEmbs[:2] datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb + "/counters", normalizeMCByLuminosity=True) datasetsSig = dataset.getDatasetsFromMulticrabCfg( cfgfile=dirSig + "/multicrab.cfg", counters=analysisSig + "/counters") datasetsSig.updateNAllEventsToPUWeighted() datasetsEmb.forEach(plots.mergeRenameReorderForDataMC) datasetsEmb.setLumiFromData() plots.mergeRenameReorderForDataMC(datasetsSig) def mergeEWK(datasets): datasets.merge( "EWKMC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"], keepSources=True) mergeEWK(datasetsSig) datasetsEmb.forEach(mergeEWK) plots._legendLabels["EWKMC"] = "EWK" # Apply TDR style style = tdrstyle.TDRStyle() histograms.cmsTextMode = histograms.CMSMode.SIMULATION histograms.cmsText[histograms.CMSMode.SIMULATION] = "Simulation" histograms.createLegend.setDefaults(y1=0.93, y2=0.75, x1=0.52, x2=0.93) tauEmbedding.normalize = True tauEmbedding.era = "Run2011AB" table = counter.CounterTable() def dop(name): doPlots(datasetsEmb, datasetsSig, name) tbl = doCounters(datasetsEmb, datasetsSig, name) for icol in xrange(tbl.getNcolumns()): table.appendColumn(tbl.getColumn(icol)) dop("TTJets") dop("WJets") dop("DYJetsToLL") dop("SingleTop") dop("Diboson") cellFormat = counter.TableFormatLaTeX( counter.CellFormatTeX(valueFormat='%.4f', withPrecision=2)) print table.format(cellFormat)
def doCounters(dirEmbs): datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb+"Counters", normalizeMCByLuminosity=True) datasetsEmb.forEach(plots.mergeRenameReorderForDataMC) datasetsEmb.setLumiFromData() datasetsEmb.remove(filter(lambda name: "HplusTB" in name, datasetsEmb.getAllDatasetNames())) datasetsEmb.remove(filter(lambda name: "TTToHplus" in name, datasetsEmb.getAllDatasetNames())) eventCounter = tauEmbedding.EventCounterMany(datasetsEmb) mainTable = eventCounter.getMainCounterTable() ewkDatasets = ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"] def ewkSum(table): table.insertColumn(1, counter.sumColumn("EWKMCsum", [table.getColumn(name=name) for name in ewkDatasets])) ewkSum(mainTable) datasetsEmb.close() return mainTable.getRow(name="deltaPhiTauMET<160")
def oldstuff(): # Create the dataset objects datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb+"Counters", normalizeMCByLuminosity=True) datasetsSig = dataset.getDatasetsFromMulticrabCfg(cfgfile=dirSig+"/multicrab.cfg", counters=analysisSig+"Counters") datasetsSig.updateNAllEventsToPUWeighted() # Remove signal and W+3jets datasets datasetsEmb.remove(filter(lambda name: "HplusTB" in name, datasetsEmb.getAllDatasetNames())) datasetsEmb.remove(filter(lambda name: "TTToHplus" in name, datasetsEmb.getAllDatasetNames())) datasetsEmb.remove(filter(lambda name: "W3Jets" in name, datasetsEmb.getAllDatasetNames())) # Keep WW separately, Diboson is WZ+ZZ #del plots._datasetMerge["WW"] datasetsEmb.forEach(lambda mgr: plots.mergeRenameReorderForDataMC(mgr, keepSourcesMC=True)) datasetsEmb.setLumiFromData() plots.mergeRenameReorderForDataMC(datasetsSig, keepSourcesMC=True) # Merge EWK datasets def mergeEWK(datasets): datasets.merge("EWKMC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson", "WW"], keepSources=True) datasets.merge("EWKMC", ["Diboson", "WW"], keepSources=True) mergeEWK(datasetsSig) datasetsEmb.forEach(mergeEWK) plots._legendLabels["EWKMC"] = "EWK" # Apply TDR style style = tdrstyle.TDRStyle() histograms.cmsTextMode = histograms.CMSMode.NONE ROOT.gStyle.SetEndErrorSize(5) histograms.createLegend.setDefaults(y1=0.93, y2=0.75, x1=0.49, x2=0.9) tauEmbedding.normalize=True tauEmbedding.era = "Run2011AB" # Create datasets with residuals # Define DYJetsToLL and WW be the datasets where residuals are calculated # Define Data and EWKMC be the datasets to which the residuals are added # I.e. Data will be embedded data + res. MC, and EWKMC embedded MC + res. MC datasetsEmbCorrected = tauEmbedding.DatasetsResidual(datasetsEmb, datasetsSig, analysisEmb, analysisSig, ["DYJetsToLL", "WW"], totalNames=["Data", "EWKMC"]) doPlots(datasetsEmbCorrected, datasetsSig, "EWKMC") doCounters(datasetsEmbCorrected, datasetsSig)
def main(): dirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.dirEmbs[1:]] datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb + "Counters", normalizeMCByLuminosity=True) datasetsEmb.forEach(plots.mergeRenameReorderForDataMC) datasetsEmb.setLumiFromData() datasetsEmb.remove( filter(lambda name: "HplusTB" in name, datasetsEmb.getAllDatasetNames())) def addSignal(datasetMgr): xsect.setHplusCrossSectionsToBR( datasetMgr, br_tH=0.03, br_Htaunu=1) # agreed to use 3 % as with QCD plots.mergeWHandHH(datasetMgr) ttjets2 = datasetMgr.getDataset("TTJets").deepCopy() ttjets2.setName("TTJets2") ttjets2.setCrossSection( ttjets2.getCrossSection() - datasetMgr.getDataset("TTToHplus_M120").getCrossSection()) datasetMgr.append(ttjets2) datasetMgr.merge("EWKnoTT", ["WJets", "DYJetsToLL", "SingleTop", "Diboson"], keepSources=True) datasetMgr.merge("EWKScaled", ["EWKnoTT", "TTJets2"]) # for mass in [80, 100]: for mass in [80, 90, 100, 120, 140, 150, 155, 160]: datasetMgr.merge("EWKSignal_M%d" % mass, ["TTToHplus_M%d" % mass, "EWKScaled"], keepSources=True) datasetsEmb.forEach(addSignal) tauEmbedding.normalize = True tauEmbedding.era = "Run2011A" doCounters(datasetsEmb)
def main(): dirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.dirEmbs[1:]] dirSig = "../" + tauEmbedding.dirSig datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb + "Counters", normalizeMCByLuminosity=True) datasetsSig = dataset.getDatasetsFromMulticrabCfg( cfgfile=dirSig + "/multicrab.cfg", counters=analysisSig + "Counters") datasetsSig.updateNAllEventsToPUWeighted() del plots._datasetMerge["WW"] # del plots._datasetMerge["WZ"] # del plots._datasetMerge["ZZ"] datasetsEmb.forEach( lambda mgr: plots.mergeRenameReorderForDataMC(mgr, keepSourcesMC=True)) datasetsEmb.setLumiFromData() plots.mergeRenameReorderForDataMC(datasetsSig, keepSourcesMC=True) def mergeEWK(datasets): datasets.merge( "EWKMC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson", "WW"], keepSources=True) #datasets.merge("EWKMC", ["WJets", "TTJets"], keepSources=True) mergeEWK(datasetsSig) datasetsEmb.forEach(mergeEWK) plots._legendLabels["EWKMC"] = "EWK" datasetsEmb.remove( filter(lambda name: "TTToHplus" in name, datasetsEmb.getAllDatasetNames())) datasetsEmb.remove( filter(lambda name: "HplusTB" in name, datasetsEmb.getAllDatasetNames())) style = tdrstyle.TDRStyle() ROOT.gStyle.SetEndErrorSize(5) histograms.createLegend.setDefaults(y1=0.93, y2=0.75, x1=0.52, x2=0.93) tauEmbedding.normalize = True tauEmbedding.era = "Run2011A" #datasetsEmbCorrected = tauEmbedding.DatasetsDYCorrection(datasetsEmb, datasetsSig, analysisEmb, analysisSig) datasetsEmbCorrected = tauEmbedding.DatasetsResidual( datasetsEmb, datasetsSig, analysisEmb, analysisSig, ["DYJetsToLL", "WW"], totalNames=["Data", "EWKMC"]) def dop(datasetName): doPlots(datasetsEmb, datasetsSig, datasetName) # doCounters(datasetsEmb, datasetsSig, datasetName) print "%s done" % datasetName #doPlots(datasetsEmbCorrected, datasetsSig, "EWKMC", addData=True, postfix="_residual") doCounters(datasetsEmb, datasetsSig, "EWKMC") return dop("TTJets") dop("WJets") #dop("W3Jets") dop("DYJetsToLL") dop("SingleTop") dop("Diboson") return dop("WW") dop("WZ") dop("ZZ") #doPlots(datasetsEmb, datasetsSig, "EWKMC", doData=True, postfix="_data") ##doPlots(datasetsEmb, datasetsSig, "Data") doPlots(datasetsEmbCorrected, datasetsSig, "EWKMC", postfix="_dycorrected")
def main(): dirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.dirEmbs[1:]] dirSig = "../" + tauEmbedding.dirSig datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb + "Counters", normalizeMCByLuminosity=True) datasetsSig = dataset.getDatasetsFromMulticrabCfg( cfgfile=dirSig + "/multicrab.cfg", counters=analysisSig + "Counters") datasetsSig.updateNAllEventsToPUWeighted() datasetsEmb.remove( filter(lambda name: "HplusTB" in name, datasetsEmb.getAllDatasetNames())) datasetsEmb.remove( filter(lambda name: "TTToHplus" in name, datasetsEmb.getAllDatasetNames())) del plots._datasetMerge["WW"] # del plots._datasetMerge["WZ"] # del plots._datasetMerge["ZZ"] datasetsEmb.forEach(plots.mergeRenameReorderForDataMC) datasetsEmb.setLumiFromData() plots.mergeRenameReorderForDataMC(datasetsSig) style = tdrstyle.TDRStyle() histograms.createLegend.moveDefaults(dx=-0.04) datasetsEmb.remove(["W3Jets"]) datasetsEmb.remove(["QCD_Pt20_MuEnriched"]) #plots._legendLabels["QCD_Pt20_MuEnriched"] = "QCD" histograms.createLegend.moveDefaults(dh=-0.05) #histograms.createLegend.moveDefaults(dx=-0.18, dy=0.05, dh=-0.05) tauEmbedding.normalize = True #tauEmbedding.normalize=False tauEmbedding.era = "Run2011A" def mergeEWK(datasets): datasets.merge( "EWKMC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson", "WW"], keepSources=True) #datasets.merge("EWKMC", ["WJets", "TTJets"], keepSources=True) mergeEWK(datasetsSig) datasetsEmb.forEach(mergeEWK) datasetsEmbCorrected = result.DatasetsDYCorrection(datasetsEmb, datasetsSig, analysisEmb, analysisSig) datasetsResidual = tauEmbedding.DatasetsResidual( datasetsEmb, datasetsSig, analysisEmb, analysisSig, ["DYJetsToLL", "WW"], totalNames=["Data", "EWKMC"]) # doPlots(datasetsEmb) #doPlots(datasetsEmbCorrected) # doPlotsWTauMu(datasetsEmb, "TTJets", True) # doPlotsWTauMu(datasetsEmb, "TTJets", False) # doCounters(datasetsEmb) #doCounters(datasetsEmbCorrected) doCountersResidual(datasetsResidual)
def main(): tauDirEmbs = [os.path.join("..", d) for d in tauEmbedding.tauDirEmbs] tauDirSig = "../" + tauEmbedding.tauDirSig dirEmbs = ["."] + [os.path.join("..", d) for d in tauEmbedding.dirEmbs[1:]] dirSig = "../" + tauEmbedding.dirSig # tauDirEmbs = tauDirEmbs[:2] # dirEmbs = dirEmbs[:2] tauDatasetsEmb = tauEmbedding.DatasetsMany(tauDirEmbs, tauAnalysisEmb + "Counters", normalizeMCByLuminosity=True) tauDatasetsSig = dataset.getDatasetsFromMulticrabCfg( cfgfile=tauDirSig + "/multicrab.cfg", counters=tauAnalysisSig + "Counters") datasetsEmb = tauEmbedding.DatasetsMany(dirEmbs, analysisEmb + "Counters", normalizeMCByLuminosity=True) datasetsSig = dataset.getDatasetsFromMulticrabCfg( cfgfile=dirSig + "/multicrab.cfg", counters=analysisSig + "Counters") tauDatasetsSig.updateNAllEventsToPUWeighted() datasetsSig.updateNAllEventsToPUWeighted() tauDatasetsEmb.forEach(plots.mergeRenameReorderForDataMC) datasetsEmb.forEach(plots.mergeRenameReorderForDataMC) tauDatasetsEmb.setLumiFromData() datasetsEmb.setLumiFromData() plots.mergeRenameReorderForDataMC(tauDatasetsSig) plots.mergeRenameReorderForDataMC(datasetsSig) def mergeEWK(datasets): datasets.merge( "EWKMC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"], keepSources=True) mergeEWK(tauDatasetsSig) mergeEWK(datasetsSig) tauDatasetsEmb.forEach(mergeEWK) datasetsEmb.forEach(mergeEWK) plots._legendLabels["EWKMC"] = "EWK" # Apply TDR style style = tdrstyle.TDRStyle() ROOT.gStyle.SetHatchesLineWidth(2) histograms.cmsTextMode = histograms.CMSMode.SIMULATION histograms.cmsText[histograms.CMSMode.SIMULATION] = "Simulation" #histograms.createLegend.setDefaults(y1=0.93, y2=0.75, x1=0.52, x2=0.93) histograms.createLegend.setDefaults(y1=0.93, y2=0.77, x1=0.45, x2=0.7, textSize=0.04) #histograms.createLegend.setDefaults(y1=0.93, y2=0.7, x1=0.45, x2=0.93) tauEmbedding.normalize = True tauEmbedding.era = "Run2011A" def dop(name): doTauPlots(tauDatasetsEmb, tauDatasetsSig, name) doTauCounters(tauDatasetsEmb, tauDatasetsSig, name) doPlots(datasetsEmb, datasetsSig, name) doCounters(datasetsEmb, datasetsSig, name) dop("TTJets") dop("WJets") dop("DYJetsToLL") dop("SingleTop") dop("Diboson")