Skip to content

Instantly share code, notes, and snippets.

View ndawe's full-sized avatar

Noel Dawe ndawe

View GitHub Profile
@ndawe
ndawe / cluster.py
Last active August 3, 2017 05:12
pyjet and numpythia
from numpythia import Pythia
from numpythia import STATUS, HAS_END_VERTEX, ABS_PDG_ID
from numpythia.testcmnd import get_cmnd
from pyjet import cluster
pythia = Pythia(get_cmnd('w'), random_state=1)
selection = ((STATUS == 1) & ~HAS_END_VERTEX &
(ABS_PDG_ID != 12) & (ABS_PDG_ID != 14) & (ABS_PDG_ID != 16))
@ndawe
ndawe / cluster_cms.py
Last active August 3, 2017 04:44
Jet clustering CMS data without CMSSW
from pyjet import cluster
from root_numpy import root2array, stretch
branches = [
'recoPFCandidates_particleFlow__RECO.obj.pt_',
'recoPFCandidates_particleFlow__RECO.obj.eta_',
'recoPFCandidates_particleFlow__RECO.obj.phi_',
'recoPFCandidates_particleFlow__RECO.obj.mass_',
]
import numpy as np
from pyjet import cluster, DTYPE_PTEPM
from pyjet.utils import ep2ptepm
from pyjet.testdata import get_event
import matplotlib.pyplot as plt
from matplotlib.pyplot import cm
from matplotlib.colors import LinearSegmentedColormap
eta_min, eta_max = -4., 4.
extent = eta_min, eta_max, -np.pi, np.pi
@ndawe
ndawe / gist:7411021
Last active December 28, 2015 00:09
from root_numpy import tree2rec
from root_numpy.testdata import get_filepath
from rootpy.io import root_open
import rootpy.compiled as C
C.register_code("""
double mult(double x, double y)
{
group.phys-higgs.periodB.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsdn_rereco_p851.120606194325_EXT0:
INCOMPLETE:
COMPLETE: SFU-LCG2_LOCALGROUPDISK
group.phys-higgs.periodB.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsdn_rereco_p851.120606194310_EXT0:
INCOMPLETE:
COMPLETE: SFU-LCG2_LOCALGROUPDISK
group.phys-higgs.periodB.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsdn_rereco_p851.120606194255_EXT0:
INCOMPLETE:
group.phys-higgs.periodB.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsdn_rereco_p851_EXT0/
group.phys-higgs.periodB.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsim_rereco_p851_EXT0/
group.phys-higgs.periodB.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsup_rereco_p851_EXT0/
group.phys-higgs.periodD.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsdn_rereco_p851_EXT0/
group.phys-higgs.periodD.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsim_rereco_p851_EXT0/
group.phys-higgs.periodD.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsup_rereco_p851_EXT0/
group.phys-higgs.periodE.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsdn_rereco_p851_EXT0/
group.phys-higgs.periodE.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsim_rereco_p851_EXT0/
group.phys-higgs.periodE.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsup_rereco_p851_EXT0/
group.phys-higgs.periodF.DESD_SGLMU.pro10.embedding-02-41.Ztautau_hh_isol_mfsdn_rereco_p851_EXT0/
DEBUG=1 python
Python 2.7.4 (default, Apr 19 2013, 18:28:01)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from rootpy import stl
INFO:rootpy.logger] | No default log handler configured. See `logging` module |
INFO:rootpy.logger] \ To suppress: 'rootpy.log.basic_config_colorized()' /
DEBUG:rootpy.utils.quickroot] Loaded libHist (required by TH1)
DEBUG:rootpy] Using ROOT 5.34/03
>>> stl.map('int,vector<map<int, float> >')
import ROOT
ROOT.gSystem.Load('GoodRunsLists/StandAlone/libGoodRunsLists.so')
from ROOT import Root
grl_str = '''\
<?xml version="1.0"?>
<!DOCTYPE LumiRangeCollection SYSTEM "http://atlas-runquery.cern.ch/LumiRangeCollection.dtd">
<!-- This document was created by goodruns: http://pypi.python.org/pypi/goodruns/ on 2013-07-16 at 08:24:28 -->
<LumiRangeCollection>
<NamedLumiRange>
roosh group.phys-higgs.167777_057599.161617._00003.hhskim.mc12_p1130_hadhad.root
WARNING:ROOT.TClass.TClass] no dictionary for class AttributeListLayout is available
WARNING:ROOT.TClass.TClass] no dictionary for class pair<string,string> is available
Welcome to the ROOSH terminal
type help for help
group.phys..adhad.root > ls
cutflow_event tau
cutflow_event_mc_weight tauMeta
group.phys..adhad.root > load tau
group.phys..adhad.root > tau.to_array(['jet_pt'])
sample_weight:
[ 4.00598725e-106 4.00598725e-106 4.91627788e-105 2.24355403e-003
5.78717038e-002 4.00598725e-106 4.91627788e-105 1.07356398e-103
1.57636332e-104 2.73278144e-002 1.16624680e-002 3.64200942e-104
8.76243476e-002 5.54496636e-005 4.00598725e-106 4.03426583e-204
4.00598725e-106 3.31825327e-104 6.44530564e-103 4.00598725e-106
4.00598725e-106 3.79262644e-102 1.15663209e-104 5.55791534e-104
1.93974860e-001 4.00598725e-106 4.38345661e-105 1.93974860e-001
1.34273015e-105 9.49335285e-003 2.31113450e-103 4.00598725e-106
4.00598725e-106 4.91627788e-105 4.00598725e-106 8.76243476e-002