Exemplo n.º 1
0
    def compute(self,
                sqrts,
                slhafile,
                lhefile=None,
                unlink=True,
                loFromSlha=None,
                pythiacard=None):
        """
        Run pythia and compute SUSY cross sections for the input SLHA file.

        :param sqrts: sqrt{s} to run Pythia, given as a unum (e.g. 7.*TeV)
        :param slhafile: SLHA file
        :param lhefile: LHE file. If None, do not write pythia output to file. If
                        file does not exist, write pythia output to this file name. If
                        file exists, read LO xsecs from this file (does not run pythia).
        :param unlink: Clean up temp directory after running pythia

        :param loFromSlha: If True, uses the LO xsecs from the SLHA file to compute the
                           higher order xsecs
        :param pythiaCard: Optional path to pythia.card. If None, uses /etc/pythia.card

        :returns: XSectionList object

        """
        sqrts = self._checkSqrts(sqrts)
        self._checkSLHA(slhafile)

        if lhefile:
            if os.path.isfile(lhefile):
                logger.warning("Using LO cross sections from " + lhefile)
                logger.error(
                    "Cross section retrieval from lhefile currently not implemented"
                )
                sys.exit()
            else:
                logger.info("Writing pythia LHE output to " + lhefile)
        if loFromSlha:
            logger.info("Using LO cross sections from " + slhafile)
            xsecsInfile = crossSection.getXsecFromSLHAFile(slhafile)
            loXsecs = crossSection.XSectionList()
            for xsec in xsecsInfile:
                if xsec.info.order == 0 and xsec.info.sqrts == sqrts:
                    loXsecs.add(xsec)

        else:
            logger.info("get LO cross sections from pythia%d" %
                        self.pythiaVersion)
            tool = toolBox.ToolBox().get("pythia%d" % self.pythiaVersion)
            tool.nevents = self.nevents
            tool.sqrts = sqrts / TeV
            tool.pythiacard = pythiacard
            loXsecs = tool.run(slhafile, lhefile, unlink=unlink)
        self.loXsecs = loXsecs
        self.loXsecs.sort()
        self.xsecs = self.addHigherOrders(sqrts, slhafile)
        self.xsecs.sort()
        #for xsec in self.loXsecs:
        #    logger.debug ( "now writing out xsecs: %s" % xsec.value )
        logger.debug("how many NLL xsecs? %d" % len(self.xsecs))
        return self.xsecs
Exemplo n.º 2
0
    def addHigherOrders(self, sqrts, slhafile):
        """ add higher order xsecs """
        xsecs = copy.deepcopy(self.loXsecs)
        wlabel = str(int(sqrts / TeV)) + ' TeV'
        if self.maxOrder == LO:
            wlabel += ' (LO)'
        elif self.maxOrder == NLO:
            wlabel += ' (NLO)'
        elif self.maxOrder == NLL:
            wlabel += ' (NLO+NLL)'
        for ixsec, xsec in enumerate(xsecs):
            xsecs[ixsec].info.label = wlabel
            xsecs[ixsec].info.order = self.maxOrder

        if self.maxOrder > 0:
            pIDs = self.loXsecs.getPIDpairs()
            nllfast = toolBox.ToolBox().get("nllfast%d" % sqrts.asNumber(TeV))
            nllfast.maycompile = self.maycompile
            for pID in pIDs:
                k = 0.
                kNLO, kNLL = nllfast.getKfactorsFor(pID, slhafile)
                if self.maxOrder == NLO and kNLO:
                    k = kNLO
                elif self.maxOrder == NLL and kNLL and kNLO:
                    k = kNLO * kNLL
                elif self.maxOrder > 2 and kNLL and kNLO:
                    logger.warning(
                        "Unkown xsec order, using NLL+NLO k-factor, "
                        "if available")
                    k = kNLO * kNLL
                k = float(k)
                for i, xsec in enumerate(xsecs):
                    if set(xsec.pid) == set(pID):
                        # Apply k-factor
                        xsecs[i] = xsec * k

        # Remove zero cross sections
        while len(xsecs) > 0 and xsecs.getMinXsec() == 0. * pb:
            for xsec in xsecs:
                if xsec.value == 0. * pb:
                    xsecs.delete(xsec)
                    break
        if self.maxOrder > 0 and len(xsecs) == 0:
            self.countNoNLOXSecs += 1
            if self.countNoNLOXSecs < 3:
                logger.warning("No NLO or NLL cross sections available.")
            if self.countNoNLOXSecs == 3:
                logger.warning(
                    "No NLO or NLL cross sections available (will quench such warnings in future)."
                )

        #for i in xsecs:
        #    logger.error ( "xsec=%s (%s)" % (i,type(i)) )
        return xsecs
