Skip to content

Instantly share code, notes, and snippets.

View betatim's full-sized avatar
🤠
Not my first rodeo

Tim Head betatim

🤠
Not my first rodeo
View GitHub Profile
from Ganga.GPI import *
import sys
import inspect
import os
local_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
if len(sys.argv) not in (2,3):
sys.exit("Script requires the ID of a DaVinci (Turbo) or Brunel job to use as inputdata and optionally name of a file containing LFNs to process.")
@betatim
betatim / gist:221cae4aef0ce8ceddf7
Last active August 29, 2015 14:11
Better name and more pythonic way of doing this?
def lockstep(a, b):
i = j = 0
while i<len(a) and j<len(b):
if a[i] == b[j]:
#yield a[i], b[j]
yield i,j
i+=1;j+=1
elif a[i] < b[j]:
i+=1
@betatim
betatim / gist:fe991eead446875f07e3
Created January 30, 2015 13:47
Basic sklearn with ROOT file input
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.cross_calidation import train_test_split
from root_numpy import root2array
signal = root2array("MySignalFile.root",
"MyDecayTree",
["names", "of", "branches", "to", "use",
"for", "classifying"])
# split our development sample into a test and train set
X_train,X_test, y_train,y_test = cross_validation.train_test_split(X_dev,
y_dev,
test_size=0.33,
random_state=7853354)
clf = GradientBoostingClassifier(n_estimators=3000,
max_depth=1,
subsample=0.5,
max_features=0.5,
import random
import pandas as pd
import numpy as np
import pandas.core.common as com
from pandas.core.index import Index
from pandas.tools import plotting
from pandas.tools.plotting import scatter_matrix
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import math
import ROOT as R
from ROOT import RooFit as RF
from ROOT import RooStats as RS
def argset__iter__(self):
start = self.fwdIterator()
for i in xrange(len(self)):
yield start.next()
@betatim
betatim / gist:4795d5b41e968b3b4c88
Last active December 15, 2015 06:45
🎉Eureka!! Oh wait ✋maybe not, uuhhmm, argh 😕 Fill in your own beliefs about how many searches were performed, typical power of a search, p-value threshold and the underlying rate of New Physics. Given there is a discovery, what are the chances it is really New Physics?
Nexp = 10000 # how many experiments/searches were performed?
power = 0.5 # power of each search or p(discovery | new physics)
Pval = 1 - 0.997300204 # p-value
NPrate = 0.001 # New physics base rate
print "true positives: %i false positives: %i"%((Nexp * NPrate * power),
((Nexp-Nexp*NPrate) * Pval))
# true positives: 5 false positives: 26
@betatim
betatim / gist:c4af33d04542f4306d38
Last active August 29, 2015 14:21
Configure a CERN SLC6 cloud image for the LHCb starterkit
#! /bin/sh
whoami
cd /tmp/
wget https://3230d63b5fc54e62148e-c95ac804525aac4b6dba79b00b39d1d3.ssl.cf1.rackcdn.com/Anaconda-2.2.0-Linux-x86_64.sh
bash Anaconda-2.2.0-Linux-x86_64.sh -b -p /opt/anaconda
yum install -y curl-devel expat-devel gettext-devel \
openssl-devel zlib-devel
yum install -y asciidoc xmlto docbook2x
yum install -y gcc
wget https://github.com/git/git/archive/v2.4.1.tar.gz
; AD : This Kerberos configuration is for CERN's Active Directory realm
; The line above this is magic and is used by cern-config-keytab. Do
; not remove.
; Installed with puppet from a series of
; template fragments.
; /etc/krb5.conf
[libdefaults]