Created
November 11, 2021 20:01
-
-
Save lgray/0e9e235fb4320b181bcfb86a9715a5d1 to your computer and use it in GitHub Desktop.
little script to understand nominal-use-case histogram sizes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from coffea import hist | |
| import numpy as np | |
| import random | |
| import string | |
| from tqdm import tqdm | |
| N_ds = 45 | |
| N_reg = 3 | |
| N_ds_full_syst = 6 | |
| N_syst = 53 | |
| N_syst_reduced = 10 | |
| def get_rand(N=6): | |
| return ''.join(random.choices(string.ascii_uppercase + string.digits, k=N)) | |
| dsnms = [get_rand() for _ in range(N_ds)] | |
| regnms = [get_rand(4) for _ in range(N_reg)] | |
| systnms = [get_rand(10) for _ in range(N_syst)] | |
| h = hist.Hist( | |
| 'Events', | |
| hist.Cat('dataset', 'Dataset'), | |
| hist.Cat('region', 'Region'), | |
| hist.Cat('systematic', 'Systematic'), | |
| hist.Bin('genflavor', 'Gen. jet flavor', [0, 3, 4]), | |
| hist.Bin('pt1', r'Jet $p_{T}$ [GeV]', [400, 450, 500, 550, 600, 675, 800, 1200]), | |
| hist.Bin('msd1', r'Jet $m_{sd}$', 23, 40, 201), | |
| hist.Bin('ddb1', r'Jet ddb score', [0, 0.64, 1]), | |
| hist.Bin('mjj', r'$m_{jj}$ [GeV]',[500,1000,2000,4000,6000,10000]), | |
| ) | |
| n_fill = 1_000_000 | |
| genflavor = np.random.randint(0,4, n_fill) | |
| pt1 = 300 + np.random.exponential(1000, n_fill) | |
| msd1 = np.random.normal(100, 30, n_fill) | |
| ddb1 = np.random.uniform(0, 1, n_fill) | |
| mjj = 400 + np.random.exponential(1000, n_fill) | |
| for ids, ds in tqdm(enumerate(dsnms)): | |
| for reg in regnms: | |
| for syst in systnms if ids < N_ds_full_syst else systnms[:N_syst_reduced]: | |
| h.fill( | |
| dataset=ds, | |
| region=reg, | |
| systematic=syst, | |
| genflavor=genflavor, | |
| pt1=pt1, | |
| msd1=msd1, | |
| ddb1=ddb1, | |
| mjj=mjj, | |
| ) | |
| print(h) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment