Skip to content

Instantly share code, notes, and snippets.

View aminnj's full-sized avatar

Nick Amin aminnj

  • Austin, TX
View GitHub Profile
@aminnj
aminnj / dump_pset_subset.py
Last active September 17, 2019 18:42
Dump a subset of a cmssw pset recursively
from pset_rawsim_onlyhlt import process
def recurse_coll(item,already_dumped=[]):
if hasattr(item,"_seq"):
print("process.{} = {}\n".format(item.label(),item.dumpPython()))
for thing in item._seq._collection:
for x in recurse_coll(thing): yield x
if hasattr(item,"_Parameterizable__parameterNames"):
if not item.label() in already_dumped:
print("process.{} = {}\n".format(item.label(),item.dumpPython()))
@aminnj
aminnj / download_psets.py
Last active September 23, 2019 21:15
Download psets for all tasks in a chain for a given dataset
from __future__ import print_function
import requests
import os
session = requests.Session()
session.cert = "/tmp/x509up_u{0}".format(os.getuid()) # should match `voms-proxy-info -path`
session.verify = "/etc/grid-security/certificates/" # or curl this locally: https://raw.githubusercontent.com/CMSTrackerDPG/cernrequests/master/cernrequests/cern-cacert.pem
def get_url_with_cert(url,params={}):
return session.get(url,params=params)
@aminnj
aminnj / installing_das.md
Created September 26, 2019 00:16
installing DAS locally
@aminnj
aminnj / bokeh_histogram_example.ipynb
Last active December 9, 2019 00:11
interactive bokeh histogram example in jupyter
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aminnj
aminnj / particle_in_bfield.ipynb
Created November 27, 2019 04:16
Position of relativistic charged particle in uniform B field
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aminnj
aminnj / compare_jecs.md
Last active April 7, 2020 17:28
jec comparison

installation in https://github.com/cmstas/FTAnalysis

cd babymaker/batch
./copy_files.sh
make -j10

cp /home/users/namin/2018/fourtop/all/FTAnalysis/babymaking/batch/compare_jecs_example.py .
# edit compare_jecs_example.py to compare the right JECs
@aminnj
aminnj / fiterrors.py
Created June 9, 2020 00:38
Fitting xy points with clopper-pearson errors using pyROOT
import os
import ROOT as r
import array
# avoid numpy because of dependency issue :(
data = [
[2, 588, 600],
[4, 579, 600],
[8, 546, 600],
[16, 513, 600],
@aminnj
aminnj / lhe_to_df.py
Last active August 11, 2020 01:52
convert LHE to dataframe
import gzip
import uproot
from tqdm.auto import tqdm
import pandas as pd
import uproot_methods
@pd.api.extensions.register_dataframe_accessor("vec")
class LorentzVectorAccessor:
def __init__(self, ob):
self._obj = ob
@aminnj
aminnj / tictactoe.py
Last active December 9, 2020 06:18
tictactoe "one"-liner
check = lambda board: (
lambda mm: {1: "x wins", -1: "o wins"}.get(
(mm == 3).sum() - (mm == -3).sum(), "invalid"
)
)(
__import__("numpy").array(
list(
map(
lambda conv: (conv.min(), conv.max()),
[
@aminnj
aminnj / seamcarving.ipynb
Created September 9, 2020 21:36
Seam carving in python (basically https://www.youtube.com/watch?v=rpB6zQNsbQU but I don't want to learn Julia)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.