Skip to content

Instantly share code, notes, and snippets.

@jdbrice
jdbrice / bookmarklet.js
Created February 13, 2022 17:31 — forked from tomcritchlow/bookmarklet.js
Gist code for Electric Tables V0.2.
// Convert this JS code into a bookmarklet using a tool like: http://js.do/blog/bookmarklets/
// Be sure to add your own macro_url and spreadsheet_url
var macro_url = "THIS IS YOUR MACRO URL";
var spreadsheet_id = "THIS IS YOUR SPREADSHEET URL";
var iframe = document.createElement("iframe");
iframe.setAttribute("name","dummyframe");
iframe.setAttribute("id","dummyframe");
iframe.setAttribute("style","display:none;");
@jdbrice
jdbrice / read_mudst.C
Created December 6, 2021 22:27
Read MuDST for testing FTT structures
void read_mudst(char* file="input.MuDst.root",
int ifile=-1, Int_t nevt=-1, char* outdir=".", int readMuDst=1){
gROOT->Macro("Load.C");
gROOT->Macro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
gSystem->Load("StEventMaker");
gSystem->Load("StFcsDbMaker");
gSystem->Load("StFttRawHitMaker");
@jdbrice
jdbrice / VMMHardwareMap.h
Created November 17, 2021 14:21
Hardware mapping class for VMM
#include <assert.h>
#include <fstream>
/*********************************************************/
// class for mapping the VMM electronics
//
// Some terminology
// in the raw data from Tonko we have (SEC, RDO, FEB ...)
// these correspond to our sTGC naming as:
//
// SEC = Plane (1, 2, 3, 4)
@jdbrice
jdbrice / Example_output_runNumber_22316001
Created November 12, 2021 17:12
sTGC pulser hash generator, runNumber provids a "random" seed
FEE[0] : 0000101110011101001001000011100100010110111010111011111011110111000010111001110100100100001110010001011011000101001100011000000000001011100111010010010000111001000101110011100011011001111001010000101110011101001001000011100100010111000100100100110001101110
FEE[1] : 0010101111000111100101011100111001001010000101111001001111010000001010111100011110010101110011100100101000111110001000010100011100101011110001111001010111001110010010100110010010101110101111100010101111000111100101011100111001001010100010110011110000110101
FEE[2] : 1100101101000111100000010111011011001111111101000011011100010100110010110100011110000001011101101101000000011010110001001000101111001011010001111000011101000101000111010010011101101001011101111100101101000111100001110100010100011101000000001101110000000000
FEE[3] : 1110101101110010101110000111001001001001010110001010000111001111111010110111001010111000011100100100100100110010000101000101100011101011011100101011100001110010010010011010010110111100101111011110101101110010101100101
@jdbrice
jdbrice / README.md
Created November 11, 2021 03:14
Read sTGC data from RTS_Example and wwrtie to ROOT TTree

Example:

cd /star/u/jdb/work/ssw/stgc-raw-hit-reader/StRoot/RTS/src/RTS_EXAMPLE starver dev make make ./rts_example /star/data03/pwg/jdb/FWD/daq/stgc-cosmic/st_hltcosmic_22314049_raw_0000002.daq -D stgcsctrg > /star/data03/pwg/jdb/FWD/daq/stgc-cosmic/st_hltcosmic_22314049_raw_0000002.daq.dat

If needed, copy output to wherever the above two scripts are root -b -q -l 'read_RTS.C( "/star/data03/pwg/jdb/FWD/daq/stgc-cosmic/st_hltcosmic_22314049_raw_0000002.daq.dat" )'

@jdbrice
jdbrice / WIPStgmGeo.xml
Last active September 28, 2021 20:18
Work in progress sTGC geometry with pentagonal design
<Document file="StarVMC/Geometry/StgmGeo/StgmGeo1.xml">
<Replace match="GeV">*1.0E+0;</Replace>
<Replace match="MeV">*1.0E-3;</Replace>
<Replace match="keV">*1.0E-6;</Replace>
<Module name="StgmGeo1" comment="Forward Tracking System Geometry / developed for the sTGC tracker">
<Created date="08/19/2021" />
<Author name="Daniel Brandenburg" />
@jdbrice
jdbrice / starlight_reader_example.C
Created July 28, 2021 18:06
Example reader code for STARLight text format
ifstream infile( starlight.c_str() );
int iEvent =0;
while (infile) {
string sEvent, sVertex, sTrack1, sTrack2;
if (!getline( infile, sEvent )) break;
if (!getline( infile, sVertex )) break;
if (!getline( infile, sTrack1 )) break;
if (!getline( infile, sTrack2 )) break;
@jdbrice
jdbrice / Agufld.C
Created April 19, 2021 13:53
Export the STAR Magnetic field
static const Int_t nrp = 200; // number of R nodes in the map
static const Int_t nzp = 800; // number of Z nodes in the map
static const Float_t zm = 800.0; // map max length
static const Float_t rm = 400.0; // map max radius
static const Int_t nphi = 36;
//________________________________________________________________________________
void Agufld(const Char_t *field = "FieldOn") {
// if ( gClassTable->GetID("TGiant3") >= 0) { // root4star
// gROOT->LoadMacro("bfc.C");
// bfc(-1,"MagF,nodefault",0);
@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;