Ejemplo n.º 1
0
    def produceScaledCards(self, mHp, tanbeta):
        if self.resultExists(mHp, tanbeta):
            return
        # Obtain branching and sigma from MSSM model database
        self._readFromDatabase(mHp, tanbeta)
        if self._results[constructResultKey(mHp,
                                            tanbeta)]["sigmaTheory"] == None:
            return

        #print "    Scaled '%s/%s' signal in datacards by branching %f (mHp=%s, tanbeta=%.1f)"%(mySignalScaleFactor, mHp, tanbeta)
        # Obtain theoretical uncertinties from MSSM model database
        myDbInputName = _modelPattern % self._mssmModel
        if not os.path.exists(myDbInputName):
            raise Exception("Error: Cannot find file '%s'!" % myDbInputName)
        # Scale datacards
        myResult = self.getResult(mHp, tanbeta)
        for fskey in self._decayModeMatrix.keys():
            print "    . final state %10s:" % fskey
            myOriginalRates = []
            myPrimaryReader = None
            for dmkey in self._decayModeMatrix[fskey].keys():
                myDatacardPattern = self._decayModeMatrix[fskey][dmkey][0]
                myRootFilePattern = self._decayModeMatrix[fskey][dmkey][1]
                if myRootFilePattern != None:
                    mySignalScaleFactor = myResult["%sTheory" % dmkey]
                    # Leave reader for first key open
                    if dmkey == self._decayModeMatrix[fskey].keys()[0]:
                        if not "_Control_" in myDatacardPattern:  # Skip control cards (they have no signal)
                            myPrimaryReader = DatacardReader.DataCardReader(
                                ".",
                                mHp,
                                myDatacardPattern,
                                myRootFilePattern,
                                rootFileDirectory="",
                                readOnly=False)
                            myPrimaryReader.scaleSignal(mySignalScaleFactor)
                            myOriginalRates.append(
                                float(
                                    myPrimaryReader.getRateValue(
                                        myPrimaryReader.getDatasetNames()[0])))
                            #print fskey,dmkey,myOriginalRates[len(myOriginalRates)-1]
                    else:
                        # Scale according to br and add signal to primary (i.e. only one datacard for the decay modes)
                        myReader = DatacardReader.DataCardReader(
                            ".",
                            mHp,
                            myDatacardPattern,
                            myRootFilePattern,
                            rootFileDirectory="",
                            readOnly=False)
                        myReader.scaleSignal(mySignalScaleFactor)
                        myOriginalRates.append(
                            float(
                                myReader.getRateValue(
                                    myReader.getDatasetNames()[0])))
                        #print fskey,dmkey,myOriginalRates[len(myOriginalRates)-1]
                        myPrimaryReader.addSignal(myReader)
                        myReader.close()
                        # Remove datacard from current directory so that it is not used for limit calculation (a copy of them is at originalDatacards directory)
                        if os.path.exists(myDatacardPattern % mHp):
                            os.system("rm %s" % (myDatacardPattern % mHp))
                            os.system("rm %s" % (myRootFilePattern % mHp))
            if myPrimaryReader != None:
                mySignalColumnName = myPrimaryReader.getDatasetNames()[0]
                myUpdatedRate = float(
                    myPrimaryReader.getRateValue(
                        myPrimaryReader.getDatasetNames()[0]))
                myTheorUncertPrefix = "theory_"
                # Add theoretical cross section uncertainties to datacard
                db = BRXSDB.BRXSDatabaseInterface(myDbInputName,
                                                  silentStatus=True)
                myXsecUncert = [0.0, 0.0]
                if float(mHp) > 179:
                    myXsecUncert = [
                        db.xsecUncertOrig("mHp", "tanb", "", mHp, tanbeta,
                                          "-"),
                        db.xsecUncertOrig("mHp", "tanb", "", mHp, tanbeta, "+")
                    ]
                    if self._separateTheoreticalXsectionAndBrUncertainties:
                        myNuisanceName = "%sxsectionHp" % myTheorUncertPrefix
                        myUncertValueString = "%.3f/%.3f" % (
                            1.0 - myXsecUncert[0], 1.0 + myXsecUncert[1])
                        myPrimaryReader.addNuisance(myNuisanceName, "lnN",
                                                    mySignalColumnName,
                                                    myUncertValueString)
                        print "      . H+ xsec uncert: %s" % myUncertValueString
                else:
                    self._separateTheoreticalXsectionAndBrUncertainties = True
                # Add theoretical branching ratio uncertainties to datacard (depends on how many decay modes are combined)
                myDecayModeKeys = self._decayModeMatrix[fskey].keys()
                for i in range(len(myDecayModeKeys)):
                    myDecayModeKeys[i] = "BR_%s" % myDecayModeKeys[i]
                myBrUncert = None
                if float(mHp) < 179:
                    myBrUncert = db.brUncertLight(
                        "mHp",
                        "tanb",
                        myDecayModeKeys,
                        mHp,
                        tanbeta,
                        linearSummation=_linearSummingForTheoryUncertainties,
                        silentStatus=True)
                else:
                    myBrUncert = db.brUncertHeavy(
                        "mHp",
                        "tanb",
                        myDecayModeKeys,
                        mHp,
                        tanbeta,
                        linearSummation=_linearSummingForTheoryUncertainties,
                        silentStatus=True)
                for i in range(len(myDecayModeKeys)):
                    for k in myBrUncert.keys():
                        if myDecayModeKeys[i] in k:
                            # Scale uncertainty according to amount of signal from that decay mode
                            myUncertValue = myBrUncert[k] * myOriginalRates[
                                i] / myUpdatedRate
                            if self._separateTheoreticalXsectionAndBrUncertainties:
                                myNuisanceName = "%s%s" % (myTheorUncertPrefix,
                                                           k)
                                myUncertValueString = "%.3f" % (1.0 +
                                                                myUncertValue)
                                if float(mHp) < 179 and (
                                        "HH" in mySignalColumnName
                                        or "ttHpHp" in mySignalColumnName):
                                    # Add for HH
                                    myUncertValueStringHH = "%.3f" % (
                                        1.0 + myUncertValue * 2.0)
                                    myPrimaryReader.addNuisance(
                                        myNuisanceName, "lnN",
                                        mySignalColumnName,
                                        myUncertValueStringHH)
                                    # Add for HW
                                    myPrimaryReader.addNuisance(
                                        myNuisanceName, "lnN",
                                        myPrimaryReader.getDatasetNames()[1],
                                        myUncertValueString)
                                    print "      . H+ HH Br uncert(%s): %s" % (
                                        k, myUncertValueStringHH)
                                    print "      . H+ HW Br uncert(%s): %s" % (
                                        k, myUncertValueString)
                                else:
                                    myPrimaryReader.addNuisance(
                                        myNuisanceName, "lnN",
                                        mySignalColumnName,
                                        myUncertValueString)
                                    print "      . H+ Br uncert(%s): %s" % (
                                        k, myUncertValueString)
                            else:
                                if _linearSummingForTheoryUncertainties:
                                    myXsecUncert[0] += myUncertValue
                                    myXsecUncert[1] += myUncertValue
                                else:
                                    myXsecUncert[0] = math.sqrt(
                                        myXsecUncert[0]**2 + myUncertValue**2)
                                    myXsecUncert[1] = math.sqrt(
                                        myXsecUncert[1]**2 + myUncertValue**2)
                if not self._separateTheoreticalXsectionAndBrUncertainties:
                    myNuisanceName = "%sxsectionHp_and_Br" % myTheorUncertPrefix
                    myUncertValueString = "%.3f/%.3f" % (1.0 - myXsecUncert[0],
                                                         1.0 + myXsecUncert[1])
                    myPrimaryReader.addNuisance(myNuisanceName, "lnN",
                                                mySignalColumnName,
                                                myUncertValueString)
                    print "      . %s: %s" % (myNuisanceName,
                                              myUncertValueString)
                # Write changes to datacard
                myPrimaryReader.close()
                # Something in memory management leaks - the following helps dramatically to recude the leak
                ROOT.gROOT.CloseFiles()
                ROOT.gROOT.GetListOfCanvases().Delete()
                ROOT.gDirectory.GetList().Delete()
            else:
                print "      . no changes to datacard needed"
