Skip to content

Instantly share code, notes, and snippets.

@douglasdavis
douglasdavis / fast_test_hist.py
Created January 10, 2019 21:30
testing fast hist
import numpy as np
from fast_histogram import histogram1d
import math
def my_slow(x, xlim=(0,10), nbins=None, weights=None, overflow=False, density=False):
if nbins is None:
nbins = int(math.pow(len(x), 0.33333))
if overflow and weights is not None:
under = x < xlim[0]
over = x > xlim[1]

Keybase proof

I hereby claim:

  • I am douglasdavis on github.
  • I am ddavis_ (https://keybase.io/ddavis_) on keybase.
  • I have a public key whose fingerprint is 2327 53AA 7537 5A62 5190 A308 18BB BE8C 694A 7ECE

To claim this, I am signing this object:

@douglasdavis
douglasdavis / first_histograms.py
Created March 8, 2018 04:04
quick and dirty plots!
#!/usr/bin/env python
import uproot
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['axes.labelsize'] = 12
mpl.rcParams['legend.fontsize'] = 12
mpl.rcParams['legend.frameon'] = False
#ifndef TYPE_HPP
#define TYPE_HPP
#include <string>
#include <typeinfo>
std::string demangle(const char* name);
template <class T>
std::string type(const T& t) {
int main(int argc, char* argv[]) {
if ( argc < 3 ) {
std::cout << "give arguments" << std::endl;
return 0;
}
std::string inputDS = argv[1];
std::string outputDS = argv[2];
// use would be:
// $ runMyAlgorithm <input> <output>
@douglasdavis
douglasdavis / roc.cpp
Last active January 23, 2023 00:11
example of building a ROC curve in vanilla ROOT
// if sigHist is a TH1F* and bkgHist is a TH1F* (with the same number of bins!)
int nbins = sigHist->GetNbinsX();
// get the total integrals for each histogram
float sig_integral = sigHist->Integral(1,nbins);
float bkg_integral = bkgHist->Integral(1,nbins);
// create containers sig = x points, bkg = y points
std::vector<float> sigPoints(nbins);