コード例 #1
0
def theta_limit_madminer(xsec=0.001,
                         lumi=1000000.0,
                         effect_phys=0.1,
                         effect_sys=0.1):
    # Set up MadMiner file
    miner = MadMiner()
    miner.add_parameter(
        lha_block="no one cares",
        lha_id=12345,
        parameter_name="theta",
        morphing_max_power=1,
        parameter_range=(-1.0, 1.0),
    )
    miner.add_benchmark({"theta": 0.0})
    miner.add_benchmark({"theta": 1.0})
    miner.set_morphing(include_existing_benchmarks=True, max_overall_power=1)
    miner.save(".data.h5")

    # Set up observations
    proc = LHEProcessor(".data.h5")
    proc.add_observable("x", "no one cares")
    proc.reference_benchmark = "benchmark_0"
    proc.nuisance_parameters = OrderedDict()
    proc.nuisance_parameters["nu"] = ("benchmark_nuisance", None)
    proc.observations = OrderedDict()
    proc.observations["x"] = np.array([1.0])
    proc.weights = OrderedDict()
    proc.weights["benchmark_0"] = np.array([xsec])
    proc.weights["benchmark_1"] = np.array([xsec * (1.0 + effect_phys)])
    proc.weights["benchmark_nuisance"] = np.array([xsec * (1.0 + effect_sys)])
    proc.save(".data2.h5")

    # Calculate Fisher information
    fisher = FisherInformation(".data2.h5")
    info, cov = fisher.calculate_fisher_information_full_truth(theta=np.array(
        [0.0]),
                                                               luminosity=lumi)
    constraint = fisher.calculate_fisher_information_nuisance_constraints()
    info = info + constraint
    profiled = profile_information(info, [0])

    # Uncertainty on theta
    theta_limit = profiled[0, 0]**-0.5

    # Remove file
    os.remove(".data.h5")
    os.remove(".data2.h5")

    return theta_limit
コード例 #2
0
            print('Number of benchmark parameters does not match number of global parameters in input file')
            raise e
    
    #add       
    miner.add_benchmark(
    dict_of_parameters_this_benchmark,
    benchmark['name']
    )

###########

#SET morphing
settings = dict_all['set_morphing']
print(settings['max_overall_power'])
miner.set_morphing(
    include_existing_benchmarks=True,
    max_overall_power=int(settings['max_overall_power'])
)


#fig = plot_2d_morphing_basis(
#    miner.morpher,
#    xlabel=r'$c_{W} v^2 / \Lambda^2$',
#    ylabel=r'$c_{\tilde{W}} v^2 / \Lambda^2$',
#    xrange=(-10.,10.),
#    yrange=(-10.,10.)
#)

miner.save('/madminer/data/madminer_example.h5')