Ejemplo n.º 2
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""
    jsonfile = "limits.json"

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    json_re = re.compile("(?P<jsonfile>(\S*\.json))")
    for argv in sys.argv:
        match = root_re.search(argv)
        if match:
            rootfile = match.group(0)
        match = json_re.search(argv)
        if match:
            jsonfile = match.group(0)

    limits = limit.BRLimits(
        limitsfile=jsonfile,
        configfile="limitdata/lightHplus_configuration.json")

    # Enable OpenGL
    ROOT.gEnv.SetValue("OpenGL.CanvasPreferGL", 1)

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    if limit.forPaper:
        histograms.cmsTextMode = histograms.CMSMode.PAPER
    #histograms.cmsTextMode = histograms.CMSMode.PAPER # tmp
    #histograms.cmsTextMode = histograms.CMSMode.UNPUBLISHED # tmp
    limit.forPaper = True  # to get GeV without c^2

    # Get BR limits

    masses = limits.mass
    brs = limits.observed

    print "Observed masses and BR's"
    for i in range(len(masses)):
        print "    ", masses[i], brs[i]

    global db
    db = BRXSDB.BRXSDatabaseInterface(rootfile)
    for i, m in enumerate(masses):
        db.addExperimentalBRLimit(m, brs[i])

    graphs = {}
    obs = limits.observedGraph()
    # Remove blinded obs points
    for i in reversed(range(0, obs.GetN())):
        if obs.GetY()[i] < 0.00000001:
            print "    REMOVING POINT", obs.GetY(
            )[i], " corresponding mass=", obs.GetX()[i]
            obs.RemovePoint(i)
    print

    graphs["exp"] = limits.expectedGraph()
    graphs["exp1"] = limits.expectedBandGraph(sigma=1)
    graphs["exp2"] = limits.expectedBandGraph(sigma=2)

    if obs.GetN() > 0:
        graphs["obs"] = obs
        # Get theory uncertainties on observed


#        obs_th_plus = limit.getObservedPlus(obs,0.21)
#        obs_th_minus = limit.getObservedMinus(obs,0.21)
#        for gr in [obs_th_plus, obs_th_minus]:
#            gr.SetLineWidth(2)
#            gr.SetLineStyle(9)
#        graphs["obs_th_plus"] = obs_th_plus
#        graphs["obs_th_minus"] = obs_th_minus

# Remove m=80
    for gr in graphs.values():
        limit.cleanGraph(gr, minX=90)

    print "Plotting graphs"
    for key in graphs.keys():
        for i in range(graphs[key].GetN()):
            xs = graphs[key].GetX()
            ys = graphs[key].GetY()
            print "    ", key, xs[i], ys[i]
        print

    # Interpret in MSSM
    xVariable = "mHp"
    #    selection = "mu==200"
    selection = "mHp > 0"
    #    scenario = "MSSM m_{h}^{max}"
    scenario = os.path.split(rootfile)[-1].replace(".root", "")

    for key in graphs.keys():
        print "Graph--------------------------------", key
        graphs[key] = db.graphToTanBetaCombined(graphs[key], xVariable,
                                                selection)
        #if key == "obs":
        #obsplus = db.getTheorUncert(graphs[key],xVariable,selection,"+")
        #graphs["obs_th_plus"] = db.graphToTanBetaCombined(obsplus,xVariable,selection)
        #obsminus = db.getTheorUncert(graphs[key],xVariable,selection,"-")
        #graphs["obs_th_minus"] = db.graphToTanBetaCombined(obsminus,xVariable,selection)
        print key, "done"

    graphs["mintanb"] = db.minimumTanbGraph("mHp", selection)

    if scenario == "lowMH-LHCHXSWG":
        graphs["Allowed"] = db.mhLimit("mH", "mHp", selection, "125.0+-3.0")
    else:
        graphs["Allowed"] = db.mhLimit("mh", "mHp", selection, "125.0+-3.0")
    graphs["isomass"] = None

    limit.doTanBetaPlotLight("limitsTanb_light_" + scenario, graphs,
                             limits.getLuminosity(),
                             limits.getFinalstateText(), limit.mHplus(),
                             scenario)

    # mH+ -> mA
    print "Replotting the graphs for (mA,tanb)"
    for key in graphs.keys():
        print key
        #db.PrintGraph(graphs[key])
        #print "check loop db.graphToMa"
        db.graphToMa(graphs[key])

    graphs["isomass"] = db.getIsoMass(160)

    limit.doTanBetaPlotLight("limitsTanb_mA_light_" + scenario, graphs,
                             limits.getLuminosity(),
                             limits.getFinalstateText(), limit.mA(), scenario)
Ejemplo n.º 3
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""
    jsonfile = "limits.json"

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    json_re = re.compile("(?P<jsonfile>(\S*\.json))")
    for argv in sys.argv:
        match = root_re.search(argv)
        if match:
            rootfile = match.group(0)
        match = json_re.search(argv)
        if match:
            jsonfile = match.group(0)
#    jsonfile = "limits_heavy2016.json"
#    jsonfile = "limits2016/limitsForMSSMplots_ICHEP_v3_heavy.json"
    jsonfile = "limits2016/limits_heavy_20171011.json"
    #    limits = limit.BRLimits(limitsfile=jsonfile,configfile="configurationHeavy.json")
    limits = limit.BRLimits(
        limitsfile=jsonfile,
        configfile="limits2016/heavyHplus_configuration.json")

    # Enable OpenGL
    ROOT.gEnv.SetValue("OpenGL.CanvasPreferGL", 1)

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    #if limit.forPaper:
    #    histograms.cmsTextMode = histograms.CMSMode.PAPER
    #histograms.cmsTextMode = histograms.CMSMode.PAPER # tmp
    #histograms.cmsTextMode = histograms.CMSMode.UNPUBLISHED # tmp
    histograms.cmsTextMode = histograms.CMSMode.PRELIMINARY
    limit.forPaper = True  # to get GeV without c^2

    # Get BR limits

    masses = limits.mass
    brs = limits.observed

    print "Observed masses and sigma*BR's"
    for i in range(len(masses)):
        print "    ", masses[i], brs[i]

    global db
    db = BRXSDB.BRXSDatabaseInterface(rootfile)
    db.BRvariable = "2*0.001*tHp_xsec*BR_Hp_taunu"  # XSEC only for H-, multiply with 2 to get H+ and H- ; multiply by 0.001 to fb -> pb
    for i, m in enumerate(masses):
        db.addExperimentalBRLimit(m, brs[i])

    graphs = {}
    obs = limits.observedGraph()

    # Remove blinded obs points
    for i in reversed(range(0, obs.GetN())):
        if obs.GetY()[i] < 0.00000001:
            print "    REMOVING POINT", obs.GetY(
            )[i], " corresponding mass=", obs.GetX()[i]
            obs.RemovePoint(i)
    print

    graphs["exp"] = limits.expectedGraph()
    graphs["exp1"] = limits.expectedBandGraph(sigma=1)
    graphs["exp2"] = limits.expectedBandGraph(sigma=2)

    if obs.GetN() > 0:
        graphs["obs"] = obs
        # Get theory uncertainties on observed
#        obs_th_plus = limit.getObservedPlus(obs,0.32)
#        obs_th_minus = limit.getObservedMinus(obs,0.32)
#        for gr in [obs_th_plus, obs_th_minus]:
#            gr.SetLineWidth(2)
#            gr.SetLineStyle(9)
#        graphs["obs_th_plus"] = obs_th_plus
#        graphs["obs_th_minus"] = obs_th_minus

