def main():
    # Read the datasets
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
           
    #datasets.loadLuminosities()

    plots.mergeRenameReorderForDataMC(datasets)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
    #    xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)
                
    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section

    # Create counter
    eventCounter = counter.EventCounter(datasets)

    #eventCounter.normalizeMCByLuminosity()
    eventCounter.normalizeMCToLuminosity(1000) # in pb^-1

    print "============================================================"
    print "Main counter (MC normalized by collision data luminosity)"
    print eventCounter.getMainCounterTable().format()

    triggerCounter = eventCounter.getSubCounter("Trigger")
    triggerCounter.forEachDataset(printTriggerEfficiency)
Example #2
0
def main():
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
#    datasets.loadLuminosities()
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    plots.mergeRenameReorderForDataMC(datasets)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)
    plots.mergeWHandHH(datasets)

    style = tdrstyle.TDRStyle()
    td = dataset.TreeDraw(analysis+"/tree", weight="weightPileup*weightTrigger*weightPrescale", 
                          selection="genMet_p4.Et() > 20"
#                          selection="genMet_p4.Et() > 20 && [email protected]() >= 1"
#                          selection="genMet_p4.Et() > 20 && [email protected]() >= 2"
#                          selection="genMet_p4.Et() > 20 && [email protected]() >= 3"
                          )

    kwargs = {}
    kwargs["normalizeToLumi"] = 1150

    dist=">>dist(25,0,5)"
    for q in ["Et", "X", "Y", "Phi"]:
        rawRes = plots.DataMCPlot(datasets, td.clone(varexp="met_p4.%s()/genMet_p4.%s() %s" % (q, q, dist)), **kwargs)
        type1Res = plots.DataMCPlot(datasets, td.clone(varexp="metType1_p4.%s()/genMet_p4.%s() %s" % (q, q, dist)), **kwargs)
        #type1Res = plots.DataMCPlot(datasets, td.clone(varexp="tcMet_p4.%s()/genMet_p4.%s() %s" % (q, q, dist)), normalizeToLumi=1150)

        compare(rawRes, type1Res, q, "TTJets")
def manageDatasets(datasets):
    '''
    def manageDatasets(datasets):
    Handles the PU weighting, luminosity loading and signal merging of the datatasets.
    '''
    
    ### Since (by default) we use weighted counters, and the analysis job inputs are 
    ### normally skims (as are "v44_4" and "v53_1"), need to update events to PU weighted
    print "\n*** Updating events to PU weighted:"
    datasets.updateNAllEventsToPUWeighted()

    if bMcOnly:
        datasets.remove(datasets.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        datasets.loadLuminosities()

    print "\n*** Default merging of dataset components:"
    plots.mergeRenameReorderForDataMC(datasets)
                
    print "\n*** Removing all signal samples, except m=%s" % (signalMass)
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M"+signalMass in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    ### Setup style
    styleGenerator = styles.generator(fill=False)
    style = tdrstyle.TDRStyle()
    histograms.createLegend.moveDefaults(dx=-0.02, dy=+0.00)

    print "*** Setting signal cross sections, using BR(t->bH+)=%s and BR(H+ -> tau+ nu)=%s" % (BR_tH, BR_Htaunu)
    xsect.setHplusCrossSectionsToBR(datasets, BR_tH, BR_Htaunu)
    print "*** Merging WH and HH signals"
    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section
    
    return datasets
Example #4
0
def main():
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets.loadLuminosities()
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    plots.mergeRenameReorderForDataMC(datasets)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)
    plots.mergeWHandHH(datasets)

    style = tdrstyle.TDRStyle()

    plot = plots.DataMCPlot(datasets, analysis+"/MET/met")
    plot.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    
    plot.createFrame("MET", opts={"ymin": 1e-4, "ymaxfactor": 10})
    plot.getPad().SetLogy(True)

    plot.setLegend(histograms.createLegend())

    plot.frame.GetXaxis().SetTitle("MET (GeV)")
    plot.frame.GetYaxis().SetTitle("Number of events")

    plot.draw()
    plot.addLuminosityText()

    plot.save()
Example #5
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    dataMCExample(datasets)
    distComparison(datasets)

    # Script execution can be paused like this, it will continue after
    # user has given some input (which must include enter)
    if drawToScreen:
        raw_input("Hit enter to continue")
Example #6
0
def main():
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
#    datasets.loadLuminosities()
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.updateNAllEventsToPUWeighted()
    plots.mergeRenameReorderForDataMC(datasets)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)
    plots.mergeWHandHH(datasets)

    style = tdrstyle.TDRStyle()
    td = dataset.TreeDraw(analysis+"/tree", weight="weightPileup*weightTrigger*weightPrescale", 
                          selection="genMet_p4.Et() > 20"
#                          selection="genMet_p4.Et() > 20 && [email protected]() >= 1"
#                          selection="genMet_p4.Et() > 20 && [email protected]() >= 2"
#                          selection="genMet_p4.Et() > 20 && [email protected]() >= 3"
                          )

    kwargs = {}
    kwargs["normalizeToLumi"] = 1150

    dist=">>dist(25,0,5)"
    for q in ["Et", "X", "Y", "Phi"]:
        rawRes = plots.DataMCPlot(datasets, td.clone(varexp="met_p4.%s()/genMet_p4.%s() %s" % (q, q, dist)), **kwargs)
        type1Res = plots.DataMCPlot(datasets, td.clone(varexp="metType1_p4.%s()/genMet_p4.%s() %s" % (q, q, dist)), **kwargs)
        #type1Res = plots.DataMCPlot(datasets, td.clone(varexp="tcMet_p4.%s()/genMet_p4.%s() %s" % (q, q, dist)), normalizeToLumi=1150)

        compare(rawRes, type1Res, q, "TTJets")
Example #7
0
def main():
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets.loadLuminosities()
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))
    plots.mergeRenameReorderForDataMC(datasets)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)
    plots.mergeWHandHH(datasets)

    style = tdrstyle.TDRStyle()

    plot = plots.DataMCPlot(datasets, analysis + "/MET/met")
    plot.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))

    plot.createFrame("MET", opts={"ymin": 1e-4, "ymaxfactor": 10})
    plot.getPad().SetLogy(True)

    plot.setLegend(histograms.createLegend())

    plot.frame.GetXaxis().SetTitle("MET (GeV)")
    plot.frame.GetYaxis().SetTitle("Number of events")

    plot.draw()
    plot.addLuminosityText()

    plot.save()
def main():
    # Read the datasets
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets.updateNAllEventsToPUWeighted()

    #datasets.loadLuminosities()

    plots.mergeRenameReorderForDataMC(datasets)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
    #    xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)

    plots.mergeWHandHH(
        datasets
    )  # merging of WH and HH signals must be done after setting the cross section

    # Create counter
    eventCounter = counter.EventCounter(datasets)

    #eventCounter.normalizeMCByLuminosity()
    eventCounter.normalizeMCToLuminosity(1000)  # in pb^-1

    print "============================================================"
    print "Main counter (MC normalized by collision data luminosity)"
    print eventCounter.getMainCounterTable().format()

    triggerCounter = eventCounter.getSubCounter("Trigger")
    triggerCounter.forEachDataset(printTriggerEfficiency)
def main(argv):
    interactive = True
    interactive = False
    #    HISTONAME = "TauIdJets"
#    HISTONAME = "TauIdBtag"
    HISTONAME = "TauIdBveto"
    
    dirs = []
    if len(sys.argv) < 2:
	usage()

    dirs.append(sys.argv[1])

    

    # Disable batch mode here to have the interactivity (see also the line with 'raw_input') below
    if interactive:
        ROOT.gROOT.SetBatch(False)

    # Create all datasets from a multicrab task
#    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
#    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra)
    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra, analysisbaseName = "signalAnalysisInvertedTau")
  
    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    #dataMCExample(datasets)
    distComparison(datasets)

    # Script execution can be paused like this, it will continue after
    # user has given some input (which must include enter)
    if interactive:
        raw_input("Hit enter to continue")
Example #10
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(analysisName=analysis)

    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Merge EWK datasets
    datasets.merge("EWK", [
            "WJets",
            "TTJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create the normalized plot of transverse mass
    # Read the histogram from the file
    #mT = plots.DataMCPlot(datasets, "transverseMass")

    # Create the histogram from the tree (and see the selections explicitly)
    td = dataset.TreeDraw("tree", weight="weightPileup*weightTrigger*weightPrescale",
                             selection="met_p4.Et() > 70 && Max$(jets_btag) > 1.7")
    mT = plots.DataMCPlot(datasets, td.clone(varexp="sqrt(2 * tau_p4.Pt() * met_p4.Et() * (1-cos(tau_p4.Phi()-met_p4.Phi())))>>dist(400, 0, 400)"))

    # Rebin before subtracting
    mT.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20))

    # Create the data-EWK histogram and draw it
    dataEwkDiff(mT)

    # Draw the mT distribution
    transverseMass(mT)
Example #11
0
def main():
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets.updateNAllEventsToPUWeighted()

    # remove data datasets
    datasets.remove(filter(lambda name: "Tau_" in name, datasets.getAllDatasetNames()))
    # remove heavy H+ datasets
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    plots.mergeRenameReorderForDataMC(datasets)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)
    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Define variables and cuts
    tauPt = "tau_p4.Pt()"; tauPtCut = tauPt+" > 40"
    tauLeadingCandPt = "tau_leadPFChargedHadrCand_p4.Pt()"; tauLeadingCandPtCut = tauLeadingCandPt+" > 20"

    met = "met_p4.Et()"; metCut = met+" > 70"

    btagMax = "Max$(jets_btag)"; btagCut = btagMax+" > 1.7"
    btagJetNum17 = "Sum$(jets_btag > 1.7"
    btag2ndMax = "MaxIf(kets_btag, jets_btag < Max$(jets_btag))"

    rtau = "tau_leadPFChargedHadrCand_p4.P()/tau_p4.P()"; rtauCut = rtau+" > 0.65"
    mt = "sqrt(2 * tau_p4.Pt() * met_p4.Et() * (1-cos(tau_p4.Phi()-met_p4.Phi())))"; mtCut = mt+" > 80"
    deltaPhi = "acos((tau_p4.Px()*met_p4.Px()+tau_p4.Py()*met_p4.Py())/tau_p4.Pt()/met_p4.Et())*57.2958"; deltaPhiCut = deltaPhi+" < 160"

    npv = "goodPrimaryVertices_n";

    td = dataset.TreeDraw(analysis+"/tree", weight="weightPileup*weightTrigger*weightPrescale")
    lumi = 1145

    def createResult(varexp, selection, weight=None, **kwargs):
        args = {"varexp": varexp, "selection": selection}
        if weight != None:
            args["weight"] = weight
        return Result(datasets, td.clone(**args), normalizeToLumi=lumi, **kwargs)

    # metRes = createResult(met+">>dist(100,0,200)", btagCut, greaterThan=True)
    # metRes.save("met", "MET (GeV)", rebin=10, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    # btagRes = createResult(btagMax+">>dist(80, 0, 8)", metCut, greaterThan=True)
    # btagRes.save("btag", "TCHE", rebin=5, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    # rtauRes = createResult(rtau+">>dist(110,0,1.1)", metCut+"&&"+btagCut, greaterThan=True)
    # rtauRes.save("rtau", "R_{#tau}", rebin=10, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    # mtRes = createResult(mt+">>dist(50,0,200)", metCut+"&&"+btagCut, greaterThan=True)
    # mtRes.save("mt", "M_{T}(#tau, MET) (GeV)", rebin=2, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    # deltaPhiRes = createResult(deltaPhi+">>dist(90,0,180)", metCut+"&&"+btagCut, lessThan=True)
    # deltaPhiRes.save("deltaPhi", "#Delta#Phi(#tau, MET) (#circ)", rebin=5, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    pileupRes = createResult(npv+">>dist(4,1,17)", metCut+"&&"+btagCut, weight="", doPassed=False, lessThan=True)
    pileupRes.save("goodPV", "N(good primary vertices)")
def main():

    ### Get the ROOT files for all datasets, merge datasets and reorder them
    print "*** Obtaining ROOT files from:\n    %s" % (multicrabPath)
    datasets = dataset.getDatasetsFromMulticrabCfg(directory=multicrabPath, dataEra="Run2011A")

    printPSet(bPrintPSet, folderName="signalAnalysisRun2011A")

    print "*** Calling datasets.updateNAllEventsToPUWeighted():"
    datasets.updateNAllEventsToPUWeighted()
    print "*** Loading luminosities"
    datasets.loadLuminosities()    
    print "*** Calling plots.mergeRenameReorderForDataMC(datasets):"
    plots.mergeRenameReorderForDataMC(datasets)
    
    if mcOnly:
        datasets.remove(datasets.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION

    ### Merge desirable datasets
    if bMergeEwk:
        print "*** Merging EWK MC"
        datasets.merge("EWK MC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"])
        plots._plotStyles["EWK MC"] = styles.ttStyle  #plots._plotStyles["EWK"] = styles.getEWKStyle()
    
    ### Remove signals other than M120
    print "*** Removing all signal except M120"
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    ### Setup style
    print "*** Setting up style"
    styleGenerator = styles.generator(fill=True)
    style = tdrstyle.TDRStyle()
    histograms.createLegend.moveDefaults(dx=-0.0, dy=+0.0)
    
    ### Merge signals into one histo
    print "*** Merging WH and HH signals into one histogram"
    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section

    ### Print desirable information here
    print "*** Available datasets:\n    %s" % (datasets.getAllDatasetNames())
    if mcOnly:
        print "*** Integrated Luminosity:\n    %s (pb)" % (mcOnlyLumi)
    else:
        print "*** Integrated Luminosity:\n     %s (pb)" % (datasets.getDataset("Data").getLuminosity())

    ### Do all plots defined in histoDict function
    doPlots(datasets, histoDict, JetSelectionCuts, SaveExtension = "JetSelection")
    doPlots(datasets, histoDict, MtCut, SaveExtension = "Mt")
    doPlots(datasets, histoDict, MetBtagDeltaPhiCuts, SaveExtension = "MetBtagDeltaPhi")
    doPlots(datasets, histoDict, MetBtagDeltaPhiMtCuts, SaveExtension = "MetBtagDeltaPhiMt")
        
    ### Keep session alive (otherwise canvases close automatically)
    if bBatchMode == False:
        raw_input("*** Press \"any\" key to exit pyROOT: ")
def main():
    
    # Get the ROOT files for all datasets, merge datasets and reorder them
    datasets = dataset.getDatasetsFromMulticrabCfg(directory="/Volumes/disk/attikis/HIG-12-037/TreeAnalysis_v44_4_130113_105229/", dataEra="Run2011A")
    datasets.updateNAllEventsToPUWeighted()
    datasets.loadLuminosities()    
    plots.mergeRenameReorderForDataMC(datasets)

    # Merge desirable datasets
    datasets.merge("EWK MC", ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"])
    plots._plotStyles["EWK MC"] = styles.ttStyle  #plots._plotStyles["EWK"] = styles.getEWKStyle()
    
    # Remove signals other than M120
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    # Setup style
    styleGenerator = styles.generator(fill=True)
    style = tdrstyle.TDRStyle()
    histograms.createLegend.moveDefaults(dx=-0.0, dy=+0.0)
    
    # Merge signals into one histo
    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section

    # Print desirable information here
    print "*** Event weight applied: %s" % (EvtWeight)
    print "*** Available datasets: %s" % (datasets.getAllDatasetNames())
    print "*** WARNING! What about btag scale factor?"
    print "*** Integrated Luminosity: %s (pb)" % (datasets.getDataset("Data").getLuminosity())

    # Define histogram name, expression, and binning here: 
    # { hName": "expression >> hNameTmp(nBins, xMin, xMax) }
    histoDict1 = {
        "sphericity": "sphericity >> sphericity(20, 0.0, 1.0)", 
        "aplanarity": "aplanarity >> aplanarity(20, 0.0, 0.5)", 
        "planarity": "planarity >> planarity(20, 0.0, 0.5)", 
        "circularity": "circularity >> circularity(20, 0.0, 1.0)", 
        "alphaT": "alphaT >> alphaT(20, 0.0, 1.0)", 
        "mT": "%s >> mT(30, 0.0, 600.0)" % (Mt)
        }

    # Do all plots defined in doPlots(datasets) function
#    doPlots(datasets, histoDict1, "", SaveExtension = "JetSelection")
#    doPlots(datasets, histoDict1, MetBtagDeltaPhiCuts, SaveExtension = "Met_Btag_DeltaPhi")
#    doPlots(datasets, histoDict1, MetBtagDeltaPhiCircularityCuts, SaveExtension = "Met_Btag_DeltaPhi_Circularity")
#    doPlots(datasets, histoDict1, TestCuts, SaveExtension = "Test")


    # Do just mT plots
    histoDict2 = {
        "mT": "%s >> mT(30, 0.0, 600.0)" % (Mt)
        }

    for i in range(1, 8):
        cutValue = (i+0.0)/(10.0)
        doPlots(datasets, histoDict2, "circularity <= %f" % (cutValue), SaveExtension = "Circularity%s" % (i))
def main():
    creator = dataset.readFromMulticrabCfg()
    datasets = creator.createDatasetManager(dataEra=dataEra)

    if not mcOnly:
        datasets.loadLuminosities()

    datasets.updateNAllEventsToPUWeighted()    
    plots.mergeRenameReorderForDataMC(datasets)

    if not mcOnly:
        mcOnlyLumi = datasets.getDataset("Data").getLuminosity()

    datasets.remove(datasets.getDataDatasetNames())
    histograms.cmsTextMode = histograms.CMSMode.SIMULATION

    histograms.createLegend.moveDefaults(dx=-0.05, dh=-0.15)

    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.01, br_Htaunu=1)
    for dset in datasets.getAllDatasets():
        if "HplusTB_" in dset.getName():
            dset.setCrossSection(1.0)

    plots.mergeWHandHH(datasets)
    datasets.merge("EWK", ["TTJets",
                           "WJets",
                           "DYJetsToLL",
                           "SingleTop", "Diboson"
                           ], keepSources=True)

    style = tdrstyle.TDRStyle()

    # Setup the systematics recipe object
    systematics = dataset.Systematics(
        allShapes=True,
        #shapes=["SystVarJER", "SystVarJES", "SystVarMET", "SystVarTES"],
        #verbose=True,
        #additionalNormalizations={"Foo": 0.2, "Bar": 0.05},
                                      )

    histograms.uncertaintyMode.set(histograms.Uncertainty.StatOnly)

    def dop(datasetName):
        doPlots(datasets, datasetName, systematics)
        doCounters(datasets, datasetName, creator.getSystematicVariationSources())

