Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add validation workflow from MC & add 2023 files #91

Merged
merged 40 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4f96701
test file for QCD
Oct 6, 2023
79d8360
QCD Pt binned samples for QCD workflow
Nov 9, 2023
4de6c26
Data samples for QCD workflow
Nov 9, 2023
9a36495
add QCD workflow selection
Nov 9, 2023
49e1301
add UL18 files for QCD
Nov 9, 2023
5f86e77
add histograms for QCD workflow
Nov 9, 2023
6ecf437
PU weights for QCD workflow
Nov 9, 2023
84e59e6
HLT_PFJet140 prescales
Nov 9, 2023
6b6f962
add variables for QCD workflow
Nov 9, 2023
a3c3ef4
add QCD Pt binned samples xsection
Nov 9, 2023
1db83bf
QCD workflow, need debug
Nov 10, 2023
c936cf9
add QCD workflow
Nov 10, 2023
266e762
add QCD plotting
Nov 10, 2023
8453835
prescales for HLT_PFJet140
Nov 10, 2023
f99dc0f
script to prepare json file for prescales
Nov 10, 2023
50575b9
csv file contains HLT_PFJet140 prescales information
Nov 10, 2023
5a1298d
Resolved conflicts
uttiyasarkar Nov 14, 2023
b437150
fix : add new files & change tagger axis & minor fixes
Ming-Yan Dec 3, 2023
fd79a80
feat: add condor resubmission scripts & fix DY hists
Nov 21, 2023
f2a5db0
Merge pull request #2 from uttiyasarkar/devhsin
hsinweihsia Dec 8, 2023
3047c9b
feat : add validation workflow & ROC/efficiency script
Ming-Yan Dec 3, 2023
5ac19b9
Merge branch 'master' of github.com:cms-btv-pog/BTVNanoCommissioning
Ming-Yan Feb 9, 2024
73ffd99
fix: correction
Ming-Yan Feb 12, 2024
668d775
fix: correction
Ming-Yan Feb 12, 2024
bf16c52
fix: correction implementation & add pu info
Ming-Yan Feb 12, 2024
1f7f492
fix: add pv hists
Ming-Yan Feb 14, 2024
9eb79f1
fix:axis
Ming-Yan Feb 15, 2024
ec2a36b
fix:minor
Ming-Yan Feb 15, 2024
8526451
Merge branch 'master' into QCD
Ming-Yan Feb 19, 2024
5fbffff
fix: compatible with current changes
Ming-Yan Feb 20, 2024
5967ba9
fix: working QCD
Ming-Yan Feb 23, 2024
ee43ed6
feat: fixed QCD
Ming-Yan Feb 24, 2024
0331cfa
feat: add veto
Ming-Yan Mar 11, 2024
f5ae16c
feat: add Summer23 info
Ming-Yan Mar 11, 2024
1c9bbc8
fix : format
Ming-Yan Mar 11, 2024
4828510
feat : change JEC implementation
Ming-Yan Mar 20, 2024
00e9404
fix : workflow
Ming-Yan Mar 20, 2024
7071cb0
fix : remove dependency python 3.8
Ming-Yan Mar 20, 2024
b677807
feat : minor fixes
Ming-Yan Mar 25, 2024
eb509a4
feat: add xsection
Ming-Yan Mar 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: fixed QCD
  • Loading branch information
Ming-Yan committed Mar 6, 2024
commit ee43ed628f6b79549ffa62bb5ef112a41d612239
2,199 changes: 0 additions & 2,199 deletions metadata/MC_Summer23_Run3_2023_qcd_BTV_Comm_v1_NanoV12.json

This file was deleted.

3,381 changes: 0 additions & 3,381 deletions metadata/MC_Summer23_Run3_2023_qcdmu_BTV_Comm_v1_NanoV12.json

This file was deleted.

168 changes: 168 additions & 0 deletions scripts/dump_prescale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
import json, os, argparse, pandas
import correctionlib.schemav2 as cs
from BTVNanoCommissioning.helpers.BTA_helper import BTA_HLT

### NOTICE The scripts only works on lxplus...

parser = argparse.ArgumentParser(description="Create prescale weights(lxplus)")

parser.add_argument(
"--lumimask",
default="src/BTVNanoCommissioning/data/lumiMasks/Cert_Collisions2022_355100_362760_Golden.json",
help="lumimask to generate prescale weights",
)
parser.add_argument("--HLT", default=None, type=str, help="Which HLT is used")
parser.add_argument("-v", "--verbose", action="store_true", help="debugging")