Exemplo n.º 3
0
class XSecTest(unittest.TestCase):
    # use different logging config for the unit tests.

    toolBox.ToolBox().compile() ## make sure the tools are compiled

    def testLOGlu(self):
        """ test the computation of LO cross section and compare with pythia6 """

        slhafile  = "./testFiles/slha/gluino_squarks.slha"
        computer6 = xsecComputer.XSecComputer(LO, Nevents, 6)
        computer8 = xsecComputer.XSecComputer(LO, Nevents, 8)
        w6 = computer6.compute(8*TeV, slhafile).getDictionary()
        w8 = computer8.compute(8*TeV, slhafile, pythiacard = './pythia8_to_pythia6.cfg').getDictionary()
        self.assertEqual(compareXSections(w6, w8,Nevents),True) 
        slhafile  = "./testFiles/slha/lightEWinos.slha"
        computer6 = xsecComputer.XSecComputer(LO, Nevents, 6)
        computer8 = xsecComputer.XSecComputer(LO, Nevents, 8)
        w6 = computer6.compute(8*TeV, slhafile).getDictionary()
        w8 = computer8.compute(8*TeV, slhafile, pythiacard = './pythia8_to_pythia6.cfg').getDictionary()
        self.assertEqual(compareXSections(w6, w8,Nevents),True) 