#    dop("TTToHplus_M80")
    dop("TTToHplus_M120")
#    dop("TTToHplus_M160")
#    dop("HplusTB_M180")
    dop("HplusTB_M200")
#    dop("HplusTB_M300")
    dop("TTJets")
#    dop("DYJetsToLL")
    dop("WJets")
    dop("EWK")
Example #15
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Merge EWK datasets
    datasets.merge("EWK", [
            "WJets",
            "TTJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create the normalized plot of transverse mass
    # Read the histogram from the file
    #mT = plots.DataMCPlot(datasets, analysis+"/transverseMass")

    # Create the histogram from the tree (and see the selections explicitly)
    td = dataset.TreeDraw(analysis+"/tree", weight="weightPileup*weightTrigger*weightPrescale",
                             selection="met_p4.Et() > 70 && Max$(jets_btag) > 1.7")
    mT = plots.DataMCPlot(datasets, td.clone(varexp="sqrt(2 * tau_p4.Pt() * met_p4.Et() * (1-cos(tau_p4.Phi()-met_p4.Phi())))>>dist(400, 0, 400)"))

    # Rebin before subtracting
    mT.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20))

    # Create the data-EWK histogram and draw it
    dataEwkDiff(mT)

    # Draw the mT distribution
    transverseMass(mT)
Example #16
0
    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"])
Example #17
0
def manageDatasets(datasets):
    '''
    def manageDatasets(datasets):
    Handles the PU weighting, luminosity loading and signal merging of the datatasets.
    '''
    
    ### Since (by default) we use weighted counters, and the analysis job inputs are 
    ### normally skims (as are "v44_4" and "v53_1"), need to update events to PU weighted
    print "\n*** Updating events to PU weighted:"
    datasets.updateNAllEventsToPUWeighted()

    if bMcOnly==True:
        datasets.remove(datasets.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        datasets.loadLuminosities()

    print "\n*** Default merging of dataset components:"
    plots.mergeRenameReorderForDataMC(datasets)
                
    print "\n*** Removing all signal samples, except m=%s GeV/cc" % (signalMass)
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M"+signalMass in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    ### Setup style
    styleGenerator = styles.generator(fill=False)
    plots._legendLabels["TTToHplus_M"+signalMass] = "m_{H^{+}} = " + signalMass + " GeV/c^{2}"
    style = tdrstyle.TDRStyle()

    print "*** Setting signal cross sections, using BR(t->bH+)=%s and BR(H+ -> tau+ nu)=%s" % (BR_tH, BR_Htaunu)
    xsect.setHplusCrossSectionsToBR(datasets, BR_tH, BR_Htaunu)
    print "*** Merging WH and HH signals"
    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section
    
    ### Now optionally remove datasets
    if bRemoveEwk:
        mergeEwkMc(datasets)
        datasets.remove(filter(lambda name: "EWK MC" in name, datasets.getAllDatasetNames()))
    else:
        if bMergeEwk==True:
            mergeEwkMc(datasets)

    if bRemoveQcd:
        datasets.remove(filter(lambda name: "QCD" in name, datasets.getAllDatasetNames()))
        
    #if bRemoveSignal: FIXME
    #    datasets.remove(filter(lambda name: "TTToHplus" in name, datasets.getAllDatasetNames()))
    #    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    print "*** Available datasets: %s" % (datasets.getAllDatasetNames())

    return datasets
def manageDatasets(datasets):
    '''
    def manageDatasets(datasets):
    Handles the PU weighting, luminosity loading and signal merging of the datatasets.
    '''
    
    ### Since (by default) we use weighted counters, and the analysis job inputs are 
    ### normally skims (as are "v44_4" and "v53_1"), need to update events to PU weighted
    print "\n*** Updating events to PU weighted:"
    datasets.updateNAllEventsToPUWeighted()

    if getBool("bRemoveData"):
        datasets.remove(datasets.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        datasets.loadLuminosities()

    print "\n*** Default merging of dataset components:"
    plots.mergeRenameReorderForDataMC(datasets)
                
    if getBool("bRemoveSignal"): 
        print "\n*** Removing all signal samples"
        datasets.remove(filter(lambda name: "TTToHplus" in name, datasets.getAllDatasetNames()))
        datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    else:
        print "\n*** Removing all signal samples, except m=%s GeV/cc" % (signalMass)
        datasets.remove(filter(lambda name: "TTToHplus" in name and not "M"+signalMass in name, datasets.getAllDatasetNames()))
        datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
        plots._legendLabels["TTToHplus_M"+signalMass] = "m_{H^{#pm}} = " + signalMass + " GeV/c^{2}"

    ### Setup style
    styleGenerator = styles.generator(fill=False)
    style = tdrstyle.TDRStyle()

    print "*** Setting signal cross sections, using BR(t->bH+)=%s and BR(H+ -> tau+ nu)=%s" % (BR_tH, BR_Htaunu)
    xsect.setHplusCrossSectionsToBR(datasets, BR_tH, BR_Htaunu)
    print "*** Merging WH and HH signals"
    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section
    
    ### Now optionally remove datasets
    if getBool("bRemoveEwk"):
        mergeEwkMc(datasets)
        datasets.remove(filter(lambda name: "EWK MC" in name, datasets.getAllDatasetNames()))
    else:
        if getBool("bMergeEwk"):
            mergeEwkMc(datasets)
    if getBool("bRemoveQcd"):
        datasets.remove(filter(lambda name: "QCD" in name, datasets.getAllDatasetNames()))
        
    print "*** Available datasets: %s" % (datasets.getAllDatasetNames())

    return datasets
    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)
Example #20
0
def main():
    # Read the datasets
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=analysis+"Counters")
    datasets.updateNAllEventsToPUWeighted()
    datasets.loadLuminosities()

    plots.mergeRenameReorderForDataMC(datasets)
    print "Int.Lumi",datasets.getDataset("Data").getLuminosity()

    # Take a deep copy of DatasetManager for all signals
    datasetsAllSignals = datasets.deepCopy()

    # Remove signals other than M120
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    # Remove QCD
    datasets.remove(filter(lambda name: "QCD" in name, datasets.getAllDatasetNames()))
    histograms.createLegend.moveDefaults(dx=-0.02)
    histograms.createLegend.moveDefaults(dh=-0.03)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)
    xsect.setHplusCrossSectionsToBR(datasetsAllSignals, br_tH=0.05, br_Htaunu=1)

    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section

    # Replace signal dataset with EWK+signal
    # This produces the "bkg+signal" histogram
    # The ttbar cross section is adjusted for the BR(t->H+)
    ttjets2 = datasets.getDataset("TTJets").deepCopy()
    ttjets2.setName("TTJets2")
    ttjets2.setCrossSection(ttjets2.getCrossSection() - datasets.getDataset("TTToHplus_M120").getCrossSection())
    datasets.append(ttjets2)
    datasets.merge("EWKnoTT", ["WJets", "DYJetsToLL", "SingleTop", "Diboson"], keepSources=True)
    datasets.merge("TTToHplus_M120", ["TTToHplus_M120", "EWKnoTT", "TTJets2"])
    plots._legendLabels["TTToHplus_M120"] = "with H^{#pm}#rightarrow#tau^{#pm}#nu"

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create plots
    doPlots(datasets)

    # Print counters
    massPoints = [80, 90, 100, 120, 140, 150, 155, 160]
    doCounters(datasetsAllSignals, massPoints)
Example #21
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(dataEra="Run2012ABCD")

    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "Hplus_taunu_" in name,
               datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "HplusTB_M" in name,
               datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    dataMCExample(datasets)
    distComparison(datasets)

    # Script execution can be paused like this, it will continue after
    # user has given some input (which must include enter)
    if drawToScreen:
        raw_input("Hit enter to continue")
Example #22
0
def main():
    interactive = True
    interactive = False

    # Disable batch mode here to have the interactivity (see also the line with 'raw_input') below
    if interactive:
        ROOT.gROOT.SetBatch(False)

    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    #dataMCExample(datasets)
    distComparison(datasets)

    # Script execution can be paused like this, it will continue after
    # user has given some input (which must include enter)
    if interactive:
        raw_input("Hit enter to continue")
def manageDatasets(datasets):
    '''
    def manageDatasets(datasets):
    Handles the PU weighting, luminosity loading and signal merging of the datatasets.
    '''

    ### Since (by default) we use weighted counters, and the analysis job inputs are
    ### normally skims (as are "v44_4" and "v53_1"), need to update events to PU weighted
    print "\n*** Updating events to PU weighted:"
    datasets.updateNAllEventsToPUWeighted()

    if bMcOnly:
        datasets.remove(datasets.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        datasets.loadLuminosities()

    print "\n*** Default merging of dataset components:"
    plots.mergeRenameReorderForDataMC(datasets)

    print "\n*** Removing all signal samples, except m=%s" % (signalMass)
    datasets.remove(
        filter(
            lambda name: "TTToHplus" in name and not "M" + signalMass in name,
            datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    ### Setup style
    styleGenerator = styles.generator(fill=False)
    style = tdrstyle.TDRStyle()
    histograms.createLegend.moveDefaults(dx=-0.02, dy=+0.00)

    print "*** Setting signal cross sections, using BR(t->bH+)=%s and BR(H+ -> tau+ nu)=%s" % (
        BR_tH, BR_Htaunu)
    xsect.setHplusCrossSectionsToBR(datasets, BR_tH, BR_Htaunu)
    print "*** Merging WH and HH signals"
    plots.mergeWHandHH(
        datasets
    )  # merging of WH and HH signals must be done after setting the cross section

    return datasets
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(dataEra="Run2012ABCD")

    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB_M" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    dataMCExample(datasets)
    distComparison(datasets)

    # Script execution can be paused like this, it will continue after
    # user has given some input (which must include enter)
    if drawToScreen:
        raw_input("Hit enter to continue")
Example #25
0
    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)
Example #26
0
def manageDatasets(datasets):

    # Since (by default) we use weighted counters, and the analysis job inputs are normally skims (as are "v44_4" and "v53_1"), need to update events to PU weighted
    print "%sUpdating events to PU weighted:" % (" " * 0)
    datasets.updateNAllEventsToPUWeighted()

    # Determine number of Data/MC datasets present
    nDataDatasets = len(datasets.getDataDatasets())
    nMCDatasets = len(datasets.getMCDatasets())
    nDatasetsToKeep = len(datasetsToKeep)

    # Sanity check
    if nDatasetsToKeep < 1:
        print "%sERROR! There are zero (0) datasets." % (" " * 0)
        sys.exit()

    # Determine luminosity and between canvas "Lumi" or "Simulation" text
    if nDataDatasets < 1:
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        datasets.loadLuminosities()

    # Merge and rename datasets
    #print "%sDefault merging of dataset components:" % (" "*0)
    plots.mergeRenameReorderForDataMC(datasets)

    # Set signal xSectio and BR, and merge WH and HH
    print "%sSetting signal cross sections, using BR(t->bH+)=%s and BR(H+ -> tau+ nu)=%s" % (
        " " * 0, BR_tH, BR_Htaunu)
    xsect.setHplusCrossSectionsToBR(datasets, BR_tH, BR_Htaunu)
    plots.mergeWHandHH(
        datasets)  # Must be done after setting the cross section

    # Remove all datasets except those passed as a list
    datasets = getCustomDatasets(datasets, datasetsToKeep)

    # Finally, set TDR as the default style
    style = tdrstyle.TDRStyle()

    return datasets
Example #27
0
def manageDatasets(datasets):
    
    # Since (by default) we use weighted counters, and the analysis job inputs are normally skims (as are "v44_4" and "v53_1"), need to update events to PU weighted
    print "%sUpdating events to PU weighted:" % (" "*0)
    datasets.updateNAllEventsToPUWeighted()

    # Determine number of Data/MC datasets present
    nDataDatasets   = len(datasets.getDataDatasets())
    nMCDatasets     = len(datasets.getMCDatasets())
    nDatasetsToKeep = len(datasetsToKeep)

    # Sanity check
    if nDatasetsToKeep < 1:
        print "%sERROR! There are zero (0) datasets." % (" "*0)
        sys.exit()

    # Determine luminosity and between canvas "Lumi" or "Simulation" text
    if nDataDatasets < 1:
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        datasets.loadLuminosities()

    # Merge and rename datasets
    #print "%sDefault merging of dataset components:" % (" "*0)
    plots.mergeRenameReorderForDataMC(datasets)

    # Set signal xSectio and BR, and merge WH and HH
    print "%sSetting signal cross sections, using BR(t->bH+)=%s and BR(H+ -> tau+ nu)=%s" % (" "*0, BR_tH, BR_Htaunu)
    xsect.setHplusCrossSectionsToBR(datasets, BR_tH, BR_Htaunu)
    plots.mergeWHandHH(datasets) # Must be done after setting the cross section

    # Remove all datasets except those passed as a list
    datasets = getCustomDatasets(datasets, datasetsToKeep)

    # Finally, set TDR as the default style
    style = tdrstyle.TDRStyle()

    return datasets
Example #28
0
def main():
    # Read the datasets
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    datasets.remove([
        "WJets_TuneD6T_Winter10",
        "TTJets_TuneD6T_Winter10",
        "TTToHplusBWB_M140_Spring11",
        "TTToHplusBWB_M80_Spring11",
        "TTToHplusBWB_M90_Spring11",
        "TTToHplusBWB_M155_Spring11",
        "TTToHplusBWB_M150_Spring11",
        "TTToHplusBWB_M160_Spring11",
        "TTToHplusBWB_M100_Spring11",
        "TTToHplusBHminusB_M80_Spring11",
        "TTToHplusBHminusB_M100_Spring11",
        "TTToHplusBHminusB_M160_Spring11",
        "TTToHplusBHminusB_M150_Spring11",
        "TTToHplusBHminusB_M140_Spring11",
        "TTToHplusBHminusB_M155_Spring11",
        "TauPlusX_160431-161016_Prompt",
        "TauPlusX_162803-162828_Prompt",
        "QCD_Pt30to50_TuneZ2_Spring11",
        "QCD_Pt50to80_TuneZ2_Spring11",
        "QCD_Pt80to120_TuneZ2_Spring11",
        "QCD_Pt120to170_TuneZ2_Spring11",
        "QCD_Pt170to300_TuneZ2_Spring11",
        "QCD_Pt300to470_TuneZ2_Spring11",
        "HplusTB_M180_Summer11",
        "HplusTB_M190_Summer11",
        "HplusTB_M250_Summer11",
        "HplusTB_M300_Summer11",
        "HplusTB_M220_Summer11",
        "HplusTB_M200_Summer11",
        #                     "Tau_165970-166164_Prompt", "Tau_166374-167043_Prompt", "Tau_167078-167784_Prompt", "Tau_165088-165633_Prompt"
        #                     "Tau_163270-163869_May10","Tau_161217-163261_May10", "Tau_160431-161176_May10"
    ])

    datasets.updateNAllEventsToPUWeighted()
    datasets.loadLuminosities()

    # Take signals from 42X
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))
    #    datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_4_patch1/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_110621_150040/multicrab.cfg", counters=counters)
    #Rtau =0
    #    datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_5/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_110804_104313/multicrab.cfg", counters=counters)

    #    datasetsSignal.selectAndReorder(["HplusTB_M200_Summer11"])
    #    datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_4_patch1/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_110622_112321/multicrab.cfg", counters=counters)
    #datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_1_5/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/Signal_v11f_scaledb_424/multicrab.cfg", counters=counters)

    #datasetsSignal.selectAndReorder(["TTToHplusBWB_M120_Summer11", "TTToHplusBHminusB_M120_Summer11"])
    #datasetsSignal.renameMany({"TTToHplusBWB_M120_Summer11" :"TTToHplusBWB_M120_Spring11",
    #                           "TTToHplusBHminusB_M120_Summer11": "TTToHplusBHminusB_M120_Spring11"})
    #datasets.extend(datasetsSignal)

    plots.mergeRenameReorderForDataMC(datasets)

    # Set the signal cross sections to the ttbar
    #    xsect.setHplusCrossSectionsToTop(datasets)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.2, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
    #    xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)

    plots.mergeWHandHH(
        datasets
    )  # merging of WH and HH signals must be done after setting the cross section

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create the plot objects and pass them to the formatting
    # functions to be formatted, drawn and saved to files

    #    selectionFlow(plots.DataMCPlot(datasets, analysis+"/SignalSelectionFlow"), "SignalSelectionFlow")

    #   met(plots.DataMCPlot(datasets, analysis+"/TauEmbeddingAnalysis_afterTauId_embeddingMet"), ratio=True)
    #   met(plots.DataMCPlot(datasets, analysis+"/TauEmbeddingAnalysis_begin_embeddingMet"), ratio=True)

    #    met2(plots.DataMCPlot(datasets, analysis+"/Met_BeforeTauId"), "MetBeforeTauId", rebin=40)

    met2(plots.DataMCPlot(datasets, analysis + "/QCD_MET_AfterJetSelection"),
         "QCD_MET_AfterJetSelection",
         rebin=1)
    met2(plots.DataMCPlot(datasets, analysis + "/QCD_MET_AfterJetsBtagging"),
         "QCD_MET_AfterJetsBtagging",
         rebin=1)
    met2(plots.DataMCPlot(datasets,
                          analysis + "/QCD_MET_AfterJetsBtagging4050"),
         "QCD_MET_AfterJetsBtagging4050",
         rebin=1)
    met2(plots.DataMCPlot(datasets,
                          analysis + "/QCD_MET_AfterJetsBtagging5060"),
         "QCD_MET_AfterJetsBtagging5060",
         rebin=1)
    met2(plots.DataMCPlot(datasets,
                          analysis + "/QCD_MET_AfterJetsBtagging6070"),
         "QCD_MET_AfterJetsBtagging6070",
         rebin=1)
    met2(plots.DataMCPlot(datasets,
                          analysis + "/QCD_MET_AfterJetsBtagging7080"),
         "QCD_MET_AfterJetsBtagging7080",
         rebin=1)
    met2(plots.DataMCPlot(datasets,
                          analysis + "/QCD_MET_AfterJetsBtagging80100"),
         "QCD_MET_AfterJetsBtagging80100",
         rebin=1)
    met2(plots.DataMCPlot(datasets,
                          analysis + "/QCD_MET_AfterJetsBtagging100120"),
         "QCD_MET_AfterJetsBtagging100120",
         rebin=1)
    met2(plots.DataMCPlot(datasets,
                          analysis + "/QCD_MET_AfterJetsBtagging120150"),
         "QCD_MET_AfterJetsBtagging120150",
         rebin=1)
    met2(plots.DataMCPlot(datasets,
                          analysis + "/QCD_MET_AfterJetsBtagging150"),
         "QCD_MET_AfterJetsBtagging150",
         rebin=1)

    # Set temporarily the signal cross sections to a value from MSSM
    #    xsect.setHplusCrossSections(datasets, tanbeta=20, mu=200)
    #    datasets.getDataset("TTToHplusBHminusB_M120").setCrossSection(0.2*165)
    #    datasets.getDataset("TTToHplusBWB_M120").setCrossSection(0.2*165)

    ####################
    datasets_tm = datasets
    #    datasets_tm = datasets.deepCopy()
    #    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.2, br_Htaunu=1)
    #    xsect.setHplusCrossSectionsToBR(datasets_tm, br_tH=0.2, br_Htaunu=1)
    #    datasets_tm.merge("TTToHplus_M120", ["TTToHplusBWB_M120", "TTToHplusBHminusB_M120"])

    transverseMass2(plots.DataMCPlot(
        datasets, analysis + "/QCD_TransverseMass_AfterJetSelection"),
                    "QCD_TransverseMass_AfterJetSelection",
                    rebin=1)
    transverseMass2(plots.DataMCPlot(
        datasets, analysis + "/QCD_TransverseMass_AfterJetSelectionMetCut"),
                    "QCD_TransverseMass_AfterJetSelectionMetCut",
                    rebin=1)
    transverseMass2(plots.DataMCPlot(
        datasets, analysis + "/QCD_TransverseMass_AfterJetsBtagging"),
                    "QCD_TransverseMass_AfterJetsBtagging",
                    rebin=1)

    transverseMass2(plots.DataMCPlot(
        datasets, analysis + "/QCD_TransverseMass_AfterBigBox"),
                    "QCD_TransverseMass_AfterBigBox",
                    rebin=1)
    transverseMass2(plots.DataMCPlot(
        datasets, analysis + "/QCD_TransverseMass_AfterBigBoxAndMet"),
                    "QCD_TransverseMass_AfterBigBoxAndMet",
                    rebin=1)
    transverseMass2(plots.DataMCPlot(
        datasets, analysis + "/QCD_TransverseMass_AfterBigBoxAndBtag"),
                    "QCD_TransverseMass_AfterBigBoxAndBtag",
                    rebin=1)
    transverseMass2(plots.DataMCPlot(
        datasets, analysis + "/QCD_TransverseMass_AfterBigBoxAndTauID"),
                    "QCD_TransverseMass_AfterBigBoxAndTauID",
                    rebin=1)
    #    xsect.setHplusCrossSections(datasets, toTop=True)

    #    genComparison(datasets)
    #    zMassComparison(datasets)
    #    topMassComparison(datasets)
    #    topPtComparison(datasets)
    #    vertexComparison(datasets)

    eventCounter = counter.EventCounter(datasets)

    eventCounter.normalizeMCByLuminosity()
    #    eventCounter.normalizeMCToLuminosity(73)
    print "============================================================"
    print "Main counter (MC normalized by collision data luminosity)"
    print eventCounter.getMainCounterTable().format()

    #    print eventCounter.getSubCounterTable("GlobalMuon_ID").format()

    #    print eventCounter.getSubCounterTable("tauIDTauSelection").format()
    #    print eventCounter.getSubCounterTable("TauIDPassedEvt::tauID_HPSTight").format()
    #    print eventCounter.getSubCounterTable("TauIDPassedJets::tauID_HPSTight").format()
    print eventCounter.getSubCounterTable("b-tagging").format()
    print eventCounter.getSubCounterTable("Jet selection").format()
    print eventCounter.getSubCounterTable("Jet main").format()

    drh1 = datasets.getDataset("Data").getDatasetRootHisto(
        analysis + "/QCD_MET_AfterJetSelection")
    drh2 = datasets.getDataset("Data").getDatasetRootHisto(
        analysis + "/QCD_MET_AfterJetsBtagging7080")
    drh1.setName("Base")
    drh1.normalizeToOne()
    drh2.normalizeToOne()
    #    drh1.normalizeMCByLuminosity()
    plot = plots.ComparisonPlot(drh1, drh2)
    #    plot = plots.PlotBase(drh1)
    #    plot = plots.MCPlot(drh1)
    # Rebin, if necessary
    plot.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    #    drh1.normalizeMCByLuminosity()
    #    plot = plots.PlotBase(drh1)
    #    plot = plots.MCPlot(drh
    # Create frame with a ratio pad
    plot.createFrame("distribution", opts={"ymin": 1e-5, "ymaxfactor": 1.5})
    #                     createRatio=True, opts2={"ymin": -10, "ymax": 50}, # bounds of the ratio plot
    #                     )

    plot.draw()
    plot.save()

    mt = plots.DataMCPlot(datasets, analysis + "/QCD_MET_AfterJetSelection")
    mt.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    mt_data = mt.histoMgr.getHisto("Data").getRootHisto().Clone("mt_data")
Example #29
0
        dataEra=era, searchMode=searchMode, optimizationMode=optimizationMode)
    # Do the usual normalisation
    dsetMgr.updateNAllEventsToPUWeighted()
    dsetMgr.loadLuminosities()
    plots.mergeRenameReorderForDataMC(dsetMgr)
    dsetMgr.merge("EWK",
                  ["TTJets", "WJets", "DYJetsToLL", "SingleTop", "Diboson"],
                  keepSources=True)  # Keep sources needed to keep open TTJets
    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(dsetMgr,
                                    br_tH=optionBrTopToHplusb,
                                    br_Htaunu=1)
    # Set the signal cross sections to a value from MSSM
    # xsect.setHplusCrossSectionsToMSSM(dsetMgr, tanbeta=20, mu=200)
    plots.mergeWHandHH(
        dsetMgr
    )  # merging of WH and HH signals must be done after setting the cross section

    # Make a directory for output
    myDir = "invertedControlPlots_%s" % myModuleInfoString
    # Remove the directory with its contents if it exists
    if os.path.exists(myDir):
        shutil.rmtree(myDir)
    os.mkdir(myDir)
    # Obtain luminosity
    myLuminosity = dsetMgr.getDataset("Data").getLuminosity()
    # Print info so that user can check that merge went correct
    if myDisplayStatus:
        dsetMgr.printDatasetTree()
        print "Luminosity = %f 1/fb" % (myLuminosity / 1000.0)
        print
def main(opts, signalDsetCreator, era, searchMode, optimizationMode):
    # Make directory for output
    mySuffix = "normalisationPlots_%s_%s_%s" % (era, searchMode,
                                                optimizationMode)
    if os.path.exists(mySuffix):
        if os.path.exists("%s_old" % mySuffix):
            shutil.rmtree("%s_old" % mySuffix)
        os.rename(mySuffix, "%s_old" % mySuffix)
    os.mkdir(mySuffix)
    # Create dataset manager
    myDsetMgr = signalDsetCreator.createDatasetManager(
        dataEra=era, searchMode=searchMode, optimizationMode=optimizationMode)
    if mcOnly:
        myDsetMgr.remove(myDsetMgr.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        myDsetMgr.loadLuminosities()
    myDsetMgr.updateNAllEventsToPUWeighted()

    # Take QCD from data
    if opts.noMCQCD:
        myDsetMgr.remove(
            filter(lambda name: "QCD" in name, myDsetMgr.getAllDatasetNames()))
    # Remove signal
    if opts.noSignal:
        myDsetMgr.remove(
            filter(lambda name: "TTToHplus" in name,
                   myDsetMgr.getAllDatasetNames()))
        myDsetMgr.remove(
            filter(lambda name: "Hplus_taunu" in name,
                   myDsetMgr.getAllDatasetNames()))
        myDsetMgr.remove(
            filter(lambda name: "HplusTB" in name,
                   myDsetMgr.getAllDatasetNames()))

    plots.mergeRenameReorderForDataMC(myDsetMgr)

    if mcOnly:
        print "Int.Lumi (manually set)", mcOnlyLumi
    else:
        print "Int.Lumi", myDsetMgr.getDataset("Data").getLuminosity()
    if not opts.noSignal:
        print "norm=", myDsetMgr.getDataset(
            "TTToHplusBWB_M120").getNormFactor()

    myDsetMgr.remove(
        filter(lambda name: "QCD_Pt20_MuEnriched" in name,
               myDsetMgr.getAllDatasetNames()))
    # Remove signals other than M120
    myDsetMgr.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               myDsetMgr.getAllDatasetNames()))
    myDsetMgr.remove(
        filter(lambda name: "Hplus_taunu" in name,
               myDsetMgr.getAllDatasetNames()))
    myDsetMgr.remove(
        filter(lambda name: "HplusTB" in name, myDsetMgr.getAllDatasetNames()))

    histograms.createLegend.moveDefaults(dx=-0.05)
    histograms.createSignalText.set(xmin=0.4, ymax=0.93, mass=120)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(myDsetMgr, br_tH=optionBr, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
    #    xsect.setHplusCrossSectionsToMSSM(myDsetMgr, tanbeta=20, mu=200)

    plots.mergeWHandHH(
        myDsetMgr
    )  # merging of WH and HH signals must be done after setting the cross section

    # Replace signal dataset with a signal+background dataset, where
    # the BR(t->H+) is taken into account for SM ttbar
    #plots.replaceLightHplusWithSignalPlusBackground(myDsetMgr)

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create plots
    doPlots(myDsetMgr, opts, mySuffix)

    # Print counters
    #doCounters(myDsetMgr)
    print "Results saved in directory: %s" % mySuffix
Example #31
0
def main():
    # Read the datasets
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    if era == "Run2011A":
        datasets.remove(
            filter(lambda name: "2011B_" in name,
                   datasets.getDataDatasetNames()))
    elif era == "Run2011B":
        datasets.remove(
            filter(lambda name: "2011A_" in name,
                   datasets.getDataDatasetNames()))
    elif era == "Run2011AB":
        pass
    else:
        raise Exception("Unsupported era " + era)
    datasets.updateNAllEventsToPUWeighted()
    datasets.loadLuminosities()
    #print datasets.getAllDatasetNames()
    #return

    #    apply_v13_1_bugfix(datasets)

    plots.mergeRenameReorderForDataMC(datasets)
    #    datasets.remove(["W3Jets"])

    #    datasets.remove(["DYJetsToLL", "SingleTop", "Diboson", "QCD_Pt20_MuEnriched"])

    # Signal
    #keepSignal = "M80"
    #keepSignal = "M90"
    #keepSignal = "M100"
    #keepSignal = "M120"
    #keepSignal = "M140"
    #keepSignal = "M150"
    keepSignal = "M155"
    #keepSignal = "M160"
    datasets.remove(
        filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    # Replace signal dataset with EWK+signal
    if False:
        datasets.remove(
            filter(lambda name: "TTToHplus" in name and not keepSignal in name,
                   datasets.getAllDatasetNames()))
        xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)
        #xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.1, br_Htaunu=1)
        plots.mergeWHandHH(
            datasets
        )  # merging of WH and HH signals must be done after setting the cross section

        ttjets2 = datasets.getDataset("TTJets").deepCopy()
        ttjets2.setName("TTJets2")
        ttjets2.setCrossSection(
            ttjets2.getCrossSection() -
            datasets.getDataset("TTToHplus_" + keepSignal).getCrossSection())
        datasets.append(ttjets2)
        datasets.merge("EWKnoTT",
                       ["WJets", "DYJetsToLL", "SingleTop", "Diboson"],
                       keepSources=True)
        #datasets.merge("TTToHplus_"+keepSignal, ["TTToHplus_"+keepSignal, "EWKnoTT", "TTJets2"])
        datasets.merge("EWKScaled", ["EWKnoTT", "TTJets2"])
        datasets.merge("EWKSignal", ["TTToHplus_" + keepSignal, "EWKScaled"],
                       keepSources=True)
        plots._legendLabels[
            "TTToHplus_" + keepSignal] = "with H^{#pm}#rightarrow#tau^{#pm}#nu"
    else:
        datasets.remove(
            filter(lambda name: "TTToHplus" in name,
                   datasets.getAllDatasetNames()))

    #datasets.remove(filter(lambda name: "TTJets" not in name, datasets.getAllDatasetNames()))

    mcLumi = None
    if not datasets.hasDataset("Data"):
        mcLumi = 5000


#    scaleLumi.signalLumi = 43.4024599650000037
#    scaleLumi.ewkLumi = datasets.getDataset("Data").getLuminosity()

# Apply TDR style
    style = tdrstyle.TDRStyle()

    histograms.createLegend.moveDefaults(dx=-0.04)
    #datasets.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)

    #    doPlots(datasets, mcLumi)
    doCounters(datasets, mcLumi)
def main():

#    HISTONAME = "TauIdJets"
    HISTONAME = "TauIdBtag"
    
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    datasets.merge("EWK", [
	    "TTJets",
            "WJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    invertedQCD = InvertedTauID()
    invertedQCD.setLumi(datasets.getDataset("Data").getLuminosity())



    bins = ["inclusive"]
#    bins = ["4050","5060","6070","7080","80100","100120","120150","150"]
#    bins = ["4050"]


    for bin in bins:

	invertedQCD.setLabel(bin)

	if bin == "inclusive":
	    bin = ""

        metBase = plots.DataMCPlot(datasets, analysis+"/MET_BaseLine"+HISTONAME+bin)
        metInver = plots.DataMCPlot(datasets, analysis+"/MET_Inverted"+HISTONAME+bin)
        # Rebin before subtracting
        metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
        metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))

        metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone(analysis+"/MET_Inverted"+HISTONAME+bin)
        metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone(analysis+"/MET_Inverted"+HISTONAME+bin)
        metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone(analysis+"/MET_Baseline"+HISTONAME+bin)
        metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone(analysis+"/MET_Baseline"+HISTONAME+bin)

        metBase_QCD = metBase_data.Clone("QCD")
        metBase_QCD.Add(metBase_EWK,-1)

        invertedQCD.plotHisto(metInverted_data,"inverted")
        invertedQCD.plotHisto(metBase_data,"baseline")
        invertedQCD.fitQCD(metInverted_data)
        invertedQCD.fitEWK(metBase_EWK,"LR")
        invertedQCD.fitData(metBase_data)
        invertedQCD.getNormalization()

    invertedQCD.Summary()
Example #33
0
def main():

    if len(sys.argv) < 2:
        usage()

    dirs = []
    dirs.append(sys.argv[1])

    # Read the datasets
    #    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra, analysisBaseName="signalAnalysisInvertedTau")
    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,
                                                    dataEra=dataEra,
                                                    searchMode=searchMode,
                                                    analysisName=analysis,
                                                    optimizationMode=optMode)
    #    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters)
    #    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters, dataEra=dataEra)
    #    datasets.updateNAllEventsToPUWeighted()
    datasets.loadLuminosities()
    datasets.updateNAllEventsToPUWeighted()

    # Take QCD from data
    datasetsQCD = None

    if QCDfromData:

        datasetsQCD = dataset.getDatasetsFromMulticrabCfg(
            cfgfile=
            "/home/rkinnune/signalAnalysis/CMSSW_4_2_8_patch2/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_111123_132128/multicrab.cfg",
            counters=counters)
        datasetsQCD.loadLuminosities()
        print "QCDfromData", QCDfromData
        datasetsQCD.mergeData()
        datasetsQCD.remove(datasetsQCD.getMCDatasetNames())
        datasetsQCD.rename("Data", "QCD")

    plots.mergeRenameReorderForDataMC(datasets)

    print "Int.Lumi", datasets.getDataset("Data").getLuminosity()

    # Remove signals other than M120
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    datasets.merge("EWK",
                   ["WJets", "DYJetsToLL", "SingleTop", "Diboson", "TTJets"],
                   keepSources=True)
    datasets.remove(
        filter(lambda name: "W2Jets" in name, datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "W3Jets" in name, datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "W4Jets" in name, datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "Hplus_taunu_s-channel" in name,
               datasets.getAllDatasetNames()))

    datasets_lands = datasets.deepCopy()

    # Set the signal cross sections to the ttbar for datasets for lands
    #    xsect.setHplusCrossSectionsToTop(datasets_lands)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.01, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
    #    xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)

    plots.mergeWHandHH(
        datasets
    )  # merging of WH and HH signals must be done after setting the cross section

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create plots
    doPlots(datasets)

    # Write mt histograms to ROOT file
    #    writeTransverseMass(datasets_lands)

    # Print counters
    doCounters(datasets)
