Skip to content

Commit

Permalink
fix: add pv hists
Browse files Browse the repository at this point in the history
  • Loading branch information
Ming-Yan committed Feb 14, 2024
1 parent bf16c52 commit 2ddd52c
Show file tree
Hide file tree
Showing 30 changed files with 136 additions and 86 deletions.
5 changes: 4 additions & 1 deletion condor/execute.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ OPTS="--wf ${ARGS[workflow]} --year ${ARGS[year]} --campaign ${ARGS[campaign]} -
if [ "${ARGS[voms]}" != "null" ]; then
OPTS="$OPTS --voms ${ARGS[voms]}"
fi
for key in isSyst isArray noHist overwrite skipbadfiles; do
if [ "${ARGS[isSyst]}" != "null" ]; then
OPTS="$OPTS --isSyst ${ARGS[isSyst]}"
fi
for key in isArray noHist overwrite skipbadfiles; do
if [ "${ARGS[$key]}" == true ]; then
OPTS="$OPTS --$key"
fi
Expand Down
Binary file modified src/BTVNanoCommissioning/data/JME/Summer22Run3/jec_compiled.pkl.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
17 changes: 15 additions & 2 deletions src/BTVNanoCommissioning/utils/AK4_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,31 @@
},
"Summer23": {
"lumiMask": "Cert_Collisions2023_366442_370790_Golden.json",
# "PU": "puweight_Summer22EERun3-80p0mb.histo.root", # 69.2mb
"PU": "puwei_Summer23.histo.root",
# "JME": "jec_compiled.pkl.gz",
"jetveto": {
"Run2023BC jetvetomap": "jetveto2023BC.histo.root"
}, # this is from Mikko https://indico.cern.ch/event/1315421/contributions/5532963/attachments/2697975/4683826/2023_08_16_jetvetomaps_v3.pdf
"JPCalib": {
"Run2023B-22Sep2023-v1": "calibeHistoWrite_Data2023B-22Sep2023.root",
"Run2023C-22Sep2023-v1": "calibeHistoWrite_Data2023C-22Sep2023_v1.root",
"Run2023C-22Sep2023-v2": "calibeHistoWrite_Data2023C-22Sep2023_v2.root",
"Run2023C-22Sep2023-v3": "calibeHistoWrite_Data2023C-22Sep2023_v3.root",
"Run2023C-22Sep2023-v4": "calibeHistoWrite_Data2023C-22Sep2023_v4.root",
"MC": "calibeHistoWrite_MC2023_Summer23.root",
},
},
"Summer23BPix": {
"lumiMask": "Cert_Collisions2023_366442_370790_Golden.json",
# "PU": "puweight_Summer22EERun3-80p0mb.histo.root", # 69.2mb
"PU": "puwei_Summer23BPix.histo.root",
# "JME": "jec_compiled.pkl.gz",
"jetveto": {
"Run2023D jetvetomap_bpix": "jetveto2023D.histo.root"
}, # this is from Mikko https://indico.cern.ch/event/1315421/contributions/5532963/attachments/2697975/4683826/2023_08_16_jetvetomaps_v3.pdf
"JPCalib": {
"Run2023D-22Sep2023-v1": "calibeHistoWrite_Data2023D-22Sep2023_v1.root",
"Run2023D-22Sep2023-v2": "calibeHistoWrite_Data2023D-22Sep2023_v2.root",
"MC": "calibeHistoWrite_MC2023_Summer23BPix.root",
},
},
}
4 changes: 1 addition & 3 deletions src/BTVNanoCommissioning/utils/correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def load_SF(campaign, syst=False):
]
elif str(filename).endswith(".json.gz"):
correct_map["PU"] = correctionlib.CorrectionSet.from_file(
importlib.resources.path(
f"BTVNanoCommissioning.data.PU.{campaign}", filename
)
str(filename)
)
elif str(filename).endswith(".histo.root"):
ext = extractor()
Expand Down
4 changes: 2 additions & 2 deletions src/BTVNanoCommissioning/utils/histogrammer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def histogrammer(events, workflow):
ptratio_axis = Hist.axis.Regular(50, 0, 1, name="ratio", label="ratio")
n_axis = Hist.axis.Integer(0, 10, name="n", label="N obj")
osss_axis = Hist.axis.IntCategory([1, -1], name="osss", label="OS(+)/SS(-)")
_hist_dict["npvs"] = Hist.Hist(npvs_axis, Hist.storage.Weight())
_hist_dict["pu"] = Hist.Hist(npvs_axis, Hist.storage.Weight())
_hist_dict["npvs"] = Hist.Hist(syst_axis, npvs_axis, Hist.storage.Weight())
_hist_dict["pu"] = Hist.Hist(syst_axis, npvs_axis, Hist.storage.Weight())
### Workflow specific
if "example" == workflow:
obj_list = [
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_DY_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ def process_shift(self, events, shift_name):
**_hist_event_dict,
}

if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)

####################
# Selections #
Expand Down Expand Up @@ -381,9 +382,11 @@ def process_shift(self, events, shift_name):
output["z_eta"].fill(syst, flatten(sz.eta), weight=weight)
output["z_phi"].fill(syst, flatten(sz.phi), weight=weight)
output["z_mass"].fill(syst, flatten(sz.mass), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_Wc_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ def process_shift(self, events, shift_name):
**_hist_event_dict,
}