# Remove m=180,190
    for gr in graphs.values():
        #        limit.cleanGraph(gr, 750)
        limit.cleanGraph(gr, 800)
        limit.cleanGraph(gr, 1000)
        limit.cleanGraph(gr, 2000)
        limit.cleanGraph(gr, 3000)

    print "Plotting graphs"
    for key in graphs.keys():
        for i in range(graphs[key].GetN()):
            xs = graphs[key].GetX()
            ys = graphs[key].GetY()
            print "    ", key, xs[i], ys[i]
        print

    # Interpret in MSSM
    xVariable = "mHp"
    selection = "mHp > 0 && mu==200"
    #    selection = "mHp > 0 && mu==500"
    #    scenario = "MSSM m_{h}^{max}"
    scenario = os.path.split(rootfile)[-1].replace(".root", "")
    print scenario

    from JsonWriter import JsonWriter
    jsonWriter = JsonWriter()
    for key in graphs.keys():
        print "Graph--------------------------------", key
        graphs[key] = db.graphToTanBeta(graphs[key],
                                        xVariable,
                                        selection,
                                        highTanbRegion=True)
        #if key == "obs":
        #obsplus = db.getTheorUncert(graphs[key],xVariable,selection,"+")
        #graphs["obs_th_plus"] = db.graphToTanBeta(obsplus,xVariable,selection)
        #obsminus = db.getTheorUncert(graphs[key],xVariable,selection,"-")
        #graphs["obs_th_minus"] = db.graphToTanBeta(obsminus,xVariable,selection)
        print key, "done"
        jsonWriter.addGraph(key, graphs[key])

#    graphs["mintanb"] = db.minimumTanbGraph("mHp",selection)
    if scenario == "lowMH-LHCHXSWG":
        graphs["Allowed"] = db.mhLimit("mH", "mHp", selection, "125.0+-3.0")
    else:
        graphs["Allowed"] = db.mhLimit("mh", "mHp", selection + "&&mHp>175",
                                       "125.0+-3.0")

    if scenario == "tauphobic-LHCHXSWG":
        # Fix a buggy second upper limit (the order of points is left to right, then right to left; remove further passes to fix the bug)
        decreasingStatus = False
        i = 0
        while i < graphs["Allowed"].GetN():
            removeStatus = False
            y = graphs["Allowed"].GetY()[i]
            if i > 0:
                if graphs["Allowed"].GetY()[i - 1] - y < 0:
                    decreasingStatus = True
                else:
                    if decreasingStatus:
                        graphs["Allowed"].RemovePoint(i)
                        removeStatus = True
            if not removeStatus:
                i += 1
        #for i in range(0, graphs["Allowed"].GetN()):
        #print graphs["Allowed"].GetX()[i], graphs["Allowed"].GetY()[i]


#    del graphs["isomass"]

    jsonWriter.addGraph("Allowed", graphs["Allowed"])

    jsonWriter.addParameter("name", "limitsTanb_heavy_" + scenario)
    jsonWriter.addParameter("scenario", scenario)
    jsonWriter.addParameter("luminosity", limits.getLuminosity())
    jsonWriter.addParameter("finalStateText", limits.getFinalstateText())
    jsonWriter.addParameter("mHplus", limit.mHplus())
    jsonWriter.addParameter("selection", selection)
    jsonWriter.addParameter("regime", "heavy")
    jsonWriter.write("MSSMLimitHeavy_" + scenario + ".json")

    limit.doTanBetaPlotHeavy("limitsTanb_heavy_" + scenario, graphs,
                             limits.getLuminosity(),
                             limits.getFinalstateText(), limit.mHplus(),
                             scenario)
    sys.exit()

    # mH+ -> mA
    print "Replotting the graphs for (mA,tanb)"
    for key in graphs.keys():
        print key
        #db.PrintGraph(graphs[key])
        #print "check loop db.graphToMa"
        db.graphToMa(graphs[key])

    graphs["isomass"] = db.getIsoMass(200)

    #    doPlot("limitsTanb_mA_heavy_"+scenario, graphs, limits, limit.mA(),scenario)

    limit.doTanBetaPlotHeavy("limitsTanb_mA_heavy_" + scenario, graphs,
                             limits.getLuminosity(),
                             limits.getFinalstateText(), limit.mA(), scenario)
Ejemplo n.º 4
0
 def doPlot(self, mAtanbeta=False):
     graphs = {}
     #["observed", "observedPlusTheorUncert", "observedMinusTheorUncert", "expected", "expectedPlus1Sigma", "expectedPlus2Sigma", "expectedMinus1Sigma", "expectedMinus2Sigma"]
     result = self._getResultGraphForOneKey("expected")
     graphs["exp"] = result[0]
     graphs["expDown"] = result[1]
     result = self._getResultGraphForTwoKeys("expectedPlus1Sigma",
                                             "expectedMinus1Sigma")
     graphs["exp1"] = result[0]
     graphs["exp1Down"] = result[1]
     result = self._getResultGraphForTwoKeys("expectedPlus2Sigma",
                                             "expectedMinus2Sigma")
     graphs["exp2"] = result[0]
     graphs["exp2Down"] = result[1]
     result = self._getResultGraphForOneKey("observed")
     graphs["obs"] = result[0]
     graphs["obsDown"] = result[1]
     myName = _modelPattern % self._mssmModel
     if not os.path.exists(myName):
         raise Exception("Error: Cannot find file '%s'!" % myName)
     db = BRXSDB.BRXSDatabaseInterface(myName)
     graphs["Allowed"] = db.mhLimit("mh", "mHp", "mHp > 0", "125.0+-3.0")
     graphs["AllowedCentral"] = db.mhLimit("mh", "mHp", "mHp > 0",
                                           "125.0+-0.0")
     if mAtanbeta:
         for k in graphs.keys():
             print k
             db.graphToMa(graphs[k])
     if mAtanbeta:
         if self.isLightHp():
             graphs["isomass"] = db.getIsoMass(160)
         else:
             graphs["isomass"] = db.getIsoMass(200)
     #graphName = "obsDown"
     #for i in range(0, graphs[graphName].GetN()):
     #print graphs[graphName].GetX()[i], graphs[graphName].GetY()[i]
     db.close()
     if self._mssmModel == "tauphobic":
         ## Fix a buggy second upper limit (the order of points is left to right, then right to left; remove further passes to fix the bug)
         #decreasingStatus = False
         #i = 0
         #while i < graphs["Allowed"].GetN():
         #removeStatus = False
         #y = graphs["Allowed"].GetY()[i]
         #if i > 0:
         #if graphs["Allowed"].GetY()[i-1] - y < 0:
         #decreasingStatus = True
         #else:
         #if decreasingStatus:
         #graphs["Allowed"].RemovePoint(i)
         #removeStatus = True
         #if not removeStatus:
         #i += 1
         #for i in range(0, graphs["Allowed"].GetN()):
         #print graphs["Allowed"].GetX()[i], graphs["Allowed"].GetY()[i]
         ## Fix m=500 and m=600
         n = graphs["Allowed"].GetN()
         graphs["Allowed"].SetPoint(n - 2, 500, 4.77)
         graphs["Allowed"].SetPoint(n - 1, 600, 4.71)
     myFinalStateLabel = []
     if float(self._massPoints[0]) < 179:
         myFinalStateLabel.append(
             "^{}H^{+}#rightarrow#tau^{+}#nu_{#tau}, ^{}#tau_{h}+jets final state"
         )
     else:
         myFinalStateLabel.append(
             "^{}H^{+}#rightarrow#tau^{+}#nu_{#tau} final states:")
         myFinalStateLabel.append("  ^{}#tau_{h}+jets")
         #myFinalStateLabel.append("  ^{}#tau_{h}+jets, #mu#tau_{h}, #it{ll}")
         myFinalStateLabel.append(
             "^{}H^{+}#rightarrowt#bar{b} final states:")
         myFinalStateLabel.append("  ^{}#it{l}+jets, #mu#tau_{h}, #it{ll}")
     if float(self._massPoints[0]) < 179:
         myName = "tanbeta_%s_light" % self._mssmModel
         if mAtanbeta:
             limit.doTanBetaPlotGeneric(myName + "_mA",
                                        graphs,
                                        19700,
                                        myFinalStateLabel,
                                        limit.mA(),
                                        self._mssmModel,
                                        regime="light")
         else:
             limit.doTanBetaPlotGeneric(myName,
                                        graphs,
                                        19700,
                                        myFinalStateLabel,
                                        limit.mHplus(),
                                        self._mssmModel,
                                        regime="light")
     else:
         myName = "limitsTanbCombination_heavy_" + self._mssmModel
         if mAtanbeta:
             limit.doTanBetaPlotGeneric(myName + "_mA",
                                        graphs,
                                        19700,
                                        myFinalStateLabel,
                                        limit.mA(),
                                        self._mssmModel,
                                        regime="combination")
         else:
             limit.doTanBetaPlotGeneric(myName,
                                        graphs,
                                        19700,
                                        myFinalStateLabel,
                                        limit.mHplus(),
                                        self._mssmModel,
                                        regime="combination")
