Skip to content

Instantly share code, notes, and snippets.

View skaplanhex's full-sized avatar

Steven Kaplan skaplanhex

View GitHub Profile
@skaplanhex
skaplanhex / singleJetTriggerBool.h
Created September 19, 2016 16:32
Single jet trigger boolean
bool singleJetFired =
TriggerBit_HLT_AK8DiPFJet280_200_TrimMass30_BTagCSV0p45_v3==1 || TriggerBit_HLT_AK8PFJet360_TrimMass30_v3==1 || TriggerBit_HLT_CaloJet500_NoJetID_v2==1 || TriggerBit_HLT_DiCaloJetAve140_v1==1 || TriggerBit_HLT_DiCaloJetAve200_v1==1 || TriggerBit_HLT_DiCaloJetAve260_v1==1 || TriggerBit_HLT_DiCaloJetAve320_v1==1 || TriggerBit_HLT_DiCaloJetAve400_v1==1 || TriggerBit_HLT_DiCaloJetAve40_v1==1 || TriggerBit_HLT_DiCaloJetAve500_v1==1 || TriggerBit_HLT_DiCaloJetAve60_v1==1 || TriggerBit_HLT_DiCaloJetAve80_v1==1 || TriggerBit_HLT_DiPFJetAve100_HFJEC_v3==1 || TriggerBit_HLT_DiPFJetAve140_v2==1 || TriggerBit_HLT_DiPFJetAve160_HFJEC_v3==1 || TriggerBit_HLT_DiPFJetAve200_v2==1 || TriggerBit_HLT_DiPFJetAve220_HFJEC_v3==1 || TriggerBit_HLT_DiPFJetAve260_v2==1 || TriggerBit_HLT_DiPFJetAve300_HFJEC_v3==1 || TriggerBit_HLT_DiPFJetAve30_HFJEC_v3==1 || TriggerBit_HLT_DiPFJetAve320_v2==1 || TriggerBit_HLT_DiPFJetAve400_v2==1 || TriggerBit_HLT_DiPFJetAve40_v2==1 || TriggerBit_HLT_DiPFJetAve500_v2==1
@skaplanhex
skaplanhex / makepdf.py
Created May 19, 2016 21:57
Will make a pdf of all the plots in a root file
import ROOT as r
import numpy
from math import *
from sys import argv
from ROOT import TMath
from array import array
r.gROOT.SetBatch()
def GetMedian(hist):
@skaplanhex
skaplanhex / TGraphToTH1D.py
Created April 20, 2016 06:11
PyRoot code that creates a TH1D from a TGraphAsymmErrors and vise versa
from ROOT import *
def TGraphAsymmErrorsToTH1D(g,histName):
numPoints = g.GetN()
# xHigh = g.GetErrorXhigh(numPoints-1)
# xLow = g.GetErrorXlow(0)
binBoundaries = []
binContents = []
binErrors = []
for i in range(numPoints):
#define fTree_cxx
#include "fTree.h"
#include "helperFunctions.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
void fTree::Loop()
{
@skaplanhex
skaplanhex / GGJetsXSs.txt
Created April 13, 2016 21:30
Table of cross sections for the sherpa GGJets datasets
# All datasets are of the form /GGJets_M-<MASSBIN>_Pt-50_13TeV-sherpa_RunIIFall15MiniAODv2-PU25nsData2015v1_76X_mcRun2_asymptotic_v12-v1_MINIAODSIM
#
# Mass Bin XS (pb) XS uncert (pb)
60-200 5.728e+00 7.750e-02
200-500 2.214e+00 3.106e-02
500-1000 1.514e-01 2.188e-03
1000-2000 1.154e-02 1.635e-04
2000-4000 3.794e-04 5.178e-06
4000-6000 2.406e-06 3.337e-08
6000-8000 1.879e-08 2.646e-10
import FWCore.ParameterSet.Config as cms
process = cms.Process("Demo")
process.load("FWCore.MessageService.MessageLogger_cfi")
process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) )
process.options.allowUnscheduled = cms.untracked.bool(True)
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) )
@skaplanhex
skaplanhex / myFakeRateMacroJet.C
Created March 14, 2016 13:02
Otman's RooFit macro calculating the fake rate for one pT bin
#include "TROOT.h"
#include "TSystem.h"
#include "TH1F.h"
#include "TF1.h"
#include "RooHistPdf.h"
#include "RooRealVar.h"
#include "RooPlot.h"
#include "RooDataHist.h"
#include "RooAddPdf.h"
#include "RooExtendPdf.h"

To hadd files where the output is on EOS

hadd root://cmseos.fnal.gov//store/user/skaplan/xrdtest.root `xrdfsls -u /store/user/skaplan/foo/bar/ | grep \.root`

To hadd files where the output is local

hadd xrdtest.root xrdfsls -u /store/user/skaplan/foo/bar/ | grep \.root

@skaplanhex
skaplanhex / duplicateChecker.py
Last active December 16, 2015 14:04
Check for duplicate root files from alabama ntuple jobs
# assumes a file list with no directories and filenames like ExoDiPhotonAnalyzer_1000_1_QP6.root
def getJobNum(f):
return f[20:][:-11]
# for "plots" instead of "ExoDiPhotonAnalyzer", return f[:-11][6:]
from glob import glob
files = glob("ExoDiPhotonAnalyzer*.root")
#files = ["ExoDiPhotonAnalyzer_1000_1_QP4.root","ExoDiPhotonAnalyzer_1000_1_QP6.root","ExoDiPhotonAnalyzer_1000_1_Q36.root"]
@skaplanhex
skaplanhex / TLegendExample.py
Last active August 29, 2015 14:16
Example of code in pyROOT to create a legend for a plot since I can never remember all the steps required :).
# Comments line by line
# leg = TLegend(.73,.32,.97,.53) # TLegend(x1,y1,x2,y2) where x,y are in units of percentage of canvas (i.e. x,y \in [0,1])
# leg.SetBorderSize(0) # no border
# leg.SetFillColor(0) # probably kWhite
# leg.SetFillStyle(0) # I'm guessing this just means pure color, no patterns
# leg.SetTextFont(42)
# leg.SetTextSize(0.035) # somewhat large, may need to play with this to make the plot look ok
# leg.AddEntry(g1,"2X_{n}","L") # AddEntry(TGraph/TH1D varName, what you want the legend to say for this graph, show the line)
# leg.AddEntry(geq1,"2X_{n,eq}","L")