Skip to content

Instantly share code, notes, and snippets.

View giorgiopizz's full-sized avatar

Giorgio Pizzati giorgiopizz

View GitHub Profile
@giorgiopizz
giorgiopizz / fileset.py
Last active June 27, 2024 11:37
my_processor snippets
import json
import random
import sys
import dask
import uproot
from coffea.dataset_tools import rucio_utils
from dbs.apis.dbsClient import DbsApi
@giorgiopizz
giorgiopizz / jme_clib.py
Created June 18, 2024 09:43
JERC with correctionlib
import json
import os
import sys
import awkward as ak
# import correctionlib._core as core
import correctionlib
import hist
import matplotlib as mpl
@giorgiopizz
giorgiopizz / main42.cc
Created May 8, 2024 07:45
Shower and ntuplizer
// /cvmfs/sft.cern.ch/lcg/releases/gcc/12.1.0-57c96/x86_64-centos7/bin/g++ main42.cc -o main42 -I/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/pythia8/310-4b0bd/x86_64-centos7-gcc12-opt/include -O2 -std=c++11 -pedantic -W -Wall -Wshadow -fPIC -pthread -L/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/pythia8/310-4b0bd/x86_64-centos7-gcc12-opt/lib -Wl,-rpath,/cvmfs/sft.cern.ch/lcg/releases/MCGenerators/pythia8/310-4b0bd/x86_64-centos7-gcc12-opt/lib -lpythia8 -ldl -I/cvmfs/sft.cern.ch/lcg/releases/fastjet/3.4.1-5af57/x86_64-centos7-gcc12-opt/include/ -L/cvmfs/sft.cern.ch/lcg/releases/fastjet/3.4.1-5af57/x86_64-centos7-gcc12-opt/lib/ -Wl,-rpath,/cvmfs/sft.cern.ch/lcg/releases/fastjet/3.4.1-5af57/x86_64-centos7-gcc12-opt/lib/ -lfastjet `root-config --cflags --glibs`
// main42.cc is a part of the PYTHIA event generator.
// Copyright (C) 2023 Torbjorn Sjostrand.
// PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
// Please respect the MCnet Guidelines, see GUIDELINES for details.
// Authors
@giorgiopizz
giorgiopizz / HIG_cfg.py
Created April 22, 2024 08:27
Produce nanoGEN in CMSSW
# Auto generated configuration file
# using:
# Revision: 1.19
# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v
# with command line options: Configuration/GenProduction/python/HIG.py --python_filename HIG_cfg.py --eventcontent NANOAODGEN --customise Configuration/DataProcessing/Utils.addMonitoring --datatier NANOAOD --fileout file:HIG-RunIISummer20UL18wmLHEGEN-01277.root --conditions 106X_upgrade2018_realistic_v4 --beamspot Realistic25ns13TeVEarly2018Collision --geometry DB:Extended --step LHE,GEN,NANOGEN --era Run2_2018 --no_exec --mc -n 10
import FWCore.ParameterSet.Config as cms
from FWCore.ParameterSet.VarParsing import VarParsing
options = VarParsing ('analysis')
@giorgiopizz
giorgiopizz / restrict.py
Last active March 11, 2024 11:42
Simple script to edit a MG restrict card and save it
import requests
import subprocess
class block:
def __init__(self, restrict, name='SMEFT'):
start = restrict.index(list(filter(lambda k: k == 'Block ' + name, restrict))[0]) + 1
stop = restrict[start:].index('###################################')
stop = start + stop
"""
Main script for the creation of shapes, starting from a configuration folder.
It gives the option to compile the configuration folder and save it as both JSON and pickle file.
It also gives the option to run the analysis in batch mode, or to check for errors in the batch submission.
The analysis can be run in batch mode or locally.
If run in batch mode it gives the ability to merge the output root files.
@giorgiopizz
giorgiopizz / runner.py
Created February 13, 2024 13:28
Support subsamples with different weights in mkShapesRDF
from copy import deepcopy
import sys
import ROOT
from array import array
from mkShapesRDF.lib.parse_cpp import ParseCpp
import os
from math import sqrt
ROOT.gROOT.SetBatch(True)
ROOT.TH1.SetDefaultSumw2(True)
@giorgiopizz
giorgiopizz / mkDatacards.py
Created February 12, 2024 14:59
mkDatacards.py updated
#!/usr/bin/env python
import sys
import ROOT
import optparse
import collections
import os.path
import shutil
@giorgiopizz
giorgiopizz / runner.py
Created January 29, 2024 09:45
New runner.py to unroll and fold in mkShapesRDF
from copy import deepcopy
import sys
import ROOT
from array import array
from mkShapesRDF.lib.parse_cpp import ParseCpp
import os
from math import sqrt
ROOT.gROOT.SetBatch(True)
ROOT.TH1.SetDefaultSumw2(True)
@giorgiopizz
giorgiopizz / an.py
Last active January 19, 2024 14:06
Read lhe and make histos
import sys
#sys.path.insert(0, '/gwpool/users/tecedor/.local/lib/python3.9/site-packages/')
sys.path.insert(0, '/gwpool/users/gpizzati/.local/lib/python3.9/site-packages/')
import ROOT
import pylhe
import awkward as ak
import numpy as np
#arr = pylhe.to_awkward(pylhe.read_lhe_with_attributes('/gwpool/users/tecedor/genproductions/GridpackConfig/bin/MadGraph5_aMCatNLO/lhe/HHjj_ewk_smhloop0_dim6_3ops_15904236_10.lhe'))
files = []