Skip to content

Instantly share code, notes, and snippets.

@jdbrice
jdbrice / plot_from_tree.C
Last active March 9, 2021 19:51
Plot tracking from ttree on Pythia events
TLatex tl;
TString label = "";
TString klabel = "";
TH1* sliceFit(TH2 * h2, TString _klabel){
TF1 * fgyRes = new TF1( "fgyRes", "gaus" );
fgyRes->SetRange( -0.5, 0.5 );
h2->RebinX(4);
h2->FitSlicesY( fgyRes );
@jdbrice
jdbrice / rootSTGM.C
Created February 12, 2021 01:03
Rough STAR sTGC geometry using ROOT TGeo
// Globals
TGeoManager *geom;
TGeoElementTable *table;
// Materials
TGeoMedium *mediumAir;
TGeoMedium *mediumG10;
TGeoMedium *mediumNPC02;
@jdbrice
jdbrice / pair_pt.C
Last active January 24, 2021 02:15
Rho photonuclear STARLight MC
#include "TFile.h"
#include "TH1F.h"
#include "TH1D.h"
#include "TH2F.h"
#include "TH3F.h"
#include "TCanvas.h"
#include "TMath.h"
#include "TVector3.h"
#include "TLegend.h"
@jdbrice
jdbrice / md-cal.sh
Last active October 8, 2024 11:49
Generate markdown table calendar. Use wiki links to individual days
# Author: Daniel Brandenburg
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@jdbrice
jdbrice / marp-example.md
Created July 13, 2020 20:48
Marp style block for custom css in preview AND export
theme _class backgroundColor marp footer tags
gaia
lead
true
Daniel Brandenburg | 07142020
<style> /* this works for export */
@jdbrice
jdbrice / gitcommitstr.C
Created July 26, 2019 14:42
TAG your ROOT files with your codes git commit so you always know what version of the code produced output
#include <cstdio>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <array>
// credit : https://stackoverflow.com/users/58008/waqas
// from : https://stackoverflow.com/questions/478898/how-do-i-execute-a-command-and-get-output-of-command-within-c-using-posix
@jdbrice
jdbrice / moment.C
Created July 25, 2019 15:05
Calculate the moments of a histogram
//usr/bin/env root -l -b -q "$0( $1, \"$2\" )"; exit $?
/* Calculate the nth moment of a distribution
*
* int n : order of the moment to calculate
* TString filehist :
*/
double moment( int n = 1, TString filehist = "", float x1=0, float x2=-1 ){
cout << "Calculating moment " << n << " on " << filehist << endl;
@jdbrice
jdbrice / linspace.py
Last active January 31, 2019 21:29
Makes numpy linspace ranges from the shell, even chain together with commas
#!/usr/bin/env python
import numpy
import sys
if len(sys.argv) < 4:
print( "Usage: linspace start stop step [, endpoint, ndecimals]" )
exit()
if not sys.stdin.isatty():
@jdbrice
jdbrice / arange.py
Last active January 31, 2019 21:30
Makes numpy arange ranges from the shell, even chain together with commas
#!/usr/bin/env python
import numpy
import sys
if len(sys.argv) < 4:
print( "Usage: arange start stop step [, ndecimals]" )
exit()
if not sys.stdin.isatty():
@jdbrice
jdbrice / jupyter.css
Created December 16, 2018 17:52
Styling for jupyter notebooks saved to html
/*!
*
* Twitter Bootstrap
*
*/
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2016 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/