Skip to content

Instantly share code, notes, and snippets.

View riga's full-sized avatar

Marcel Rieger riga

View GitHub Profile
@riga
riga / index.php
Created August 16, 2021 14:56
Index page for viewing plots in web browsers (copy recursively to subdirectories)
<?
// CHANGE ME: add your local www root here
$local_root = "/eos/home-i03/m/mrieger/www";
// extensions to scan
$additional_extensions = array("pdf", "cxx", "eps", "root", "txt");
// mode for showing hits when searching
// "all", "any" or empty
$search_pattern_mode = "any";
@riga
riga / calib.py
Created October 21, 2021 17:01
Calibration curves with ROOT
# coding: utf-8
from array import array
from scinum import Number
import ROOT
ROOT.PyConfig.IgnoreCommandLineOptions = True
ROOT.gROOT.SetBatch()
@riga
riga / cmsdist.md
Last active September 1, 2023 09:21
First steps with cmsdist

First steps with cmsdist

1. Create fork of cmsdist

  • Go to https://github.com/cms-sw/cmsdist
  • Fork the repository into your user space by clicking on the "Fork" bottom at the top right. If you don't have a personal GitHub account yet, please create one and create the fork.

2. Setup cmsdist and pkgtools

@riga
riga / Makefile
Last active May 26, 2024 19:44
Accelerated Graph Evaluation with TensorFlow XLA AOT
INC = -I${TF_INSTALL_PATH}/include
LIB = -L${TF_INSTALL_PATH}/xla_aot_runtime_src
LIBS = -lpthread -ltf_xla_runtime
CXXFLAGS = -D_GLIBCXX_USE_CXX11_ABI=0
.phony: all clean
all: test_model
test_model: test_model.cc my_model.o
@riga
riga / met_phi_correction.py
Last active October 11, 2022 16:29
CMS MET Phi (Type II) correction
# coding: utf-8
"""
Lightweight Python implementation of the Run 2 MET phi (type II) correction, following
https://lathomas.web.cern.ch/lathomas/METStuff/XYCorrections/XYMETCorrection_withUL17andUL18andUL16.h,
taken from https://twiki.cern.ch/twiki/bin/view/CMS/MissingETRun2Corrections?rev=72.
Downloadable source at https://mrieger.web.cern.ch/snippets/met_phi_correction.py,
gist at https://gist.github.com/riga/951076bcde6ea7cb4da2bf7c7417379a.
# coding: utf-8
import dask_awkward as dak
import awkward as ak
# located at https://cernbox.cern.ch/remote.php/dav/public-files/rvipIIozKQAypwu/calib.parquet
input_path = "calib.parquet"
@riga
riga / nano_unique.py
Created July 5, 2023 09:18
Merge two NanoAOD files while removing duplicate events
#!/usr/bin/env python3
# coding: utf-8
"""
Script that merges the events tree of two NanoAOD files, removing duplicates identified
by event number, run number and luminosity block.
> nano_unique.py in1.root in2.root out.root
NOTE: This is just a first draft whose performance could surely be improved
@riga
riga / evaluate_klub.py
Last active July 11, 2023 09:09
Evaluation script for KLUB samples
# coding: utf-8
from __future__ import annotations
import os
from fnmatch import fnmatch
from multiprocessing import Pool as ProcessPool
from typing import Any
from tqdm import tqdm
@riga
riga / tasks.py
Last active August 26, 2023 18:21
Dynamic law workflows
# coding: utf-8
import law
class LongRunning(law.Task):
def output(self):
return law.LocalFileTarget("$PWD/data/long_running.json")
@riga
riga / pytorch_grad_stop.py
Created October 30, 2023 09:15
Test partial gradient stopping in PyTorch
# coding: utf-8
"""
Setup via
> pip install torch torchvision
"""
from __future__ import annotations
from contextlib import contextmanager