Example #34
0
def main():
    # Read the datasets
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    datasets.remove(["WJets_TuneD6T_Winter10", "TTJets_TuneD6T_Winter10",
                     "TTToHplusBWB_M140_Spring11","TTToHplusBWB_M80_Spring11","TTToHplusBWB_M90_Spring11",
                   "TTToHplusBWB_M155_Spring11","TTToHplusBWB_M150_Spring11","TTToHplusBWB_M160_Spring11","TTToHplusBWB_M100_Spring11",
                    "TTToHplusBHminusB_M80_Spring11","TTToHplusBHminusB_M100_Spring11","TTToHplusBHminusB_M160_Spring11",
                     "TTToHplusBHminusB_M150_Spring11","TTToHplusBHminusB_M140_Spring11","TTToHplusBHminusB_M155_Spring11",                       "TauPlusX_160431-161016_Prompt","TauPlusX_162803-162828_Prompt",
                     "QCD_Pt30to50_TuneZ2_Spring11","QCD_Pt50to80_TuneZ2_Spring11","QCD_Pt80to120_TuneZ2_Spring11",
                     "QCD_Pt120to170_TuneZ2_Spring11","QCD_Pt170to300_TuneZ2_Spring11","QCD_Pt300to470_TuneZ2_Spring11",
                     "HplusTB_M180_Summer11", "HplusTB_M190_Summer11","HplusTB_M250_Summer11","HplusTB_M300_Summer11","HplusTB_M220_Summer11","HplusTB_M200_Summer11",
#                     "Tau_165970-166164_Prompt", "Tau_166374-167043_Prompt", "Tau_167078-167784_Prompt", "Tau_165088-165633_Prompt"
#                     "Tau_163270-163869_May10","Tau_161217-163261_May10", "Tau_160431-161176_May10"
                     ])
    
    datasets.loadLuminosities()

    # Take signals from 42X
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
#    datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_4_patch1/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_110621_150040/multicrab.cfg", counters=counters)
#Rtau =0
#    datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_5/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_110804_104313/multicrab.cfg", counters=counters)

#    datasetsSignal.selectAndReorder(["HplusTB_M200_Summer11"])
#    datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_4_patch1/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_110622_112321/multicrab.cfg", counters=counters)
    #datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_1_5/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/Signal_v11f_scaledb_424/multicrab.cfg", counters=counters)

    #datasetsSignal.selectAndReorder(["TTToHplusBWB_M120_Summer11", "TTToHplusBHminusB_M120_Summer11"])
    #datasetsSignal.renameMany({"TTToHplusBWB_M120_Summer11" :"TTToHplusBWB_M120_Spring11",
    #                           "TTToHplusBHminusB_M120_Summer11": "TTToHplusBHminusB_M120_Spring11"})
    #datasets.extend(datasetsSignal)

    plots.mergeRenameReorderForDataMC(datasets)

    # Set the signal cross sections to the ttbar
#    xsect.setHplusCrossSectionsToTop(datasets)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.2, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
#    xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)

    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section

    # Apply TDR style
    style = tdrstyle.TDRStyle()


    # Create the plot objects and pass them to the formatting
    # functions to be formatted, drawn and saved to files

    

#    selectionFlow(plots.DataMCPlot(datasets, analysis+"/SignalSelectionFlow"), "SignalSelectionFlow")
    

#   met(plots.DataMCPlot(datasets, analysis+"/TauEmbeddingAnalysis_afterTauId_embeddingMet"), ratio=True)
#   met(plots.DataMCPlot(datasets, analysis+"/TauEmbeddingAnalysis_begin_embeddingMet"), ratio=True)

#    met2(plots.DataMCPlot(datasets, analysis+"/Met_BeforeTauId"), "MetBeforeTauId", rebin=40)

    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetSelection"), "QCD_MET_AfterJetSelection", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging"), "QCD_MET_AfterJetsBtagging", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging4050"), "QCD_MET_AfterJetsBtagging4050", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging5060"), "QCD_MET_AfterJetsBtagging5060", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging6070"), "QCD_MET_AfterJetsBtagging6070", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging7080"), "QCD_MET_AfterJetsBtagging7080", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging80100"), "QCD_MET_AfterJetsBtagging80100", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging100120"), "QCD_MET_AfterJetsBtagging100120", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging120150"), "QCD_MET_AfterJetsBtagging120150", rebin=1)
    met2(plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging150"), "QCD_MET_AfterJetsBtagging150", rebin=1)

    # Set temporarily the signal cross sections to a value from MSSM
#    xsect.setHplusCrossSections(datasets, tanbeta=20, mu=200)
#    datasets.getDataset("TTToHplusBHminusB_M120").setCrossSection(0.2*165)
#    datasets.getDataset("TTToHplusBWB_M120").setCrossSection(0.2*165)

####################
    datasets_tm = datasets
#    datasets_tm = datasets.deepCopy()
#    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.2, br_Htaunu=1)
#    xsect.setHplusCrossSectionsToBR(datasets_tm, br_tH=0.2, br_Htaunu=1)
#    datasets_tm.merge("TTToHplus_M120", ["TTToHplusBWB_M120", "TTToHplusBHminusB_M120"])


   
    transverseMass2(plots.DataMCPlot(datasets, analysis+"/QCD_TransverseMass_AfterJetSelection"), "QCD_TransverseMass_AfterJetSelection", rebin=1)
    transverseMass2(plots.DataMCPlot(datasets, analysis+"/QCD_TransverseMass_AfterJetSelectionMetCut"), "QCD_TransverseMass_AfterJetSelectionMetCut", rebin=1)
    transverseMass2(plots.DataMCPlot(datasets, analysis+"/QCD_TransverseMass_AfterJetsBtagging"), "QCD_TransverseMass_AfterJetsBtagging", rebin=1)
                    
    transverseMass2(plots.DataMCPlot(datasets, analysis+"/QCD_TransverseMass_AfterBigBox"), "QCD_TransverseMass_AfterBigBox", rebin=1)
    transverseMass2(plots.DataMCPlot(datasets, analysis+"/QCD_TransverseMass_AfterBigBoxAndMet"), "QCD_TransverseMass_AfterBigBoxAndMet", rebin=1)
    transverseMass2(plots.DataMCPlot(datasets, analysis+"/QCD_TransverseMass_AfterBigBoxAndBtag"), "QCD_TransverseMass_AfterBigBoxAndBtag", rebin=1)
    transverseMass2(plots.DataMCPlot(datasets, analysis+"/QCD_TransverseMass_AfterBigBoxAndTauID"), "QCD_TransverseMass_AfterBigBoxAndTauID", rebin=1)              
#    xsect.setHplusCrossSections(datasets, toTop=True)


    
#    genComparison(datasets)
#    zMassComparison(datasets)
#    topMassComparison(datasets)
#    topPtComparison(datasets) 
#    vertexComparison(datasets)


    eventCounter = counter.EventCounter(datasets, counters=countersWeighted)

    eventCounter.normalizeMCByLuminosity()
#    eventCounter.normalizeMCToLuminosity(73)
    print "============================================================"
    print "Main counter (MC normalized by collision data luminosity)"
    print eventCounter.getMainCounterTable().format()

#    print eventCounter.getSubCounterTable("GlobalMuon_ID").format()

#    print eventCounter.getSubCounterTable("tauIDTauSelection").format()
#    print eventCounter.getSubCounterTable("TauIDPassedEvt::tauID_HPSTight").format()
#    print eventCounter.getSubCounterTable("TauIDPassedJets::tauID_HPSTight").format()
    print eventCounter.getSubCounterTable("b-tagging").format()
    print eventCounter.getSubCounterTable("Jet selection").format()
    print eventCounter.getSubCounterTable("Jet main").format()    


   

    drh1 = datasets.getDataset("Data").getDatasetRootHisto(analysis+"/QCD_MET_AfterJetSelection")
    drh2 = datasets.getDataset("Data").getDatasetRootHisto(analysis+"/QCD_MET_AfterJetsBtagging7080")
    drh1.setName("Base")
    drh1.normalizeToOne()
    drh2.normalizeToOne()
#    drh1.normalizeMCByLuminosity()
    plot = plots.ComparisonPlot(drh1, drh2)
#    plot = plots.PlotBase(drh1)
#    plot = plots.MCPlot(drh1)
    # Rebin, if necessary
    plot.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
#    drh1.normalizeMCByLuminosity()
#    plot = plots.PlotBase(drh1)
#    plot = plots.MCPlot(drh     
    # Create frame with a ratio pad
    plot.createFrame("distribution", opts={"ymin":1e-5, "ymaxfactor": 1.5})
#                     createRatio=True, opts2={"ymin": -10, "ymax": 50}, # bounds of the ratio plot
#                     )

    plot.draw()
    plot.save()


    mt = plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetSelection")
    mt.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    mt_data = mt.histoMgr.getHisto("Data").getRootHisto().Clone("mt_data")
def main():
    # Read the datasets, see twiki page for more examples
    # https://twiki.cern.ch/twiki/bin/view/CMS/HiggsChToTauNuFullyHadronicSoftware#Construct_datasets
    #
    # This one constructs datasets assuming that the multicrab
    # directory is the working directory
    datasets = dataset.getDatasetsFromMulticrabCfg(analysisName=analysis, dataEra=dataEra)

    # This one constructs from some other multicrab directory, the
    # path can be absolute or relative
    #datasets = dataset.getDatasetsFromMulticrabCfg(directory="/path/to/your/multicrab/directory", analysisName=analysis, dataEra=dataEra)

    # Usually you can also omit the analysisName, as it can be detected automatically
    # datasets = dataset.getDatasetsFromMulticrabCfg(dataEra=dataEra)

    # If you have both light and heavy analysis and/or optimization
    # enabled, you have to specify searchMode and/or optimizationMode
    # explicitly
    # datasets = dataset.getDatasetsFromMulticrabCfg(searchMode="Light", dataEra=dataEra, optimizationMode="Opt...")

    if mcOnly:
        datasets.remove(datasets.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        datasets.loadLuminosities()

    datasets.updateNAllEventsToPUWeighted()    
    plots.mergeRenameReorderForDataMC(datasets)

    if mcOnly:
        print "*** Int.Lumi (manually set)", mcOnlyLumi
    else:
        print "*** Int.Lumi",datasets.getDataset("Data").getLuminosity()
    print "*** norm=",datasets.getDataset("TTToHplusBWB_M120").getNormFactor()

    # Remove signals other than M120
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M%d"%lightHplusMassPoint in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_" in name, datasets.getAllDatasetNames()))

    # Change legend creator defaults
    histograms.createLegend.moveDefaults(dx=-0.05)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=lightHplusTopBR, br_Htaunu=1)
    # Example how to set cross section to a specific MSSM point
    #xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)
    histograms.createSignalText.set(mass=lightHplusMassPoint)

    # Merge TT->WH+ and TT->H+H- signals into one dataset (per mass point)
    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section

    # Merge T->H+ signals into one dataset (per mass point)
    #plots.mergeSingleTopHplus(datasets)

    # Merge TT->WH+, TT->H+H-, and T->H+ signals into one dataset (per mass point)
    #plots.mergeLightHplus(datasets)

    # Replace signal dataset with a signal+background dataset, where
    # the BR(t->H+) is taken into account for SM ttbar
    plots.replaceLightHplusWithSignalPlusBackground(datasets)
    
    # You can print a tree of all the merged datasets with this
    #datasets.printDatasetTree()

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create plots
    doPlots(datasets)

    # Create counters
    doCounters(datasets)

    if interactiveMode:
        raw_input("*** Press \"Enter\" to exit pyROOT: ")
Example #36
0
def main(argv):

#    HISTONAME = "TauIdJets"
#    HISTONAME = "TauIdJetsCollinear"
#    HISTONAME = "TauIdBtag"
#    HISTONAME = "TauIdBvetoCollinear"
#    HISTONAME = "TauIdBveto"
    HISTONAME = "TauIdAfterCollinearCuts"
   
    dirs = []
    if len(sys.argv) < 2:
	usage()

    dirs.append(sys.argv[1])



    
    # Create all datasets from a multicrab task
    # datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters, dataEra=dataEra, analysisBaseName="signalAnalysisInvertedTau")
    #datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra, analysisBaseName="signalAnalysisInvertedTau")
    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,dataEra=dataEra,  searchMode=searchMode, analysisName=analysis, optimizationMode=optimizationMode)
