colors = [ ROOT.kMagenta + 1, ROOT.kBlue + 1, ROOT.kCyan + 1, ROOT.kGreen + 1, ROOT.kOrange + 7, ROOT.kRed, ROOT.kMagenta, ] markers = [20, 24, 20, 24, 20, 24, 20] plotInfos = [] for i in xrange(13): plotInfos.append(PlotInfo()) plotInfos[-1].markerStyle = markers[i % 7] plotInfos[-1].markerColor = colors[i % 7] plotInfos[-1].lineColor = colors[i % 7] plotInfos[-1].yTitle = "Fake factor" if not os.path.exists(plotDir + "/" + name): os.makedirs(plotDir + "/" + name) outputFile = ROOT.TFile.Open(plotDir + "/" + name + "/" + name + ".root", "RECREATE") efficiencyPlots = [] #effPlots = EfficiencyInBinsPlots() #effPlots.name = name #effPlots.histoBaseName = "hFakeRate"
tree_prod_name = 'H2TauTauTreeProducerTauMu' data_dir = analysis_dir samples_mc, samples_data, samples, all_samples, sampleDict = createSampleLists(analysis_dir=analysis_dir, tree_prod_name=tree_prod_name) for sample in all_samples: setSumWeights(sample, directory='MCWeighter') mcRescalings = [] for sample in mcSamples: cmgName = cmgSampleTranslation[sample] mcRescalings.append(int_lumi*sampleDict[cmgName].xsec/sampleDict[cmgName].sumweights) ###################################### ### define plot information plotInfos = [PlotInfo(), PlotInfo(), PlotInfo()] ## Data plotInfos[0].markerStyle = 20 plotInfos[0].yTitle = "Fake factor" plotInfos[0].legend = 'Data' ## MC plotInfos[1].markerStyle = 20 plotInfos[1].markerColor = ROOT.kRed plotInfos[1].lineColor = ROOT.kRed plotInfos[1].yTitle = "Fake factor" plotInfos[1].legend = 'MC' ## MC reference plotInfos[2].markerStyle = 24 plotInfos[2].markerColor = ROOT.kRed plotInfos[2].lineColor = ROOT.kRed plotInfos[2].yTitle = "Fake factor"
names2 = [] names2.append("Iso_Medium_Vs_InvertIso_Medium") variables = ["tau_pt", "tau_decayMode"] variableNames = {} variableNames["tau_pt"] = "p_{T}^{#tau} [GeV]" variableNames["tau_eta"] = "#eta^{#tau}" variableNames["tau_decayMode"] = "decayMode" variableNames["tau_pdgId"] = "|pdg ID| #times sign-flip" variableNames["nevents"] = "" variableNames["nvertices"] = "N_{PV}" variableNames["rho"] = "#rho" variableNames["tau_jet_pt"] = "p_{T}^{jet} [GeV]" plotInfos = [PlotInfo()] plotInfos[0].markerStyle = 20 plotInfos[0].yTitle = "Fake factor" if not os.path.exists(plotDir + "/" + name): os.makedirs(plotDir + "/" + name) outputFile = ROOT.TFile.Open(plotDir + "/" + name + "/" + name + ".root", "RECREATE") efficiencyPlots = [] effPlots = EfficiencyPlots() effPlots.name = name effPlots.publicationDir = publicationDir effPlots.histoBaseName = "hFakeRate" effPlots.inputFileNames = [inputFileNames]
ROOT.kBlack, ROOT.kRed, ROOT.kRed, ] markers = [ 20, 24, 20, 24, ] plotInfos = [] for i in xrange(len(colors)): plotInfos.append(PlotInfo()) plotInfos[-1].markerStyle = markers[i] plotInfos[-1].markerColor = colors[i] plotInfos[-1].lineColor = colors[i] plotInfos[-1].yTitle = "Fake factor" if not os.path.exists(plotDir+"/"+name): os.makedirs(plotDir+"/"+name) outputFile = ROOT.TFile.Open(plotDir+"/"+name+"/"+name+".root", "RECREATE") efficiencyPlots = [] #effPlots = EfficiencyPlots() #effPlots.name = name
# ZJets1D_VsPdgId = ZJets1DFile.Get('FakeFactors_ZMuMu_1D_Iso_Medium_InvertIso_Medium_tau_pdgId') ZJets1D_VsPdgId.__class__ = ROOT.TGraphAsymmErrors WJets1D_VsPdgId = WJets1DFile.Get('FakeFactors_HighMT_1D_Iso_Medium_InvertIso_Medium_tau_pdgId') WJets1D_VsPdgId.__class__ = ROOT.TGraphAsymmErrors # ZJetsBinned_VsJetPt_Decay = [] WJetsBinned_VsJetPt_Decay = [] for decay in xrange(3): ZJetsBinned_VsJetPt_Decay.append(ZJetsBinnedFile.Get('FakeFactors_ZMuMu_Binned_Iso_Medium_InvertIso_Medium_tau_jet_pt_vs_decayMode_{DECAY}'.format(DECAY=decay))) ZJetsBinned_VsJetPt_Decay[-1].__class__ = ROOT.TGraphAsymmErrors WJetsBinned_VsJetPt_Decay.append(WJetsBinnedFile.Get('FakeFactors_HighMT_Binned_Iso_Medium_InvertIso_Medium_tau_jet_pt_vs_decayMode_{DECAY}'.format(DECAY=decay))) WJetsBinned_VsJetPt_Decay[-1].__class__ = ROOT.TGraphAsymmErrors plotInfoWJets = PlotInfo() plotInfoWJets.markerStyle = 24 plotInfoWJets.markerColor = ROOT.kBlack plotInfoWJets.lineColor = ROOT.kBlack plotInfoWJets.legend = 'W+jet, m_{T}>40GeV' plotInfoWJets.yTitle = 'Fake factor' # plotInfoZJets = PlotInfo() plotInfoZJets.markerStyle = 20 plotInfoZJets.markerColor = ROOT.kBlack plotInfoZJets.lineColor = ROOT.kBlack plotInfoZJets.legend = 'Z+jet' plotInfoZJets.yTitle = 'Fake factor' def updateXTitle(plotInfo, xTitle): infoCopy = copy.copy(plotInfo)
DIR=directory, HISTO=background)) histos[background].__class__ = ROOT.TH1F if not histo_total: histo_total = histos[background].Clone( '{DIR}_sum'.format(DIR=directory)) else: histo_total.Add(histos[background]) plots = [] for background, histo in histos.items(): plot = EfficiencyPlot() plot.name = "backgroundFraction_{DIR}_{BACK}".format(DIR=directory, BACK=background) plot.plotDir = "results/" plot.publicationDir = "" plot.efficiency(histo, histo_total, "cp", PlotInfo()) plot.plot(0, 1) plots.append(plot) outputFile = ROOT.TFile.Open( 'results/backgroundFraction_{DIR}.root'.format(DIR=directory), 'RECREATE') for plot in plots: for graph in plot.efficiencyGraphs: graph.SetName('g_' + plot.name) graph.Write() for histo in plot.efficiencyHistos: histo.SetName('h_' + plot.name) histo.Write() outputFile.Close() inputFile.Close()
# ZJetsBinned_VsJetPt_Decay = [] WJetsBinned_VsJetPt_Decay = [] for decay in xrange(3): ZJetsBinned_VsJetPt_Decay.append( ZJetsBinnedFile.Get( 'FakeFactors_ZMuMu_Binned_Iso_Medium_InvertIso_Medium_tau_jet_pt_vs_decayMode_{DECAY}' .format(DECAY=decay))) ZJetsBinned_VsJetPt_Decay[-1].__class__ = ROOT.TGraphAsymmErrors WJetsBinned_VsJetPt_Decay.append( WJetsBinnedFile.Get( 'FakeFactors_HighMT_Binned_Iso_Medium_InvertIso_Medium_tau_jet_pt_vs_decayMode_{DECAY}' .format(DECAY=decay))) WJetsBinned_VsJetPt_Decay[-1].__class__ = ROOT.TGraphAsymmErrors plotInfoWJets = PlotInfo() plotInfoWJets.markerStyle = 24 plotInfoWJets.markerColor = ROOT.kBlack plotInfoWJets.lineColor = ROOT.kBlack plotInfoWJets.legend = 'W+jet, m_{T}>40GeV' plotInfoWJets.yTitle = 'Fake factor' # plotInfoZJets = PlotInfo() plotInfoZJets.markerStyle = 20 plotInfoZJets.markerColor = ROOT.kBlack plotInfoZJets.lineColor = ROOT.kBlack plotInfoZJets.legend = 'Z+jet' plotInfoZJets.yTitle = 'Fake factor' def updateXTitle(plotInfo, xTitle):
# QCDSS1D_VsDecay = QCDSS1DFile.Get('FakeFactors_Data_QCDSS_1D_SS_Iso_Medium_SS_InvertIso_Medium_tau_decayMode') QCDSS1D_VsDecay.__class__ = ROOT.TGraphAsymmErrors QCDOS1D_VsDecay = QCDOS1DFile.Get('FakeFactors_Data_QCDOS_1D_Iso_Medium_InvertIso_Medium_tau_decayMode') QCDOS1D_VsDecay.__class__ = ROOT.TGraphAsymmErrors # QCDSSBinned_VsPt_Decay = [] QCDOSBinned_VsPt_Decay = [] for decay in xrange(3): QCDSSBinned_VsPt_Decay.append(QCDSSBinnedFile.Get('FakeFactors_Data_QCDSS_Binned_SS_Iso_Medium_SS_InvertIso_Medium_tau_pt_vs_decayMode_{DECAY}'.format(DECAY=decay))) QCDSSBinned_VsPt_Decay[-1].__class__ = ROOT.TGraphAsymmErrors QCDOSBinned_VsPt_Decay.append(QCDOSBinnedFile.Get('FakeFactors_Data_QCDOS_Binned_Iso_Medium_InvertIso_Medium_tau_pt_vs_decayMode_{DECAY}'.format(DECAY=decay))) QCDOSBinned_VsPt_Decay[-1].__class__ = ROOT.TGraphAsymmErrors plotInfoQCDOS = PlotInfo() plotInfoQCDOS.markerStyle = 24 plotInfoQCDOS.markerColor = ROOT.kBlack plotInfoQCDOS.lineColor = ROOT.kBlack plotInfoQCDOS.legend = 'iso(#mu)>0.15, OS' plotInfoQCDOS.yTitle = 'Fake factor' # plotInfoQCDSS = PlotInfo() plotInfoQCDSS.markerStyle = 20 plotInfoQCDSS.markerColor = ROOT.kBlack plotInfoQCDSS.lineColor = ROOT.kBlack plotInfoQCDSS.legend = 'iso(#mu)>0.15, SS' plotInfoQCDSS.yTitle = 'Fake factor' def updateXTitle(plotInfo, xTitle): infoCopy = copy.copy(plotInfo)