Ejemplo n.º 1
0
    def conclude(self) :
        for tag in self.sideBySideAnalysisTags() :
            #for skimming only
            org = organizer.organizer( self.sampleSpecs(tag) )
            utils.printSkimResults(org)            

            #organize
            org = organizer.organizer( self.sampleSpecs(tag) )
            lineWidth = 3; goptions = "hist"
            org.mergeSamples(targetSpec = {"name":"2011 Data", "color":r.kBlack, "markerStyle":20}, allWithPrefix="SingleMu.Run2011A")
            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":"SM",        "color":r.kGreen+3,"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 = supy.plotter(org,
                                 pdfFileName = self.pdfFileName(tag),
                                 samplesForRatios = ("2011 Data","SM"),
                                 sampleLabelsForRatios = ("data","s.m."),
                                 showStatBox = True,
                                 #doLog = False,
                                 linYAfter = ("value", "0.40<=xcak5JetMhtOverHtPat"),
                                 pegMinimum = 0.1,
                                 blackList = ["lumiHisto","xsHisto","nJobsHisto"],
                                 )
            pl.plotAll()
Ejemplo n.º 2
0
    def meldScale(self) :
        meldSamples = {"top_muon_pf" : ["SingleMu","tt_tauola_fj","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 len(organizers) < len(meldSamples) : return
        for org in organizers :
            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":"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")

        self.orgMelded = organizer.organizer.meld(organizers = organizers)

        def measureFractions(dist) :
            before = next(self.orgMelded.indicesOfStep("label","selection complete"))
            distTup = self.orgMelded.steps[next(iter(filter(lambda i: before<i, self.orgMelded.indicesOfStepsWithKey(dist))))][dist]
            #distTup = self.orgMelded.steps[next(self.orgMelded.indicesOfStepsWithKey(dist))][dist]

            templateSamples = ['top.t#bar{t}','top.w_jets','QCD.Data 2011']
            templates = [None] * len(templateSamples)
            for ss,hist in zip(self.orgMelded.samples,distTup) :
                contents = [hist.GetBinContent(i) for i in range(hist.GetNbinsX()+2)]
                if ss['name'] == "top.Data 2011" :
                    observed = contents
                    nEventsObserved = sum(observed)
                elif ss['name'] in templateSamples :
                    templates[templateSamples.index(ss['name'])] = contents
                else : pass
        
            from core.fractions import componentSolver,drawComponentSolver
            cs = componentSolver(observed, templates, 1e4)
            csCanvas = drawComponentSolver(cs)
            name = "measuredFractions_%s"%dist
            utils.tCanvasPrintPdf(csCanvas[0], "%s/%s"%(self.globalStem,name))
            with open(self.globalStem+"/%s.txt"%name,"w") as file :
                print >> file, cs
                print >> file, cs.components
            return distTup,cs

        distTup,cs = map(measureFractions,["KarlsruheDiscriminant","TriDiscriminant"])[-1]

        fractions = dict(zip(templateSamples,cs.fractions))        
        for iSample,ss in enumerate(self.orgMelded.samples) :
            if ss['name'] in fractions : self.orgMelded.scaleOneRaw(iSample, fractions[ss['name']] * nEventsObserved / distTup[iSample].Integral(0,distTup[iSample].GetNbinsX()+1))
        self.orgMelded.mergeSamples(targetSpec = {"name":"S.M.", "color":r.kGreen+2}, sources = ['top.w_jets','top.t#bar{t}','QCD.Data 2011'], keepSources = True, force = True)
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
 def org(tag) :
     org = organizer.organizer( self.sampleSpecs(tag) )
     self.mergeSamples(org, tag)
     if "Z" in tag : org.scale(1.0)
     else :              org.scale()
     return org