Ejemplo n.º 5
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""
    jsonfile = "limits.json"

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    json_re = re.compile("(?P<jsonfile>(\S*\.json))")
    for argv in sys.argv:
        match = root_re.search(argv)
        if match:
            rootfile = match.group(0)
        match = json_re.search(argv)
        if match:
            jsonfile = match.group(0)

    jsonfile = "limits2016/limits_withLeptonic_180522.json"
    limits = limit.BRLimits(limitsfile=jsonfile,
                            configfile="limits2016/mu_configuration.json")

    # Enable OpenGL
    ROOT.gEnv.SetValue("OpenGL.CanvasPreferGL", 1)

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    if limit.forPaper:
        histograms.cmsTextMode = histograms.CMSMode.PAPER

    # Get BR limits

    masses = limits.mass
    brs = limits.observed

    print "Observed masses and BR's"
    for i in range(len(masses)):
        print "    ", masses[i], brs[i]

    global db
    db = BRXSDB.BRXSDatabaseInterface(
        rootfile, BRvariable="0.001*831.76*2*tHp_xsec*BR_Hp_taunu")
    for i, m in enumerate(masses):
        db.addExperimentalBRLimit(m, brs[i])

    graphs = {}
    obs = limits.observedGraph()
    # Remove blinded obs points
    for i in reversed(range(0, obs.GetN())):
        if obs.GetY()[i] < 0.00000001:
            print "    REMOVING POINT", obs.GetY(
            )[i], " corresponding mass=", obs.GetX()[i]
            obs.RemovePoint(i)
    print

    #    graphs["exp"] = limits.expectedGraph()
    #x = array.array('d',masses)
    #y = array.array('d',[0.02]*len(masses))
    #graphs["exp"] = ROOT.TGraph(len(masses),x,y)
    #    graphs["exp1"] = limits.expectedBandGraph(sigma=1)
    #    graphs["exp2"] = limits.expectedBandGraph(sigma=2)

    if obs.GetN() > 0:
        graphs["obs"] = obs

    # Remove m=80
    for gr in graphs.values():
        limit.cleanGraph(gr, 80)

    print "Plotting graphs"
    for key in graphs.keys():
        for i in range(graphs[key].GetN()):
            xs = graphs[key].GetX()
            ys = graphs[key].GetY()
            print "    ", key, xs[i], ys[i]
        print

    # Interpret in MSSM
    xVariable = "mu"
    scenario = os.path.split(rootfile)[-1].replace(".root", "")
    if scenario == "lowMHaltv-LHCHXSWG":
        xVariable = "mHp"
    selection = ""
    from JsonWriter import JsonWriter
    #    for i in range(len(masses)):
    #        mass = masses[i]
    #        brlimit = brs[i]
    #	if mass < 90:
    #	    continue
    #        if not mass == 160:
    #            continue
    #	selection = "mHp == %s"%mass
    #graphs["muexcluded"] = db.muLimit(mass,"mu",selection,brlimit)
    #db.PrintGraph(graphs["muexcluded"],"muexcluded")

    jsonWriter = JsonWriter()
    print "check keys", graphs.keys()

    for key in graphs.keys():
        print "Graph--------------------------------", key
        #db.PrintGraph(graphs[key],"Before graphToTanBetaCombined")
        graphs[key] = db.graphToTanBetaMu(graphs[key], xVariable, selection,
                                          True)
        print key, "done"
        jsonWriter.addGraph(key, graphs[key])

    #graphs["Allowed"] = db.mhLimit("mH","mu",selection,"125.0+-3.0")
    if xVariable == "mHp":
        graphs["Allowed"] = db.mHLimit_mHp(selection, "125.0+-3.0")
    else:
        graphs["Allowed"] = db.mHLimit_mu(selection, "125.0+-3.0")
    jsonWriter.addGraph("Allowed", graphs["Allowed"])

    graphs["Inaccessible"] = db.inaccessible(xVariable, selection)
    jsonWriter.addGraph("Inaccessible", graphs["Inaccessible"])

    jsonWriter.addParameter("name", "limitsTanb_light_" + scenario)
    jsonWriter.addParameter("scenario", scenario)
    jsonWriter.addParameter("luminosity", limits.getLuminosity())
    jsonWriter.addParameter("finalStateText", limits.getFinalstateText())
    xvar = limit.mu()
    if xVariable == "mHp":
        xvar = limit.mHplus()
    jsonWriter.addParameter("mHplus", xvar)
    jsonWriter.addParameter("selection", selection)
    jsonWriter.addParameter("regime", "mu")
    jsonWriter.write("MSSMLimitMu_" + scenario + ".json")

    #limit.doTanBetaPlotLight("limitsTanb_light_"+scenario, graphs, limits.getLuminosity(), limits.getFinalstateText(), limit.mHplus(), scenario)
    #        if int(mass) in [155, 160]:
    #            graphs["obs_th_plus"] = db.muLimit(mass,"mu",selection,brlimit*(1+0.29))
    #            graphs["obs_th_minus"] = db.muLimit(mass,"mu",selection,brlimit*(1-0.29))
    #
    #            for gr in [graphs["obs_th_plus"], graphs["obs_th_minus"]]:
    #                gr.SetLineWidth(2)
    #                gr.SetLineStyle(9)
    #
    #            graphs["observed"] = graphs["muexcluded"].Clone()
    #            graphs["observed"].SetLineWidth(2)
    #            graphs["observed"].SetLineStyle(ROOT.kSolid)
    #            graphs["observed"].SetLineColor(ROOT.kBlack)
    #
    #            # Remove obs point
    #            for name in ["observed", "obs_th_plus", "obs_th_minus"]:
    #                gr = graphs[name]
    #                print "Graph", name
    #                for i in reversed(range(0,gr.GetN())):
    #                    if gr.GetY()[i] < 2 or gr.GetY()[i] > 65:
    #                        print "    REMOVING POINT",gr.GetY()[i]," corresponding mass=",gr.GetX()[i]
    #                        gr.RemovePoint(i)
    #
    #        graphs["Allowed"]  = db.getHardCoded_mH_limitForMu(mass,0)
    #        graphs["Allowed2"] = db.getHardCoded_mH_limitForMu(mass,1)
    #
    #        doPlot(("limitsMu_light_mHp%s_"+scenario)%(int(mass)), graphs, limits, "#mu (GeV)",scenario, int(mass))
    sys.exit()
Ejemplo n.º 6
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""
    jsonfile = "limits.json"

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    json_re = re.compile("(?P<jsonfile>(\S*\.json))")
    for argv in sys.argv:
        match = root_re.search(argv)
        if match:
            rootfile = match.group(0)
        match = json_re.search(argv)
        if match:
            jsonfile = match.group(0)

    limits = limit.BRLimits(
        limitsfile=jsonfile,
        configfile="limitdata/lightHplus_configuration.json")

    # Enable OpenGL
    ROOT.gEnv.SetValue("OpenGL.CanvasPreferGL", 1)

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    if limit.forPaper:
        histograms.cmsTextMode = histograms.CMSMode.PAPER

    # Get BR limits

    masses = limits.mass
    brs = limits.observed

    print "Observed masses and BR's"
    for i in range(len(masses)):
        print "    ", masses[i], brs[i]

    global db
    db = BRXSDB.BRXSDatabaseInterface(rootfile)
    for i, m in enumerate(masses):
        db.addExperimentalBRLimit(m, brs[i])

    graphs = {}
    obs = limits.observedGraph()
    # Remove blinded obs points
    for i in reversed(range(0, obs.GetN())):
        if obs.GetY()[i] < 0.00000001:
            print "    REMOVING POINT", obs.GetY(
            )[i], " corresponding mass=", obs.GetX()[i]
            obs.RemovePoint(i)
    print

    scenario = os.path.split(rootfile)[-1].replace(".root", "")
    selection = ""
    for i in range(len(masses)):
        mass = masses[i]
        brlimit = brs[i]
        if mass < 90:
            continue


