Skip to content

Instantly share code, notes, and snippets.

## My helper python functions
def make_dirs(dirname):
"""
Ensure that a named directory exists; if it does not, attempt to create it.
"""
try:
os.makedirs(dirname)
except OSError, e:
if e.errno != errno.EEXIST:
# On server
# from https://github.com/jirutka/rsub-client
pip install --user rsub
echo 'export PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc #or the path where it installed
# On client
# Install Package control https://packagecontrol.io/installation
# CTrl+Shift+P # to open package control
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'canary',
def cut(tdf, ptlow=300, pthigh=2000, mlow = 20, mhigh = 220):
cdf = tdf[(tdf.fj_pt < pthigh) & (tdf.fj_pt>ptlow) &(tdf.fj_sdmass < mhigh) & (tdf.fj_sdmass>mlow)]
return cdf
def roc_input(frame, signal=["HCC"], include = ["HCC", "Light", "gBB", "gCC", "HBB"], norm=False, tagger='fj_doubleb'):
# Bkg def - filter unwanted
bkg = np.zeros(frame.shape[0])
for label in include:
bkg = np.add(bkg, frame['truth'+label].values )
bkg = [bool(x) for x in bkg]
import FWCore.ParameterSet.Config as cms
from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask
process = cms.Process("PATtest"
#Run 303832, Event 1081102788, LumiSection 918i
#,eventsToProcess = cms.untracked.VEventRange('303832:918:1081102780-303832:918:1081102790')
)
## MessageLogger
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-7-07466b6a31e5> in <module>
1 for arrays in tree.iterate({"fj_pt": uproot.asarray(">f8", pt_buffer),
2 "fj_eta": uproot.asarray(">f8", eta_buffer)},
----> 3 outputtype=tuple, entrysteps=5000):
4 pass
~/software/miniconda3/envs/def/lib/python3.7/site-packages/uproot/tree.py in iterate(self, branches, entrysteps, outputtype, namedecode, reportentries, entrystart, entrystop, flatten, flatname, awkwardlib, cache, basketcache, keycache, executor, blocking)
710 else:
@andrzejnovak
andrzejnovak / snippet.py
Created November 5, 2019 10:21
ROC Plots
# Remove weird deepcsv events
def cleandf(tdf):
cdf = tdf[(tdf['Jet_btagDeepB'] < 1) & (tdf['Jet_btagDeepC'] < 1)
& (tdf['Jet_btagDeepB'] > 0) & (tdf['Jet_btagDeepC'] > 0) ]#&(tdf.fj_sdmass < mhigh) & (tdf.fj_sdmass>mlow)]
cdf = cdf[:2000000]
return cdf
for df in [df16, df17, df18]:
df['fj_pt'] = df['Jet_pt']
df['truthb'] = (df['Jet_hadronFlavour'] == 5).astype(int)
This file has been truncated, but you can view the full file.
==9451== Memcheck, a memory error detector
==9451== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==9451== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==9451== Command: cmsRunGlibC RecoBTag/ONNXRuntime/test/test_deep_doublex_cfg.py
==9451==
**************************************************************
b tagging needs to be run on uncorrected jets. Hence, the JECs
will first be undone for 'updatedPatJets' and then applied to
'updatedPatJetsTransientCorrected'.
**************************************************************
This file has been truncated, but you can view the full file.
==9451== Memcheck, a memory error detector
==9451== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==9451== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==9451== Command: cmsRunGlibC RecoBTag/ONNXRuntime/test/test_deep_doublex_cfg.py
==9451==
**************************************************************
b tagging needs to be run on uncorrected jets. Hence, the JECs
will first be undone for 'updatedPatJets' and then applied to
'updatedPatJetsTransientCorrected'.
**************************************************************
imax 1 number of channels
jmax 1 number of backgrounds
kmax 2 number of nuisance parameters (sources of systematical uncertainties)
------------
bin bin1
observation 10001
------------
bin bin1 bin1
process sig bkg
process 0 1