Exemplo n.º 4
0
def getKfactorsFor(pIDs, sqrts, slhafile, pdf='cteq'):
    """
    Read the NLLfast grid and returns a pair of k-factors (NLO and NLL) for the
    pair.

    :returns: k-factors = None, if NLLfast does not contain the process; uses
              the slhafile to obtain the SUSY spectrum.
    
    """
    if not os.path.isfile(slhafile):
        logger.error("SLHA file %s not found", slhafile)
        return False

    # Get process name (in NLLfast notation)
    process = getProcessName(pIDs)
    if not process:
        # Return k-factors = None, if NLLfast does not have the process
        return (None, None)

    # Obtain relevant masses
    readfile = pyslha.readSLHAFile(slhafile)
    masses = readfile.blocks['MASS']
    check_pids = squarks + gluinos + third
    for check in check_pids:
        if not check in masses.entries:
            logger.error ( "cannot compute k factor for pdgid %d: " \
              " no particle mass given. will set mass to inf." % check )
            masses.entries[check] = 1.e10

    gluinomass = abs(masses.entries[1000021])
    squarkmass = sum([abs(masses.entries[pid]) for pid in squarks]) / 8.
    pid1, pid2 = sorted(pIDs)
    if pid1 in antisquarks and pid2 in squarks:
        squarkmass = (abs(masses.entries[abs(pid1)]) +
                      abs(masses.entries[pid2])) / 2.
    elif pid1 in squarks and pid2 in squarks:
        squarkmass = (abs(masses.entries[pid1]) +
                      abs(masses.entries[pid2])) / 2.
    elif abs(pid1) == pid2 and pid2 in third:
        squarkmass = abs(masses.entries[abs(pid1)])

    # Set up NLLfast run, the old way
    sqrtS = float(sqrts / TeV)
    energy = str(int(sqrtS)) + 'TeV'
    toolname = "nllfast%d" % int(sqrtS)
    box = toolBox.ToolBox()
    tool = box.get(toolname)
    if tool == None:
        logger.warning("No NLLfast data for sqrts = " + str(sqrts))
        return (None, None)
    nllpath = tool.installDirectory()
    tool.pathOfExecutable()
    tool.checkInstallation()
    if process == "st":
        nll_run = "./nllfast_" + energy + " %s %s %s" % \
                  (process, pdf, squarkmass)
    else:
        nll_run = "./nllfast_" + energy + " %s %s %s %s" % \
                  (process, pdf, squarkmass, gluinomass)

    # Run NLLfast
    nll_output = runNLLfast(nll_run, nllpath)

    # If run was successful, return k-factors:
    if "K_NLO" in nll_output:
        # NLLfast ran ok, try to get the k-factors
        kFacs = getKfactorsFrom(nll_output)
        if not kFacs or min(kFacs) <= 0.:
            logger.warning("Error obtaining k-factors")
            return (None, None)
        else:
            return kFacs
    # If run was not successful, check for decoupling error messages:
    elif not "too low/high" in nll_output.lower():
        logger.warning("Error running NLLfast")
        return (None, None)

    # Check for decoupling cases with a decoupling grid (only for sb and gg)
    doDecoupling = False
    if "too low/high gluino" in nll_output.lower():
        if gluinomass > 500. and process == 'sb':
            doDecoupling = True
            dcpl_mass = gluinomass
    elif "too low/high squark" in nll_output.lower():
        if squarkmass > 500. and process == 'gg':
            doDecoupling = True
            dcpl_mass = squarkmass

    # If process do not have decoupled grids, return None:
    if not doDecoupling:
        logger.warning("Masses out of NLLfast grid for " + process)
        return (None, None)

    # Obtain k-factors from the NLLfast decoupled grid
    kfacs = getDecoupledKfactors(nllpath, process, energy, pdf,
                                 min(gluinomass, squarkmass))
    # Decoupling limit is satisfied, do not interpolate
    if not kfacs:
        logger.warning(
            "Error obtaining k-factors from the NLLfast decoupled grid for " +
            process)
        return (None, None)
    elif dcpl_mass / min(gluinomass, squarkmass) > 10.:
        return kfacs
    # Interpolate between the non-decoupled and decoupled grids
    else:
        kFacsVector = [[10. * min(gluinomass, squarkmass), kfacs]
                       ]  #First point for interpolation (decoupled grid)
        kfacs = None
        while not kfacs and dcpl_mass > 500.:
            dcpl_mass -= 100.  # Reduce decoupled mass, until NLLfast produces results
            if process == 'sb':
                nllinput = (process, pdf, squarkmass, dcpl_mass)
            else:
                nllinput = (process, pdf, dcpl_mass, gluinomass)
            nll_run = "./nllfast_" + energy + " %s %s %s %s" % nllinput
            nll_output = runNLLfast(nll_run, nllpath)
            kfacs = getKfactorsFrom(nll_output)
        kFacsVector.append(
            [dcpl_mass,
             kfacs])  #Second point for interpolation (non-decoupled grid)

    if len(kFacsVector) < 2:
        logger.warning("Not enough points for interpolation in the decoupling "
                       "limit")
        return (None, None)
    else:
        # Interpolate k-factors
        kFacs = interpolateKfactors(kFacsVector, max(squarkmass, gluinomass))
    return kFacs
