Skip to content

Instantly share code, notes, and snippets.

@jdbrice
jdbrice / bnlSirMount.sh
Created July 27, 2015 15:58
Uses the sshfs_mount script to mount /star/institutions/rice locally
#!/bin/bash
sshfs_mount.sh jdb@rftpexp.rhic.bnl.gov /star/institutions/rice/ /Users/danielbrandenburg/bnl/sir $1
@jdbrice
jdbrice / TF1toXml.cpp
Created August 5, 2015 19:54
Converts a Root TF1 to an xml attribute string
string Common::toXml( TF1 * f ){
string line = "";
line += "formula=\"";
line += f->GetTitle();
line += "\"";
for ( int ip = 0; ip < f->GetNpar(); ip++ ){
line += " p" + ts(ip) + "=\"";
@jdbrice
jdbrice / hadder.py
Created August 25, 2015 22:09
Pythonized version of ROOT's hadd program for adding histograms together. It breaks jobs into manageable sized chunks.
#!/usr/bin/env python2.7
"""
root's hadd gets really inefficiency for large numbers of files - it becomes much more efficienct to do it in small batches.
This tool hadds some collection of files in smaller batches and gives you the result. maybe in the future ill make it parallelized
"""
import argparse
import os
import glob
@jdbrice
jdbrice / cov_matrix.cpp
Created September 7, 2015 02:12
macro for calculating cov matrix of a given set of variables from TChain
#include "Reporter.h"
#include "RooPlotLib.h"
map< string, double> cov_matrix( vector<string> sources, string cut ){
Reporter rp( "rp_cov_matrix.pdf", 600, 600 );
RooPlotLib rpl;
TChain * c = new TChain( "rcpPicoDst" );
@jdbrice
jdbrice / SpectraLoader.h
Last active September 8, 2015 04:06
Quick code for reading in the spectra format that I and several others use
#include <fstream>
#include "TGraphErrors.h"
class SpectraLoader{
public:
vector<double> pT;
vector<double> value;
vector<double> stat;
vector<double> sys;
@jdbrice
jdbrice / Root_confidence_interval.C
Last active September 19, 2015 19:03
root confidence interval
// call this immediately after calling TH1->Fit(...)
// f - Fit function pointer
// name - histogram name
// cl - confidence level : ie 0.68 for 1 sigma, 0.95 for 2 sigma
// x1 - minimum x range
// x2 - maximum x range
TH1 * fitCL( TF1 * f, string name, double cl, int nPoints, double x1, double x2 ){
@jdbrice
jdbrice / auto_start_condor.plist
Created January 22, 2016 22:01
plist file to start condor on os x
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>condor</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/condor/sbin/condor_master</string>
@jdbrice
jdbrice / loadListRange.h
Created January 26, 2016 20:00
Load data from list in a condor efficient way
void loadListRange( TChain * _chain, string _listFile, int _jobIndex, int _splitBy ){
int min = _jobIndex * _splitBy;
int max = (_jobIndex + 1) * _splitBy - 1;
if ( 0 > _splitBy || 0 > _jobIndex ){
return;
}
int fileIndex = 0;
@jdbrice
jdbrice / MakeStatusFile.C
Last active February 3, 2016 23:47
Produces Root file with histograms for Tof Status QA
{
TFile * f = new TFile( "TofStatusQA.root" );
vector<bool> tray_status;
tray_status.push_back( false ); // index starts at 1
map< string, bool> module_status;
@jdbrice
jdbrice / cLife.xml
Created February 4, 2016 07:49
VPD Channel Life (and mapping )
<?xml version="1.0" encoding="UTF-8"?>
<!-- A root node is required -->
<!-- It can be anything <root></root>, it just has to exist -->
<config>
<input>
<dst treeName="tof" maxFiles="2" nEvents="10000" url="/Users/danielbrandenburg/bnl/local/"/>
</input>