if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
####################
# Selections #
####################
Expand Down Expand Up @@ -512,9 +513,11 @@ def process_shift(self, events, shift_name):
output["w_mass"].fill(syst, osss, flatten(sw.mass), weight=weight)
output["MET_pt"].fill(syst, osss, flatten(smet.pt), weight=weight)
output["MET_phi"].fill(syst, osss, flatten(smet.phi), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_dileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@ def process_shift(self, events, shift_name):
**_hist_event_dict,
}

if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)

####################
# Selections #
Expand Down Expand Up @@ -455,9 +456,11 @@ def process_shift(self, events, shift_name):
output["z_mass"].fill(syst, flatten(sz.mass), weight=weight)
output["MET_pt"].fill(syst, flatten(smet.pt), weight=weight)
output["MET_phi"].fill(syst, flatten(smet.phi), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_eDY_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ def process_shift(self, events, shift_name):
**_hist_event_dict,
}

if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
####################
# Selections #
####################
Expand Down Expand Up @@ -381,9 +382,11 @@ def process_shift(self, events, shift_name):
output["z_eta"].fill(syst, flatten(sz.eta), weight=weight)
output["z_phi"].fill(syst, flatten(sz.phi), weight=weight)
output["z_mass"].fill(syst, flatten(sz.mass), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_eWc_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ def process_shift(self, events, shift_name):
**_hist_event_dict,
}

if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
####################
# Selections #
####################
Expand Down Expand Up @@ -487,9 +488,11 @@ def process_shift(self, events, shift_name):
output["w_mass"].fill(syst, osss, flatten(sw.mass), weight=weight)
output["MET_pt"].fill(syst, osss, flatten(smet.pt), weight=weight)
output["MET_phi"].fill(syst, osss, flatten(smet.phi), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_edileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ def process_shift(self, events, shift_name):
"sumw": processor.defaultdict_accumulator(float),
**_hist_event_dict,
}
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
####################
# Selections #
####################
Expand Down Expand Up @@ -451,9 +452,11 @@ def process_shift(self, events, shift_name):
output["z_mass"].fill(syst, flatten(sz.mass), weight=weight)
output["MET_pt"].fill(syst, flatten(smet.pt), weight=weight)
output["MET_phi"].fill(syst, flatten(smet.phi), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_emdileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ def process_shift(self, events, shift_name):
**_hist_event_dict,
}

if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
####################
# Selections #
####################
Expand Down Expand Up @@ -505,9 +506,11 @@ def process_shift(self, events, shift_name):
output["z_mass"].fill(syst, flatten(sz.mass), weight=weight)
output["MET_pt"].fill(syst, flatten(smet.pt), weight=weight)
output["MET_phi"].fill(syst, flatten(smet.phi), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_ettsemilep_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,11 @@ def process_shift(self, events, shift_name):
**_hist_event_dict,
}

if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)

####################
# Selections #
Expand Down Expand Up @@ -491,9 +492,11 @@ def process_shift(self, events, shift_name):
output["w_mass"].fill(syst, flatten(sw.mass), weight=weight)
output["MET_pt"].fill(syst, flatten(smet.pt), weight=weight)
output["MET_phi"].fill(syst, flatten(smet.phi), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_semileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@ def process_shift(self, events, shift_name):
**_hist_event_dict,
}

if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)

###############
# Event level #
Expand Down Expand Up @@ -507,9 +508,11 @@ def process_shift(self, events, shift_name):
output["w_mass"].fill(syst, flatten(sw.mass), weight=weight)
output["MET_pt"].fill(syst, flatten(smet.pt), weight=weight)
output["MET_phi"].fill(syst, flatten(smet.phi), weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
9 changes: 5 additions & 4 deletions src/BTVNanoCommissioning/workflows/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ def process_shift(self, events, shift_name):
"sumw": processor.defaultdict_accumulator(float),
**_hist_event_dict,
}
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
####################
# Selections #
####################
Expand Down
9 changes: 5 additions & 4 deletions src/BTVNanoCommissioning/workflows/ttbar_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ def process_shift(self, events, shift_name):
"sumw": processor.defaultdict_accumulator(float),
**_hist_event_dict,
}
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)

####################
# Selections #
Expand Down
15 changes: 9 additions & 6 deletions src/BTVNanoCommissioning/workflows/ttdilep_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,11 @@ def process_shift(self, events, shift_name):
"sumw": processor.defaultdict_accumulator(float),
**_hist_event_dict,
}
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
if shift_name is None:
if isRealData:
output["sumw"] = len(events)
else:
output["sumw"] = ak.sum(events.genWeight)
####################
# Selections #
####################
Expand Down Expand Up @@ -402,9 +403,11 @@ def process_shift(self, events, shift_name):
weight=weight,
)
output["njet"].fill(syst, nseljet, weight=weight)
output["npvs"].fill(events[event_level].PV.npvs, weight=weight)
output["npvs"].fill(syst, events[event_level].PV.npvs, weight=weight)
if not isRealData:
output["pu"].fill(events[event_level].Pileup.nTrueInt, weight=weight)
output["pu"].fill(
syst, events[event_level].Pileup.nTrueInt, weight=weight
)
#######################
# Create root files #
#######################
Expand Down
Loading

0 comments on commit 2ddd52c

Please sign in to comment.