Exemplo n.º 5
0
class XSecTest(unittest.TestCase):
    # use different logging config for the unit tests.
    logging.config.fileConfig( "./logging.conf" )
    from smodels.tools.smodelsLogging import setLogLevel,logger
    
    setLogLevel ( "warn" )

    toolBox.ToolBox().compile() ## make sure the tools are compiled

    def testLOGlu(self):
        """ test the computation of LO cross section, pythia6 """
        self.logger.info ( "test LO xsecs @ 8 TeV" )
        slhafile= "./testFiles/slha/simplyGluino.slha"
        computer = xsecComputer.XSecComputer ( LO, 2000, 6 )
        w = computer.compute(8*TeV, slhafile ).getDictionary()
        # print ( w )
        w8lo= w[(1000021, 1000021)]['8 TeV (LO)'].asNumber( fb )
        self.assertAlmostEqual(w8lo/264., 1., 2 ) 

    def testNLLGlu(self):
        """ test the computation of NLL cross section """
        self.logger.info ( "test NLL xsecs @ 8 TeV" )
        slhafile="./testFiles/slha/simplyGluino.slha"
        computer = xsecComputer.XSecComputer ( NLL, 2000, 6 )
        w = computer.compute( 8*TeV, slhafile ).getDictionary()
        w8nll= w[(1000021, 1000021)]['8 TeV (NLO+NLL)'].asNumber( fb )
        self.assertAlmostEqual(w8nll / 573., 1., 2 )

    def testLOGlu13(self):
        """ test the computation of LO cross section, pythia6 """
        self.logger.info ( "test LO xsecs @ 13 TeV" )
        slhafile="./testFiles/slha/simplyGluino.slha"
        computer = xsecComputer.XSecComputer ( LO, 3000, 6 )
        w = computer.compute( 13*TeV, slhafile ).getDictionary()
        w13lo= w[(1000021, 1000021)]['13 TeV (LO)'].asNumber( fb )
        self.assertAlmostEqual(w13lo / 2237., 1., 1 )

    def testNLLGlu13(self):
        """ test the computation of NLL cross section with pythia6 """
        self.logger.info ( "test NLL xsecs @ 13 TeV" )
        slhafile="./testFiles/slha/simplyGluino.slha"
        computer = xsecComputer.XSecComputer ( NLL, 3000, 6 )
        w = computer.compute( 13*TeV, slhafile ).getDictionary()
        w13nll= w[(1000021, 1000021)]['13 TeV (NLO+NLL)'].asNumber( fb )
        self.assertAlmostEqual(w13nll / 4320. , 1., 2 )
        
    def testXSecMain(self):
        """ test the main routine for computation of LO and NLL cross section for several sqrts"""
        
        slhafile="./testFiles/slha/simplyGluino.slha"
        f = open(slhafile,'r')
        fdata = f.read()
        fdata = fdata[:fdata.find('XSECTION')]
        f.close()
        fnew = tempfile.mkstemp()
        os.close(fnew[0])
        tmpfile = fnew[1]
        fnew = open(tmpfile,'w')
        fnew.write(fdata)
        fnew.close()        
        self.logger.info ("test NLL xsecs @ 8 and 13 TeV" )
        #Set overall options:
        #Options for cross section calculation:
        xargs = argparse.Namespace()
        xargs.sqrts = [[8.,13.]]
        xargs.ncpus = 1
        xargs.noautocompile = True
        xargs.nevents = 2000
        #Compute LO xsecs:
        xargs.query = False
        xargs.NLL = False
        xargs.NLO = False
        xargs.LOfromSLHA = False
        xargs.keep = False
        xargs.tofile = True
        xargs.alltofile = False
        xargs.pythia6 = True
        xargs.filename = tmpfile
        xargs.colors = False
        xargs.ssmultipliers = None
        xargs.verbosity = "warning"
        #Compute LO cross sections
        xsecComputer.main(xargs)
        #Compute NLL cross sections
        xargs.NLL = True
        xargs.LOfromSLHA = True
        xsecComputer.main(xargs)
        #Read xsecs:
        xsecsInfile = crossSection.getXsecFromSLHAFile(tmpfile)
        os.remove(tmpfile)
        
        #Check 8 TeV xsecs:
        lo = xsecsInfile.getXsecsFor('8 TeV (LO)')[0].value.asNumber(fb)
        nll = xsecsInfile.getXsecsFor('8 TeV (NLL)')[0].value.asNumber(fb)
        self.assertAlmostEqual(lo/264.,1.,2)
        self.assertAlmostEqual(nll/573.6,1.,2)
        #Check 13 TeV xsecs:
        lo = xsecsInfile.getXsecsFor('13 TeV (LO)')[0].value.asNumber(fb)
        nll = xsecsInfile.getXsecsFor('13 TeV (NLL)')[0].value.asNumber(fb)
        self.assertAlmostEqual(lo / 2230., 1., 1 )
        self.assertAlmostEqual(nll / 4308., 1., 1 )

    def testSSMultipliers(self):
        """ test the signal strength multipliers """
        
        slhafile="./testFiles/slha/simplyGluino.slha"
        f = open(slhafile,'r')
        fdata = f.read()
        fdata = fdata[:fdata.find('XSECTION')]
        f.close()
        fnew = tempfile.mkstemp()
        os.close(fnew[0])
        tmpfile = fnew[1]
        fnew = open(tmpfile,'w')
        fnew.write(fdata)
        fnew.close()        
        self.logger.info ("test NLL xsecs @ 8 and 13 TeV" )
        #Set overall options:
        #Options for cross section calculation:
        xargs = argparse.Namespace()
        xargs.sqrts = [[8.,13.]]
        xargs.ncpus = 1
        xargs.noautocompile = True
        xargs.nevents = 5000
        #Compute LO xsecs:
        xargs.query = False
        xargs.NLL = False
        xargs.NLO = False
        xargs.LOfromSLHA = False
        xargs.keep = False
        xargs.tofile = True
        xargs.alltofile = False
        xargs.pythia6 = True
        xargs.filename = tmpfile
        xargs.colors = False
        xargs.ssmultipliers = { (1000021,1000021): 4. }
        # xargs.ssmultipliers = { 1000021: 2. }
        xargs.verbosity = "warning"
        #Compute LO cross sections
        xsecComputer.main(xargs)
        #Compute NLL cross sections
        xargs.NLL = True
        xargs.LOfromSLHA = True
        xsecComputer.main(xargs)
        #Read xsecs:
        xsecsInfile = crossSection.getXsecFromSLHAFile(tmpfile)
        os.remove(tmpfile)
        
        #Check 8 TeV xsecs:
        lo = xsecsInfile.getXsecsFor('8 TeV (LO)')[0].value.asNumber(fb)
        nll = xsecsInfile.getXsecsFor('8 TeV (NLL)')[0].value.asNumber(fb)
        self.assertAlmostEqual(lo/1058.444,1.,1)
        self.assertAlmostEqual(nll/2299.046,1.,1)
        #Check 13 TeV xsecs:
        lo = xsecsInfile.getXsecsFor('13 TeV (LO)')[0].value.asNumber(fb)
        nll = xsecsInfile.getXsecsFor('13 TeV (NLL)')[0].value.asNumber(fb)
        self.assertAlmostEqual(lo/8910.76,1.,1 )
        self.assertAlmostEqual(nll/17215.5906, 1.,1)
        
    def testSSJokers(self):
        """ test the signal strength multipliers, with jokers """
        
        slhafile="./testFiles/slha/simplyGluino.slha"
        f = open(slhafile,'r')
        fdata = f.read()
        fdata = fdata[:fdata.find('XSECTION')]
        f.close()
        fnew = tempfile.mkstemp()
        os.close(fnew[0])
        tmpfile = fnew[1]
        fnew = open(tmpfile,'w')
        fnew.write(fdata)
        fnew.close()        
        self.logger.info ("test NLL xsecs @ 8 and 13 TeV" )
        #Set overall options:
        #Options for cross section calculation:
        xargs = argparse.Namespace()
        xargs.sqrts = [[8.,13.]]
        xargs.noautocompile = True
        xargs.ncpus = 1
        xargs.nevents = 5000
        #Compute LO xsecs:
        xargs.query = False
        xargs.NLL = False
        xargs.NLO = False
        xargs.LOfromSLHA = False
        xargs.keep = False
        xargs.tofile = True
        xargs.alltofile = False
        xargs.pythia6 = True
        xargs.filename = tmpfile
        xargs.colors = False
        xargs.ssmultipliers = { ('*100002?','*1000021'): 4. }
        # xargs.ssmultipliers = { 1000021: 2. }
        xargs.verbosity = "warning"
        #Compute LO cross sections
        xsecComputer.main(xargs)
        #Compute NLL cross sections
        xargs.NLL = True
        xargs.LOfromSLHA = True
        xsecComputer.main(xargs)
        #Read xsecs:
        xsecsInfile = crossSection.getXsecFromSLHAFile(tmpfile)
        os.remove(tmpfile)
        
        #Check 8 TeV xsecs:
        lo = xsecsInfile.getXsecsFor('8 TeV (LO)')[0].value.asNumber(fb)
        nll = xsecsInfile.getXsecsFor('8 TeV (NLL)')[0].value.asNumber(fb)
        self.assertAlmostEqual(lo/1056.,1.,2)
        self.assertAlmostEqual(nll/2294.,1.,2)
        #Check 13 TeV xsecs:
        lo = xsecsInfile.getXsecsFor('13 TeV (LO)')[0].value.asNumber(fb)
        nll = xsecsInfile.getXsecsFor('13 TeV (NLL)')[0].value.asNumber(fb)
        self.assertAlmostEqual(lo/8910.76,1.,2 )
        self.assertAlmostEqual(nll/17215.5906, 1.,1)
