Skip to content

Instantly share code, notes, and snippets.

View jpata's full-sized avatar

Joosep Pata jpata

View GitHub Profile
//compile as c++ -g `root-config --cflags --libs` CloneTreeCorruption.cc -o CloneTreeCorruption
#include "TFile.h"
#include "TTree.h"
int main(int argc, const char** argv) {
TFile* inf = new TFile("DoubleEG_Run2015D_v4_7_post.root");
TTree* intree = (TTree*)(inf->Get("mt2"));
ULong64_t evt;
intree->SetBranchAddress("evt", &evt);
TFile* outf = new TFile("out.root", "RECREATE");
import dask
import sys, glob
import numpy as np
def fixPath():
newpath = []
for v in sys.path:
if "cvmfs" in v and "pandas" in v:
continue
newpath += [v]
import cProfile, time
def func():
s = 0
for i in range(100000):
s += i
p = cProfile.Profile(time.clock)
p.runcall(func)
p.print_stats()
using Cxx
const ROOT_PATH = "/Users/joosep/Documents/root-build/"
addHeaderDir(joinpath(ROOT_PATH, "include"), kind=C_System)
for lib in ["Core", "RIO", "Hist"]
Libdl.dlopen("$ROOT_PATH/lib$lib.so", Libdl.RTLD_GLOBAL)
end
cxx"""#include <TFile.h> """
cxx"""#include <TH1D.h> """
@jpata
jpata / diff-setup.py
Created September 20, 2016 10:06
root_numpy setup.py patch
diff --git a/setup.py b/setup.py
index 6569037..48d1603 100755
--- a/setup.py
+++ b/setup.py
@@ -80,8 +80,9 @@ librootnumpy = Extension(
extra_compile_args=root_cflags + [
'-Wno-unused-function',
'-Wno-write-strings',
+ '-mmacosx-version-min=10.7'
],
@jpata
jpata / files
Last active April 4, 2017 16:08
[SingleElectron]
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_1.root = 0
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_10.root = 14136
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_100.root = 27350
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_101.root = 25062
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_102.root = 22851
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_103.root = 30098
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_104.root = 25321
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_105.root = 13815
/store/user/jpata/tth/Mar29_rereco_v1/SingleElectron/Mar29_rereco_v1/170329_155828/0000/tree_106.root = 14586
@jpata
jpata / simple_loop.cc
Created August 24, 2018 18:41
Simple event loop on NanoAOD
//Compile with:
//c++ `root-config --cflags --libs --evelibs` -Wno-unsequenced -O3 code/simple_loop.cc -o simple_loop
#include <iostream>
#include <map>
#include <string>
#include <TFile.h>
#include <TROOT.h>
#include <TH1D.h>
@jpata
jpata / example_job.jdl
Last active September 4, 2019 20:25
Example Tier2 batch job
Universe = vanilla
Executable = example_job.sh
Arguments = 10
#The logs directory must exist
Log = logs/example_job.$(Cluster).log
Output = logs/example_job.out.$(Cluster).$(Process)
Error = logs/example_job.err.$(Cluster).$(Process)
@jpata
jpata / mylib.cc
Created May 23, 2019 17:32
numba CFFI class method C wrapper
//compile with g++ -fPIC mylib.cc -shared -o mylib.dylib
class MyClass {
public:
MyClass(const char* filename) {
//do something with filename
}
double func(int a) {
//an expensive C++ function
@jpata
jpata / test_root.py
Created May 11, 2020 16:54
ROOT histogram bins
import ROOT
from test_uproot import vals
if __name__ == "__main__":
h = ROOT.TH1D("h", "h", 10, 0, 1)
for v in vals:
h.Fill(v)
print("h1")