#        if not mass == 160:
#            continue
        selection = "mHp == %s" % mass
        graphs["muexcluded"] = db.muLimit(mass, "mu", selection, brlimit)

        if int(mass) in [155, 160]:
            graphs["obs_th_plus"] = db.muLimit(mass, "mu", selection,
                                               brlimit * (1 + 0.29))
            graphs["obs_th_minus"] = db.muLimit(mass, "mu", selection,
                                                brlimit * (1 - 0.29))

            for gr in [graphs["obs_th_plus"], graphs["obs_th_minus"]]:
                gr.SetLineWidth(2)
                gr.SetLineStyle(9)

            graphs["observed"] = graphs["muexcluded"].Clone()
            graphs["observed"].SetLineWidth(2)
            graphs["observed"].SetLineStyle(ROOT.kSolid)
            graphs["observed"].SetLineColor(ROOT.kBlack)

            # Remove obs point
            for name in ["observed", "obs_th_plus", "obs_th_minus"]:
                gr = graphs[name]
                print "Graph", name
                for i in reversed(range(0, gr.GetN())):
                    if gr.GetY()[i] < 2 or gr.GetY()[i] > 65:
                        print "    REMOVING POINT", gr.GetY(
                        )[i], " corresponding mass=", gr.GetX()[i]
                        gr.RemovePoint(i)

        graphs["Allowed"] = db.getHardCoded_mH_limitForMu(mass, 0)
        graphs["Allowed2"] = db.getHardCoded_mH_limitForMu(mass, 1)

        doPlot(("limitsMu_light_mHp%s_" + scenario) % (int(mass)), graphs,
               limits, "#mu (GeV)", scenario, int(mass))
    sys.exit()
Ejemplo n.º 7
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    match = root_re.search(sys.argv[1])
    if match:
        rootfile = match.group(0)

    limits = limit.BRLimits()

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    if limit.forPaper:
        histograms.cmsTextMode = histograms.CMSMode.PAPER

    # Get BR limits

    masses = limits.mass
    brs = limits.observed

    #print masses,brs

    db = BRXSDB.BRXSDatabaseInterface(rootfile, heavy=True, program="2HDMC")
    progversion = db.GetProgram() + " v" + db.GetVersion()
    for i, m in enumerate(masses):
        db.addExperimentalBRLimit(m, brs[i])

    graphs = {}
    obs = limits.observedGraph()
    graphs["obs"] = obs
    graphs["exp"] = limits.expectedGraph()
    #    graphs["exp"].SetLineStyle(2)
    graphs["exp1"] = limits.expectedBandGraph(sigma=1)
    graphs["exp2"] = limits.expectedBandGraph(sigma=2)

    # Remove m=80
    for gr in graphs.values():
        limit.cleanGraph(gr, minX=100)
        N = gr.GetN()
#        for i in range(gr.GetN()):
#            j = N - 1 - i
#            if gr.GetX()[j] > 154 and gr.GetX()[j] < 156:
#                gr.RemovePoint(j)

# Get theory uncertainties on observed
    obs_th_plus = limit.getObservedPlus(obs)
    obs_th_minus = limit.getObservedMinus(obs)
    for gr in [obs_th_plus, obs_th_minus]:
        gr.SetLineWidth(2)
        gr.SetLineStyle(9)
    graphs["obs_th_plus"] = obs_th_plus
    graphs["obs_th_minus"] = obs_th_minus

    # Interpret in MSSM
    xVariable = "mHp"
    ####    selection = "mu==200&&Xt==2000&&m2==200"
    #    selection = "mu==200"
    #    scenario = "MSSM m_{h}^{max}"
    #    scenario = "MSSM m_{h}^{max up}"
    #    scenario = "MSSM m_{h}^{mod+}"
    #    scenario = "MSSM m_{h}^{mod-}"
    #    scenario = "MSSM #tau-phobic"        #mu=500
    #    scenario = "MSSM light #tilde{#tau}" #mu=500
    #    scenario = "MSSM light #tilde{t}" #mu=350
    #    scenario = "MSSM low m_{H}"	  #mu=1700

    selection = ""
    scenario = "Type II 2HDM"

    for key in graphs.keys():
        #        removeNotValid = not (key in ["exp1", "exp2"])
        #        graphs[key] = limit.graphToTanBeta(graphs[key], mu, removeNotValid)
        graphs[key] = db.graphToTanBeta(graphs[key],
                                        xVariable,
                                        selection,
                                        highTanbRegion=True,
                                        limitBRtoMin=False)
#        graphs[key] = db.graphToTanBetaCombined(graphs[key],xVariable,selection)
#        graphs[key] = db.graphToSharpTanbExclusion(graphs[key],xVariable,selection)

####    graphs["mintanb"] = db.minimumTanbGraph("mHp",selection)
####    graphs["Allowed"] = db.mhLimit("mh","mHp",selection,"125.9+-3.0")

    graphs["excluded"] = db.excluded(graphs["obs"], "ExcludedArea")

    #    doPlot("limitsTanb_mh", graphs, limits, limit.mHplus(),scenario)
    doPlot("limitsmHpTanb_" + rootfile.replace(".root", ""), graphs, limits,
           "m_{H^{+}} (" + GeVUnit + ")", scenario, progversion)
Ejemplo n.º 8
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""
    jsonfile = "limits.json"

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    json_re = re.compile("(?P<jsonfile>(\S*\.json))")
    for argv in sys.argv:
        match = root_re.search(argv)
        if match:
            rootfile = match.group(0)
        match = json_re.search(argv)
        if match:
            jsonfile = match.group(0)
#    jsonfile = "limits_light2016.json"
#    jsonfile = "limits2016/limitsForMSSMplots_ICHEP_v2_light.json"
#    jsonfile = "limits2016/limits_light_20171011.json"
#    jsonfile = "limits2016/limits_light_180131.json"
#    jsonfile = "limits2016/limits_light_180205.json"
#    jsonfile = "limits2016/limits_light_180318.json"
#    jsonfile = "limits2016/limits_light_180417.json"
#    jsonfile = "limits2016/limits_unblinded_180809/limits_light.json"
#    jsonfile = "limits2016/limits_unblinded_180809/limits_full_leptonic+hadronic_with_intermediate.json"
    jsonfile = "limits2016/limits_unblinded_withLeptonic_30082018/taunu_extInt_BR.json"
    #    limits = limit.BRLimits(limitsfile=jsonfile,configfile="limitdata/lightHplus_configuration.json")
    limits = limit.BRLimits(
        limitsfile=jsonfile,
        configfile="limits2016/lightHplus_configuration.json")

    # Enable OpenGL
    ROOT.gEnv.SetValue("OpenGL.CanvasPreferGL", 1)

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    #    if limit.forPaper:
    #        histograms.cmsTextMode = histograms.CMSMode.PAPER
    histograms.cmsTextMode = histograms.CMSMode.PRELIMINARY
    #    histograms.cmsTextMode = histograms.CMSMode.PAPER # tmp
    #histograms.cmsTextMode = histograms.CMSMode.UNPUBLISHED # tmp
    limit.forPaper = True  # to get GeV without c^2

    # Get BR limits

    masses = limits.mass
    brs = limits.observed

    print "Observed masses and BR's"
    for i in range(len(masses)):
        print "    ", masses[i], brs[i]

    global db
    db = BRXSDB.BRXSDatabaseInterface(rootfile)
    for i, m in enumerate(masses):
        db.addExperimentalBRLimit(m, brs[i])

    graphs = {}
    obs = limits.observedGraph()
    # Remove blinded obs points
    for i in reversed(range(0, obs.GetN())):
        if obs.GetY()[i] < 0.00000001:
            print "    REMOVING POINT", obs.GetY(
            )[i], " corresponding mass=", obs.GetX()[i]
            obs.RemovePoint(i)
    print

    graphs["exp"] = limits.expectedGraph()
    graphs["exp1"] = limits.expectedBandGraph(sigma=1)
    graphs["exp2"] = limits.expectedBandGraph(sigma=2)

    if obs.GetN() > 0:
        graphs["obs"] = obs
        # Get theory uncertainties on observed