Exemplo n.º 6
0
 def testToolBox(self):
     self.logger.info("ToolBox")
     box = toolBox.ToolBox()
     ok = box.checkInstallation(make=True, printit=False)
     self.assertTrue(ok)
Exemplo n.º 7
0
class XSecTest(unittest.TestCase):
    # use different logging config for the unit tests.
    logging.config.fileConfig( "./logging.conf" )
    from smodels.tools.smodelsLogging import setLogLevel,logger
    
    setLogLevel ( "warn" )

    toolBox.ToolBox().compile() ## make sure the tools are compiled

    def testLOGlu(self):
        """ test the computation of LO cross section, pythia6 """
        self.logger.info ( "test LO xsecs @ 8 TeV" )
        slhafile= "./testFiles/slha/simplyGluino.slha"
        computer = xsecComputer.XSecComputer ( LO, 100, 6 )
        w = computer.compute(8*TeV, slhafile ).getDictionary()
        # print ( w )
        w8lo= w[(1000021, 1000021)]['8 TeV (LO)'].asNumber( fb )
        self.assertAlmostEqual(w8lo, 268.2255 ) 

    def testNLLGlu(self):
        """ test the computation of NLL cross section """
        self.logger.info ( "test NLL xsecs @ 8 TeV" )
        slhafile="./testFiles/slha/simplyGluino.slha"
        computer = xsecComputer.XSecComputer ( NLL, 100, 6 )
        w = computer.compute( 8*TeV, slhafile ).getDictionary()
        w8nll= w[(1000021, 1000021)]['8 TeV (NLO+NLL)'].asNumber( fb )
        self.assertAlmostEqual(w8nll, 582.61261, 4 )

    def testLOGlu13(self):
        """ test the computation of LO cross section, pythia6 """
        self.logger.info ( "test LO xsecs @ 13 TeV" )
        slhafile="./testFiles/slha/simplyGluino.slha"
        computer = xsecComputer.XSecComputer ( LO, 100, 6 )
        w = computer.compute( 13*TeV, slhafile ).getDictionary()
        w13lo= w[(1000021, 1000021)]['13 TeV (LO)'].asNumber( fb )
        self.assertAlmostEqual(w13lo, 2240.7303 )

    def testNLLGlu13(self):
        """ test the computation of NLL cross section with pythia6 """
        self.logger.info ( "test NLL xsecs @ 13 TeV" )
        slhafile="./testFiles/slha/simplyGluino.slha"
        computer = xsecComputer.XSecComputer ( NLL, 100, 6 )
        w = computer.compute( 13*TeV, slhafile ).getDictionary()
        w13nll= w[(1000021, 1000021)]['13 TeV (NLO+NLL)'].asNumber( fb )
        self.assertAlmostEqual(w13nll, 4329.091, 3 )
        
    def testXSecMain(self):
        """ test the main routine for computation of LO and NLL cross section for several sqrts"""
        
        slhafile="./testFiles/slha/simplyGluino.slha"
        f = open(slhafile,'r')
        fdata = f.read()
        fdata = fdata[:fdata.find('XSECTION')]
        f.close()
        fnew = tempfile.mkstemp()
        os.close(fnew[0])
        tmpfile = fnew[1]
        fnew = open(tmpfile,'w')
        fnew.write(fdata)
        fnew.close()        
        self.logger.info ("test NLL xsecs @ 8 and 13 TeV" )
        #Set overall options:
        #Options for cross section calculation:
        xargs = argparse.Namespace()
        xargs.sqrts = [[8.,13.]]
        xargs.ncpus = 1
        xargs.nevents = 100
        #Compute LO xsecs:
        xargs.query = False
        xargs.NLL = False
        xargs.NLO = False
        xargs.LOfromSLHA = False
        xargs.keep = False
        xargs.tofile = True
        xargs.alltofile = False
        xargs.pythia6 = True
        xargs.filename = tmpfile
        xargs.colors = False
        xargs.verbosity = "warning"
        #Compute LO cross sections
        xsecComputer.main(xargs)
        #Compute NLL cross sections
        xargs.NLL = True
        xargs.LOfromSLHA = True
        xsecComputer.main(xargs)
        #Read xsecs:
        xsecsInfile = crossSection.getXsecFromSLHAFile(tmpfile)
        os.remove(tmpfile)
        
        #Check 8 TeV xsecs:
        lo = xsecsInfile.getXsecsFor('8 TeV (LO)')[0].value.asNumber(fb)
        nll = xsecsInfile.getXsecsFor('8 TeV (NLL)')[0].value.asNumber(fb)
        self.assertAlmostEqual(lo,268.2255,3)
        self.assertAlmostEqual(nll,582.612609,3)
        #Check 13 TeV xsecs:
        lo = xsecsInfile.getXsecsFor('13 TeV (LO)')[0].value.asNumber(fb)
        nll = xsecsInfile.getXsecsFor('13 TeV (NLL)')[0].value.asNumber(fb)
        self.assertAlmostEqual(lo,2240.7303,2 )
        self.assertAlmostEqual(nll,4329.09094,2)
