Skip to content

Instantly share code, notes, and snippets.

@pgjones
pgjones / ConvertAirFill.mac
Created March 3, 2012 20:50
Converts air fill files to normal root structure
/run/initialize
/rat/proc count
/rat/procset update 100
/rat/proc outroot
/rat/procset file "unpacked.root"
/rat/unpack/read packed.root
exit
@pgjones
pgjones / In.mac
Created March 6, 2012 18:01
Simple inroot reader for rat
/run/initialize
/rat/proc count
/rat/procset update 100
/rat/proc fitter
/rat/procset method "nearAV" #For example
/rat/proc outroot
/rat/procset file "new.root"
/rat/inroot/read old.root
exit
@pgjones
pgjones / vis.mac
Created March 14, 2012 14:55
Useful heprep visualisation file
/rat/db/set DETECTOR geo_file "geo/snoplus.geo"
# Add a N16 Geometry
/rat/db/load geo/N16Source.geo
/rat/db/set GEO[N16Source] pos [-160.3, 235.0, 152.8]
# Make sure the PMTs are fully visible
/rat/db/set GEO[innerPMT] vis_simple 0
/rat/db/set GEO[outerPMT] vis_simple 0
@pgjones
pgjones / Batch.sh
Created March 14, 2012 15:45
Useful batch script file
#!/bin/bash
CODEFOLDER=/home/jonesph/MCComparison/Electrons/RAT
DATAFOLDER=/data/snoplus/jonesph/MCComparisonData
TEMPFOLDER=$TMPDIR
source /home/jonesph/snoplusenv
file[1]=RAT5MeV
cd $TEMPFOLDER
@pgjones
pgjones / .emacs
Last active June 6, 2023 07:42
Good emacs init file, colours and no tabs
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(column-number-mode t)
'(inhibit-startup-screen t)
'(line-number-mode t)
'(load-home-init-file t t)
'(package-selected-packages (quote (terraform-mode))))
@pgjones
pgjones / PMTOpticsSNOMAN.mac
Created May 30, 2012 21:42
SNOMAN PMT rat commands
/rat/db/set GEO[innerPMT] type "panelbuilder"
/rat/db/set GEO[innerPMT] bucket_type "bSNOMAN"
/rat/db/set GEO[innerPMT] concentrator_type "cSNOMAN"
/rat/db/set GEO[innerPMT] pmt_type "s1408"
/rat/db/set PMT[s1408] model_type "PMTOpticsSNOMAN"
/rat/db/set PMT[s1408] model_params "PMTOpticsSNOMAN_salt"
@pgjones
pgjones / LoadRatDB.py
Created July 13, 2012 11:22
Load a ratdb file into a python dict using yaml and json_minify
#!/usr/bin/env python
# Author P G Jones - 13/07/2012 <[email protected]>
# This script parses a ratdb file and loads the information into a python dict
import yaml # Needs installing, not part of the standard python library
import sys
from minify_json import json_minify # Available from https://github.com/getify/JSON.minify
def LoadRatDB( fileName ):
""" Load a ratdb file and return a dictionary of the contents."""
ratDBFile = open( fileName, "r" )
@pgjones
pgjones / ExtractTimeNhit.cc
Created September 28, 2012 10:02
Extract Nhit and time per event histogram from SNOMAN QSNO root files
////////////////////////////////////////////////////////
/// Extracts the Nhit histograms and Time histograms, into
/// a SNOMAN independent version.
///
/// 06/12/10 - New File
////////////////////////////////////////////////////////
#include <TH1D.h>
#include <TFile.h>
#include <TTree.h>
@pgjones
pgjones / Load.cc
Created October 8, 2012 13:13
Basic rat macros and code
////////////////////////////////////////////////////////
/// My preferred method to load a root file in root.
/// Must load in root as .L Load.cc+
///
/// 11/10/2012 : New File
////////////////////////////////////////////////////////
#include <RAT/DS/Root.hh>
#include <RAT/DS/EV.hh>
#include <RAT/DS/Run.hh>
@pgjones
pgjones / plot_stopping_power.py
Last active October 12, 2015 14:08
Plot dE/dx from rat
#!/usr/bin/env python
# Plot the stopping power versus energy, and deposited energy versus distance travelled
# Author P G Jones - 13/09/2012 <[email protected]>
import ROOT
import rat
import time
import sys
import math
def plot_file(file_name):