#        obs_th_plus = limit.getObservedPlus(obs,0.21)
#        obs_th_minus = limit.getObservedMinus(obs,0.21)
#        for gr in [obs_th_plus, obs_th_minus]:
#            gr.SetLineWidth(2)
#            gr.SetLineStyle(9)
#        graphs["obs_th_plus"] = obs_th_plus
#        graphs["obs_th_minus"] = obs_th_minus

# Remove m=80
    for gr in graphs.values():
        limit.cleanGraph(gr, 80)

    print "Plotting graphs"
    for key in graphs.keys():
        for i in range(graphs[key].GetN()):
            xs = graphs[key].GetX()
            ys = graphs[key].GetY()
            print "    ", key, xs[i], ys[i]
        print

    # Interpret in MSSM
    xVariable = "mHp"
    selection = "mu==200"
    #    selection = "mHp > 0"
    #    scenario = "MSSM m_{h}^{max}"
    scenario = os.path.split(rootfile)[-1].replace(".root", "")

    from JsonWriter import JsonWriter
    jsonWriter = JsonWriter()
    for key in graphs.keys():
        print "Graph--------------------------------", key
        graphs[key] = db.graphToTanBetaCombined(graphs[key], xVariable,
                                                selection)
        #if key == "obs":
        #obsplus = db.getTheorUncert(graphs[key],xVariable,selection,"+")
        #graphs["obs_th_plus"] = db.graphToTanBetaCombined(obsplus,xVariable,selection)
        #obsminus = db.getTheorUncert(graphs[key],xVariable,selection,"-")
        #graphs["obs_th_minus"] = db.graphToTanBetaCombined(obsminus,xVariable,selection)
        print key, "done"
        jsonWriter.addGraph(key, graphs[key])

    graphs["mintanb"] = db.minimumTanbGraph("mHp", selection)

    if scenario == "lowMH-LHCHXSWG":
        graphs["Allowed"] = db.mhLimit("mH", "mHp", selection, "125.0+-3.0")
    else:
        graphs["Allowed"] = db.mhLimit("mh", "mHp", selection, "125.0+-3.0")


#    graphs["isomass"] = None

    jsonWriter.addGraph("Allowed", graphs["Allowed"])
    jsonWriter.addGraph("mintanb", graphs["mintanb"])

    name = "limitsTanb_light_"
    finalStateText = limits.getFinalstateText()
    if "leptonic" in jsonfile:
        name = "limitsTanb_light_LeptHadrFS_"
        finalStateText = "#tau+jets final state"

    jsonWriter.addParameter("name", name + scenario)
    jsonWriter.addParameter("scenario", scenario)
    jsonWriter.addParameter("luminosity", limits.getLuminosity())
    jsonWriter.addParameter("finalStateText", finalStateText)
    jsonWriter.addParameter("mHplus", limit.mHplus())
    jsonWriter.addParameter("selection", selection)
    jsonWriter.addParameter("regime", "light")
    jsonWriter.write(name + scenario + ".json")

    limit.doTanBetaPlotLight("limitsTanb_light_" + scenario, graphs,
                             limits.getLuminosity(),
                             limits.getFinalstateText(), limit.mHplus(),
                             scenario)
    sys.exit()

    # mH+ -> mA
    print "Replotting the graphs for (mA,tanb)"
    for key in graphs.keys():
        print key
        #db.PrintGraph(graphs[key])
        #print "check loop db.graphToMa"
        db.graphToMa(graphs[key])

    graphs["isomass"] = db.getIsoMass(160)

    limit.doTanBetaPlotLight("limitsTanb_mA_light_" + scenario, graphs,
                             limits.getLuminosity(),
                             limits.getFinalstateText(), limit.mA(), scenario)
Ejemplo n.º 9
0
def evaluateUncertainties(myScenarios):
    print "Evaluating theoretical syst. uncertainties"
    myMassPoints = ["200", "300", "400", "500", "600"]
    tanbMin = 10
    tanbMax = 60
    #hXsectUncert = ROOT.TH2F("xsectUncert","xsectUncert",len(myMassPoints),myMassPoints[0],myMassPoints[len(myMassPoints)-1], tanbMax-tanbMin, tanbMin, tanbMax)
    #hBrTaunuUncert = ROOT.TH2F("BrTaunuUncert","BrTaunuUncert",len(myMassPoints),myMassPoints[0],myMassPoints[len(myMassPoints)-1], tanbMax-tanbMin, tanbMin, tanbMax)
    #hBrTBUncert = ROOT.TH2F("BrTBUncert","BrTBUncert",len(myMassPoints),myMassPoints[0],myMassPoints[len(myMassPoints)-1], tanbMax-tanbMin, tanbMin, tanbMax)
    for scen in myScenarios:
        xsectUncertPlusMin = 9999
        xsectUncertPlusMax = 0
        xsectUncertMinusMin = 9999
        xsectUncertMinusMax = 0
        brTaunuUncertPlusMin = 9999
        brTaunuUncertPlusMax = 0
        brTaunuUncertMinusMin = 9999
        brTaunuUncertMinusMax = 0
        brTBUncertPlusMin = 9999
        brTBUncertPlusMax = 0
        brTBUncertMinusMin = 9999
        brTBUncertMinusMax = 0
        brCombUncertPlusMin = 9999
        brCombUncertPlusMax = 0
        brCombUncertMinusMin = 9999
        brCombUncertMinusMax = 0
        myDbInputName = "%s-LHCHXSWG.root"%scen
        if not os.path.exists(myDbInputName):
            raise Exception("Error: Cannot find file '%s'!"%myDbInputName)
        db = BRXSDB.BRXSDatabaseInterface(myDbInputName, silentStatus=True)
        for mHp in myMassPoints:
            print scen,mHp
            for tanbeta in range(tanbMin, tanbMax):
                myTheorUncertLabel = "theory_Hpxsection"
                value = db.xsecUncertOrig("mHp", "tanb", "", mHp, tanbeta, "-")
                xsectUncertMinusMin = min(xsectUncertMinusMin, value)
                xsectUncertMinusMax = max(xsectUncertMinusMin, value)
                value = db.xsecUncertOrig("mHp", "tanb", "", mHp, tanbeta, "+")
                xsectUncertPlusMin = min(xsectUncertPlusMin, value)
                xsectUncertPlusMax = max(xsectUncertPlusMin, value)
                value = db.brUncert("mHp", "tanb", "BR_Hp_taunu", mHp, tanbeta, "-")
                brTaunuUncertMinusMin = min(brTaunuUncertMinusMin, value)
                brTaunuUncertMinusMax = max(brTaunuUncertMinusMax, value)
                value = db.brUncert("mHp", "tanb", "BR_Hp_taunu", mHp, tanbeta, "+")
                brTaunuUncertPlusMin = min(brTaunuUncertPlusMin, value)
                brTaunuUncertPlusMax = max(brTaunuUncertPlusMax, value)
                value = db.brUncert("mHp", "tanb", "BR_Hp_tb", mHp, tanbeta, "-")
                brTBUncertMinusMin = min(brTBUncertMinusMin, value)
                brTBUncertMinusMax = max(brTBUncertMinusMax, value)
                value = db.brUncert("mHp", "tanb", "BR_Hp_tb", mHp, tanbeta, "+")
                brTBUncertPlusMin = min(brTBUncertPlusMin, value)
                brTBUncertPlusMax = max(brTBUncertPlusMax, value)
                db.brUncert2("mHp", "tanb", "BR_Hp_taunu", "BR_Hp_tb", mHp, tanbeta, "-")
                brCombUncertMinusMin = min(brCombUncertMinusMin, value)
                brCombUncertMinusMax = max(brCombUncertMinusMax, value)
                db.brUncert2("mHp", "tanb", "BR_Hp_taunu", "BR_Hp_tb", mHp, tanbeta, "+")
                brCombUncertPlusMin = min(brCombUncertPlusMin, value)
                brCombUncertPlusMax = max(brCombUncertPlusMax, value)
        db.close()
        print "Syst. uncertainties for %s, mHp=%s-%s, tanbeta=%s-%s"%(scen, myMassPoints[0],myMassPoints[len(myMassPoints)-1], tanbMin, tanbMax)
        print "xsect uncert: minus: %f-%f, plus %f-%f"%(xsectUncertMinusMin,xsectUncertMinusMax,xsectUncertPlusMin,xsectUncertPlusMax)
        print "br(taunu) uncert: minus: %f-%f, plus %f-%f"%(brTaunuUncertMinusMin,brTaunuUncertMinusMax,brTaunuUncertPlusMin,brTaunuUncertPlusMax)
        print "br(tb) uncert: minus: %f-%f, plus %f-%f"%(brTBUncertMinusMin,brTBUncertMinusMax,brTBUncertPlusMin,brTBUncertPlusMax)
        print "br(taunu+tb) uncert: minus: %f-%f, plus %f-%f"%(brCombUncertMinusMin,brCombUncertMinusMax,brCombUncertPlusMin,brCombUncertPlusMax)
