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
@betatim
betatim / serial.cpp
Created July 17, 2013 07:44
On my mac it compiles with: $ g++ -g serial.cpp -o serial -lboost_serialization-mt running it create dead_pixels.archive $ ./serial somewhere I have the magic line to add to the requirements file to get it to link to boost_serialisation ...
#include <fstream>
#include <map>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/map.hpp>
int main() {
std::ofstream ofs("dead_pixels.archive", std::ios::binary);
The big velo tidy
inline void channel_neighbours(const LHCb::VPChannelID& seedChannel,
Pix* adjecent,
std::bitset<9>& adjecent_set) {
// Loop over the possible positions in the 3x3 cluster
// around the seedChannel
int pixY = (seedChannel).pixel_hp();
int pixX = (seedChannel).pixel_lp();
int chip = (seedChannel).chip();
// hardcoded for the compact VP design
// number of chips in a ladder and
std::vector<std::function<Matrix5d()>> covariances;
for (int i(0); i<10000000; ++i) {
// delay calculation by sending back a lambda
//r3 += m*c*m.transpose();
covariances.push_back([=]() {return m*c*m.transpose();});
}
for (auto fun: covariances) {
if (rand.Rndm() > 0.75) {
r3 += fun();
}
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