Skip to content

Instantly share code, notes, and snippets.

Avatar

Kyle Cranmer cranmer

View GitHub Profile
@cranmer
cranmer / RooMomentMorphExample.py
Last active Dec 31, 2021
RooMomentMorph example for RooFit
View RooMomentMorphExample.py
#for C++ look here: https://gist.github.com/cranmer/b67830e46d53d5f7cf2d
import ROOT
import numpy as np
def testMomentMorph():
#Going to make a few statistical models we want to interpolate
#initialize workspace with some common background part
w = ROOT.RooWorkspace('w')
w.factory('Exponential::e(x[-5,15],tau[-.15,-3,0])')
x = w.var('x')
@cranmer
cranmer / RooMomentMorphExample.C
Last active Feb 5, 2020
RooMomentMorph example for RooFit
View RooMomentMorphExample.C
#for python, look here: https://gist.github.com/cranmer/46fff8d22015e5a26619
void testMM(){
// #Make statistical model
w = new RooWorkspace("w");
w->factory("Exponential::e(x[-5,15],tau[-.15,-3,0])");
x = w->var("x");
w->factory("mu[0,10]");
mu = w->var("mu");
frame = x->frame();
RooArgList pdfs;
View RooBSplineExample.py
import ROOT
import numpy as np
def makeBSpline(w,interpParam, observable, pdfList, paramPoints):
# source code for these classes can be found here:
# https://github.com/svenkreiss/roostats/tree/development/roofit/histfactory
#if you don't have this class in your ROOT library, but have it locally
ROOT.gROOT.ProcessLine(".L RooBSpline.cxx+")
paramVec = ROOT.TVectorD(len(paramPoints))
@cranmer
cranmer / gist:96c4930b87b98387a11a
Created Oct 17, 2014
Betterize with Arial font instead
View gist:96c4930b87b98387a11a
javascript:(function%20()%20%7Bvar%20els%20=%20%5B'div',%20'p',%20'span',%20'td',%20'th',%20'tr',%20'body',%20'section'%5D;%20for%20(var%20k%20=%200;%20k%20%3C%20els.length;%20++k)%20%7B%20$(els%5Bk%5D).css('font-family',%20'Arial');%7D%7D)();
@cranmer
cranmer / gist:24f6b1f4074b65dd34f0
Created Jun 15, 2015
Embed custom.css into IPython for slides customization
View gist:24f6b1f4074b65dd34f0
from IPython.display import HTML
try:
myf = open('custom.css')
htmlstring = "<style>%s </style>" %(myf.read())
HTML(htmlstring)
except IOError:
print "no file"
View example.tex
\documentclass[11pt]{article}
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper} % ... or a4paper or a5paper or ...
%\geometry{landscape} % Activate for for rotated page geometry
%\usepackage[parfill]{parskip} % Activate to begin paragraphs with an empty line rather than an indent
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{epstopdf}
\usepackage[