Ejemplo n.º 10
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    match = root_re.search(sys.argv[1])
    if match:
        rootfile = match.group(0)

    limits = limit.BRLimits()

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    if limit.forPaper:
        histograms.cmsTextMode = histograms.CMSMode.PAPER

    xvar = "mHp"
    yvars = []
    yvars.append("BR_Hp_taunu")
    yvars.append("BR_Hp_tb")
    yvars.append("BR_Hp_h0W")
    yvars.append("BR_Hp_A0W")
    yvars.append("BR_Hp_HW")
    #    yvars.append("BR_Hp_Neu1Cha1")
    #    yvars.append("BR_Hp_Neu2Cha1")

    susyvars = []
    susyvars.append("BR_Hp_Neu1Cha1")
    susyvars.append("BR_Hp_Neu2Cha1")
    #    susyvars.append("BR_Hp_Neu3Cha1")
    #    susyvars.append("BR_Hp_Neu4Cha1")
    #    susyvars.append("BR_Hp_Neu1Cha2")
    #    susyvars.append("BR_Hp_Neu2Cha2")
    #    susyvars.append("BR_Hp_Neu3Cha2")
    #    susyvars.append("BR_Hp_Neu4Cha2")

    #    db = BRXSDB.BRXSDatabaseInterface(rootfile,heavy=True,program="2HDMC")
    db = BRXSDB.BRXSDatabaseInterface(rootfile,
                                      heavy=True,
                                      program="FeynHiggs")
    progversion = db.GetProgram() + " v" + db.GetVersion()

    selection = "tanb==10"
    #    scenario = "2HDM Type II"
    scenario = "mhmax"

    graphs = {}

    for icolor, yvar in enumerate(yvars):
        tmpsel = selection
        br = db.getGraph(xvar, yvar, tmpsel)
        xarray = array.array('d')
        yarray = array.array('d')
        for i in range(0, br.GetN()):
            x = ROOT.Double()
            y = ROOT.Double()
            br.GetPoint(i, x, y)
            xarray.append(x)
            yarray.append(y)
        newx, newy = sort(xarray, yarray)
        newGraph = ROOT.TGraph(len(newx), newx, newy)
        newGraph.SetLineWidth(3)
        newGraph.SetLineColor(1 + icolor)
        graphs[yvar] = newGraph

    xsusy = array.array('d')
    ysusy = array.array('d')
    for yvar in susyvars:
        tmpsel = selection
        br = db.getGraph(xvar, yvar, tmpsel)
        xarray = array.array('d')
        yarray = array.array('d')
        for i in range(0, br.GetN()):
            x = ROOT.Double()
            y = ROOT.Double()
            br.GetPoint(i, x, y)
            xarray.append(x)
            yarray.append(y)
            print "check x,y", x, y
        xsusy, ysusy = add(xsusy, ysusy, xarray, yarray)
    print "check len", len(xsusy)
    newx, newy = sort(xsusy, ysusy)
    for i in range(len(newx)):
        print newx[i], newy[i]
    susyGraph = ROOT.TGraph(len(newx), newx, newy)
    susyGraph.SetLineWidth(3)
    susyGraph.SetLineColor(1 + len(graphs))
    graphs["BR_Hp_SUSY"] = susyGraph

    plot = plots.PlotBase([
        histograms.HistoGraph(graphs["BR_Hp_taunu"],
                              "BR(H^{+}#rightarrow#tau#nu)",
                              drawStyle="L",
                              legendStyle="l"),
        histograms.HistoGraph(graphs["BR_Hp_tb"],
                              "BR(H^{+}#rightarrow tb)",
                              drawStyle="L",
                              legendStyle="l"),
        histograms.HistoGraph(graphs["BR_Hp_h0W"],
                              "BR(H^{+}#rightarrow hW)",
                              drawStyle="L",
                              legendStyle="l"),
        histograms.HistoGraph(graphs["BR_Hp_A0W"],
                              "BR(H^{+}#rightarrow AW)",
                              drawStyle="L",
                              legendStyle="l"),
        histograms.HistoGraph(graphs["BR_Hp_HW"],
                              "BR(H^{+}#rightarrow HW)",
                              drawStyle="L",
                              legendStyle="l"),
        histograms.HistoGraph(graphs["BR_Hp_SUSY"],
                              "BR(H^{+}#rightarrow#chi_{i}^{0}#chi_{j}^{+})",
                              drawStyle="L",
                              legendStyle="l"),
        #	    histograms.HistoGraph(graphs["BR_Hp_Neu1Cha1"], "BR(H^{+}#rightarrow#chi_{1}^{0}#chi_{1}^{+})", drawStyle="L", legendStyle="l"),
        #	    histograms.HistoGraph(graphs["BR_Hp_Neu2Cha1"], "BR(H^{+}#rightarrow#chi_{2}^{0}#chi_{1}^{+})", drawStyle="L", legendStyle="l"),
    ])

    plot.setLegend(histograms.createLegend(0.57, 0.60, 0.87, 0.80))
    plot.legend.SetFillColor(0)
    plot.legend.SetFillStyle(1001)
    plot.createFrame("br",
                     opts={
                         "ymin": 0.0001,
                         "ymax": 1,
                         "xmin": 180,
                         "xmax": 600
                     })
    plot.frame.GetXaxis().SetTitle("m_{H^{+}} (" + GeVUnit + ")")
    plot.frame.GetYaxis().SetTitle("BR")
    ROOT.gPad.SetLogy(True)

    plot.draw()

    size = 20
    x = 0.57
    #    histograms.addText(x, 0.9, limit.processHeavy, size=size)
    #    histograms.addText(x, 0.863, limits.getFinalstateText(), size=size)
    ####    histograms.addText(x, 0.815, "MSSM m_{h}^{max}", size=size)
    histograms.addText(x, 0.863, scenario, size=size)
    selectiontxt = selection.replace("==", "=")
    histograms.addText(x, 0.815, selectiontxt, size=size)

    #Adding a LHC label:
    ROOT.LHCHIGGS_LABEL(0.97, 0.72, 1)
    #    histograms.addText(x, 0.55, progversion, size=size)

    plot.save()