#    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra)

    # Check multicrab consistency
    consistencyCheck.checkConsistencyStandalone(dirs[0],datasets,name="QCD inverted")
   
    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_t-channel" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_tW-channel" in name, datasets.getAllDatasetNames()))
    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    datasets.merge("EWK", [
	    "TTJets",
            "WJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    style.setOptStat(True)

    invertedQCD = InvertedTauID()
    invertedQCD.setLumi(datasets.getDataset("Data").getLuminosity())
    invertedQCD.setInfo([dataEra,searchMode,HISTONAME])

    histonames = datasets.getDataset("Data").getDirectoryContent("baseline/METBaseline"+HISTONAME)
    bins = []
    binLabels = []
    for histoname in histonames:
        bins.append(histoname.replace("METBaseline"+HISTONAME,""))
        title = datasets.getDataset("Data").getDatasetRootHisto("baseline/METBaseline"+HISTONAME+"/"+histoname).getHistogram().GetTitle()
        title = title.replace("METBaseline"+HISTONAME,"")
        title = title.replace("#tau p_{T}","taup_T")
        title = title.replace("#tau eta","taueta")
        title = title.replace("<","lt")
        title = title.replace(">","gt")
        title = title.replace("=","eq")
        title = title.replace("..","to")
        title = title.replace(".","p")
        title = title.replace("/","_")
        binLabels.append(title)

    print
    print "Histogram bins available",bins

#    bins = ["Inclusive"]
#    bins = ["taup_Tleq50","taup_Teq50to60"]
    print "Using bins              ",bins
    print
    print "Bin labels"
    for i in range(len(binLabels)):
        line = bins[i]
        while len(line) < 10:
            line += " "
        line += ": "+binLabels[i]
        print line
    print

    for i,bin in enumerate(bins):

	invertedQCD.setLabel(binLabels[i])

        metBase = plots.DataMCPlot(datasets, "baseline/METBaseline"+HISTONAME+"/METBaseline"+HISTONAME+bin)
        metInver = plots.DataMCPlot(datasets, "Inverted/METInverted"+HISTONAME+"/METInverted"+HISTONAME+bin)
        # Rebin before subtracting
        metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        
        metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone("Inverted/METInverted"+HISTONAME+"/METInverted"+HISTONAME+bin)
        metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone("Inverted/METInverted"+HISTONAME+"/METInverted"+HISTONAME+bin)
        metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone("Baseline/METBaseLine"+HISTONAME+"/METBaseline"+HISTONAME+bin)
        metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone("Baseline/METBaseLine"+HISTONAME+"/METBaseline"+HISTONAME+bin)

        metBase_QCD = metBase_data.Clone("QCD")
        metBase_QCD.Add(metBase_EWK,-1)

        metInverted_QCD = metInverted_data.Clone("QCD")
        metInverted_QCD.Add(metInverted_EWK,-1)

        metInverted_data = addlabels(metInverted_data)
        metInverted_EWK  = addlabels(metInverted_EWK)
        metBase_data     = addlabels(metBase_data)
        metBase_EWK      = addlabels(metBase_EWK)
        metInverted_QCD  = addlabels(metInverted_QCD)

        invertedQCD.plotHisto(metInverted_data,"inverted")
        invertedQCD.plotHisto(metInverted_EWK,"invertedEWK")
        invertedQCD.plotHisto(metBase_data,"baseline")
        invertedQCD.plotHisto(metBase_EWK,"baselineEWK")


        fitOptions = "LRB"
#        fitOptions = "RB"
#        fitOptions = "IEB"

#        ROOT.TVirtualFitter.SetDefaultFitter("Minuit")
#        ROOT.TVirtualFitter.SetDefaultFitter("Minuit2")
#        fitOptions = "Q"   # Chi2 Fit
#        fitOptions = "VEB"  # Chi2 Fit with Minos Error
#        fitOptions = "IEB"  # Chi2 Fit with Integral and Minos
#        fitOptions = "VLEB" # Likelihood Fit with Minos Error

#        ROOT.TVirtualFitter.SetDefaultFitter("Fumili")
#        ROOT.TVirtualFitter.SetDefaultFitter("Fumili2")
#        fitOptions = "Q"   # Chi2 Fit
#        fitOptions = "VE"  # Chi2 Fit with Minos Error
#        fitOptions = "IE"  # Chi2 Fit with Integral and Minos
#        fitOptions = "VLE" # Likelihood Fit with Minos Error
        

        invertedQCD.fitEWK(metInverted_EWK,fitOptions)
        invertedQCD.fitEWK(metBase_EWK,fitOptions)
        invertedQCD.fitQCD(metInverted_QCD,fitOptions)
        invertedQCD.fitData(metBase_data)

        invertedQCD.getNormalization()

    invertedQCD.Summary()
    invertedQCD.WriteNormalizationToFile("QCDInvertedNormalizationFactors.py")
    invertedQCD.WriteLatexOutput("fits.tex")
def main():

    if len(sys.argv) < 2:
        usage()

    dirs = []
    dirs.append(sys.argv[1])

    # Read the datasets
#    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra, analysisBaseName="signalAnalysisInvertedTau")
    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,dataEra=dataEra, searchMode=searchMode, analysisName=analysis) 
#    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters)
#    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters, dataEra=dataEra)
#    datasets.updateNAllEventsToPUWeighted()
    datasets.loadLuminosities()
    datasets.updateNAllEventsToPUWeighted()

    
    # Take QCD from data
    datasetsQCD = None

    if QCDfromData:

        datasetsQCD = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_8_patch2/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_111123_132128/multicrab.cfg", counters=counters)
        datasetsQCD.loadLuminosities()
        print "QCDfromData", QCDfromData
        datasetsQCD.mergeData()
        datasetsQCD.remove(datasetsQCD.getMCDatasetNames())
        datasetsQCD.rename("Data", "QCD")
    


    plots.mergeRenameReorderForDataMC(datasets)

    print "Int.Lumi",datasets.getDataset("Data").getLuminosity()

    # Remove signals other than M120
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    datasets.merge("EWK", ["WJets", "DYJetsToLL", "SingleTop", "Diboson","TTJets"], keepSources=True)
    datasets.remove(filter(lambda name: "W2Jets" in name, datasets.getAllDatasetNames()))        
    datasets.remove(filter(lambda name: "W3Jets" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "W4Jets" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_s-channel" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_t-channel" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_tW-channel" in name, datasets.getAllDatasetNames()))
    datasets_lands = datasets.deepCopy()

    # Set the signal cross sections to the ttbar for datasets for lands
#    xsect.setHplusCrossSectionsToTop(datasets_lands)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.01, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
#    xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)

    plots.mergeWHandHH(datasets) # merging of WH and HH signals must be done after setting the cross section


    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create plots
    doPlots(datasets)

    # Write mt histograms to ROOT file
#    writeTransverseMass(datasets_lands)

    # Print counters
    doCounters(datasets)
Example #38
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Merge EWK datasets
    datasets.merge("EWK", [
            "WJets",
            "TTJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create the normalized plot of transverse mass
    # Read the histogram from the file
    #mT = plots.DataMCPlot(datasets, analysis+"/transverseMass")

    # Create the histogram from the tree (and see the selections explicitly)
    td = dataset.TreeDraw(analysis+"/tree", weight="weightPileup*weightTrigger*weightPrescale",
                             selection="met_p4.Et() > 70 && Max$(jets_btag) > 1.7")
#    mT = plots.DataMCPlot(datasets, td.clone(varexp="sqrt(2 * tau_p4.Pt() * met_p4.Et() * (1-cos(tau_p4.Phi()-met_p4.Phi())))>>dist(400, 0, 400)"))
    
#    met = plots.DataMCPlot(datasets, td.clone(varexp="met_p4.Et()>>dist(400, 0, 400)"))
    met5060 = plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging5060")
    met6070 = plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging6070")
    met7080 = plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging7080")
    met80100 = plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging80100")
    met100120 = plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging100120")
    met120150 = plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging120150")
    met150 = plots.DataMCPlot(datasets, analysis+"/QCD_MET_AfterJetsBtagging150")
    
    # Rebin before subtracting
    met5060.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met6070.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met7080.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met80100.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met100120.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1)) 
    met120150.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met150.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
       
    
    data5060 = met5060.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data6070 = met6070.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data7080 = met7080.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data80100 = met80100.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data100120 = met100120.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data120150 = met120150.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data150 = met150.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    
    # Create the data-EWK histogram and draw it
#    diffBase = dataEwkDiff(metBase, "MET_base_data-ewk")
#    diffInverted = dataEwkDiff(metInver,"MET_inverted_data-ewk")

    # Draw the MET distribution
#    transverseMass(metBase,"MET_base")
#    transverseMass(metInver,"MET_inverted")


    # Set the styles
#    dataset._normalizeToOne(diffBase)
#    dataset._normalizeToOne(diffInverted)
    plot = plots.PlotBase()
    plot.histoMgr.appendHisto(histograms.Histo(data5060, "50 < p_{T}^{#tau jet} < 60 GeV"))
    plot.histoMgr.appendHisto(histograms.Histo(data6070, "60 < p_{T}^{#tau jet} < 70 GeV"))
    plot.histoMgr.appendHisto(histograms.Histo(data7080, "70 < p_{T}^{#tau jet} < 80 GeV"))
    plot.histoMgr.appendHisto(histograms.Histo(data80100, "80 < p_{T}^{#tau jet} < 100 GeV"))
    plot.histoMgr.appendHisto(histograms.Histo(data100120, "100 < p_{T}^{#tau jet} < 120 GeV"))
    plot.histoMgr.appendHisto(histograms.Histo(data120150, "120 < p_{T}^{#tau jet} < 150 GeV"))
    plot.histoMgr.appendHisto(histograms.Histo(data150, "p_{T}^{#tau jet} > 150 GeV")) 
    
    st1 = styles.getDataStyle().clone()
    st2 = st1.clone()
    st2.append(styles.StyleLine(lineColor=ROOT.kRed))
    st3 = st1.clone()
    st3.append(styles.StyleLine(lineColor=ROOT.kBlue))
    st4 = st1.clone()
    st4.append(styles.StyleLine(lineColor=ROOT.kGreen))
    st5 = st1.clone()
    st5.append(styles.StyleLine(lineColor=ROOT.kMagenta, lineStyle=2))
    st6 = st1.clone()
    st6.append(styles.StyleLine(lineColor=ROOT.kPink, lineStyle=8)) # lineWidth=6))
    st7 = st1.clone()
    st7.append(styles.StyleLine(lineColor=ROOT.kBlue-2, lineStyle=3))
    
    plot.histoMgr.forHisto("50 < p_{T}^{#tau jet} < 60 GeV", st1)
    plot.histoMgr.forHisto("60 < p_{T}^{#tau jet} < 70 GeV", st2)
    plot.histoMgr.forHisto("70 < p_{T}^{#tau jet} < 80 GeV", st3)
    plot.histoMgr.forHisto("80 < p_{T}^{#tau jet} < 100 GeV", st4)
    plot.histoMgr.forHisto("100 < p_{T}^{#tau jet} < 120 GeV", st5)
    plot.histoMgr.forHisto("120 < p_{T}^{#tau jet} < 150 GeV", st6)
    plot.histoMgr.forHisto("p_{T}^{#tau jet} > 150 GeV", st7)  

    plot.createFrame("METinBins", opts={"xmax": 200, "ymin":1e-1, "ymaxfactor": 1.5},
#                     createRatio=True, opts2={"ymin": -5 , "ymax": 6 }, # bounds of the ratio plot
                     )

    plot.getPad().SetLogy(True)    
    plot.setLegend(histograms.createLegend(0.6, 0.68, 0.8, 0.93))
    plot.frame.GetXaxis().SetTitle("MET (GeV)")
    plot.frame.GetYaxis().SetTitle("Data")
 
# Draw the plot
    plot.draw()
    plot.save()
def main():
    if len(sys.argv) < 2:
        usage()


#    HISTONAME = "METInvertedTauIdAfterJets"
    HISTONAME = "METInvertedTauIdAfterCollinearCuts"
#    HISTONAME = "MET_InvertedTauIdBveto"
#    HISTONAME = "METInvertedTauIdAfterCollinearCutsPlusBtag"
#    HISTONAME = "METInvertedTauIdAfterCollinearCutsPlusBtag"
#    HISTONAME = "MTInvertedTauIdJet"
#    HISTONAME = "MTInvertedTauIdPhi"

    invertedhisto = HISTONAME
    baselinehisto = HISTONAME.replace("Inverted","BaseLine")

    dirs = []
    if len(sys.argv) < 2:
        usage()

    dirs.append(sys.argv[1])
    
    # Create all datasets from a multicrab task
    #datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,dataEra=dataEra,  searchMode=searchMode, analysisName=analysis)
#    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra, analysisBaseName="signalAnalysisInvertedTau" )

    # As we use weighted counters for MC normalisation, we have to
    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    datasets.merge("EWK", [
	    "TTJets",
            "WJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    invertedQCD = InvertedTauID()
    invertedQCD.setLumi(datasets.getDataset("Data").getLuminosity())



    if ReBinning:
        rebinfactor = 1.3
        histobins = []
        histobins.append(0)
        histobins.append(1)
        i = 1
        while histobins[len(histobins)-1] < 400:
            edge = histobins[i] + (histobins[i]-histobins[i-1])*rebinfactor
            histobins.append(edge)
            i += 1
            print histobins
            
#        metBase_data = metBase_data.Rebin(len(histobins)-1,   metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone(analysis+"/"+invertedhisto) "",array.array("d", histobins))
        metInverted_data = metInverted_data.Rebin(len(histobins)-1,"",array.array("d", histobins))
        metBase_EWK = metBase_EWK.Rebin(len(histobins)-1,"",array.array("d", histobins))
        metInverted_EWK = metInverted_EWK.Rebin(len(histobins)-1,"",array.array("d", histobins))
    
    normData,normEWK=normalisation()

    metInverted = []
    metBaseline = []
    metBaselineQCD = []
    
    for ptbin in ptbins:
        ## inverted
        met_tmp = plots.PlotBase([datasets.getDataset("Data").getDatasetRootHisto("Inverted/METInvertedTauIdAfterCollinearCuts/METInvertedTauIdAfterCollinearCuts"+ptbin)])

        #met_tmp = plots.PlotBase([datasets.getDataset("Data").getDatasetRootHisto("Inverted/"+invertedhisto+ptbin)])
        met_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        met = met_tmp.histoMgr.getHisto("Data").getRootHisto().Clone()        
        met.Scale(normData[ptbin])
    
        metEWK_tmp = plots.PlotBase([datasets.getDataset("EWK").getDatasetRootHisto("Inverted/METInvertedTauIdAfterCollinearCuts/METInvertedTauIdAfterCollinearCuts"+ptbin)])        
        #metEWK_tmp = plots.PlotBase([datasets.getDataset("EWK").getDatasetRootHisto("Inverted/"+invertedhisto+ptbin)])
        metEWK_tmp.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity())
        metEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        metEWK = metEWK_tmp.histoMgr.getHisto("EWK").getRootHisto().Clone()
        metEWK.Scale(normEWK[ptbin])
        met.Add(metEWK, -1)
        metInverted.append(met) 

## baseline
        met_tmp = plots.PlotBase([datasets.getDataset("Data").getDatasetRootHisto("baseline/METBaselineTauIdAfterCollinearCuts/METBaselineTauIdAfterCollinearCuts"+ptbin)])

        #met_tmp = plots.PlotBase([datasets.getDataset("Data").getDatasetRootHisto("Inverted/"+invertedhisto+ptbin)])
        met_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        metbaseline = met_tmp.histoMgr.getHisto("Data").getRootHisto().Clone()        
    
        metEWK_tmp = plots.PlotBase([datasets.getDataset("EWK").getDatasetRootHisto("baseline/METBaselineTauIdAfterCollinearCuts/METBaselineTauIdAfterCollinearCuts"+ptbin)])        
        #metEWK_tmp = plots.PlotBase([datasets.getDataset("EWK").getDatasetRootHisto("Inverted/"+invertedhisto+ptbin)])
        metEWK_tmp.histoMgr.normalizeMCToLuminosity(datasets.getDataset("Data").getLuminosity())
        metEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        metEWKbaseline = metEWK_tmp.histoMgr.getHisto("EWK").getRootHisto().Clone()
        metBaseline.append(metbaseline)
        metbaseline.Add(metEWKbaseline, -1)
        metBaselineQCD.append(metbaseline)

        
    metInverted_data = metInverted[0].Clone("met")
    metInverted_data.SetName("met")
    metInverted_data.SetTitle("Inverted tau ID")
    metInverted_data.Reset()
    for histo in metInverted:
        metInverted_data.Add(histo)
        
    metBaseline_data = metBaseline[0].Clone("met")
    metBaseline_data.SetName("met")
    metBaseline_data.SetTitle("baseline tau ID")
    metBaseline_data.Reset()
    for histo in metBaseline:
        metBaseline_data.Add(histo)

    metBaseline_QCD = metBaselineQCD[0].Clone("met")
    metBaseline_QCD .SetName("met")
    metBaseline_QCD.SetTitle("baseline tau ID")
    metBaseline_QCD.Reset()
    for histo in metBaselineQCD:
        metBaseline_QCD.Add(histo)

        
    #metBase_data.SetTitle("Data: BaseLine TauID")
    #metInverted_data.SetTitle("Data: Inverted TauID")
    #metBase_QCD = metBase_data.Clone("QCD")

    #metBase_QCD.Add(metBase_EWK,-1)
    #metBase_QCD.SetTitle("Data - EWK MC: BaseLine TauID")

    invertedQCD.setLabel("BaseVsInverted")
    invertedQCD.comparison(metInverted_data,metBaseline_data)
    invertedQCD.setLabel("BaseMinusEWKVsInverted")
    invertedQCD.comparison(metInverted_data,metBaseline_QCD)
    invertedQCD.setLabel("McVsInverted")
#    invertedQCD.comparison(metInverted_data,metInverted_MC)
    invertedQCD.setLabel("EfficiencyBaseMinusEWKVsInverted")
    invertedQCD.cutefficiency(metInverted_data,metBaseline_QCD )
Example #40
0
def main():

    errorBars = False
    dirs = []
    if len(sys.argv) < 2:
        usage()

    dirs.append(sys.argv[1])
    

    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,dataEra=dataEra,  searchMode=searchMode, analysisName=analysis) 
#    datasets = dataset.getDatasetsFromMulticrabDirs(dirs, counters=counters, dataEra=dataEra,  analysisBaseName="signalAnalysisInvertedTau")
##    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters, dataEra=dataEra)

    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    datasets.merge("EWK", [
	    "TTJets",
            "WJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    invertedQCD = InvertedTauID()
    invertedQCD.setLumi(datasets.getDataset("Data").getLuminosity())
    invertedQCD.useErrorBars(errorBars)

    metBase = plots.DataMCPlot(datasets, "BaseLine/MET_BaseLineTauIdBvetoCollinear")
    metInver = plots.DataMCPlot(datasets, "Inverted/MET_InvertedTauIdBvetoCollinear")
#    metBase = plots.DataMCPlot(datasets, "BaseLine/MET_BaseLineTauIdJetsCollinear")
#    metInver = plots.DataMCPlot(datasets, "Inverted/MET_InvertedTauIdJetsCollinear")
#    metBase = plots.DataMCPlot(datasets, "BaseLine/MET_BaseLineTauIdBveto")
#    metInver = plots.DataMCPlot(datasets, "Inverted/MET_InvertedTauIdBveto") 

    # Rebin before subtracting
    metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    
#    metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone("Inverted/MET_InvertedTauIdBveto")
#    metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone("Inverted/MET_InvertedTauIdBveto") 
#    metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone("BaseLine/MET_BaselineTauIdBveto")
#    metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone("BaseLine/MET_BaselineTauIdBveto")

    metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone("Inverted/MET_InvertedTauIdBvetoCollinear")
    metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone("Inverted/MET_InvertedTauIdBvetoCollinear") 
    metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone("BaseLine/MET_BaselineTauIdBvetoCollinear")
    metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone("BaseLine/MET_BaselineTauIdBvetoCollinear")
#    metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone("Inverted/MET_InvertedTauIdJetsCollinear")
#    metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone("Inverted/MET_InvertedTauIdJetsCollinear") 
#    metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone("BaseLine/MET_BaselineTauIdJetsCollinear")
#    metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone("BaseLine/MET_BaselineTauIdJetsCollinear")


    metBase_data.SetTitle("Data: BaseLine TauID")
    metInverted_data.SetTitle("Data: Inverted TauID")
    metBase_QCD = metBase_data.Clone("QCD")
    metBase_QCD.Add(metBase_EWK,-1)
    metBase_QCD.SetTitle("Data - EWK MC: BaseLine TauID")

    metInverted_data.GetXaxis().SetTitle("PFMET (GeV)")

    invertedQCD.setLabel("BaseVsInverted")
#    invertedQCD.comparison(metInverted_data,metBase_data)
    invertedQCD.setLabel("BaseMinusEWKVsInverted")
#    invertedQCD.comparison(metInverted_data,metBase_QCD)

    invertedQCD.cutefficiency(metInverted_data,metBase_QCD)
Example #41
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Merge EWK datasets
    datasets.merge("EWK",
                   ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create the normalized plot of transverse mass
    # Read the histogram from the file
    #mT = plots.DataMCPlot(datasets, analysis+"/transverseMass")

    # Create the histogram from the tree (and see the selections explicitly)
    td = dataset.TreeDraw(
        analysis + "/tree",
        weight="weightPileup*weightTrigger*weightPrescale",
        selection="met_p4.Et() > 70 && Max$(jets_btag) > 1.7")
    #    mT = plots.DataMCPlot(datasets, td.clone(varexp="sqrt(2 * tau_p4.Pt() * met_p4.Et() * (1-cos(tau_p4.Phi()-met_p4.Phi())))>>dist(400, 0, 400)"))

    #    met = plots.DataMCPlot(datasets, td.clone(varexp="met_p4.Et()>>dist(400, 0, 400)"))
    met5060 = plots.DataMCPlot(datasets,
                               analysis + "/QCD_MET_AfterJetsBtagging5060")
    met6070 = plots.DataMCPlot(datasets,
                               analysis + "/QCD_MET_AfterJetsBtagging6070")
    met7080 = plots.DataMCPlot(datasets,
                               analysis + "/QCD_MET_AfterJetsBtagging7080")
    met80100 = plots.DataMCPlot(datasets,
                                analysis + "/QCD_MET_AfterJetsBtagging80100")
    met100120 = plots.DataMCPlot(datasets,
                                 analysis + "/QCD_MET_AfterJetsBtagging100120")
    met120150 = plots.DataMCPlot(datasets,
                                 analysis + "/QCD_MET_AfterJetsBtagging120150")
    met150 = plots.DataMCPlot(datasets,
                              analysis + "/QCD_MET_AfterJetsBtagging150")

    # Rebin before subtracting
    met5060.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met6070.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met7080.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met80100.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met100120.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met120150.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))
    met150.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(1))

    data5060 = met5060.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data6070 = met6070.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data7080 = met7080.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data80100 = met80100.histoMgr.getHisto("Data").getRootHisto().Clone("Data")
    data100120 = met100120.histoMgr.getHisto("Data").getRootHisto().Clone(
        "Data")
    data120150 = met120150.histoMgr.getHisto("Data").getRootHisto().Clone(
        "Data")
    data150 = met150.histoMgr.getHisto("Data").getRootHisto().Clone("Data")

    # Create the data-EWK histogram and draw it
    #    diffBase = dataEwkDiff(metBase, "MET_base_data-ewk")
    #    diffInverted = dataEwkDiff(metInver,"MET_inverted_data-ewk")

    # Draw the MET distribution
    #    transverseMass(metBase,"MET_base")
    #    transverseMass(metInver,"MET_inverted")

    # Set the styles
    #    dataset._normalizeToOne(diffBase)
    #    dataset._normalizeToOne(diffInverted)
    plot = plots.PlotBase()
    plot.histoMgr.appendHisto(
        histograms.Histo(data5060, "50 < p_{T}^{#tau jet} < 60 GeV"))
    plot.histoMgr.appendHisto(
        histograms.Histo(data6070, "60 < p_{T}^{#tau jet} < 70 GeV"))
    plot.histoMgr.appendHisto(
        histograms.Histo(data7080, "70 < p_{T}^{#tau jet} < 80 GeV"))
    plot.histoMgr.appendHisto(
        histograms.Histo(data80100, "80 < p_{T}^{#tau jet} < 100 GeV"))
    plot.histoMgr.appendHisto(
        histograms.Histo(data100120, "100 < p_{T}^{#tau jet} < 120 GeV"))
    plot.histoMgr.appendHisto(
        histograms.Histo(data120150, "120 < p_{T}^{#tau jet} < 150 GeV"))
    plot.histoMgr.appendHisto(
        histograms.Histo(data150, "p_{T}^{#tau jet} > 150 GeV"))

    st1 = styles.getDataStyle().clone()
    st2 = st1.clone()
    st2.append(styles.StyleLine(lineColor=ROOT.kRed))
    st3 = st1.clone()
    st3.append(styles.StyleLine(lineColor=ROOT.kBlue))
    st4 = st1.clone()
    st4.append(styles.StyleLine(lineColor=ROOT.kGreen))
    st5 = st1.clone()
    st5.append(styles.StyleLine(lineColor=ROOT.kMagenta, lineStyle=2))
    st6 = st1.clone()
    st6.append(styles.StyleLine(lineColor=ROOT.kPink,
                                lineStyle=8))  # lineWidth=6))
    st7 = st1.clone()
    st7.append(styles.StyleLine(lineColor=ROOT.kBlue - 2, lineStyle=3))

    plot.histoMgr.forHisto("50 < p_{T}^{#tau jet} < 60 GeV", st1)
    plot.histoMgr.forHisto("60 < p_{T}^{#tau jet} < 70 GeV", st2)
    plot.histoMgr.forHisto("70 < p_{T}^{#tau jet} < 80 GeV", st3)
    plot.histoMgr.forHisto("80 < p_{T}^{#tau jet} < 100 GeV", st4)
    plot.histoMgr.forHisto("100 < p_{T}^{#tau jet} < 120 GeV", st5)
    plot.histoMgr.forHisto("120 < p_{T}^{#tau jet} < 150 GeV", st6)
    plot.histoMgr.forHisto("p_{T}^{#tau jet} > 150 GeV", st7)

    plot.createFrame(
        "METinBins",
        opts={
            "xmax": 200,
            "ymin": 1e-1,
            "ymaxfactor": 1.5
        },
        #                     createRatio=True, opts2={"ymin": -5 , "ymax": 6 }, # bounds of the ratio plot
    )

    plot.getPad().SetLogy(True)
    plot.setLegend(histograms.createLegend(0.6, 0.68, 0.8, 0.93))
    plot.frame.GetXaxis().SetTitle("MET (GeV)")
    plot.frame.GetYaxis().SetTitle("Data")

    # Draw the plot
    plot.draw()
    plot.save()
Example #42
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    ttjets2 = datasets.getDataset("TTJets").deepCopy()
    ttjets2.setCrossSection(
        ttjets2.getCrossSection() -
        datasets.getDataset("TTToHplus_M120").getCrossSection())
    print "Set TTJets2 cross section to %f" % ttjets2.getCrossSection()
    ttjets2.setName("TTJets2")
    datasets.append(ttjets2)

    datasets.merge("EWKnott", ["WJets", "DYJetsToLL", "SingleTop", "Diboson"])
    tmp = datasets.getDataset("EWKnott").deepCopy()
    tmp.setName("EWKnott2")
    datasets.append(tmp)

    datasets.merge("EWK", ["EWKnott", "TTJets"])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    invertedQCD = InvertedTauID()

    metBase = plots.DataMCPlot(datasets, analysis + "/MET_BaseLineTauIdJets")
    metInver = plots.DataMCPlot(datasets, analysis + "/MET_InvertedTauIdJets")
    # Rebin before subtracting
    metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20))
    metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20))

    metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone(
        analysis + "/MET_InvertedTauIdJets")
    metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone(
        analysis + "/MET_InvertedTauIdJets")
    metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone(
        analysis + "/MET_BaselineTauIdJets")
    metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone(
        analysis + "/MET_BaselineTauIdJets")

    metBase_QCD = metBase_data.Clone("QCD")
    metBase_QCD.Add(metBase_EWK, -1)

    metBase_EWK.SetTitle("MC EWK")

    invertedQCD.setLabel("InvData")
    invertedQCD.fitQCD(metInverted_data)

    invertedQCD.setLabel("ChiSq")
    invertedQCD.fitEWK(metBase_EWK, "R")
    invertedQCD.fitData(metBase_data)
    normalizationWithChiSq = invertedQCD.getNormalization()

    invertedQCD.setLabel("LogLikelihood")
    invertedQCD.fitEWK(metBase_EWK, "LR")
    invertedQCD.fitData(metBase_data)
    normalizationWithLogLL = invertedQCD.getNormalization()

    print "Difference Signal vs no signal in EWK fit", (
        normalizationWithLogLL -
        normalizationWithChiSq) / normalizationWithChiSq
