Skip to content

Instantly share code, notes, and snippets.

View neggert's full-sized avatar

Nic Eggert neggert

View GitHub Profile
@neggert
neggert / hist_errorbars.py
Created April 16, 2012 14:49
Function for plotting histogram with error bars
import matplotlib.pyplot as plt
import numpy as np
import inspect
def hist_errorbars( data, xerrs=True, *args, **kwargs) :
"""Plot a histogram with error bars. Accepts any kwarg accepted by either numpy.histogram or pyplot.errorbar"""
# pop off normed kwarg, since we want to handle it specially
norm = False
if 'normed' in kwargs.keys() :
norm = kwargs.pop('normed')
@neggert
neggert / matplotlibrc
Created April 17, 2012 14:08
matplotlibrc that produces plots similar to the official CMS style
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
@neggert
neggert / ABCD.py
Created April 18, 2012 15:04
Background estimates using ABCD method
import math
class ABCDCalculator(object):
"""Class to calculate background using the ABCD method"""
def __init__(self, x, y):
self.x = x
self.y = y
def set_x_data(self, data):
"""Give the calculator the x data"""
self.x = data
229:cms+cmssw-tool-conf+25.########################################### [100%]
230:cms+cmssw+CMSSW_5_2_0 ########################################### [100%]
Done.
Create user area for CMSSW_5_2_0 release ...
Enter PEM pass phrase:
/bin/sh: scramv1: command not found
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/Users/nic/cms/soft/Releases/<ipython-input-1-f0d9fe6489f2> in <module>()
----> 1 get_ipython().magic(u'install CMSSW_5_2_0')
cms-sh|5> info run=160915
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/afs/cern.ch/user/n/neggert/<ipython-input-5-c10902d46b4c> in <module>()
----> 1 get_ipython().magic(u'info run=160915')
/afs/cern.ch/work/v/valya/public/soft/install/lib/python2.6/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s, next_input)
1983 self._magic_locals = sys._getframe(1).f_locals
1984 with self.builtin_trap:
-> 1985 result = fn(magic_args)
cms-sh|1> info run=160915
---------------------------------------------------------------------------
HTTPError Traceback (most recent call last)
/afs/cern.ch/user/n/neggert/<ipython-input-1-c10902d46b4c> in <module>()
----> 1 get_ipython().magic(u'info run=160915')
/afs/cern.ch/work/v/valya/public/soft/install/lib/python2.6/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s, next_input)
1983 self._magic_locals = sys._getframe(1).f_locals
1984 with self.builtin_trap:
-> 1985 result = fn(magic_args)
def get_seu_logs()
# get the portion of the logs relevant to the seu
logs = []
Dir['**/PixelFEDSupervisor_*.log'].each do |path|
contents = File.read(path)
regex = /Message : Detected soft error using FED channel monitoring(.*?)Message : New state is:Running/m
matches = contents.scan(regex)
if (matches != nil)
(0..matches.size-1).each do |i|
@neggert
neggert / gist:3691954
Created September 10, 2012 16:31
stacked_step_hist tests
"""
..K...K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K.EEE.K............K..K..K..K..K..K..KK.................................................................K......K..K...K.K..KK...K..K..K......................................................................................................................................................................................K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K..K
@neggert
neggert / AndersonDarlingTestStat.cc
Last active December 11, 2015 10:28
Anderson-Darling Test Statistic for use in RooStats. This has only been tested on the model I produced using HistFactory, so YMMV. In particularl, it only works on binned data, although modifications to make it work on unbinned data would be minimal. Fixes and forks are welcome.
#include "AndersonDarlingTestStat.h"
#include "RooStats/RooStatsUtils.h"
#include "RooMsgService.h"
#include "TMath.h"
#include <utility>
using namespace std;
typedef pair<Double_t, Double_t> double_pair;
===================== glite-job-logging-info Success =====================
LOGGING INFORMATION:
Printing info for the Job : https://wms309.cern.ch:9000/EHTWzFN0kL288AvLiTVx9A
---
Event: RegJob
- Arrived = Thu Feb 21 13:54:15 2013 CST