def main(scen):
    # Create data members
    xsec = MyMinMax("xsection")
    brtaunuonly = MyMinMax("Br(Hp->taunu) alone")
    brtaunu = MyMinMax("Br(Hp->taunu)")
    brtb = MyMinMax("Br(Hp->tb)")
    myData = [xsec, brtaunuonly, brtaunu, brtb]

    # Open scenario
    myDbInputName = "%s-LHCHXSWG.root" % scen
    if not os.path.exists(myDbInputName):
        raise Exception("Error: Cannot find file '%s'!" % myDbInputName)
    db = BRXSDB.BRXSDatabaseInterface(myDbInputName, silentStatus=True)
    # Loop over mass points
    for m in myMassPoints:
        print "Scanning tan beta points for m=%s" % m
        # Loop over tan beta range
        tb = _minTanBeta
        while tb < _maxTanBeta:
            xsecminus = db.xsecUncertOrig("mHp", "tanb", "", int(m), tb, "-")
            xsecplus = db.xsecUncertOrig("mHp", "tanb", "", int(m), tb, "+")
            xsec.update(xsecplus, xsecminus)
            # taunu alone
            myDecayModeKeys = ["BR_Hp_taunu"]
            myBrUncert = db.brUncert(
                "mHp",
                "tanb",
                myDecayModeKeys,
                m,
                tb,
                linearSummation=_linearSummingForTheoryUncertainties,
                silentStatus=True)
            taunuSum = 0.0
            for k in myBrUncert.keys():
                if myDecayModeKeys[0] in k:
                    if _linearSummingForTheoryUncertainties:
                        taunuSum += myBrUncert[k]
                    else:
                        taunuSum = math.sqrt(taunuSum**2 + myBrUncert[k]**2)
            brtaunuonly.update(taunuSum, taunuSum)
            # taunu and tb uncert
            myDecayModeKeys = ["BR_Hp_taunu", "BR_Hp_tb"]
            myBrUncert = db.brUncert(
                "mHp",
                "tanb",
                myDecayModeKeys,
                m,
                tb,
                linearSummation=_linearSummingForTheoryUncertainties,
                silentStatus=True)
            taunuSum = 0.0
            tbSum = 0.0
            for k in myBrUncert.keys():
                if myDecayModeKeys[0] in k:
                    if _linearSummingForTheoryUncertainties:
                        taunuSum += myBrUncert[k]
                    else:
                        taunuSum = math.sqrt(taunuSum**2 + myBrUncert[k]**2)
                if myDecayModeKeys[1] in k:
                    if _linearSummingForTheoryUncertainties:
                        tbSum += myBrUncert[k]
                    else:
                        tbSum = math.sqrt(tbSum**2 + myBrUncert[k]**2)
            brtaunu.update(taunuSum, taunuSum)
            brtb.update(tbSum, tbSum)
            if tb < 10:
                tb += 0.1
            else:
                tb += 1
    # Print result
    print "\nTheoretical uncertainty ranges (%s):" % (scen)
    print "Linear summing of uncertainties:", _linearSummingForTheoryUncertainties
    print "Tan beta range=%.1f-%.1f" % (_minTanBeta, _maxTanBeta)
    for item in myData:
        item.output()
    print ""
    # Something in memory management leaks - the following helps dramatically to recude the leak
    ROOT.gROOT.CloseFiles()
    ROOT.gROOT.GetListOfCanvases().Delete()
    ROOT.gDirectory.GetList().Delete()
Ejemplo n.º 12
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    match = root_re.search(sys.argv[1])
    if match:
        rootfile = match.group(0)

    limits = limit.BRLimits()

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    if limit.forPaper:
        histograms.cmsTextMode = histograms.CMSMode.PAPER

    # Get BR limits

    masses = limits.mass
    brs = limits.observed

    #print masses,brs

    db = BRXSDB.BRXSDatabaseInterface(rootfile)
    for i, m in enumerate(masses):
        db.addExperimentalBRLimit(m, brs[i])


#    # SUSY parameter variations (mu, Xt, m2, mgluino, mSUSY, read from the db)

    xVariable = "mHp"
    xLabel = "m_{H^{+}} [GeV/c^{2}]"
    #    variationVariable = "mu"
    #    variationLabel    = "#mu"
    #    variationValues   = [-1000,-200,200,1000]
    #    variationVariable = "mSUSY"
    #    variationLabel    = "M_{SUSY}"
    #    variationValues   = [500,1000,2000]
    #    variationVariable = "mGluino"
    #    variationLabel    = "m_{#tilde{g}}"
    #    variationValues   = [200,800,2000]
    #    variationVariable = "m2"
    #    variationLabel    = "M_{2}"
    #    variationValues   = [200,1000]
    variationVariable = "Xt"
    variationLabel = "X_{t}"
    variationValues = [-2000, 2000]

    variationSelection = "mHp>99&&" + variationVariable + "==%s"
    plot(db, limits, xVariable, xLabel, variationVariable, variationLabel,
         variationValues, variationSelection)

    # x-axis and variation parameter definitions, y-axis=tanb
    #    xVariable = "mu"
    #    xLabel  = "#mu [GeV/c^{2}]"

    #    xVariable = "Xt"
    #    xLabel  = "X_{t} [GeV/c^{2}]"

    #    xVariable = "m2"
    #    xLabel  = "M_{2} [GeV/c^{2}]"

    #    xVariable = "mGluino"
    #    xLabel  = "m_{#tilde{g}} [GeV/c^{2}]"

    #    xVariable = "mSUSY"
    #    xLabel  = "M_{SUSY} [GeV/c^{2}]"

    xVariable = variationVariable
    xLabel = variationLabel + " [GeV/c^{2}]"

    variationVariable = "m_{H^{#pm}}"
    variationValues = [100, 120, 140, 150, 155, 160]
    #    variationValues   = [140]
    variationSelection = "mHp==%s"

    plot(db, limits, xVariable, xLabel, variationVariable, variationLabel,
         variationValues, variationSelection)
Ejemplo n.º 13
0
def main():
    if len(sys.argv) == 1:
        usage()

    rootfile = ""
    jsonfile = "limits.json"

    root_re = re.compile("(?P<rootfile>(\S*\.root))")
    json_re = re.compile("(?P<jsonfile>(\S*\.json))")
    for argv in sys.argv:
        match = root_re.search(argv)
        if match:
            rootfile = match.group(0)
        match = json_re.search(argv)
        if match:
            jsonfile = match.group(0)

    limits = limit.BRLimits(
        limitsfile=jsonfile,
        configfile="limitdata/lightHplus_configuration.json")

    # Enable OpenGL
    ROOT.gEnv.SetValue("OpenGL.CanvasPreferGL", 1)

    # Apply TDR style
    style = tdrstyle.TDRStyle()
    if limit.forPaper:
        histograms.cmsTextMode = histograms.CMSMode.PAPER
    limit.forPaper = True  # to get GeV without c^2

    # Get BR limits

    masses = limits.mass
    brs = limits.observed

    print "Observed masses and BR's"
    for i in range(len(masses)):
        print "    ", masses[i], brs[i]

    global db
    db = BRXSDB.BRXSDatabaseInterface(rootfile,
                                      program="2HDMC",
                                      BRvariable="BR_tHpb")
    for i, m in enumerate(masses):
        db.addExperimentalBRLimit(m, brs[i])

    graphs = {}
    obs = limits.observedGraph()
    # Remove blinded obs points
    for i in reversed(range(0, obs.GetN())):
        if obs.GetY()[i] < 0.00000001:
            print "    REMOVING POINT", obs.GetY(
            )[i], " corresponding mass=", obs.GetX()[i]
            obs.RemovePoint(i)
    print

    graphs["exp"] = limits.expectedGraph()
    graphs["exp1"] = limits.expectedBandGraph(sigma=1)
    graphs["exp2"] = limits.expectedBandGraph(sigma=2)

    if obs.GetN() > 0:
        graphs["obs"] = obs
        # Get theory uncertainties on observed
        obs_th_plus = limit.getObservedPlus(obs, 0.21)
        obs_th_minus = limit.getObservedMinus(obs, 0.21)
        for gr in [obs_th_plus, obs_th_minus]:
            gr.SetLineWidth(2)
            gr.SetLineStyle(9)
        graphs["obs_th_plus"] = obs_th_plus
        graphs["obs_th_minus"] = obs_th_minus

    # Remove m=80
    for gr in graphs.values():
        limit.cleanGraph(gr, minX=90)

    print "Plotting graphs"
    for key in graphs.keys():
        for i in range(graphs[key].GetN()):
            xs = graphs[key].GetX()
            ys = graphs[key].GetY()
            print "    ", key, xs[i], ys[i]
        print

    # Interpret in MSSM
    xVariable = "mHp"
    #    selection = "mu==200"
    selection = "mHp>0"
    #    scenario = "MSSM m_{h}^{max}"
    scenario = os.path.split(rootfile)[-1].replace(".root", "")

    for key in graphs.keys():
        print "Graph--------------------------------", key
        #        graphs[key] = db.graphToTanBetaCombined(graphs[key],xVariable,selection)
        graphs[key] = db.graphToTanBeta(graphs[key], xVariable, selection,
                                        False)
        print key, "done"

    graphs["mintanb"] = db.minimumTanbGraph("mHp", selection)

    doPlot("limitsTanb_light_" + scenario, graphs, limits, limit.mHplus(),
           scenario)