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 collections import namedtuple
from pprint import pprint
import numpy as np
np.random.seed(12345)
import matplotlib.pyplot as plt
Appointment = namedtuple("Appointment", "scheduled late_by emergency")
import random
random.seed(12345)
class Dice(object):
def __init__(self, sides=6):
print "creating a dice with %i sides."%sides
self.sides = sides
# All sorts of stuff for setting up the Forward tracking
# itneresting stuff towards the bottom
FstForward = PrForwardTracking("FstForward")
FstForward.InputName = self.getProp("RootInTES") + "Track/VeloUTFst"
FstForward.OutputName = self.getProp("RootInTES") + "Track/Forward"
FstForward.addTool(PrForwardTool)
FstForward.PrForwardTool.AddUTHitsToolName = ""
# Now with the momentum estimate FstForward.PrForwardTool.UseMomentumEstimate = True
# MinPt determines the size of the search window, set # this to the lowest pT you want to be able to find
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from collections import namedtuple
Infos = namedtuple('Infos', ["bias"," threshold", "alignment"])
# information about runs 1234 and 1235
run_info = {1234: Infos(12.3, 2., 42.),
1235: Infos(12.2, 2.1, 42.3)}
# retrieve it
print run_info[1234]
@betatim
betatim / gist:a0f5c9ef5681e84a5e87
Created June 2, 2014 14:42
sklearn sample weights before they are ready!
$ git clone https://github.com/scikit-learn/scikit-learn.git
$ git remote add pprett https://github.com/pprett/scikit-learn.git
$ git remote add ndawe https://github.com/ndawe/scikit-learn.git
$ git fetch
$ git checkout -b weighted_scores ndawe/weighted_scores
$ git rebase master
$ git checkout master
$ git merge weighted_scores
$ git checkout -b gbrt-sample-weight pprett/gbrt-sample-weight
$ git rebase master
@betatim
betatim / dst-explore.py
Last active August 29, 2015 14:04
Interactively explore a DST or a micro DST. Particularly useful to work out why/what decay descriptor works.
# SetupProject DaVinci v35r1
# ipython -i dst-explore.py <inputDST>
import sys
import GaudiPython as GP
from GaudiConf import IOHelper
from Configurables import LHCbApp, ApplicationMgr, DataOnDemandSvc
from Configurables import SimConf, DigiConf, DecodeRawEvent
from Configurables import CondDB, DstConf, PhysConf
from Configurables import LoKiSvc
def cluster2mc_particles(cluster, event):
links = event['/Event/Link/Raw/VP/Clusters']
refs = links.linkReference()
mc_particles = event['MC/Particles']
next_idx = -1
particles = []
for channel, key in links.keyIndex():
if channel == cluster.channelID().channelID():
mc_key = refs[key].objectKey()
particles.append(mc_particles.object(mc_key))
def nodes(evt, node=None):
nodenames = []
if node is None:
root = evt.retrieveObject('')
node = root.registry()
if node.object():
nodenames.append(node.identifier())
for l in evt.leaves(node):
@betatim
betatim / Track finding and fitting.ipynb
Created October 23, 2014 09:20
Generate some basic tracks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.