### NOTICE The scripts only works on lxplus...
def get_prescale(HLT, lumimask, verbose=False):
# os.system("source /cvmfs/cms-bril.cern.ch/cms-lumi-pog/brilws-docker/brilws-env")
prescales = pandas.DataFrame()
runs = json.load(open(lumimask))
runs = list(runs.keys())
os.system("source /cvmfs/cms-bril.cern.ch/cms-lumi-pog/brilws-docker/brilws-env")
if not os.path.exists(
f"src/BTVNanoCommissioning/data/Prescales/HLTinfo_{HLT}_run{runs[0]}_{runs[-1]}.csv"
):

for run in runs:

os.system(
f"brilcalc trg --prescale --hltpath 'HLT_{HLT}*' -r {run} --output-style csv &>tmp.csv"
)
ps = pandas.read_csv("tmp.csv")
prescales = prescales._append(ps)
# prescales= prescales[prescales['totprescval']!=0]
prescales.to_csv(
f"src/BTVNanoCommissioning/data/Prescales/HLTinfo_{HLT}_run{runs[0]}_{runs[-1]}.csv"
)

if verbose:
print("prescaled :", prescales)
else:
prescales = pandas.read_csv(
f"src/BTVNanoCommissioning/data/Prescales/HLTinfo_{HLT}_run{runs[0]}_{runs[-1]}.csv"
)
return prescales


### code from Hsin-Wei: https://github.com/cms-btv-pog/BTVNanoCommissioning/blob/f2a5db0e325c9b26d220089a49ddb8f73682f846/prescales.ipynb
## read prescale


def get_ps(ps, verbose=False):
if len(ps) != 1:
if verbose:
print("Length of ps after selection ", len(ps))
raise ValueError(ps)
if verbose:
print("Final prescale weight: ", ps.iloc[0]["totprescval"])
return float(ps.iloc[0]["totprescval"])


def build_lumibins(ps, verbose=False):
##### to sort as bin edges properly, starting lumi sections need to be stored as floats
if verbose:
print("Path: ", ps["hltpath/prescval"], ps["totprescval"])
edges = sorted(set(ps["cmsls"].astype(float)))
if len(edges) == 1:
return get_ps(ps)
elif len(edges) > 1:
edges.append(float("inf"))
if verbose:
print("Lumi bin edges: ", list(zip(edges[:-1], edges[1:])))
content = [
get_ps(
ps[(ps["cmsls"].astype(float) >= lo) & (ps["cmsls"].astype(float) < hi)]
)
for lo, hi in zip(edges[:-1], edges[1:])
]
if verbose:
print("Prescales: ", content)
return cs.Binning.parse_obj(
{
"nodetype": "binning",
"input": "lumi",
"edges": edges,
"content": content,
"flow": "clamp",
}
)


def build_runs(ps, HLT_paths, verbose=False):
runs = sorted(ps["# run"].unique())
if verbose:
print("Selected ", len(runs), ": ", runs)
return cs.Category.parse_obj(
{
"nodetype": "category",
"input": "run",
"content": [
{
"key": int(run),
"value": build_paths(ps[ps["# run"] == run], HLT_paths),
}
for run in runs
],
}
)


def build_paths(ps, HLT_paths, verbose=False):
if verbose:
print("Run: ", ps["# run"].iloc[0], type(ps["# run"].iloc[0]))
# paths are unique bc of hltpath/lumi --> make array of path name separate
paths = [HLT_paths]
if verbose:
print("Type of path key: ", type(paths[0]), paths)
return cs.Category.parse_obj(
{
"nodetype": "category",
"input": "path",
"content": [
{"key": str(path), "value": build_lumibins(ps)} for path in paths
],
}
)


if __name__ == "__main__":
args = parser.parse_args()
if args.HLT is None:
args.HLT = BTA_HLT
else:
if args.HLT.split(","):
args.HLT = args.HLT
args.HLT = [args.HLT]

for HLT in args.HLT:
print("HLT : ", HLT)
ps_csvData = get_prescale(HLT, args.lumimask, args.verbose)
psCorr = cs.Correction.parse_obj(
{
"version": 2,
"name": "prescaleWeight",
"inputs": [
{"name": "run", "type": "int"},
{"name": "path", "type": "string"},
{"name": "lumi", "type": "real"},
],
"output": {"name": "weight", "type": "real"},
"data": build_runs(ps_csvData, "HLT_" + HLT),
}
)
cset = cs.CorrectionSet(
schema_version=2,
corrections=[psCorr],
description=f"prescales for HLT_{HLT}",
)
runs = json.load(open(args.lumimask))

runs = list(runs.keys())
with open(
f"src/BTVNanoCommissioning/data/Prescales/ps_weight_{HLT}_run{runs[0]}_{runs[-1]}.json",
"w",
) as f:
f.write(cset.json(exclude_unset=True))

Large diffs are not rendered by default.

Loading