def main():
    if len(sys.argv) < 2:
        usage()

#    HISTONAME = "METInvertedTauIdAfterJets"
    HISTONAME = "METInvertedTauIdAfterCollinearCuts"
    #    HISTONAME = "MET_InvertedTauIdBveto"
    #    HISTONAME = "METInvertedTauIdAfterCollinearCutsPlusBtag"
    #    HISTONAME = "METInvertedTauIdAfterCollinearCutsPlusBtag"
    #    HISTONAME = "MTInvertedTauIdJet"
    #    HISTONAME = "MTInvertedTauIdPhi"

    invertedhisto = HISTONAME
    baselinehisto = HISTONAME.replace("Inverted", "BaseLine")

    dirs = []
    if len(sys.argv) < 2:
        usage()

    dirs.append(sys.argv[1])

    # Create all datasets from a multicrab task
    #datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,
                                                    dataEra=dataEra,
                                                    searchMode=searchMode,
                                                    analysisName=analysis)
    #    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra, analysisBaseName="signalAnalysisInvertedTau" )

    # As we use weighted counters for MC normalisation, we have to
    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    datasets.merge("EWK",
                   ["TTJets", "WJets", "DYJetsToLL", "SingleTop", "Diboson"])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    invertedQCD = InvertedTauID()
    invertedQCD.setLumi(datasets.getDataset("Data").getLuminosity())

    if ReBinning:
        rebinfactor = 1.3
        histobins = []
        histobins.append(0)
        histobins.append(1)
        i = 1
        while histobins[len(histobins) - 1] < 400:
            edge = histobins[i] + (histobins[i] -
                                   histobins[i - 1]) * rebinfactor
            histobins.append(edge)
            i += 1
            print histobins


#        metBase_data = metBase_data.Rebin(len(histobins)-1,   metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone(analysis+"/"+invertedhisto) "",array.array("d", histobins))
        metInverted_data = metInverted_data.Rebin(
            len(histobins) - 1, "", array.array("d", histobins))
        metBase_EWK = metBase_EWK.Rebin(
            len(histobins) - 1, "", array.array("d", histobins))
        metInverted_EWK = metInverted_EWK.Rebin(
            len(histobins) - 1, "", array.array("d", histobins))

    normData, normEWK = normalisation()

    metInverted = []
    metBaseline = []
    metBaselineQCD = []

    for ptbin in ptbins:
        ## inverted
        met_tmp = plots.PlotBase([
            datasets.getDataset("Data").getDatasetRootHisto(
                "Inverted/METInvertedTauIdAfterCollinearCuts/METInvertedTauIdAfterCollinearCuts"
                + ptbin)
        ])

        #met_tmp = plots.PlotBase([datasets.getDataset("Data").getDatasetRootHisto("Inverted/"+invertedhisto+ptbin)])
        met_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        met = met_tmp.histoMgr.getHisto("Data").getRootHisto().Clone()
        met.Scale(normData[ptbin])

        metEWK_tmp = plots.PlotBase([
            datasets.getDataset("EWK").getDatasetRootHisto(
                "Inverted/METInvertedTauIdAfterCollinearCuts/METInvertedTauIdAfterCollinearCuts"
                + ptbin)
        ])
        #metEWK_tmp = plots.PlotBase([datasets.getDataset("EWK").getDatasetRootHisto("Inverted/"+invertedhisto+ptbin)])
        metEWK_tmp.histoMgr.normalizeMCToLuminosity(
            datasets.getDataset("Data").getLuminosity())
        metEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        metEWK = metEWK_tmp.histoMgr.getHisto("EWK").getRootHisto().Clone()
        metEWK.Scale(normEWK[ptbin])
        met.Add(metEWK, -1)
        metInverted.append(met)

        ## baseline
        met_tmp = plots.PlotBase([
            datasets.getDataset("Data").getDatasetRootHisto(
                "baseline/METBaselineTauIdAfterCollinearCuts/METBaselineTauIdAfterCollinearCuts"
                + ptbin)
        ])

        #met_tmp = plots.PlotBase([datasets.getDataset("Data").getDatasetRootHisto("Inverted/"+invertedhisto+ptbin)])
        met_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        metbaseline = met_tmp.histoMgr.getHisto("Data").getRootHisto().Clone()

        metEWK_tmp = plots.PlotBase([
            datasets.getDataset("EWK").getDatasetRootHisto(
                "baseline/METBaselineTauIdAfterCollinearCuts/METBaselineTauIdAfterCollinearCuts"
                + ptbin)
        ])
        #metEWK_tmp = plots.PlotBase([datasets.getDataset("EWK").getDatasetRootHisto("Inverted/"+invertedhisto+ptbin)])
        metEWK_tmp.histoMgr.normalizeMCToLuminosity(
            datasets.getDataset("Data").getLuminosity())
        metEWK_tmp.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(5))
        metEWKbaseline = metEWK_tmp.histoMgr.getHisto(
            "EWK").getRootHisto().Clone()
        metBaseline.append(metbaseline)
        metbaseline.Add(metEWKbaseline, -1)
        metBaselineQCD.append(metbaseline)

    metInverted_data = metInverted[0].Clone("met")
    metInverted_data.SetName("met")
    metInverted_data.SetTitle("Inverted tau ID")
    metInverted_data.Reset()
    for histo in metInverted:
        metInverted_data.Add(histo)

    metBaseline_data = metBaseline[0].Clone("met")
    metBaseline_data.SetName("met")
    metBaseline_data.SetTitle("baseline tau ID")
    metBaseline_data.Reset()
    for histo in metBaseline:
        metBaseline_data.Add(histo)

    metBaseline_QCD = metBaselineQCD[0].Clone("met")
    metBaseline_QCD.SetName("met")
    metBaseline_QCD.SetTitle("baseline tau ID")
    metBaseline_QCD.Reset()
    for histo in metBaselineQCD:
        metBaseline_QCD.Add(histo)

    #metBase_data.SetTitle("Data: BaseLine TauID")
    #metInverted_data.SetTitle("Data: Inverted TauID")
    #metBase_QCD = metBase_data.Clone("QCD")

    #metBase_QCD.Add(metBase_EWK,-1)
    #metBase_QCD.SetTitle("Data - EWK MC: BaseLine TauID")

    invertedQCD.setLabel("BaseVsInverted")
    invertedQCD.comparison(metInverted_data, metBaseline_data)
    invertedQCD.setLabel("BaseMinusEWKVsInverted")
    invertedQCD.comparison(metInverted_data, metBaseline_QCD)
    invertedQCD.setLabel("McVsInverted")
    #    invertedQCD.comparison(metInverted_data,metInverted_MC)
    invertedQCD.setLabel("EfficiencyBaseMinusEWKVsInverted")
    invertedQCD.cutefficiency(metInverted_data, metBaseline_QCD)
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    ttjets2 = datasets.getDataset("TTJets").deepCopy()
    ttjets2.setCrossSection(ttjets2.getCrossSection()-datasets.getDataset("TTToHplus_M120").getCrossSection())
    print "Set TTJets2 cross section to %f" % ttjets2.getCrossSection()
    ttjets2.setName("TTJets2")
    datasets.append(ttjets2)

    datasets.merge("EWKnott", [
            "WJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])
    tmp = datasets.getDataset("EWKnott").deepCopy()
    tmp.setName("EWKnott2")
    datasets.append(tmp)

    datasets.merge("EWK", [
        "EWKnott",
        "TTJets"
        ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    invertedQCD = InvertedTauID()

    metBase = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets")
    metInver = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets")  
    # Rebin before subtracting
    metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20))
    metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(20))
    
    metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone(analysis+"/MET_InvertedTauIdJets")
    metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone(analysis+"/MET_InvertedTauIdJets") 
    metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone(analysis+"/MET_BaselineTauIdJets")
    metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone(analysis+"/MET_BaselineTauIdJets")

    metBase_QCD = metBase_data.Clone("QCD")
    metBase_QCD.Add(metBase_EWK,-1)

    metBase_EWK.SetTitle("MC EWK")

    invertedQCD.setLabel("InvData")
    invertedQCD.fitQCD(metInverted_data)

    invertedQCD.setLabel("ChiSq")
    invertedQCD.fitEWK(metBase_EWK,"R")
    invertedQCD.fitData(metBase_data)
    normalizationWithChiSq = invertedQCD.getNormalization()

    invertedQCD.setLabel("LogLikelihood")
    invertedQCD.fitEWK(metBase_EWK,"LR")
    invertedQCD.fitData(metBase_data)
    normalizationWithLogLL = invertedQCD.getNormalization()
    
    print "Difference Signal vs no signal in EWK fit",(normalizationWithLogLL - normalizationWithChiSq)/normalizationWithChiSq
def main(argv):

#    HISTONAME = "TauIdJets"
#    HISTONAME = "TauIdJetsCollinear"
#    HISTONAME = "TauIdBtag"
#    HISTONAME = "TauIdBvetoCollinear"
#    HISTONAME = "TauIdBveto"
    HISTONAME = "TauIdAfterCollinearCuts"
    FAKEHISTO = "OnlyEWKFakeTaus"
   
    dirs = []
    if len(sys.argv) < 2:
	usage()

    dirs.append(sys.argv[1])

    
    # Create all datasets from a multicrab task

    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,dataEra=dataEra,  searchMode=searchMode, analysisName="signalAnalysisInvertedTau",optimizationMode="") #no collinear
    #datasets = dataset.getDatasetsFromMulticrabDirs(dirs,dataEra=dataEra,  searchMode=searchMode, analysisName="signalAnalysisInvertedTau",optimizationMode="OptQCDTailKillerLoosePlus") #collinear


    # Check multicrab consistency
    consistencyCheck.checkConsistencyStandalone(dirs[0],datasets,name="QCD inverted")
   
    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_t-channel" in name, datasets.getAllDatasetNames()))
    datasets.remove(filter(lambda name: "Hplus_taunu_tW-channel" in name, datasets.getAllDatasetNames()))
    #datasets.remove(filter(lambda name: "TTJets_SemiLept" in name, datasets.getAllDatasetNames()))
    #datasets.remove(filter(lambda name: "TTJets_FullLept" in name, datasets.getAllDatasetNames()))
    #datasets.remove(filter(lambda name: "TTJets_Hadronic" in name, datasets.getAllDatasetNames()))
    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    datasets.merge("EWK", [
	    "TTJets",
            "WJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    style.setOptStat(True)

    invertedQCD = InvertedTauID()
    invertedQCD.setLumi(datasets.getDataset("Data").getLuminosity())
    invertedQCD.setInfo([dataEra,searchMode,HISTONAME])
    
    histonames = datasets.getDataset("Data").getDirectoryContent("baseline/METBaseline"+HISTONAME)
    bins = []
    binLabels = []
    for histoname in histonames:
        bins.append(histoname.replace("METBaseline"+HISTONAME,""))
        title = datasets.getDataset("Data").getDatasetRootHisto("baseline/METBaseline"+HISTONAME+"/"+histoname).getHistogram().GetTitle()
        title = title.replace("METBaseline"+HISTONAME,"")
        title = title.replace("#tau p_{T}","taup_T")
        title = title.replace("#tau eta","taueta")
        title = title.replace("<","lt")
        title = title.replace(">","gt")
        title = title.replace("=","eq")
        title = title.replace("..","to")
        title = title.replace(".","p")
        title = title.replace("/","_")
        binLabels.append(title)
    #binLabels = bins # for this data set
    print
    print "Histogram bins available",bins
    
    #    bins = ["Inclusive"]
    #    bins = ["taup_Tleq50","taup_Teq50to60"]
    print "Using bins              ",bins
    print
    print "Bin labels"
    for i in range(len(binLabels)):
        line = bins[i]
        while len(line) < 10:
            line += " "
        line += ": "+binLabels[i]
        print line
    print

    for i,bin in enumerate(bins):
        invertedQCD.setLabel(binLabels[i])

        metBase = plots.DataMCPlot(datasets, "baseline/METBaseline"+HISTONAME+"/METBaseline"+HISTONAME+bin)
        metInver = plots.DataMCPlot(datasets, "Inverted/METInverted"+HISTONAME+"/METInverted"+HISTONAME+bin)

        metBase_FakeTaus = plots.DataMCPlot(datasets, "baseline/METBaseline"+HISTONAME+FAKEHISTO+"/METBaseline"+HISTONAME+FAKEHISTO+bin)
        metInver_FakeTaus = plots.DataMCPlot(datasets, "Inverted/METInverted"+HISTONAME+FAKEHISTO+"/METInverted"+HISTONAME+FAKEHISTO+bin)


        # Rebin before subtracting
        
        metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) #5
        metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) #5
        
        metBase_FakeTaus.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) #5
        metInver_FakeTaus.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10)) #5
        
        metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone("Inverted/METInverted"+HISTONAME+"/METInverted"+HISTONAME+bin)
        metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone("baseline/METBaseLine"+HISTONAME+"/METBaseline"+HISTONAME+bin)

        metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone("Inverted/METInverted"+HISTONAME+"/METInverted"+HISTONAME+bin)
        metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone("baseline/METBaseLine"+HISTONAME+"/METBaseline"+HISTONAME+bin)

        metInverted_EWK_FakeTaus = metInver_FakeTaus.histoMgr.getHisto("EWK").getRootHisto().Clone("Inverted/METInverted"+HISTONAME+FAKEHISTO+"/METInverted"+HISTONAME+FAKEHISTO+bin)
        metBase_EWK_FakeTaus = metBase_FakeTaus.histoMgr.getHisto("EWK").getRootHisto().Clone("baseline/METBaseLine"+HISTONAME+FAKEHISTO+"/METBaseline"+HISTONAME+FAKEHISTO+bin)

        metBase_QCD = metBase_data.Clone("QCD")
        metBase_QCD.Add(metBase_EWK,-1)
        metInverted_QCD = metInverted_data.Clone("QCD")
        metInverted_QCD.Add(metInverted_EWK,-1)

        metInverted_data = addlabels(metInverted_data)
        metInverted_EWK  = addlabels(metInverted_EWK)
        metInverted_EWK_FakeTaus  = addlabels(metInverted_EWK_FakeTaus)
        
        metBase_data = addlabels(metBase_data)
        metBase_EWK  = addlabels(metBase_EWK)
        metBase_EWK_FakeTaus = addlabels(metBase_EWK_FakeTaus)

        metInverted_QCD  = addlabels(metInverted_QCD)

        invertedQCD.plotHisto(metInverted_data,"inverted")
        invertedQCD.plotHisto(metInverted_EWK,"invertedEWK")
        invertedQCD.plotHisto(metBase_data,"baseline")
        invertedQCD.plotHisto(metBase_EWK,"baselineEWK")
        invertedQCD.plotHisto(metInverted_EWK_FakeTaus,"invertedEWK_FakeTaus")
        invertedQCD.plotHisto(metBase_EWK_FakeTaus,"baselineEWK_FakeTaus")

        fitOptions = "LRB"
        #fitOptions = "RB"                                                                              
        #fitOptions = "IEB"

        invertedQCD.fitEWK(metInverted_EWK,fitOptions)
        invertedQCD.fitEWK(metBase_EWK,fitOptions)
        invertedQCD.fitQCD(metInverted_QCD,fitOptions)
        invertedQCD.fitData(metBase_data)

        invertedQCD.fitEWK_FakeTaus(metInverted_EWK_FakeTaus,fitOptions)
        invertedQCD.fitEWK_FakeTaus(metBase_EWK_FakeTaus,fitOptions)

        invertedQCD.getNormalization()
        
    invertedQCD.Summary()
    invertedQCD.WriteNormalizationToFile("QCDInvertedNormalizationFactors.py")
    invertedQCD.WriteLatexOutput("fits.tex")