Exemplo n.º 8
0
 def testWeakino8(self):
     tool = toolBox.ToolBox().get("nllfast13")
     o = tool.getKfactorsFor((1000022, 1000022),
                             "./testFiles/slha/complicated.slha")
     self.assertEqual(o[0], None)
     self.assertEqual(o[1], None)
Exemplo n.º 9
0
 def testSquark13(self):
     tool = toolBox.ToolBox().get("nllfast13")
     o = tool.getKfactorsFor((1000001, 1000001),
                             "%sgluino_squarks.slha" % path)
     self.assertAlmostEqual(o[0], 1.24)
     self.assertAlmostEqual(o[1], 1.01)
Exemplo n.º 10
0
 def testGluino7(self):
     tool = toolBox.ToolBox().get("nllfast7")
     o = tool.getKfactorsFor((1000021, 1000021),
                             "%ssimplyGluino.slha" % path)
     self.assertAlmostEqual(o[0], 2.1)
     self.assertAlmostEqual(o[1], 1.08)
Exemplo n.º 11
0
def runPythia(slhafile,
              nevts,
              sqrts,
              lhefile=None,
              unlink=True,
              pythiacard=None):
    """
    Execute pythia_lhe with n events, at sqrt(s)=sqrts.

    :param slhafile: input SLHA file
    :param nevts: number of events to be generated
    :param sqrts: center of mass sqrt{s} (in TeV)
    :param lhefile: option to write LHE output to file; ff None, do not write
                    output to disk.
    :param unlink: Clean up temp directory after running pythia
    :param pythiaCard: Optional path to pythia.card. If None, uses /etc/pythia.card
    
    :returns: file object with the LHE events

    """
    box = toolBox.ToolBox()
    tool = box.get("pythia6")
    #Change pythia card, if defined:
    if pythiacard:
        pythiacard_default = tool.cfgfile
        tool.cfgfile = pythiacard
    # Check if template config file exists
    tool.unlink()
    tool.replaceInCfgFile({"NEVENTS": nevts, "SQRTS": 1000 * sqrts})
    tool.setParameter("MSTP(163)", "6")

    if unlink == False:
        logger.info("keeping temporary directory at %s" % tool.tempDirectory())
    r = tool.checkInstallation()
    if r == False:
        logger.info("Installation check failed.")
        sys.exit()
    #logger.info ( "cfgfile=%s" % tool.cfgfile )
    #logger.info ( "executable=%s" % tool.executable )
    #logger.info ( "tempdir=%s" % tool.tempdir )
    #logger.info ( "nevents=%s" % tool.nevents )
    tool.replaceInCfgFile({"NEVENTS": nevts, "SQRTS": 1000 * sqrts})
    tool.setParameter("MSTP(163)", "6")
    lhedata = tool.run(slhafile, do_check=False, do_unlink=unlink)
    if not "<LesHouchesEvents" in lhedata:
        pythiadir = "%s/log" % tool.tempDirectory()
        logger.error("No LHE events found in pythia output %s" % pythiadir)
        if not os.path.exists(pythiadir):
            logger.error("Will dump pythia output to %s" % pythiadir)
            f = open(pythiadir, "w")
            for line in lhedata:
                f.write(line)
            f.close()
        raise SModelSError("No LHE events found in %s" % pythiadir)

    #Reset pythia card to its default value
    if pythiacard:
        tool.cfgfile = pythiacard_default

    # Generate file object with lhe events
    if lhefile:
        lheFile = open(lhefile, 'w')
        lheFile.write(lhedata)
        lheFile.close()
        lheFile = open(lhefile, 'r')
    else:
        # Create memory only file object
        lheFile = io.StringIO(lhedata)

    return lheFile
Exemplo n.º 12
0
 def getPythia(self):
     """ returns the pythia tool that is configured to be used """
     ret = toolBox.ToolBox().get("pythia%d" % self.pythiaVersion)
     ret.maycompile = self.maycompile
     return ret