Exemple #1
0
def get_one_event(config='w.config', random_state=1, gen_params=None, **kwargs):
    gen_params = gen_params or dict()
    gen_params.setdefault('verbosity', 0)
    gen_input = get_generator_input('pythia', config,
                                    random_state=random_state,
                                    **gen_params)
    return list(cluster(generate_events(gen_input, ignore_weights=True), 1, **kwargs))[0]
Exemple #2
0
def get_one_event_reco(pythia_config='w.config', pythia_random_state=1, delphes_random_state=1,
                       gen_params=None, delphes_params=None, **kwargs):
    gen_params = gen_params or dict()
    gen_params.setdefault('verbosity', 0)
    delphes_params = delphes_params or dict()
    gen_input = get_generator_input('pythia', pythia_config,
                                    random_state=pythia_random_state,
                                    **gen_params)
    return list(cluster(reconstruct(generate_events(gen_input, ignore_weights=True),
                                    random_state=delphes_random_state, **delphes_params),
                                    1, **kwargs))[0]
Exemple #3
0
def test_hdf5_vs_direct_hepmc():
    testfile = get_filepath('sherpa_wz.hepmc')

    with tempfile.NamedTemporaryFile() as tmp:
        with h5.File(tmp.name, 'w') as h5output:
            create_event_datasets(h5output, 1)
            h5output['events'][0] = list(generate_events(HepMCInput(testfile), 1))[0]
        h5input = h5.File(tmp.name, 'r')
        jets = list(cluster(reconstruct(h5input['events'], random_state=1)))[0]
    jets_direct = list(cluster(reconstruct(HepMCInput(testfile), random_state=1)))[0]

    assert_equal(jets.jets[0]['pT'], jets_direct.jets[0]['pT'])
Exemple #4
0
def test_hdf5_vs_direct_pythia():
    testfile = get_filepath('pythia_wz.config')

    with tempfile.NamedTemporaryFile() as tmp:
        with h5.File(tmp.name, 'w') as h5output:
            create_event_datasets(h5output, 1)
            h5output['events'][0] = list(
                generate_events(
                    get_generator_input('pythia', testfile, verbosity=0,
                                        random_state=1), 1, ignore_weights=True))[0]
        h5input = h5.File(tmp.name, 'r')
        jets = list(cluster(reconstruct(h5input['events'], random_state=1)))[0]
    jets_direct = list(
        cluster(
            reconstruct(
                generate_events(
                    get_generator_input('pythia', testfile, verbosity=0,
                                        random_state=1), 1, ignore_weights=True), random_state=1)))[0]

    assert_true(jets.jets[0]['pT'] > 0)
    assert_equal(jets.jets[0]['pT'], jets_direct.jets[0]['pT'])
def generate_event(renorm_fac=1., factor_fac=1., random_state=1):
    # generate one event
    gen_input = get_generator_input('pythia',
                                    'w.config',
                                    random_state=random_state,
                                    verbosity=0,
                                    params_dict={
                                        'PhaseSpace:pTHatMin': 250,
                                        'PhaseSpace:pTHatMax': 300,
                                        'SigmaProcess:renormMultFac':
                                        renorm_fac,
                                        'SigmaProcess:factorMultFac':
                                        factor_fac
                                    })

    event = list(
        cluster(reconstruct(generate_events(gen_input, ignore_weights=True),
                            random_state=1),
                events=1,
                jet_size=1.0,
                subjet_size=0.3,
                trimmed_pt_min=250,
                trimmed_pt_max=300,
                trimmed_mass_min=65,
                trimmed_mass_max=95))[0]

    edges = pixel_edges(jet_size=1.0, pixel_size=(0.1, 0.1), border_size=0)

    image = preprocess(event.subjets,
                       event.trimmed_constit,
                       edges,
                       zoom=1.,
                       normalize=True,
                       out_width=25)

    return image
Exemple #6
0
def test_cluster_reconstruct_generate_length():
    assert_equal(len(list(cluster(reconstruct(generate_events('w.config', ignore_weights=True, verbosity=0)), 1))), 1)
    assert_equal(len(list(cluster(reconstruct(generate_events('w.config', ignore_weights=True, verbosity=0)), 10))), 10)
    assert_equal(len(list(cluster(reconstruct(generate_events('w.config', ignore_weights=True, verbosity=0)), 100))), 100)
Exemple #7
0
from deepjets.generate import generate_events

for event in generate_events('w_vincia.config', 1, write_to='vincia.hepmc', shower='vincia', random_state=1, verbosity=0):
    pass

for event, weight in generate_events('w.config', 1, write_to='dire.hepmc', shower='dire', random_state=1, verbosity=0):
    print weight
Exemple #8
0
from deepjets.generate import generate_events, get_generator_input
from deepjets.clustering import cluster
from deepjets.detector import reconstruct
from deepjets.preprocessing import preprocess, pixel_edges

gen_input = get_generator_input('pythia',
                                'w.config',
                                random_state=1,
                                verbosity=0)
edges = pixel_edges(jet_size=1.0, pixel_size=(0.1, 0.1), border_size=0)

for particles in generate_events(gen_input, events=1, ignore_weights=True):
    print particles  # numpy record array

for particle_jets in cluster(generate_events(gen_input, ignore_weights=True),
                             events=1):
    print particle_jets  # jet struct
    image = preprocess(particle_jets.subjets, particle_jets.trimmed_constit,
                       edges)

for towers in reconstruct(generate_events(gen_input, ignore_weights=True),
                          events=1,
                          random_state=1):
    print towers  # numpy record array

for tower_jets in cluster(reconstruct(generate_events(gen_input,
                                                      ignore_weights=True),
                                      random_state=1),
                          events=1):
    print tower_jets  # jet struct
    image = preprocess(tower_jets.subjets, tower_jets.trimmed_constit, edges)