Skip to content

Instantly share code, notes, and snippets.

View ram1123's full-sized avatar
💭
I may be slow to respond.

Ramkrishna Sharma ram1123

💭
I may be slow to respond.
View GitHub Profile
@ram1123
ram1123 / PrintHist.py
Last active August 8, 2023 15:27
Print the cut-flow histogram. Then arrange the cuts based on number of events. Also, print the 3rd column as the % change in the number of events.
import ROOT
# Set ROOT to run in batch mode
ROOT.gROOT.SetBatch(True)
def print_bins_noSort(hist):
xaxis = hist.GetXaxis()
for i in range(1, hist.GetNbinsX() + 1):
bin_content = hist.GetBinContent(i)
bin_label = xaxis.GetBinLabel(i)
@ram1123
ram1123 / gist:bf8921377949c3b19f82ce14e1ea95a0
Last active July 23, 2023 16:12 — forked from jdye64/gist:ca07e01ff3d8e93210c3
Convert .dav files in current directory to .mp4
#!/usr/bin/python
print("Converting all of the .dav files in this current directory into .mp4 files using ffmpeg")
import os
from subprocess import call
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
ext = f.split(".")[-1]
if ext == "dav" or ext == "DAV":
import ROOT as ROOT
import sys
ROOT.gROOT.SetBatch(ROOT.kTRUE)
def get_standard_deviation(histogram):
# Compute the standard deviation of a histogram
mean = histogram.GetMean()
variance = histogram.GetStdDev() ** 2
return variance ** 0.5
import os
# Specify the directory containing the PDF files
pdf_dir = '/afs/cern.ch/user/r/rasharma/work/LearnCombine/CMSSW_11_3_4/src/2l2Q_limitSettingTool/ImpactPlotCollection/'
# Get a list of the PDF files in the directory
pdf_files = [f for f in os.listdir(pdf_dir) if f.endswith('.pdf')]
# Create a LaTeX file for the presentation
with open('presentation.tex', 'w') as f:
import ROOT
def SignificanceScan(var="evalDNN_HH"):
sigFile = "/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN_Evaluate_HHWWyyDNN_NewModel6_E700_LR10em4_B150_VarMixV1MaxBRmvCorr_Trial1_BalanceYields/GluGluToHHTo2G4Q_node_cHHH1_2017.root"
# bkgFiles = ["/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN_Evaluate_HHWWyyDNN_NewModel6_E700_LR10em4_B150_VarMixV1MaxBRmvCorr_Trial1_BalanceYields/Data_2017.root"]
bkgFiles = ["/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN_Evaluate_HHWWyyDNN_NewModel6_E700_LR10em4_B150_VarMixV1MaxBRmvCorr_Trial1_BalanceYields/Data_2017.root", "/eos/user/r/rasharma/post_doc_ihep/double-higgs/ntuples/January_2021_Production/DNN_Evaluate_HHWWyyDNN_NewModel6_E700_LR10em4_B150_VarMixV1MaxBRmvCorr_Trial1_BalanceYields/Data_2018.root"]
fileCount = 0
# Open the input ROOT file
@ram1123
ram1123 / getMDTableForCrabStatus.py
Last active February 19, 2023 14:08
From big crab status output prepare a summary markdown table
import os
import sys
if sys.version_info[0] < 3:
print("This script requires Python 3. Please use Python 3 to run this script.")
sys.exit()
# Run crab status command and append in log file
ifRunCrabStatus = False
import sys
if sys.version_info[0] < 3:
print("This script requires Python 3. Please use Python 3 to run this script.")
sys.exit()
@ram1123
ram1123 / condor_events.sub
Last active December 22, 2022 06:19
condor script for slc6 for generating gridpack and CMSSW simulation. Reference: Ankita Mehta and Alexander Grohsjean
request_cpus = 1
request_memory = 4GB
request_disk = 4GB
executable = /afs/cern.ch/user/r/rasharma/work/slc6_condor/generate_events.sh
output = /afs/cern.ch/user/r/rasharma/work/slc6_condor/$(ClusterId).out
error = /afs/cern.ch/user/r/rasharma/work/slc6_condor/$(ClusterId).out
getenv = FALSE
should_transfer_files = NO
+RequestRuntime = 3600
+JobFlavour = "workday"
@ram1123
ram1123 / condor_setup.py
Created November 11, 2022 14:28
Condor setup script
import os
sh_file_template = '''#!/bin/bash
echo "Starting job on " `date`
echo "Running on: `uname -a`"
echo "System software: `cat /etc/redhat-release`"
source /cvmfs/cms.cern.ch/cmsset_default.sh
echo "###################################################"
echo "# List of Input Arguments: "
from ROOT import *
f_xBF = TFile('xs_125.0_2017/hzz4l_4muS_13TeV_xs_SM_125_mass4l_v3.Databin0.root','READ')
w_xBF = f_xBF.Get("w")
# w_xBF.Print()
f_LLR = TFile('xs_125.0_2017/hzz4l_4muS_13TeV_xs_SM_125_mass4l_v3.Databin0.root','READ')
w_LLR = f_LLR.Get("w")
# w_LLR.Print()