Skip to content

Instantly share code, notes, and snippets.

View alexpearce's full-sized avatar

Alex Pearwin alexpearce

View GitHub Profile
@alexpearce
alexpearce / D0Tohh_mass_2010_MagUp.tex
Created February 11, 2015 16:36
D0Tohh mass plot, exported to LaTeX
\begin{tikzpicture}
\pgfdeclareplotmark{cross} {
\pgfpathmoveto{\pgfpoint{-0.3\pgfplotmarksize}{\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{+0.3\pgfplotmarksize}{\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{+0.3\pgfplotmarksize}{0.3\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{+1\pgfplotmarksize}{0.3\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{+1\pgfplotmarksize}{-0.3\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{+0.3\pgfplotmarksize}{-0.3\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{+0.3\pgfplotmarksize}{-1.\pgfplotmarksize}}
\pgfpathlineto{\pgfpoint{-0.3\pgfplotmarksize}{-1.\pgfplotmarksize}}
@alexpearce
alexpearce / davinci.py
Created March 23, 2015 17:00
MVA discriminant in DecayTreeTuple
# Add this directory to PATH
import sys
import os
sys.path.append(os.getcwd())
from Configurables import (
DaVinci,
DecayTreeTuple,
GaudiSequencer,
ProcStatusCheck,
@alexpearce
alexpearce / sweights_example.png
Last active June 24, 2018 03:37
Example of sWeight generation and sWeight distributions in RooFit
sweights_example.png
@alexpearce
alexpearce / workspace_aliases.py
Last active August 29, 2015 14:20
Test RooDataSet handling of TTree branch aliases.
"""Test RooDataSet handling of TTree branch aliases.
The TTree::SetAlias method allows you to create "branch aliases", names that
point to formulas of other branches.
It seems RooFit will not load alias branches when importing a TTree in to a
RooDatSet, filling the variable with zeros.
This script demonstrates that, firstly by fitting the non-aliased branch 'x',
which works fine, and then fitting the alias to x, 'y', which fails because the
values are all zero.
@alexpearce
alexpearce / are_nightlies_healthy.py
Created May 6, 2015 14:08
Check the status of the LHCb nightlies
#!/usr/bin/env python
from __future__ import print_function
import argparse
import os
import re
import ssl
import sys
import urllib
from xml.dom import minidom
@alexpearce
alexpearce / boosting.py
Created May 9, 2015 10:11
Compare 2010 proton-proton collision CoM values with new method
# -*- coding: utf-8 -*-
from __future__ import print_function
from math import sqrt, sin
from array import array
import ROOT
# Proton mass in MeV
PROTON_MASS = 938.27
@alexpearce
alexpearce / triple_gaussian.py
Created September 2, 2015 14:21
Define a triple Gaussian PDF in RooFit
# Name of the delta mass variable in the workspace
dmass_var = 'Dst_delta_M'
# Species of the PDF we're about to build
species = 'sig'
workspace.factory('mu_dm_{0}[141, 146]'.format(species))
workspace.factory('sigma_one_dm_{0}[1, 0, 5]'.format(species))
workspace.factory('nsigma_two_dm_{0}[1.5, 1, 3]'.format(species))
workspace.factory('nsigma_three_dm_{0}[1.5, 1, 3]'.format(species))
workspace.factory((
'expr::sigma_two_dm_{0}('
@alexpearce
alexpearce / tbrowser.py
Last active November 23, 2015 09:00
Open ROOT files in an Python/IPython shell. Pops open a TBrowser automatically
#!/usr/bin/env python
"""Inspect ROOT files."""
from __future__ import print_function
import argparse
import sys
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('files', metavar='file', nargs='+',
help='ROOT file to inspect (ending in .root)')
@alexpearce
alexpearce / open_eos.py
Created December 7, 2015 13:24
Interface to EOS files mimicking native `open`.
from distutils.spawn import find_executable
import logging as log
import os
import shutil
from subprocess import call
import tempfile
class open_eos(object):
"""An EOS file wrapper that acts like the native `open`.
@alexpearce
alexpearce / binned_chi2.ipynb
Created May 4, 2016 06:53
Notebook to reproduce Alex Rogozhnikov's binned chi^2 demonstration plot
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.