def main(opts,signalDsetCreator,era,searchMode,optimizationMode):
    # Make directory for output
    mySuffix = "normalisationPlots_%s_%s_%s"%(era,searchMode,optimizationMode)
    if os.path.exists(mySuffix):
        if os.path.exists("%s_old"%mySuffix):
            shutil.rmtree("%s_old"%mySuffix)
        os.rename(mySuffix, "%s_old"%mySuffix)
    os.mkdir(mySuffix)
    # Create dataset manager
    myDsetMgr = signalDsetCreator.createDatasetManager(dataEra=era,searchMode=searchMode,optimizationMode=optimizationMode)
    if mcOnly:
        myDsetMgr.remove(myDsetMgr.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        myDsetMgr.loadLuminosities()
    myDsetMgr.updateNAllEventsToPUWeighted()

    # Take QCD from data
    if opts.noMCQCD:
        myDsetMgr.remove(filter(lambda name: "QCD" in name, myDsetMgr.getAllDatasetNames()))
    # Remove signal
    if opts.noSignal:
        myDsetMgr.remove(filter(lambda name: "TTToHplus" in name, myDsetMgr.getAllDatasetNames()))
        myDsetMgr.remove(filter(lambda name: "Hplus_taunu" in name, myDsetMgr.getAllDatasetNames()))
        myDsetMgr.remove(filter(lambda name: "HplusTB" in name, myDsetMgr.getAllDatasetNames()))

    plots.mergeRenameReorderForDataMC(myDsetMgr)

    if mcOnly:
        print "Int.Lumi (manually set)",mcOnlyLumi
    else:
        print "Int.Lumi",myDsetMgr.getDataset("Data").getLuminosity()
    if not opts.noSignal:
        print "norm=",myDsetMgr.getDataset("TTToHplusBWB_M120").getNormFactor()

    myDsetMgr.remove(filter(lambda name: "QCD_Pt20_MuEnriched" in name, myDsetMgr.getAllDatasetNames()))
    # Remove signals other than M120
    myDsetMgr.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, myDsetMgr.getAllDatasetNames()))
    myDsetMgr.remove(filter(lambda name: "Hplus_taunu" in name, myDsetMgr.getAllDatasetNames()))
    myDsetMgr.remove(filter(lambda name: "HplusTB" in name, myDsetMgr.getAllDatasetNames()))
    
    histograms.createLegend.moveDefaults(dx=-0.05)
    histograms.createSignalText.set(xmin=0.4, ymax=0.93, mass=120)
    
    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(myDsetMgr, br_tH=optionBr, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
#    xsect.setHplusCrossSectionsToMSSM(myDsetMgr, tanbeta=20, mu=200)

    plots.mergeWHandHH(myDsetMgr) # merging of WH and HH signals must be done after setting the cross section
    
    # Replace signal dataset with a signal+background dataset, where
    # the BR(t->H+) is taken into account for SM ttbar
    #plots.replaceLightHplusWithSignalPlusBackground(myDsetMgr)
        
    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create plots
    doPlots(myDsetMgr, opts, mySuffix)

    # Print counters
    #doCounters(myDsetMgr)
    print "Results saved in directory: %s"%mySuffix
Example #47
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Merge EWK datasets
    datasets.merge("EWK", [
            "WJets",
            "TTJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create the normalized plot of transverse mass
    # Read the histogram from the file
    #mT = plots.DataMCPlot(datasets, analysis+"/transverseMass")

    # Create the histogram from the tree (and see the selections explicitly)
    td = dataset.TreeDraw(analysis+"/tree", weight="weightPileup*weightTrigger*weightPrescale",
                             selection="met_p4.Et() > 70 && Max$(jets_btag) > 1.7")
#    mT = plots.DataMCPlot(datasets, td.clone(varexp="sqrt(2 * tau_p4.Pt() * met_p4.Et() * (1-cos(tau_p4.Phi()-met_p4.Phi())))>>dist(400, 0, 400)"))    
#    met = plots.DataMCPlot(datasets, td.clone(varexp="met_p4.Et()>>dist(400, 0, 400)"))
    metBase = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets")
    metInver = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets")

    metBase4050 = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJet4070")
    metInver4050 = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets4070")
    metBase5060 = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets5060")
    metInver5060 = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets5060")
    metBase6070 = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets6070")
    metInver6070 = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets6070")
    metBase7080 = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets7080")
    metInver7080 = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets7080")
    metBase80100 = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets80100")
    metInver80100 = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets80100")
    metBase100120 = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets100120")
    metInver100120 = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets100120")
    metBase120150 = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets120150")
    metInver120150 = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets120150")
    metBase150 = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets150")
    metInver150 = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets150")
    
#    metInver = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdLoose")
      
    # Rebin before subtracting
    metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    metBase4050.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    metInver4050.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))

    
    metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone(analysis+"/MET_InvertedTauIdJets")
    metInverted_data4050 = metInver.histoMgr.getHisto("Data").getRootHisto().Clone(analysis+"/MET_InvertedTauIdJets4050")
    print "print inverted met"
    print metInverted_data.GetEntries()

    # Create the data-EWK histogram and draw it
    diffBase = dataEwkDiff(metBase, "MET_base_data-ewk")
#    diffInverted = dataEwkDiff(metInver,"MET_inverted_data-ewk")
    diffInverted = dataEwkNoDiff(metInver,"MET_inverted_data-ewk")
    
    diffBase4050 = dataEwkDiff(metBase, "MET_base_data-ewk-4050")
#    diffInverted4070 = dataEwkDiff(metInver,"MET_inverted_data-ewk-4070")
    diffInverted4050 = dataEwkNoDiff(metInver,"MET_inverted_data-ewk-4050")

    # Draw the MET distribution
    transverseMass(metBase,"MET_base")
    transverseMass(metInver,"MET_inverted")
    # Draw the MET distribution
    transverseMass(metBase4050,"MET_base4050")
    transverseMass(metInver4050,"MET_inverted4050")
  
    # Set the styles
    dataset._normalizeToOne(diffBase)
    dataset._normalizeToOne(diffInverted)
    plot = plots.ComparisonPlot(
        histograms.Histo(diffBase, "Baseline"),
        histograms.Histo(diffInverted, "Inverted"))

    dataset._normalizeToOne(diffBase4050)
    dataset._normalizeToOne(diffInverted4050)
    plot2 = plots.ComparisonPlot(
        histograms.Histo(diffBase4050, "Baseline4050"),
        histograms.Histo(diffInverted4050, "Inverted4050"))

    
    st1 = styles.getDataStyle().clone()
    st2 = st1.clone()
    st2.append(styles.StyleLine(lineColor=ROOT.kRed))
    plot.histoMgr.forHisto("Baseline", st1)
    plot.histoMgr.forHisto("Inverted", st2)
    

    plot.createFrame("METbaseVSinverted-ewk", opts={"xmax": 400, "ymin":1e-5, "ymaxfactor": 1.5},
                     createRatio=True, opts2={"ymin": -5 , "ymax": 6 }, # bounds of the ratio plot
                     )

    plot.getPad().SetLogy(True)    
    plot.setLegend(histograms.createLegend(0.7, 0.68, 0.9, 0.93))
    plot.frame.GetXaxis().SetTitle("MET (GeV)")
    plot.frame.GetYaxis().SetTitle("Data - EWK")
 
# Draw the plot
    plot.draw()
    plot.save()

    plot2.createFrame("METbaseVSinverted-ewk-4070", opts={"xmax": 400, "ymin":1e-5, "ymaxfactor": 1.5},
                     createRatio=True, opts2={"ymin": -5 , "ymax": 6 }, # bounds of the ratio plot
                     )

    plot2.getPad().SetLogy(True)    
    plot2.setLegend(histograms.createLegend(0.7, 0.68, 0.9, 0.93))
    plot2.frame.GetXaxis().SetTitle("MET (GeV)")
    plot2.frame.GetYaxis().SetTitle("Data - EWK")
 
# Draw the plot
    plot2.draw()
    plot2.save()
Example #48
0
def main():
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets.updateNAllEventsToPUWeighted()

    # remove data datasets
    datasets.remove(
        filter(lambda name: "Tau_" in name, datasets.getAllDatasetNames()))
    # remove heavy H+ datasets
    datasets.remove(
        filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    plots.mergeRenameReorderForDataMC(datasets)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)
    plots.mergeWHandHH(
        datasets
    )  # merging of WH and HH signals must be done after setting the cross section

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Define variables and cuts
    tauPt = "tau_p4.Pt()"
    tauPtCut = tauPt + " > 40"
    tauLeadingCandPt = "tau_leadPFChargedHadrCand_p4.Pt()"
    tauLeadingCandPtCut = tauLeadingCandPt + " > 20"

    met = "met_p4.Et()"
    metCut = met + " > 70"

    btagMax = "Max$(jets_btag)"
    btagCut = btagMax + " > 1.7"
    btagJetNum17 = "Sum$(jets_btag > 1.7"
    btag2ndMax = "MaxIf(kets_btag, jets_btag < Max$(jets_btag))"

    rtau = "tau_leadPFChargedHadrCand_p4.P()/tau_p4.P()"
    rtauCut = rtau + " > 0.65"
    mt = "sqrt(2 * tau_p4.Pt() * met_p4.Et() * (1-cos(tau_p4.Phi()-met_p4.Phi())))"
    mtCut = mt + " > 80"
    deltaPhi = "acos((tau_p4.Px()*met_p4.Px()+tau_p4.Py()*met_p4.Py())/tau_p4.Pt()/met_p4.Et())*57.2958"
    deltaPhiCut = deltaPhi + " < 160"

    npv = "goodPrimaryVertices_n"

    td = dataset.TreeDraw(analysis + "/tree",
                          weight="weightPileup*weightTrigger*weightPrescale")
    lumi = 1145

    def createResult(varexp, selection, weight=None, **kwargs):
        args = {"varexp": varexp, "selection": selection}
        if weight != None:
            args["weight"] = weight
        return Result(datasets,
                      td.clone(**args),
                      normalizeToLumi=lumi,
                      **kwargs)

    # metRes = createResult(met+">>dist(100,0,200)", btagCut, greaterThan=True)
    # metRes.save("met", "MET (GeV)", rebin=10, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    # btagRes = createResult(btagMax+">>dist(80, 0, 8)", metCut, greaterThan=True)
    # btagRes.save("btag", "TCHE", rebin=5, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    # rtauRes = createResult(rtau+">>dist(110,0,1.1)", metCut+"&&"+btagCut, greaterThan=True)
    # rtauRes.save("rtau", "R_{#tau}", rebin=10, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    # mtRes = createResult(mt+">>dist(50,0,200)", metCut+"&&"+btagCut, greaterThan=True)
    # mtRes.save("mt", "M_{T}(#tau, MET) (GeV)", rebin=2, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    # deltaPhiRes = createResult(deltaPhi+">>dist(90,0,180)", metCut+"&&"+btagCut, lessThan=True)
    # deltaPhiRes.save("deltaPhi", "#Delta#Phi(#tau, MET) (#circ)", rebin=5, logy=True, opts={"ymin": 0.01, "ymaxfactor": 10})

    pileupRes = createResult(npv + ">>dist(4,1,17)",
                             metCut + "&&" + btagCut,
                             weight="",
                             doPassed=False,
                             lessThan=True)
    pileupRes.save("goodPV", "N(good primary vertices)")
Example #49
0
def main():

    errorBars = False

    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(filter(lambda name: "TTToHplus" in name and not "M120" in name, datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.05, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    datasets.merge("EWK", [
	    "TTJets",
            "WJets",
            "DYJetsToLL",
            "SingleTop",
            "Diboson"
            ])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    invertedQCD = InvertedTauID()
    invertedQCD.setLumi(datasets.getDataset("Data").getLuminosity())
    invertedQCD.useErrorBars(errorBars)

    metBase = plots.DataMCPlot(datasets, analysis+"/MET_BaseLineTauIdJets")
    metInver = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdJets")  

    # Rebin before subtracting
    metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    
    metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone(analysis+"/MET_InvertedTauIdJets")
    metInverted_EWK = metInver.histoMgr.getHisto("EWK").getRootHisto().Clone(analysis+"/MET_InvertedTauIdJets") 
    metBase_data = metBase.histoMgr.getHisto("Data").getRootHisto().Clone(analysis+"/MET_BaselineTauIdJets")
    metBase_EWK = metBase.histoMgr.getHisto("EWK").getRootHisto().Clone(analysis+"/MET_BaselineTauIdJets")

    metBase_data.SetTitle("Data: BaseLine TauID")
    metInverted_data.SetTitle("Data: Inverted TauID")
    metBase_QCD = metBase_data.Clone("QCD")
    metBase_QCD.Add(metBase_EWK,-1)
    metBase_QCD.SetTitle("Data - EWK MC: BaseLine TauID")

    metInverted_data.GetXaxis().SetTitle("PFMET (GeV)")

    invertedQCD.setLabel("BaseVsInverted")
#    invertedQCD.comparison(metInverted_data,metBase_data)
    invertedQCD.setLabel("BaseMinusEWKVsInverted")
#    invertedQCD.comparison(metInverted_data,metBase_QCD)

    invertedQCD.cutefficiency(metInverted_data,metBase_QCD)
    # Do the usual normalisation
    dsetMgr.updateNAllEventsToPUWeighted()
    dsetMgr.loadLuminosities()
    plots.mergeRenameReorderForDataMC(dsetMgr)
    dsetMgr.merge("EWK", [
                  "TTJets",
                  "WJets",
                  "DYJetsToLL",
                  "SingleTop",
                  "Diboson"
                  ],keepSources=True) # Keep sources needed to keep open TTJets
    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(dsetMgr, br_tH=optionBrTopToHplusb, br_Htaunu=1)
    # Set the signal cross sections to a value from MSSM
    # xsect.setHplusCrossSectionsToMSSM(dsetMgr, tanbeta=20, mu=200)
    plots.mergeWHandHH(dsetMgr) # merging of WH and HH signals must be done after setting the cross section

    # Make a directory for output
    myDir = "invertedControlPlots_%s"%myModuleInfoString
    # Remove the directory with its contents if it exists
    if os.path.exists(myDir):
        shutil.rmtree(myDir)
    os.mkdir(myDir)
    # Obtain luminosity
    myLuminosity = dsetMgr.getDataset("Data").getLuminosity()
    # Print info so that user can check that merge went correct
    if myDisplayStatus:
        dsetMgr.printDatasetTree()
        print "Luminosity = %f 1/fb"%(myLuminosity / 1000.0)
        print
        myDisplayStatus = False
Example #51
0
def main(argv):
    interactive = True
    interactive = False
    #    HISTONAME = "TauIdJets"
    #    HISTONAME = "TauIdBtag"
    HISTONAME = "TauIdBveto"

    dirs = []
    if len(sys.argv) < 2:
        usage()

    dirs.append(sys.argv[1])

    # Disable batch mode here to have the interactivity (see also the line with 'raw_input') below
    if interactive:
        ROOT.gROOT.SetBatch(False)

    # Create all datasets from a multicrab task


#    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
#    datasets = dataset.getDatasetsFromMulticrabDirs(dirs,counters=counters, dataEra=dataEra)
    datasets = dataset.getDatasetsFromMulticrabDirs(
        dirs,
        counters=counters,
        dataEra=dataEra,
        analysisbaseName="signalAnalysisInvertedTau")

    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    #dataMCExample(datasets)
    distComparison(datasets)

    # Script execution can be paused like this, it will continue after
    # user has given some input (which must include enter)
    if interactive:
        raw_input("Hit enter to continue")
def main():
    # Read the datasets
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)
    datasets.loadLuminosities()

    # Take QCD from data
    datasetsQCD = None
    if QCDfromData:
        datasetsQCD = dataset.getDatasetsFromMulticrabCfg(
            cfgfile=
            "/home/rkinnune/signalAnalysis/CMSSW_4_2_8_patch2/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_111123_132128/multicrab.cfg",
            counters=counters)
        datasetsQCD.loadLuminosities()
        datasetsQCD.mergeData()
        datasetsQCD.remove(datasetsQCD.getMCDatasetNames())
        datasetsQCD.rename("Data", "QCD")

#Rtau =0
#    datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_5/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_110804_104313/multicrab.cfg", counters=counters)

#    datasetsSignal.selectAndReorder(["HplusTB_M200_Summer11"])
#    datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_2_4_patch1/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/multicrab_110622_112321/multicrab.cfg", counters=counters)
#datasetsSignal = dataset.getDatasetsFromMulticrabCfg(cfgfile="/home/rkinnune/signalAnalysis/CMSSW_4_1_5/src/HiggsAnalysis/HeavyChHiggsToTauNu/test/Signal_v11f_scaledb_424/multicrab.cfg", counters=counters)

#datasetsSignal.selectAndReorder(["TTToHplusBWB_M120_Summer11", "TTToHplusBHminusB_M120_Summer11"])
#datasetsSignal.renameMany({"TTToHplusBWB_M120_Summer11" :"TTToHplusBWB_M120_Spring11",
#                           "TTToHplusBHminusB_M120_Summer11": "TTToHplusBHminusB_M120_Spring11"})
#datasets.extend(datasetsSignal)

    plots.mergeRenameReorderForDataMC(datasets)

    print "Int.Lumi", datasets.getDataset("Data").getLuminosity()

    # Remove signals other than M120
    #datasets.remove(filter(lambda name: "TTToHplus" in name, datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    # Remove QCD
    datasets.remove(
        filter(lambda name: "QCD" in name, datasets.getAllDatasetNames()))
    histograms.createLegend.moveDefaults(dx=-0.02)
    histograms.createLegend.moveDefaults(dh=-0.03)

    datasets_lands = datasets.deepCopy()

    # Set the signal cross sections to the ttbar for datasets for lands
    xsect.setHplusCrossSectionsToTop(datasets_lands)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Set the signal cross sections to a value from MSSM
    #    xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)

    plots.mergeWHandHH(
        datasets
    )  # merging of WH and HH signals must be done after setting the cross section

    # Replace signal dataset with EWK+signal
    if True:
        ttjets2 = datasets.getDataset("TTJets").deepCopy()
        ttjets2.setName("TTJets2")
        ttjets2.setCrossSection(
            ttjets2.getCrossSection() -
            datasets.getDataset("TTToHplus_M120").getCrossSection())
        datasets.append(ttjets2)
        datasets.merge("EWKnoTT",
                       ["WJets", "DYJetsToLL", "SingleTop", "Diboson"],
                       keepSources=True)
        datasets.merge("TTToHplus_M120",
                       ["TTToHplus_M120", "EWKnoTT", "TTJets2"])
        plots._legendLabels[
            "TTToHplus_M120"] = "with H^{#pm}#rightarrow#tau^{#pm}#nu"

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create plots
    doPlots(datasets)

    # Write mt histograms to ROOT file
    #writeTransverseMass(datasets_lands)

    # Print counters
    doCounters(datasets)
Example #53
0
def main():
    # Create all datasets from a multicrab task
    datasets = dataset.getDatasetsFromMulticrabCfg(counters=counters)

    # As we use weighted counters for MC normalisation, we have to
    # update the all event count to a separately defined value because
    # the analysis job uses skimmed pattuple as an input
    datasets.updateNAllEventsToPUWeighted()

    # Read integrated luminosities of data datasets from lumi.json
    datasets.loadLuminosities()

    # Include only 120 mass bin of HW and HH datasets
    datasets.remove(
        filter(lambda name: "TTToHplus" in name and not "M120" in name,
               datasets.getAllDatasetNames()))

    # Default merging nad ordering of data and MC datasets
    # All data datasets to "Data"
    # All QCD datasets to "QCD"
    # All single top datasets to "SingleTop"
    # WW, WZ, ZZ to "Diboson"
    plots.mergeRenameReorderForDataMC(datasets)

    # Set BR(t->H) to 0.2, keep BR(H->tau) in 1
    xsect.setHplusCrossSectionsToBR(datasets, br_tH=0.05, br_Htaunu=1)

    # Merge WH and HH datasets to one (for each mass bin)
    # TTToHplusBWB_MXXX and TTToHplusBHminusB_MXXX to "TTToHplus_MXXX"
    plots.mergeWHandHH(datasets)

    # Merge EWK datasets
    datasets.merge("EWK",
                   ["WJets", "TTJets", "DYJetsToLL", "SingleTop", "Diboson"])

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Create the normalized plot of transverse mass
    # Read the histogram from the file
    #mT = plots.DataMCPlot(datasets, analysis+"/transverseMass")

    # Create the histogram from the tree (and see the selections explicitly)
    td = dataset.TreeDraw(
        analysis + "/tree",
        weight="weightPileup*weightTrigger*weightPrescale",
        selection="met_p4.Et() > 70 && Max$(jets_btag) > 1.7")
    #    mT = plots.DataMCPlot(datasets, td.clone(varexp="sqrt(2 * tau_p4.Pt() * met_p4.Et() * (1-cos(tau_p4.Phi()-met_p4.Phi())))>>dist(400, 0, 400)"))
    #    met = plots.DataMCPlot(datasets, td.clone(varexp="met_p4.Et()>>dist(400, 0, 400)"))
    metBase = plots.DataMCPlot(datasets, analysis + "/MET_BaseLineTauIdJets")
    metInver = plots.DataMCPlot(datasets, analysis + "/MET_InvertedTauIdJets")

    metBase4050 = plots.DataMCPlot(datasets,
                                   analysis + "/MET_BaseLineTauIdJet4070")
    metInver4050 = plots.DataMCPlot(datasets,
                                    analysis + "/MET_InvertedTauIdJets4070")
    metBase5060 = plots.DataMCPlot(datasets,
                                   analysis + "/MET_BaseLineTauIdJets5060")
    metInver5060 = plots.DataMCPlot(datasets,
                                    analysis + "/MET_InvertedTauIdJets5060")
    metBase6070 = plots.DataMCPlot(datasets,
                                   analysis + "/MET_BaseLineTauIdJets6070")
    metInver6070 = plots.DataMCPlot(datasets,
                                    analysis + "/MET_InvertedTauIdJets6070")
    metBase7080 = plots.DataMCPlot(datasets,
                                   analysis + "/MET_BaseLineTauIdJets7080")
    metInver7080 = plots.DataMCPlot(datasets,
                                    analysis + "/MET_InvertedTauIdJets7080")
    metBase80100 = plots.DataMCPlot(datasets,
                                    analysis + "/MET_BaseLineTauIdJets80100")
    metInver80100 = plots.DataMCPlot(datasets,
                                     analysis + "/MET_InvertedTauIdJets80100")
    metBase100120 = plots.DataMCPlot(datasets,
                                     analysis + "/MET_BaseLineTauIdJets100120")
    metInver100120 = plots.DataMCPlot(
        datasets, analysis + "/MET_InvertedTauIdJets100120")
    metBase120150 = plots.DataMCPlot(datasets,
                                     analysis + "/MET_BaseLineTauIdJets120150")
    metInver120150 = plots.DataMCPlot(
        datasets, analysis + "/MET_InvertedTauIdJets120150")
    metBase150 = plots.DataMCPlot(datasets,
                                  analysis + "/MET_BaseLineTauIdJets150")
    metInver150 = plots.DataMCPlot(datasets,
                                   analysis + "/MET_InvertedTauIdJets150")

    #    metInver = plots.DataMCPlot(datasets, analysis+"/MET_InvertedTauIdLoose")

    # Rebin before subtracting
    metBase.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    metInver.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    metBase4050.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))
    metInver4050.histoMgr.forEachHisto(lambda h: h.getRootHisto().Rebin(10))

    metInverted_data = metInver.histoMgr.getHisto("Data").getRootHisto().Clone(
        analysis + "/MET_InvertedTauIdJets")
    metInverted_data4050 = metInver.histoMgr.getHisto(
        "Data").getRootHisto().Clone(analysis + "/MET_InvertedTauIdJets4050")
    print "print inverted met"
    print metInverted_data.GetEntries()

    # Create the data-EWK histogram and draw it
    diffBase = dataEwkDiff(metBase, "MET_base_data-ewk")
    #    diffInverted = dataEwkDiff(metInver,"MET_inverted_data-ewk")
    diffInverted = dataEwkNoDiff(metInver, "MET_inverted_data-ewk")

    diffBase4050 = dataEwkDiff(metBase, "MET_base_data-ewk-4050")
    #    diffInverted4070 = dataEwkDiff(metInver,"MET_inverted_data-ewk-4070")
    diffInverted4050 = dataEwkNoDiff(metInver, "MET_inverted_data-ewk-4050")

    # Draw the MET distribution
    transverseMass(metBase, "MET_base")
    transverseMass(metInver, "MET_inverted")
    # Draw the MET distribution
    transverseMass(metBase4050, "MET_base4050")
    transverseMass(metInver4050, "MET_inverted4050")

    # Set the styles
    dataset._normalizeToOne(diffBase)
    dataset._normalizeToOne(diffInverted)
    plot = plots.ComparisonPlot(histograms.Histo(diffBase, "Baseline"),
                                histograms.Histo(diffInverted, "Inverted"))

    dataset._normalizeToOne(diffBase4050)
    dataset._normalizeToOne(diffInverted4050)
    plot2 = plots.ComparisonPlot(
        histograms.Histo(diffBase4050, "Baseline4050"),
        histograms.Histo(diffInverted4050, "Inverted4050"))

    st1 = styles.getDataStyle().clone()
    st2 = st1.clone()
    st2.append(styles.StyleLine(lineColor=ROOT.kRed))
    plot.histoMgr.forHisto("Baseline", st1)
    plot.histoMgr.forHisto("Inverted", st2)

    plot.createFrame(
        "METbaseVSinverted-ewk",
        opts={
            "xmax": 400,
            "ymin": 1e-5,
            "ymaxfactor": 1.5
        },
        createRatio=True,
        opts2={
            "ymin": -5,
            "ymax": 6
        },  # bounds of the ratio plot
    )

    plot.getPad().SetLogy(True)
    plot.setLegend(histograms.createLegend(0.7, 0.68, 0.9, 0.93))
    plot.frame.GetXaxis().SetTitle("MET (GeV)")
    plot.frame.GetYaxis().SetTitle("Data - EWK")

    # Draw the plot
    plot.draw()
    plot.save()

    plot2.createFrame(
        "METbaseVSinverted-ewk-4070",
        opts={
            "xmax": 400,
            "ymin": 1e-5,
            "ymaxfactor": 1.5
        },
        createRatio=True,
        opts2={
            "ymin": -5,
            "ymax": 6
        },  # bounds of the ratio plot
    )

    plot2.getPad().SetLogy(True)
    plot2.setLegend(histograms.createLegend(0.7, 0.68, 0.9, 0.93))
    plot2.frame.GetXaxis().SetTitle("MET (GeV)")
    plot2.frame.GetYaxis().SetTitle("Data - EWK")

    # Draw the plot
    plot2.draw()
    plot2.save()
