Skip to content

Instantly share code, notes, and snippets.

Avatar

Andy Mastbaum mastbaum

  • Rutgers University
  • New Brunswick, NJ
View GitHub Profile
@mastbaum
mastbaum / TestUser.cc
Created April 11, 2017 19:28
RAT-PAC setup to look at antiprotons
View TestUser.cc
// This lives in user/
///////////////////////////////////////////////////////////////////////////////
/// \file TestUser.cc
/// \brief An example User Processor
///
/// This example demonstrates how to write a User Processor. MyUserProc
/// (declared and defined below) just creates a 1-D histogram of the number of
/// photoelectrons in each event, filled it as events are generated and writes
/// it to a file called "numpe.root".
@mastbaum
mastbaum / hough.cpp
Created December 4, 2015 21:44
Hough transform for QEvents
View hough.cpp
#include <cmath>
#include <TH2F.h>
#include <TVector3.h>
#include <QEvent.h>
#include <QGlobals.h>
#include <QPMTxyz.h>
TH2F* hough(const QEvent* event, TVector3& vfit, float tres_cut, bool qweight) {
// Calculate Cherenkov angle using FTK energy
float beta = sqrt(1.0 - (0.511 / (0.511 + e)) * (0.511 / (0.511 + e)));
@mastbaum
mastbaum / startnode
Created November 1, 2015 18:26
Docker SLURM node Resume and Suspend scripts
View startnode
#!/bin/bash
echo "`date` Resume invoked $0 $*" >> /var/log/slurm-llnl/power_save.log
hosts=`scontrol show hostnames $1`
for host in $hosts
do
docker run --rm \
--name $host \
-h $host \
-v /home:/home \
@mastbaum
mastbaum / Dockerfile
Last active November 1, 2015 18:28
Dockerfile for Ubuntu 14.04 SLURM
View Dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get -y install munge slurm-llnl
RUN mkdir -p /var/run/munge && \
chown munge:munge /var/run/munge && \
chmod 0700 /etc/munge && \
chmod 0711 /var/lib/munge && \
chmod 0700 /var/log/munge && \
chmod 0755 /var/run/munge && \
@mastbaum
mastbaum / slurm.conf
Last active May 17, 2017 12:46
Example slurm.conf for elastic cluster
View slurm.conf
# Example /etc/slurm-llnl/slurm.conf
ControlMachine=master
ControlAddr=192.168.57.100
Proctracktype=proctrack/linuxproc
SlurmctldPort=6819
SlurmdPort=6818
SlurmdSpoolDir=/tmp/slurmd
SlurmUser=slurm
StateSaveLocation=/tmp/slurmd
SwitchType=switch/none
@mastbaum
mastbaum / mkdoc.sh
Created October 15, 2015 22:50
Markdown lab notebook generator
View mkdoc.sh
#!/bin/bash
# Collect the Markdown. Webpage it.
#
# Searches subdirectories for Markdown files and creates a static webpage
# with frames for navigation in a new directory _notebook/. Also copies
# over any images referenced in the md source.
#
# A. Mastbaum <mastbaum@hep.upenn.edu>, 10/2015
#
@mastbaum
mastbaum / time_example.py
Created July 22, 2015 01:49
Python dates & times example
View time_example.py
from datetime import datetime
import pytz # Probably need to install this one on your system
import dateutil.parser
# An example timestamp string
timestamp = "2014-12-12T08:51:06.082327-05:00"
# Convert the string to a datetime object
timestamp_obj = dateutil.parser.parse(timestamp)
@mastbaum
mastbaum / mcphoton.cpp
Created June 10, 2015 17:24
Plot RAT-PAC MC photon data
View mcphoton.cpp
/**
* Example script for drawing MCPhoton information from RAT-PAC ROOT files.
*
* Usage:
*
* root[0] .L mcphoton.cpp+
* root[1] plotMCData("myfile.root");
*
* A. Mastbaum <mastbaum@hep.upenn.edu>, June 2015
*/
@mastbaum
mastbaum / nulobster.py
Created May 8, 2015 22:19
Neutrinoless double-beta decay "lobster" plot
View nulobster.py
'''Make the "lobster plot."
That is, the possible values of the Majorana mass given the mixing parameters
and assuming standard three-neutrino mixing, for the normal and inverted
mass hierarchy.
By the way, the current global best fit parameters from NuFit are:
sin(t12)^2 = 0.304 +/- 0.012
sin(t23)^2 = 0.451 +/- 0.002 (first quadrant)
@mastbaum
mastbaum / check_couchdb_replications.py
Last active December 8, 2016 20:05
Nagios plugin to check that CouchDB replications are working
View check_couchdb_replications.py
#!/usr/bin/env python
'''Check to make sure that all the replications on the local CouchDB server
are actually running.'''
import argparse
from datetime import datetime, timedelta
from operator import itemgetter
import requests
import sys
import tempfile