Skip to content

Instantly share code, notes, and snippets.

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

Ram krishna Sharma ram1123

💭
I may be slow to respond.
View GitHub Profile
@ram1123
ram1123 / PrintWorkspaceToTextFile.C
Created October 16, 2024 11:59
Print Workspace content into a text file
#include <fstream>
#include <iostream>
#include <streambuf>
#include "TFile.h"
#include "RooWorkspace.h"
// void PrintWorkspaceToTextFile(const char *rootFilePath, const char *textFilePath)
void PrintWorkspaceToTextFile(const char *rootFilePath)
{
@ram1123
ram1123 / List of daily uses commands.md
Created May 28, 2024 14:32
List of general commands that i use frequently
@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"