Skip to content

Instantly share code, notes, and snippets.

View alexpearce's full-sized avatar

Alex Pearwin alexpearce

View GitHub Profile
@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 / 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 / sweights_example.png
Last active June 24, 2018 03:37
Example of sWeight generation and sWeight distributions in RooFit
sweights_example.png
@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 / 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 / simul.py
Created February 6, 2015 16:20
Simultaneous fit
import ROOT as R
from ROOT import RooFit as RF
# 'Unblind' or 'Blind'
# BLINDING = 'Blind'
BLINDING = 'Unblind'
BLIND_STR = '6LJgnoyA4Zr95gec'
def roovar_value(rv):
'''Return a pretty-printed central value and uncertainty of rv.
@alexpearce
alexpearce / shutup.patch
Created February 5, 2015 10:07
Shut up, RooFit
diff --git a/roofit/roofitcore/src/RooBanner.cxx b/roofit/roofitcore/src/RooBanner.cxx
index 89c0338..8cc41b9 100644
--- a/roofit/roofitcore/src/RooBanner.cxx
+++ b/roofit/roofitcore/src/RooBanner.cxx
@@ -10,6 +10,7 @@
// END_HTML
//
+#define __ROOFIT_NOBANNER
using namespace std;
@alexpearce
alexpearce / make_error.log
Created February 4, 2015 16:29
make error
g++ -c -o obj/TMVAClassification.o src/TMVAClassification.cxx -g -O0 -I./include/ -Wall -std=c++11 -fPIC -pthread -stdlib=libc++ -std=c++11 -m64 -I/usr/local/Cellar/root6/6.02.04/include/root
g++ -c -o obj/AnyWriter.o src/AnyWriter.cxx -g -O0 -I./include/ -Wall -std=c++11 -fPIC -pthread -stdlib=libc++ -std=c++11 -m64 -I/usr/local/Cellar/root6/6.02.04/include/root
g++ -c -o obj/DConfig.o src/DConfig.cxx -g -O0 -I./include/ -Wall -std=c++11 -fPIC -pthread -stdlib=libc++ -std=c++11 -m64 -I/usr/local/Cellar/root6/6.02.04/include/root
g++ -c -o obj/MyUtils.o src/MyUtils.cxx -g -O0 -I./include/ -Wall -std=c++11 -fPIC -pthread -stdlib=libc++ -std=c++11 -m64 -I/usr/local/Cellar/root6/6.02.04/include/root
g++ -c -o obj/BDTTools.o src/BDTTools.cxx -g -O0 -I./include/ -Wall -std=c++11 -fPIC -pthread -stdlib=libc++ -std=c++11 -m64 -I/usr/local/Cellar/root6/6.02.04/include/root
rootcint -f dict/MyDict.cxx -c -p include/ROOTex.h include/LinkDef.h
g++ -c -o obj/ROOTex.o dict/MyDict.cxx -I./ -g -O0 -I./include/ -Wall -std=c+
@alexpearce
alexpearce / alias.py
Created January 30, 2015 10:57
TTree::SetAlias example
import ROOT
import numpy
f = ROOT.TFile('alias.root', 'recreate')
t = ROOT.TTree('t', 't')
a = numpy.zeros(1, dtype=float)
t.Branch('a', a, 'a/D')
for i in range(10):
@alexpearce
alexpearce / test_ttreeformula.py
Created January 19, 2015 08:48
TTreeFormula example
import ROOT
# Replace with location to your favourite ntuple
f = ROOT.TFile((
'/Users/apearce/Physics/Data/CharmProduction2010/Reprocessed'
'/DVntuple.2010.12.MagUp.root'
), 'read')
t = f.Get('TupleD0Tohh/DecayTree')
h1 = ROOT.TH1F('h1', 'h1', 170, 1780, 1950)
h2 = ROOT.TH1F('h2', 'h2', 170, 1780, 1950)