Ejemplo n.º 1
0
        params(name).value = value

    for val in np.linspace(-1,1,21):
        directory, paramfile = get_dir(par,val)
        subprocess.call(["mkdir","-p",directory])
        params("signal_dt_" + par).value = val
        params.save(paramfile)

for i in range(nexp):
    for par in cpv_pars:
        for val in np.linspace(-1,1,21):
            directory, paramfile = get_dir(par,val)
            output = os.path.join(directory,"%03d" % i)
            toymc.add_job(output, paramfile, genflags, fitflags, data, templates)

results = toymc.run_jobs()

for pfile in results:
    params.load(pfile)
    par, val = get_par(pfile)
    pindex = cpv_params.index("signal_dt_"+par)
    p_input = cpv_input[:]
    p_input[pindex] = val
    for i,(param,initial) in enumerate(zip(cpv_params,p_input)):
        p = params(param)
        histograms[par][i].Fill(val, p.value)
        histograms[par+"_pull"][i].Fill(val, (p.value-initial)/p.error)

rfile.Write()
rfile.Close()
Ejemplo n.º 2
0
        if not os.path.exists(paramfile):
            #for name, irange in zip(lintest_params, lintest_irange):
            #    if irange is None: continue
            #    params(name).value = random.uniform(*irange)
            Jc,Js1,Js2 = get_random_cp()
            br = random.uniform(*lintest_irange[3])
            #f1, f2 = [random.uniform(*e) for e in lintest_irange[-2:]]
            for name, value in zip(lintest_params, [Jc,Js1,Js2,br]):#,f1,f2]):
                params(name).value = value

            subprocess.call(["mkdir", "-p", directory])
            params.save(paramfile)

        toymc.add_job(output, paramfile, genflags, fitflags1, fitflags2, data, templates)

    results = toymc.run_jobs(False, True)

    pinput = dspdsmks.Parameters()

    for pfile in results:
        params.load(pfile)
        pinput.load(os.path.splitext(pfile)[0] + ".in")
        for par in lintest_params:
            p = params(par)
            initial = pinput(par)
            if isinstance(histograms[par], root.TH2D):
                histograms[par].Fill(initial.value, p.value)
                histograms[par+"_pull"].Fill(initial.value, (p.value-initial.value)/p.error)
            else:
                histograms[par].Fill(p.value)
                histograms[par+"_pull"].Fill((p.value-initial.value)/p.error)