Ejemplo n.º 1
0
def get_Kfac(slha,pathtoslha,process):
    """
    returns the NLL K factor for a given process from NLLfast
    extracts squark and gluino masses from slha required as NLLfast input for process
    """
    msq,mgl = [str(float(a)) for a in get_sq_gl_masses(slha,pathtoslha)]
    nlloutput2 = None
    print NLL, process,msq,mgl
    if process=="st":
        print "stop pair not wrapped yet"
        nlloutput=""
    elif process=="gdcpl":
        nlloutput=runwrapper([NLL, process,mgl],path)
    elif process=="sdcpl":
        nlloutput=runwrapper([NLL, process,msq],path)
    elif process=="sqsum":
        nlloutput=runwrapper([NLL, "ss",msq,mgl],path)
        nlloutput2=runwrapper([NLL, "sb",msq,mgl],path)
    else:
        nlloutput=runwrapper([NLL, process,msq,mgl],path)
    line= nlloutput.split()
    if not line[0]=="TOO":
        sigma = float(line[-6])/1000. # in nb
        K = float(line[-1])
        if nlloutput2:
            line= nlloutput2.split()
            sigma += float(line[-6])/1000.
            print "K factor no reliable"
    else:
        K = 1.
        sigma = -1.
    return sigma,K
Ejemplo n.º 2
0
def MSSMKfaccompare(msq, mgl, pro):
    nlloutput = runwrapper([NLL, pro, "nnpdf", str(msq), str(mgl)], NLLpath)
    nnlloutput = runwrapper([NNLL, pro, str(msq), str(mgl)], NNLLpath)

    Knlo = float(nlloutput.split()[-2])  #/float(nlloutput.split()[-11])
    Knll = float(nlloutput.split()[-1])
    Knnl = float(nnlloutput.split()[-1])
    return [Knlo, Knlo * Knll, Knlo * Knnl]
Ejemplo n.º 3
0
def lhe_hepmc(lhepath,filename,tmpfile,runpath,paramfile, configfile,n):
    with open(configfile,'r') as f:
        lines = f.read()
    # appending for each SLHA file this spectrum as input and declaring to run 
    # parton shower, hadronisation simulation creating
    # the hepmc-file
    startstring = "read snippets/PPCollider.in"+"\n"+"read "+ paramfile +"\n"
    
    endstring = "set /Herwig/Analysis/HepMC:PrintEvent " + str(n) + \
        "\nset /Herwig/Generators/myLesHouchesGenerator:NumberOfEvents " + str(n) + \
        "\nset /Herwig/Generators/myLesHouchesGenerator:MaxErrors " + str(n/20) +  \
        "\nset /Herwig/EventHandlers/myReader:FileName " + lhepath + \
        "\nrun " + osp.basename(filename) +" myLesHouchesGenerator\n"
    with open(tmpfile,'w') as f:
        f.write(startstring+lines+endstring)
    runwrapper(["Herwig++", "read", tmpfile],runpath)
Ejemplo n.º 4
0
    def MRSSMKfac(msq, mgl, process=process):
        nlo = np.zeros(len(tabs))
        for pro in process:
            if pro in ["gg", "sg"]:
                if msq > 3000:
                    msqg = 3000
                else:
                    msqg = msq
                if mgl > 3000:
                    mglg = 3000
                else:
                    mglg = mgl
                nlloutput = runwrapper(
                    [NLL, pro, "mstw", str(msqg),
                     str(mglg)], NLLpath)
                nlo[-1] += float(nlloutput.split()[-11])  # LO
                nlo[:-1] += float(nlloutput.split()[-10])  #NLO
            elif pro == "ss":
                #print msq,mgl, ssgr.xsecs(msq,mgl)
                temp = np.asarray([x for x in ssgr.xsecs(msq, mgl)])
                #print temp
                nlo += temp
            elif pro == "sb":
                #print msq,mgl, sbgr.xsecs(msq,mgl)
                temp = np.asarray([x for x in sbgr.xsecs(msq, mgl)])
                #print temp
                nlo += temp

        lo = nlo[-1]
        nlo = nlo[:-1]
        return [x / lo for x in nlo]
Ejemplo n.º 5
0
def herwig_read(filename,tmpfile,runpath,paramfile, configfile, n):
    with open(configfile,'r') as f:
        lines = f.read()
    # appending for each SLHA file this spectrum as input and declaring to run 
    # full MC simulation creating
    # the hepmc-file
    startstring = "read "+ paramfile +"\n"
    
    endstring = "set /Herwig/Analysis/HepMC:PrintEvent " + str(n) + \
        "\nset /Herwig/Generators/LHCGenerator:NumberOfEvents " + str(n) + \
        "\nset /Herwig/Generators/LHCGenerator:MaxErrors " + str(n/20) +  \
        "\nset /Herwig/Generators/LHCGenerator:RandomNumberGenerator:Seed " + \
        str(randint(1,31122001)) + \
        "\nrun " + osp.basename(filename) +" LHCGenerator\n"
    with open(tmpfile+".in",'w') as f:
        f.write(startstring+lines+endstring)
    runwrapper(["Herwig++", "read", tmpfile+".in"],runpath)
Ejemplo n.º 6
0
def MSSMKfac(msq, mgl, process=["gg", "ss", "sb", "sg"]):
    lo = 0
    nlo = 0
    for pro in process:
        nlloutput = runwrapper([NLL, pro, "mstw", str(msq), str(mgl)], NLLpath)
        lo += float(nlloutput.split()[-11])
        nlo += float(nlloutput.split()[-10])
    return nlo / lo
Ejemplo n.º 7
0
def do_MG_scan(scans, process, lo=True, mu=None, pdfset=None):
    """ scans - iterable of tuples
    process - string of processname
    lo - lo or nlo
    """
    processdir = osp.join(MGpath, process)
    paramcardpath = osp.join(processdir, "Cards/param_card.dat")
    runcardpath = osp.join(processdir, "Cards/run_card.dat")
    optionpath = osp.join(processdir, "launch.txt")
    executable = ["./bin/aMCatNLO", "launch.txt"]

    if lo:
        if not pdfset:
            pdf = 25000
        else:
            pdf = pdfset
        order = "LO"
        prec = 0.001
    else:
        if not pdfset:
            pdf = 25100
        else:
            pdf = pdfset
        order = "NLO"
        prec = 0.003
    if mu:
        renorm = "True"
    else:
        renorm = "False"
        mu = [500]
    for i, scan in enumerate(scans):
        print process, order
        print scan, mu[i], pdf
        if len(scan) == 4:
            with open(paramcardpath, 'w') as f:
                f.write(paramcard_mrssm_wrapper(scan))
        elif len(scan) == 3:  # stop left and right different
            with open(paramcardpath, 'w') as f:
                f.write(paramcard_MSSM(scan))
        else:
            print "wrong number of parameters passed"
            return False
        with open(runcardpath, 'w') as f:
            if len(scans) == len(mu):
                f.write(runcard([i, pdf, prec, renorm, mu[i]]))
            elif len(mu) == 1:
                f.write(runcard([i, pdf, prec, renorm, mu[0]]))
            else:
                print 'wrong len of mu'
                return False
        with open(optionpath, 'w') as f:
            f.write(optioncard(order))
        out = runwrapper(executable, processdir)
        with open('/theoc/theoc-fs01/data/diessner/logging_mg.log', 'a') as f:
            f.write(out)
Ejemplo n.º 8
0
def NNLLKfac(msq, mgl, process=["gg", "ss", "sb", "sg"]):
    nlo = 0
    nnl = 0
    pdf = 0
    if msq > 3000:
        msq = 3000
    if mgl > 3000:
        mgl = 3000
    for pro in process:
        nlloutput = runwrapper(
            [NNLL, pro, str(msq), str(mgl)], NNLLpath).split("\n")[-2].split()
        #print nlloutput
        nnl += float(nlloutput[3])
        nlo += float(nlloutput[2])
        pdf += float(nlloutput[2]) * float(nlloutput[6]) / 100.
    pdf = pdf / nlo
    return nnl / nlo
Ejemplo n.º 9
0
def MG_run(execut,paramcard,directory):
    print execut,paramcard,directory
    runwrapper([execut, paramcard], directory)
Ejemplo n.º 10
0
def Herwig_paramcard(pegmodel, slhafile, outfile,rundir):
     runwrapper(["slha2herwig", pegmodel,slhafile,"-o", outfile],rundir)
Ejemplo n.º 11
0
def run_CM(CMpath, paramfile,path): 
    runwrapper([CMpath, paramfile],path)
Ejemplo n.º 12
0
def herwig_run(filename, runpath,n):
    out = runwrapper(["Herwig++", "run", filename+".run", "-N"+str(n),"-d2"]
                     ,runpath)
    with open(osp.join(runpath,"Hlog.txt")) as f:
        f.write(out)