Skip to content

Instantly share code, notes, and snippets.

@raggleton
raggleton / printFileContent.py
Created February 21, 2014 18:29
Prints out event content during path run (like edmDumpEventContent)
process.eca= cms.EDAnalyzer("EventContentAnalyzer"
#getData = cms.untracked.bool(True),
#listContent = cms.untracked.bool(False)
)
then later on
process.p = cms.Path( ... + process.eca + ... )
# https://github.com/cms-sw/cmssw/blob/e858790c803839263e8b9c67ba6a07273d953af3/FWCore/Modules/python/printContent_cfi.py
@raggleton
raggleton / rootNotes.cc
Created April 4, 2014 09:58
ROOT notes
/**
* For reminders about ROOT idiosyncrasies
*
* /
// Put tick marks on inside of all axis of a plot (ie right hand y and top x axes)
// NOT a fn of the TH1, but of the pad instead (sigh)
myPad->SetTicks(1,1);
@raggleton
raggleton / deleteEmpties.sh
Created June 2, 2014 10:36
Deletes empty files in the current directory. -type f required as directories have size 0 even if not empty!
find . -type f -empty -delete
@raggleton
raggleton / rmSymbolics.sh
Created July 10, 2014 11:36
Remove symbolic links
find -type l -exec rm {} \;
@raggleton
raggleton / loopTest.cpp
Created November 13, 2014 18:04
How to loop over TFile with BRanches etc
#include <iostream>
#include <TChain.h>
#include "TFile.h"
#include "TDirectoryFile.h"
#include "TTree.h"
#include "DeltaR_Matcher.h"
int main() {
std::cout << "Looping test" << std::endl;
@raggleton
raggleton / slider.py
Created March 23, 2015 09:40
Show fn, fit it, show the fit. Not perfect. For exploring possible shapes of fns.
from collections import namedtuple
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button, RadioButtons
from scipy.optimize import curve_fit
from itertools import izip
# 0 to 0.347
xpt = [20.9499,20.7179,21.4734,22.0312,22.9523,24.6784,26.0982,28.7842,31.0813,33.0672,35.4857,38.3296,40.9982,43.7918,46.1765,49.2252,52.6305,55.078,58.345,61.1288,63.9831,67.1981,70.5813,73.5319,76.9119,79.7721,82.9528,86.3631,89.1184,93.0097,96.0561,99.2763,103.673,105.919,109.948,112.495,116.37,119.104,122.172,126.262,129.863,133.374,135.358,140.215,143.906,146.964,151.518,152.608,157.312,161.298,163.645,168.758,171.285,174.861,179.208,182.253,186.099,189.914,193.942]
ypt = [0.903289,1.31444,1.48306,1.57877,1.67689,1.75208,1.81371,1.78577,1.78443,1.77425,1.76701,1.74634,1.72242,1.68689,1.67924,1.66272,1.63702,1.62118,1.59681,1.5808,1.57993,1.55617,1.54106,1.53675,1.52014,1.50499,1.49345,1.48556,1.46981,1.46973,1.46255,1.45699,1.43602,1.42543,1.42378,1.42657,1.4099,1.40933,1.39935,1.387
@raggleton
raggleton / profileBash
Created December 5, 2013 15:22
This prints out time (in s since 1970) and line number+content to aid in profiling a bash script. Taken from: http://stackoverflow.com/questions/4336035/performance-profiling-tools-for-shell-scripts Note, that sometimes the first digit gets chopped off the date :/
PS4='$(date "+%s.%N ($LINENO) + ")' bash -x scriptname
find . -type f -name "example-*.txt" -printf '%T@ %p\n' | sort -n | tail -1 | cut -f2- -d" "
@raggleton
raggleton / performance_test.py
Last active January 4, 2016 11:26
Different ways to access TTree elements, some slow, some fast. Note cProfile doesn't work great here.
#!/usr/bin/env python
"""
Example ways to access tree elements, to test relative performance
"""
import ROOT
from array import array
# import cProfile
#!/usr/bin/env python
"""
Example ways to access tree elements, to test relative performance
"""
import ROOT
from array import array
# import cProfile