Skip to content

Instantly share code, notes, and snippets.

import uproot
import awkward
import hist
import numpy as np
import os
import math
def get_root_parent(index, mcparticles):
parents = mcparticles[index].member("parents").tolist()
if len(parents) == 0:
@lgray
lgray / geant_to_parquet.py
Created October 31, 2022 19:04
converts standard geant root tree output to something more suitable for rapid analysis
import awkward
import uproot
import glob
from rich.progress import track
import multiprocessing
import concurrent.futures
import pathlib
def extract_file(c3FileName, keep):
c3File = uproot.open(c3FileName)
@lgray
lgray / zpool_iostat.txt
Created September 26, 2022 19:54
zpool for ssd setup
Every 1.0s: zpool iostat -vly 1 1 godrick: Mon Sep 26 19:53:16 2022
capacity operations bandwidth total_wait disk_wait syncq_wait asyncq_wait scrub trim
pool alloc free read write read write read write read write read write read write wait wait
----------------------------------------------- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
chrysalid 3.81T 10.7T 13 667 1.74M 28.3M 2ms 7ms 2ms 502us 2us 1us 2us 7ms - -
mirror-0 1.91T 5.35T 2 295 383K 13.1M 2ms 8ms 2ms 464us 2us 1us - 7ms -
# ==========================================================================
# AIDA Detector description implementation
# --------------------------------------------------------------------------
# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
# All rights reserved.
#
# For the licensing terms see $DD4hepINSTALL/LICENSE.
# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
#
# ==========================================================================
import random
from dask.distributed import Client, worker_client, as_completed, secede, rejoin
import pprint
import time
def reduce_chunks(items):
out = 0
for item in items:
out += item #.result()
return out
import torch
from torch_cmspepr.gravnet_model import GravnetModelWithNoiseFilter
model = GravnetModelWithNoiseFilter(input_dim=9, output_dim=6, k=50, signal_threshold=.05)
weights = torch.load("ckpt_train_taus_integrated_noise_Oct20_212115_best_397.pth.tar")
model.load_state_dict(weights["model"])
jitted = torch.jit.script(model)
import torch
from torch_cmspepr.dataset import TauDataset
import json
from tqdm import tqdm
dataset = TauDataset("/mnt/d/mldata/hgcalml/npzs_all")
out_list = []
for i, data in tqdm(enumerate(dataset[:1000])):
@lgray
lgray / test_hist_size.py
Created November 11, 2021 20:01
little script to understand nominal-use-case histogram sizes
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
def loadData(fileName):
# 1. Load Data #
#fileName = "/uscms/home/dkim2/nobackup/safetodel/nano_mc2017_1-11_Skim.root"
file = uproot.open(fileName)
printer.info("file: "+ fileName)
events = file["Events"].arrays(how="zip")
mask = events.pfcand_pt > 0
ARG SERVERBASE=20.09-py3
FROM nvcr.io/nvidia/pytorch:${SERVERBASE}
ENV FORCE_CUDA=1
ARG LIB_WITH_CUDA=ON
ARG NPROC=4
RUN git clone https://github.com/rusty1s/pytorch_cluster.git
RUN pushd pytorch_cluster &&\