def conclude(self,pars) : from core import plotter org = self.organizer(pars) org.mergeSamples(targetSpec = {"name":"qcd_py6", "color":r.kBlue}, allWithPrefix="v12_qcd_py6") org.scale(100) plotter.plotter( org, psFileName = self.psFileName(org.tag), blackList = ["lumiHisto","xsHisto","xsPostWeightsHisto","nJobsHisto"], ).plotAll()
def conclude(self,pars) : #make a pdf file with plots from the histograms created above org = self.organizer(pars) org.scale() plotter.plotter( org, psFileName = self.psFileName(org.tag), samplesForRatios = ("Example_Skimmed_900_GeV_Data","Example_Skimmed_900_GeV_MC"), sampleLabelsForRatios = ("data","sim"), ).plotAll()
def conclude(self,pars) : from core import plotter org = self.organizer(pars) org.mergeSamples(targetSpec = {"name":"qcd_mg", "color":r.kBlue}, allWithPrefix="qcd_mg") org.mergeSamples(targetSpec = {"name":"qcd_py6", "color":r.kRed}, allWithPrefix="qcd_py6") org.scale() plotter.plotter( org, psFileName = self.psFileName(org.tag), blackList = ["lumiHisto","xsHisto","xsPostWeightsHisto","nJobsHisto","genpthat"], detailedCalculables = True, ).plotAll()
def conclude(self, conf) : org = self.organizer(conf) ##for skimming only #utils.printSkimResults(org) lineWidth = 3; goptions = "hist" org.mergeSamples(targetSpec = {"name":"2011 Data", "color":r.kBlack, "markerStyle":20}, allWithPrefix="DoubleMu.Run2011") org.mergeSamples(targetSpec = {"name":"t#bar{t}", "color":r.kOrange, "lineWidth":lineWidth, "goptions":goptions}, allWithPrefix="tt") org.mergeSamples(targetSpec = {"name":"DY->ll", "color":r.kBlue, "lineWidth":lineWidth, "goptions":goptions}, allWithPrefix="dyll") org.mergeSamples(targetSpec = {"name":"W + jets", "color":r.kRed, "lineWidth":lineWidth, "goptions":goptions}, allWithPrefix="w_jets") org.mergeSamples(targetSpec = {"name":"s.m.", "color":r.kGreen, "lineWidth":lineWidth, "goptions":goptions}, sources = ["t#bar{t}", "DY->ll", "W + jets"], keepSources = True) org.scale() if not self.parameters()["tanBeta"] else org.scale(100.0) #plot pl = plotter.plotter(org, psFileName = self.psFileName(org.tag), samplesForRatios = ("2011 Data","DY->ll"), sampleLabelsForRatios = ("data","DY"), showStatBox = True, #doLog = False, linYAfter = ("value", "0.40<=xcak5JetMhtOverHtPat"), pegMinimum = 0.1, blackList = ["lumiHisto","xsHisto","nJobsHisto"], ) pl.plotAll()
def conclude(self,pars) : from core.plotter import plotter org = self.organizer(pars) org.mergeSamples(targetSpec = {"name":"SingleMu","color":r.kBlack,"markerStyle":20}, allWithPrefix="SingleMu") org.mergeSamples(targetSpec = {"name":"qcd", "color":r.kBlue}, allWithPrefix="qcd") org.mergeSamples(targetSpec = {"name":"w_jets","color":r.kRed}, allWithPrefix="w_jets") org.mergeSamples(targetSpec = {"name":"t#bar{t}","color":r.kViolet}, allWithPrefix="tt_tauola_fj_mg") #org.scaleOneRaw([ss['name'] for ss in org.samples].index('w_jets'), 0.6) org.mergeSamples(targetSpec = {"name":"s.m.", "color":r.kGreen+3}, keepSources = True, sources = ['qcd','w_jets','t#bar{t}'], force = True) org.scale() kwargs = { "blackList":["lumiHisto","xsHisto","nJobsHisto","muonTriggerWeightPF"], "samplesForRatios":("SingleMu","s.m.") if "s.m." in [ss['name'] for ss in org.samples] else ("","")} plotter(org, psFileName = self.psFileName(org.tag+'_log'), doLog = True, **kwargs).plotAll() plotter(org, psFileName = self.psFileName(org.tag+'_nolog'), doLog = False, **kwargs).plotAll()
def conclude(self,conf) : org = self.organizer(conf) #org.mergeSamples(targetSpec = {"name":"SingleMu", "color":r.kBlack}, allWithPrefix="SingleMu") #org.scale() from core.plotter import plotter plotter(org, psFileName = self.psFileName(org.tag), #samplesForRatios = ("2010 Data","standard_model"), #sampleLabelsForRatios = ("data","s.m."), #whiteList = ["lowestUnPrescaledTrigger"], #doLog = False, #compactOutput = True, #noSci = True, #pegMinimum = 0.1, blackList = ["lumiHisto","xsHisto","nJobsHisto"], ).plotAll()
def plotMeldScale(self) : if not hasattr(self,"orgMelded") : print "run meldScale() before plotMeldScale()"; return melded = copy.deepcopy(self.orgMelded) for ss in filter(lambda ss: 'tt_tauola_fj' in ss['name'], melded.samples) : melded.drop(ss['name']) pl = plotter.plotter(melded, psFileName = self.psFileName(melded.tag), doLog = False, blackList = ["lumiHisto","xsHisto","nJobsHisto"], rowColors = self.rowcolors, samplesForRatios = ("top.Data 2011","S.M."), sampleLabelsForRatios = ('data','s.m.') ).plotAll()
def makeIndividualPlots(self, org) : #plot all pl = plotter.plotter(org, psFileName = self.psFileName(org.tag), showStatBox = False, doLog = False, anMode = True, ) pl.individualPlots(plotSpecs = [{"plotName":"xcak5JetAlphaTFewBinsPat", "stepName" :"alphaHistogrammer", "stepDesc" :"xcak5JetPat", "newTitle":";#alpha_{T};events / bin"}, #{"plotName":"xcak5JetAlphaTRoughPat", # "stepName" :"variablePtGreaterFilter", # "stepDesc" :"xcak5JetSumP4Pat.pt()>=140.0 GeV", # "newTitle":";#alpha_{T};events / bin / 35 pb^{-1}"}, {"plotName":"xcak5JetIndicesPat", "stepName" :"histogrammer", "stepDesc" :"(lambda x:len(x))(xcak5JetIndicesPat)", "newTitle":";N_{jets};events / bin"}, #{"plotName":"photonPat1MinDRToJet", # "stepName" :"passFilter", # "stepDesc" :"singlePhotonPlots2", # "newTitle":";#DeltaR(photon, nearest jet);events / bin / 35 pb^{-1}", # "reBinFactor":3}, # #{"plotName":"photonPat1SeedTime", # "stepName" :"passFilter", # "stepDesc" :"singlePhotonPlots2", # "newTitle":";time of photon seed crystal hit (ns);events / bin / 35 pb^{-1}", # "sampleWhiteList": ["2010 Data"]}, # #{"plotName":"photonPat1sigmaIetaIetaBarrel", # "stepName" :"passFilter", # "stepDesc" :"singlePhotonPlots2", # "newTitle":";#sigma_{i#eta i#eta};events / bin / 35 pb^{-1}"}, #{"plotName":"photonPat1combinedIsolation", # "stepName" :"passFilter", # "stepDesc" :"singlePhotonPlots2", # "onlyDumpToFile":True}, ], newSampleNames = {"qcd_mg_nVtx": "Madgraph QCD", "g_jets_mg_nVtx": "Madgraph #gamma + jets", "2011 Data": "Data", "standard_model_nVtx": "Standard Model", }, preliminary = True, )
def conclude(self,pars) : org = self.organizer(pars) org.mergeSamples(targetSpec = {"name":"Data 2011", "color":r.kBlack, "markerStyle":20}, allWithPrefix="SingleMu") org.mergeSamples(targetSpec = {"name":"qcd_py6", "color":r.kBlue}, allWithPrefix="qcd_py6") org.mergeSamples(targetSpec = {"name":"t#bar{t}", "color":r.kViolet}, sources=["tt_tauola_fj.wNonQQbar.tw.nvr","tt_tauola_fj.wTopAsymP00.tw.nvr"], keepSources = True) org.mergeSamples(targetSpec = {"name":"t#bar{t}.q#bar{q}.N30", "color":r.kRed}, sources = ["tt_tauola_fj.wTopAsymN30.tw.nvr","tt_tauola_fj.wNonQQbar.tw.nvr"][:1]) org.mergeSamples(targetSpec = {"name":"t#bar{t}.q#bar{q}.P30", "color":r.kGreen}, sources = ["tt_tauola_fj.wTopAsymP30.tw.nvr","tt_tauola_fj.wNonQQbar.tw.nvr"][:1]) org.mergeSamples(targetSpec = {"name":"standard_model", "color":r.kGreen+2}, sources = ["qcd_py6","t#bar{t}","w_jets_fj_mg.tw.nvr"], keepSources = True) #for ss in filter(lambda ss: 'tt_tauola' in ss['name'],org.samples) : org.drop(ss['name']) orgpdf = copy.deepcopy(org) orgpdf.scale( toPdf = True ) org.scale( lumiToUseInAbsenceOfData = 1.1e3 ) names = [ss["name"] for ss in org.samples] kwargs = {"detailedCalculables": False, "blackList":["lumiHisto","xsHisto","nJobsHisto"], "samplesForRatios" : next(iter(filter(lambda x: x[0] in names and x[1] in names, [("Data 2011","standard_model")])), ("","")), "sampleLabelsForRatios" : ("data","s.m."), "detailedCalculables" : True, "rowColors" : self.rowcolors, } plotter.plotter(org, psFileName = self.psFileName(org.tag+"_log"), doLog = True, pegMinimum = 0.01, **kwargs ).plotAll() plotter.plotter(org, psFileName = self.psFileName(org.tag+"_nolog"), doLog = False, **kwargs ).plotAll() kwargs["samplesForRatios"] = ("","") kwargs["dependence2D"] = True plotter.plotter(orgpdf, psFileName = self.psFileName(org.tag+"_pdf"), doLog = False, **kwargs ).plotAll()
def conclude(self,pars) : org = self.organizer(pars) org.scale(toPdf=True) self.signalChi2(org,("tt_tauola_fj_mg.wTopAsymN30","tt_tauola_fj_mg.wTopAsymP30"), org.keysMatching(["genTopBeta", "genTopDeltaAbsYttbar", "genTopTrue", "genTopMez" ])) from core import plotter pl = plotter.plotter(org, psFileName = self.psFileName(org.tag), doLog = False, pegMinimum = 0.1, blackList = ["lumiHisto","xsHisto","nJobsHisto"], ).plotAll()
def meldQCDpartitions(self) : samples = {"top_muon_pf" : ["qcd_py6fjmu"], "Wlv_muon_pf" : [], "QCD_muon_pf" : ["qcd_py6fjmu","SingleMu"]} organizers = [organizer.organizer(tag, [s for s in self.sampleSpecs(tag) if any(item in s['name'] for item in samples[tag])]) for tag in [p['tag'] for p in self.readyConfs]] if not organizers : return for org in organizers : org.mergeSamples(targetSpec = {"name":"Data 2011", "color":r.kBlack, "markerStyle":20}, allWithPrefix="SingleMu") org.mergeSamples(targetSpec = {"name":"qcd_py6mu", "color":r.kRed if "QCD" in org.tag else r.kBlue, "markerStyle": 22}, allWithPrefix="qcd_py6fjmu") org.scale(toPdf=True) melded = organizer.organizer.meld("qcdPartitions",filter(lambda o: o.samples, organizers)) pl = plotter.plotter(melded, psFileName = self.psFileName(melded.tag), doLog = False, blackList = ["lumiHisto","xsHisto","nJobsHisto"], ).plotAll()
def makeStandardPlots(self, org) : #plot pl = plotter.plotter(org, psFileName = self.psFileName(org.tag), samplesForRatios = ("2011 Data","Standard Model "), sampleLabelsForRatios = ("data","s.m."), printRatios = True, showStatBox = not self.ra1Cosmetics(), rowColors = [r.kBlack, r.kViolet+4], #whiteList = ["lowestUnPrescaledTrigger"], #doLog = False, #compactOutput = True, #noSci = True, #latexYieldTable = True, linYAfter = ("variableGreaterFilter", "xcak5JetAlphaTEtPat>=0.550 "), pegMinimum = 0.1, blackList = ["lumiHisto","xsHisto","nJobsHisto"], ) pl.plotAll()
def makeStandardPlots(self, org) : #plot pl = plotter.plotter(org, psFileName = self.psFileName(org.tag), samplesForRatios = ("2011 Data","standard_model" if not self.ra1Cosmetics() else "Standard Model "), sampleLabelsForRatios = ("data","s.m."), #samplesForRatios = ("calo_325_scaled.xcak5JetnJetsWeightPat", "calo_325_scaled"), #sampleLabelsForRatios = ("3jet","Njet"), showStatBox = not self.ra1Cosmetics(), #whiteList = ["lowestUnPrescaledTrigger"], #doLog = False, #compactOutput = True, #noSci = True, #latexYieldTable = True, linYAfter = ("variableGreaterFilter", "xcak5JetAlphaTEtPat>=0.550 "), pegMinimum = 0.1, blackList = ["lumiHisto","xsHisto","nJobsHisto"], ) pl.plotAll()
def conclude(self,pars) : import re org = self.organizer(pars) black = sum([[hist for hist in step if re.match(r"HLT_Mu\d*_v\d*_p\d*",hist)] for step in org.steps],[]) args = {"blackList":["lumiHisto","xsHisto","nJobsHisto"] + black, "detailedCalculables" : True } from core.plotter import plotter plotter(org, psFileName = self.psFileName(org.tag+"unmerged"), **args ).plotAll() plotter(org, psFileName = self.psFileName(org.tag+"unmerged_nolog"), doLog=False, **args ).plotAll() org.mergeSamples(targetSpec = {"name":"SingleMu","color":r.kRed}, allWithPrefix="SingleMu") plotter(org, psFileName = self.psFileName(org.tag), **args ).plotAll() self.printPrescales(org)
def makeStandardPlots(self, org) : names = [ss["name"] for ss in org.samples] samplesForRatios = filter(lambda x: x[0] in names and x[1] in names, [("2011 Data","standard_model_nVtx"), (".2011 Data",".standard_model_nVtx"), ("g.2011 Data","g.standard_model_nVtx"), ("2011 Data","standard_model"), ("2011 Data","standard_model_py6"), ("2010 Data","sm_2010")]) #plot all pl = plotter.plotter(org, psFileName = self.psFileName(org.tag), sampleLabelsForRatios = ("data","s.m."), samplesForRatios = next(iter(samplesForRatios), ("","")), blackList = ["lumiHisto","xsHisto","nJobsHisto", "deltaRGenReco", "photonMothergenPt", "photonMotherrecoPt", "photonMothermht", "quarkMothergenPt", "quarkMotherrecoPt", "quarkMothermht", "otherMothergenPt", "otherMotherrecoPt", "otherMothermht", "nGenPhotonsStatus1Photon","photonEtaStatus1Photon","photonPtStatus1Photon", "photonPhiVsEtaStatus1Photon", "photonIsoStatus1Photon", "nJetsStatus1Photon", "jetHtStatus1Photon", "nJetsPlusnPhotonsStatus1Photon", "jetHtPlusPhotonHtStatus1Photon", ], doLog = False, #latexYieldTable = True, rowColors = [r.kBlack, r.kViolet+4], showErrorsOnDataYields = False, #whiteList = ["xcak5JetIndicesPat", # #"photonPat1Pt", # #"photonPat1mhtVsPhotonPt", # "xcak5JetAlphaTFewBinsPat", # "xcak5JetAlphaTRoughPat", # "xcak5JetAlphaTWithPhoton1PtRatherThanMhtPat", # ], ) pl.plotAll()
def meldNorm(self) : meldSamples = {"top_muon_pf" : ["SingleMu","P00","NonQQbar","w_jets"], #"Wlv_muon_pf" : ["w_jets"], "QCD_muon_pf" : ["SingleMu"]} organizers = [organizer.organizer(tag, [s for s in self.sampleSpecs(tag) if any(item in s['name'] for item in meldSamples[tag])]) for tag in [p['tag'] for p in self.readyConfs if p["tag"] in meldSamples]] if not organizers : return for org in organizers : org.mergeSamples(targetSpec = {"name":"t#bar{t}", "color":r.kViolet}, sources=["tt_tauola_fj.wNonQQbar.nvr","tt_tauola_fj.wTopAsymP00.nvr"]) org.mergeSamples(targetSpec = {"name":"w_jets", "color":r.kRed}, allWithPrefix = "w_jets") org.mergeSamples(targetSpec = {"name":"Data 2011", "color":r.kBlue if "qcd_" in org.tag else r.kBlack, "markerStyle":(20 if "top" in org.tag else 1)}, allWithPrefix="SingleMu") if True : templates = [] dist = "TriDiscriminant" for org in organizers : before = next(org.indicesOfStep("label","selection complete")) distTup = org.steps[next(iter(filter(lambda i: before<i, org.indicesOfStepsWithKey(dist))))][dist] for ss,hist in zip(org.samples,distTup) : contents = [hist.GetBinContent(i) for i in range(hist.GetNbinsX()+2)] if "top" in org.tag and ss["name"] is "Data 2011": signal = contents else : templates.append(contents) print org.tag, ss["name"] from core import fractions cs = fractions.componentSolver(signal, templates, 1e4) with open("measuredFractions.txt","w") as file : print >> file, cs stuff = fractions.drawComponentSolver(cs) stuff[0].Print("measuredFractions.eps") for org in organizers : org.scale(toPdf=True) melded = organizer.organizer.meld(organizers = organizers) pl = plotter.plotter(melded, psFileName = self.psFileName(melded.tag), doLog = False, blackList = ["lumiHisto","xsHisto","nJobsHisto"] ).plotAll()
def conclude(self, conf) : org = self.organizer(conf) pl = plotter.plotter(org, psFileName = self.psFileName(org.tag), blackList = ["lumiHisto","xsHisto","nJobsHisto"]) pl.plotAll()
def makeIndividualPlots(self, org) : #plot all pl = plotter.plotter(org, psFileName = self.psFileName(org.tag), showStatBox = False, doLog = True, pegMinimum = 0.1, anMode = True, ) pl.individualPlots(plotSpecs = [{"plotName":"xcak5JetAlphaTRoughPat", "stepName" :"alphaHistogrammer", "stepDesc" :"xcak5JetPat", "newTitle":";#alpha_{T};events / bin", "legendCoords": (0.55, 0.60, 0.85, 0.90), "stampCoords": (0.75, 0.55) }, {"plotName":"jetMultiplicity", "stepName":"singleJetHistogrammer", "stepDesc":"xcak5JetPat through index 2", "newTitle":";N_{jets};events / bin", "legendCoords": (0.7, 0.7, 0.92, 0.92), "stampCoords": (0.5, 0.28), }, {"plotName":"xcak5JetHtPat", "stepName":"cleanJetHtMhtHistogrammer", "stepDesc":"xcak5JetPat", "newTitle":";H_{T} (GeV);events / bin", "legendCoords": (0.6, 0.60, 0.92, 0.92), "stampCoords": (0.45, 0.88) }, ##after alphaT {"plotName":"xcak5JetDeltaPhiStarPat", "stepName":"histogrammer", "stepDesc" :"(lambda x:x[0][0])(xcak5JetDeltaPhiStarPat)", "index" : -1, "newTitle":";#Delta#phi*;events / bin", "legendCoords": (0.6, 0.6, 0.92, 0.92), "stampCoords": (0.33, 0.88), }, {"plotName":"xcak5JetHtPlusMhtRoughPat", "stepName":"cleanJetHtMhtHistogrammer", "stepDesc":"xcak5JetPat", "index":-1, "newTitle":";M_{eff} (GeV);events / bin", "legendCoords": (0.7, 0.7, 0.92, 0.92), "stampCoords": (0.75, 0.4), }, {"plotName":"xcak5JetIndicesPat", "stepName":"histogrammer", "stepDesc" :"(lambda x:len(x))(xcak5JetIndicesPat)", "index" : -1, "newTitle":";N_{jets};events / bin", "legendCoords": (0.6, 0.6, 0.92, 0.92), "stampCoords": (0.6, 0.38), } ], newSampleNames = None, #newSampleNames = {"qcd_mg_nVtx": "Madgraph QCD", # "g_jets_mg_nVtx": "Madgraph #gamma + jets", # "2011 Data": "Data", # "standard_model_nVtx": "Standard Model", # }, preliminary = True, )