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
from rootpy.tree import Tree, TreeModel, FloatCol
from rootpy.io import root_open
from root_numpy import root2array, array2tree
import numpy as np
from random import gauss
import random
random.seed(0)
class BCHCleaning(EventFilter):
"""
https://twiki.cern.ch/twiki/bin/view/AtlasProtected/BCHCleaningTool
"""
def __init__(self, tree, passthrough, datatype, **kwargs):
if not passthrough:
from externaltools import TileTripReader
from externaltools import BCHCleaningTool
from ROOT import Root
from ROOT import BCHTool
WARNING:ROOT.Root.TPileupReweighting.GetPrimaryWeight] No mc for weight 'pileup' in channelNumber=1, periodNumber/runNumber=195847,x=44.000000
WARNING:ROOT.Root.TPileupReweighting.GetPrimaryWeight] No mc for weight 'pileup' in channelNumber=1, periodNumber/runNumber=195847,x=44.000000
WARNING:ROOT.Root.TPileupReweighting.GetPrimaryWeight] No mc for weight 'pileup' in channelNumber=1, periodNumber/runNumber=195847,x=44.000000
INFO:higgstautau.pileup] Run: 195848
INFO:higgstautau.pileup] Channel: 161617
INFO:higgstautau.pileup] mu: 44.0
INFO:higgstautau.pileup] Weight: 0.0
WARNING:ROOT.Root.TPileupReweighting.GetPrimaryWeight] No mc for weight 'pileup' in channelNumber=1, periodNumber/runNumber=195847,x=44.000000
WARNING:ROOT.Root.TPileupReweighting.GetPrimaryWeight] No mc for weight 'pileup' in channelNumber=1, periodNumber/runNumber=195847,x=44.000000
WARNING:ROOT.Root.TPileupReweighting.GetPrimaryWeight] No mc for weight 'pileup' in channelNumber=1, periodNumber/runNumber=195847,x=44.000000
"""
=====================================
Multi-class AdaBoosted Decision Trees
=====================================
This example reproduces Figure 1 of Zhu et al [1] and shows how boosting can
improve prediction accuracy on a multi-class problem. The classification
dataset is constructed by taking a ten-dimensional standard normal distribution
and defining three classes separated by nested concentric ten-dimensional
spheres such that roughly equal numbers of samples are in each class (quantiles
115 # Check parameters
116 self._validate_estimator()
117
118 # Clear any previous fit results
119 self.estimators_ = []
120 self.estimator_weights_ = np.zeros(self.n_estimators, dtype=np.float)
121 self.estimator_errors_ = np.ones(self.n_estimators, dtype=np.float)
122
123 for iboost ∈ xrange(self.n_estimators):
124 # Boosting step
{
"metadata": {
"name": "rootpy_matplotlib_mpl3d"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@ndawe
ndawe / mc12
Created February 18, 2014 21:29
# ttbar 1 lepton filter
mc12_8TeV.117050.PowhegPythia_P2011C_ttbar.merge.NTUP_TAU.e1728_s1581_s1586_r3658_r3549_p1443/
# ttbar fully hadronic
mc12_8TeV.117049.TTbar_MT1725_allhad_PowHeg_Pythia_P2011C.merge.NTUP_TAU.e2075_s1581_s1586_r3658_r3549_p1344/
# MC@NLO NOT USED
#mc12_8TeV.105200.McAtNloJimmy_CT10_ttbar_LeptonFilter.merge.NTUP_TAU.e1513_s1499_s1504_r3658_r3549_p1344/
#mc12_8TeV.105204.McAtNloJimmy_AUET2CT10_ttbar_allhad.merge.NTUP_TAU.e1576_s1499_s1504_r3658_r3549_p1344/
# Single top Wt
mc12_8TeV.110140.PowhegPythia_P2011C_st_Wtchan_incl_DR.merge.NTUP_TAU.e1743_s1581_s1586_r3658_r3549_p1344/