Example #54
0
def main():
    # Read the datasets, see twiki page for more examples
    # https://twiki.cern.ch/twiki/bin/view/CMS/HiggsChToTauNuFullyHadronicSoftware#Construct_datasets
    # Usually you can also omit the analysisName, as it can be detected automatically
    # If you have optimization enabled, you have to specify optimizationMode explicitly (optimizationMode="Opt...")
    datasets = dataset.getDatasetsFromMulticrabCfg(directory=multicrabDir,
                                                   analysisName=analysis,
                                                   dataEra=dataEra)

    if mcOnly:
        datasets.remove(datasets.getDataDatasetNames())
        histograms.cmsTextMode = histograms.CMSMode.SIMULATION
    else:
        datasets.loadLuminosities()

    datasets.updateNAllEventsToPUWeighted()
    plots.mergeRenameReorderForDataMC(datasets)

    if mcOnly:
        myIntegratedLuminosity = mcOnlyLumi
    else:
        myIntegratedLuminosity = datasets.getDataset("Data").getLuminosity()
    print "*** Integrated luminosity", myIntegratedLuminosity, "/pb"
    # print "*** Norm =",datasets.getDataset("TTToHplusBWB_M120").getNormFactor()

    # Remove signals other than M120
    datasets.remove(
        filter(
            lambda name: "TTToHplus" in name and not "M%d" %
            lightHplusMassPoint in name, datasets.getAllDatasetNames()))
    datasets.remove(
        filter(lambda name: "HplusTB" in name, datasets.getAllDatasetNames()))

    # Remove QCD datasets (because the simulated QCD background is negligible but has huge artefacts)
    if removeQCD:
        datasets.remove(
            filter(lambda name: "QCD" in name, datasets.getAllDatasetNames()))

    # Change legend creator defaults
    histograms.createLegend.moveDefaults(dx=-0.05)

    # Set the signal cross sections to a given BR(t->H), BR(h->taunu)
    xsect.setHplusCrossSectionsToBR(datasets,
                                    br_tH=lightHplusTopBR,
                                    br_Htaunu=1)
    # Example how to set cross section to a specific MSSM point
    #xsect.setHplusCrossSectionsToMSSM(datasets, tanbeta=20, mu=200)

    myXSect = datasets.getDataset("TTToHplusBWB_M120").getCrossSection()
    myNormFactor = datasets.getDataset("TTToHplusBWB_M120").getNormFactor()
    myNAll = datasets.getDataset("TTToHplusBWB_M120").getNAllEvents()
    print "### HW cross section =", myXSect

    # Merge signals into one dataset (per mass point)
    plots.mergeWHandHH(
        datasets
    )  # merging of WH and HH signals must be done after setting the cross section

    # Replace signal dataset with a signal+background dataset, where
    # the BR(t->H+) is taken into account for SM ttbar
    plots.replaceLightHplusWithSignalPlusBackground(datasets)

    # You can print a tree of all the merged datasets with this
    #datasets.printDatasetTree()

    # Apply TDR style
    style = tdrstyle.TDRStyle()

    # Calculate N_signal/N_background and Poisson significance of signal
    #numberOfSignalEvents = datasets.getDataset("TTToHplus_M120").getCrossSection() * myIntegratedLuminosity
    numberOfSignalEvents = myXSect * myIntegratedLuminosity
    print "###", datasets.getDataset("TTToHplus_M120").getCrossSection()
    print "###", myIntegratedLuminosity
    print "*** Number of signal events:", numberOfSignalEvents
    print "*** ...or:", myNormFactor * myNAll * myIntegratedLuminosity

    # names = datasetMgr.getAllDatasetNames()
    #d_ttjets = datasets.getDataset("TTJets")
    #print d_ttjets.getNAllEvents()

    # Create plots
    doPlots(datasets)

    if interactiveMode:
        raw_input("*** Press \"Enter\" to exit pyROOT: ")