Skip to content

Commit

Permalink
Merge branch 'master' into actions_update
Browse files Browse the repository at this point in the history
  • Loading branch information
toicca authored Dec 17, 2024
2 parents ca9eda6 + a85f574 commit b0da9ff
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 6 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ctag_Wc_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,33 @@ jobs:
opts=$(echo "$opts" | sed 's/--isSyst all/--isSyst weight_only/g')
fi
python runner.py --workflow ectag_Wc_sf --json metadata/test_bta_run3.json --executor iterative --overwrite $opts
- name: ctag muon W+c fixed WP workflows with correctionlib
run: |
string=$(git log -1 --pretty=format:'%s')
if [[ $string == *"ci:skip array"* ]]; then
opts=$(echo "$opts" | sed 's/--isArray //g')
fi
if [[ $string == *"ci:skip syst"* ]]; then
opts=$(echo "$opts" | sed 's/--isSyst all//g')
elif [[ $string == *"ci:JERC_split"* ]]; then
opts=$(echo "$opts" | sed 's/--isSyst all/--isSyst JERC_split/g')
elif [[ $string == *"ci:weight_only"* ]]; then
opts=$(echo "$opts" | sed 's/--isSyst all/--isSyst weight_only/g')
fi
python runner.py --workflow ctag_Wc_WP_sf --json metadata/test_bta_run3.json --executor iterative $opts
- name: ctag electron W+c fixed WP workflows with correctionlib
run: |
message=$(git log -1 --pretty=format:'%s')
if [[ $string == *"ci:skip array"* ]]; then
opts=$(echo "$opts" | sed 's/--isArray //g')
fi
if [[ $string == *"ci:skip syst"* ]]; then
opts=$(echo "$opts" | sed 's/--isSyst all//g')
elif [[ $string == *"ci:JERC_split"* ]]; then
opts=$(echo "$opts" | sed 's/--isSyst all/--isSyst JERC_split/g')
elif [[ $string == *"ci:weight_only"* ]]; then
opts=$(echo "$opts" | sed 's/--isSyst all/--isSyst weight_only/g')
fi
python runner.py --workflow ectag_Wc_WP_sf --json metadata/test_bta_run3.json --executor iterative --overwrite $opts
17 changes: 16 additions & 1 deletion src/BTVNanoCommissioning/utils/histogrammer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from BTVNanoCommissioning.utils.selection import btag_wp_dict
from BTVNanoCommissioning.helpers.definitions import (
definitions,
SV_definitions,
Expand All @@ -6,7 +7,7 @@
import hist as Hist


def histogrammer(events, workflow):
def histogrammer(events, workflow, campaign="Summer22"):
_hist_dict = {}
## Common variables
flav_axis = Hist.axis.IntCategory([0, 1, 4, 5, 6], name="flav", label="Genflavour")
Expand Down Expand Up @@ -462,7 +463,21 @@ def histogrammer(events, workflow):
_hist_dict["nsoftmu"] = Hist.Hist(
syst_axis, osss_axis, n_axis, Hist.storage.Weight()
)

for obj in obj_list:
# mujet pt passing tagger WPs
if "mujet" in obj:
for tagger in btag_wp_dict[campaign].keys():
for wp in btag_wp_dict[campaign][tagger]["c"].keys():
if not "No" in wp:
_hist_dict[f"{obj}_pt_{tagger}{wp}"] = Hist.Hist(
syst_axis,
flav_axis,
osss_axis,
jpt_axis,
Hist.storage.Weight(),
)

if "jet" in obj or "soft_l" in obj:
if obj == "soft_l":
_hist_dict["soft_l_pt"] = Hist.Hist(
Expand Down
107 changes: 107 additions & 0 deletions src/BTVNanoCommissioning/utils/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,114 @@ def btag_wp(jets, campaign, tagger, borc, wp):
},
},
},
"Summer23": {
"DeepFlav": {
"b": {
"No": 0.0,
"L": 0.0479,
"M": 0.2431,
"T": 0.6553,
"XT": 0.7667,
"XXT": 0.9459,
},
"c": {
"No": [0.0, 0.0],
"L": [0.042, 0.234], # CvL, then CvB
"M": [0.102, 0.322],
"T": [0.250, 0.262],
"XT": [0.371, 0.440],
},
},
"RobustParTAK4": {
"b": {
"No": 0.0,
"L": 0.0681,
"M": 0.3487,
"T": 0.7969,
"XT": 0.8882,
"XXT": 0.9883,
},
"c": {
"No": [0.0, 0.0],
"L": [0.038, 0.086],
"M": [0.109, 0.153],
"T": [0.308, 0.113],
"XT": [0.469, 0.275],
},
},
"PNet": {
"b": {
"No": 0.0,
"L": 0.0358,
"M": 0.1917,
"T": 0.6172,
"XT": 0.7515,
"XXT": 0.9659,
},
"c": {
"No": [0.0, 0.0],
"L": [0.052, 0.220],
"M": [0.148, 0.353],
"T": [0.434, 0.300],
"XT": [0.634, 0.549],
},
},
},
"Summer23BPix": {
"DeepFlav": {
"b": {
"No": 0.0,
"L": 0.048,
"M": 0.2435,
"T": 0.6563,
"XT": 0.7671,
"XXT": 0.9483,
},
"c": {
"No": [0.0, 0.0],
"L": [0.042, 0.242], # CvL, then CvB
"M": [0.102, 0.328],
"T": [0.250, 0.267],
"XT": [0.371, 0.444],
},
},
"RobustParTAK4": {
"b": {
"No": 0.0,
"L": 0.0683,
"M": 0.3494,
"T": 0.7994,
"XT": 0.8877,
"XXT": 0.9883,
},
"c": {
"No": [0.0, 0.0],
"L": [0.038, 0.091],
"M": [0.109, 0.157],
"T": [0.308, 0.116],
"XT": [0.469, 0.281],
},
},
"PNet": {
"b": {
"No": 0.0,
"L": 0.0359,
"M": 0.1919,
"T": 0.6133,
"XT": 0.7544,
"XXT": 0.9688,
},
"c": {
"No": [0.0, 0.0],
"L": [0.052, 0.228],
"M": [0.149, 0.358],
"T": [0.436, 0.303],
"XT": [0.634, 0.5552],
},
},
},
}

met_filters = {
"2016preVFP_UL": {
"data": [
Expand Down
6 changes: 6 additions & 0 deletions src/BTVNanoCommissioning/workflows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
# W+c
workflows["ctag_Wc_sf"] = partial(CTAGWcTTValidSFProcessor, selectionModifier="WcM")
workflows["ectag_Wc_sf"] = partial(CTAGWcTTValidSFProcessor, selectionModifier="WcE")
workflows["ctag_Wc_WP_sf"] = partial(
CTAGWcTTValidSFProcessor, selectionModifier="cutbased_WcM"
)
workflows["ectag_Wc_WP_sf"] = partial(
CTAGWcTTValidSFProcessor, selectionModifier="cutbased_WcE"
)

# DY
workflows["ctag_DY_sf"] = partial(CTAGDYValidSFProcessor, selectionModifier="DYM")
Expand Down
45 changes: 40 additions & 5 deletions src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
mu_idiso,
ele_mvatightid,
softmu_mask,
btag_wp,
btag_wp_dict,
)


Expand Down Expand Up @@ -102,11 +104,15 @@ def process_shift(self, events, shift_name):

isMu = False
isEle = False
### selections from Spandan
if "WcM" in self.selMod or "semittM" in self.selMod:
triggers = ["IsoMu27", "IsoMu24"]
isMu = True
dxySigcut = 1.0
muNeEmSum = 0.7
### remove muNeEmSum for cutbased
if "cutbased_WcM" == self.selMod:
muNeEmSum = 1.0
muonpTratioCut = 0.4
isolepdz, isolepdxy, isolepsip3d = 0.01, 0.002, 2
elif "WcE" in self.selMod or "semittE" in self.selMod:
Expand All @@ -122,11 +128,15 @@ def process_shift(self, events, shift_name):
histoname = {
"WcM": "ctag_Wc_sf",
"WcE": "ectag_Wc_sf",
"cutbased_WcM": "ctag_cutbased_Wc_sf",
"cutbased_WcE": "ectag_cutbased_Wc_sf",
"semittM": "ctag_Wc_sf", # same histogram representation as W+c
"semittE": "ectag_Wc_sf", # same histogram representation as W+c
}
_hist_event_dict = (
{"": None} if self.noHist else histogrammer(events, histoname[self.selMod])
{"": None}
if self.noHist
else histogrammer(events, histoname[self.selMod], self._campaign)
)

output = {
Expand Down Expand Up @@ -383,9 +393,20 @@ def process_shift(self, events, shift_name):

osss = 1
ossswrite = shmu.charge * ssmu.charge * -1
if "Wc" in self.selMod:
smuon_jet_passc = {}
c_algos = []
c_wps = []
if "cutbased_Wc" in self.selMod:
osss = shmu.charge * ssmu.charge * -1

c_algos = btag_wp_dict[self._campaign].keys()
for c_algo in c_algos:
smuon_jet_passc[c_algo] = {}
c_wps = btag_wp_dict[self._campaign][c_algo]["c"].keys()
for c_wp in c_wps:
if not "No" in c_wp:
smuon_jet_passc[c_algo][c_wp] = btag_wp(
smuon_jet, self._campaign, c_algo, "c", c_wp
)
njet = ak.count(sjets.pt, axis=1)
# Find the PFCands associate with selected jets. Search from jetindex->JetPFCands->PFCand
if "PFCands" in events.fields:
Expand Down Expand Up @@ -517,7 +538,10 @@ def process_shift(self, events, shift_name):
flatten(ssmu[histname.replace("soft_l_", "")]),
weight=weight,
)
elif "mujet_" in histname:
elif (
"mujet_" in histname
and histname.replace("mujet_", "") in smuon_jet.fields
):
h.fill(
syst,
smflav,
Expand Down Expand Up @@ -617,7 +641,7 @@ def process_shift(self, events, shift_name):
output["MET_phi"].fill(syst, osss, flatten(smet.phi), weight=weight)
output["npvs"].fill(
syst,
events[event_level].PV.npvs,
ak.values_astype(events[event_level].PV.npvs, int),
weight=weight,
)
if not isRealData:
Expand All @@ -626,6 +650,17 @@ def process_shift(self, events, shift_name):
ak.values_astype(events[event_level].Pileup.nTrueInt, int),
weight=weight,
)
if "cutbased_Wc" in self.selMod:
for c_algo in c_algos:
for c_wp in c_wps:
if not "No" in c_wp:
output[f"mujet_pt_{c_algo}{c_wp}"].fill(
syst,
smflav[smuon_jet_passc[c_algo][c_wp]],
osss[smuon_jet_passc[c_algo][c_wp]],
flatten(smuon_jet[smuon_jet_passc[c_algo][c_wp]].pt),
weight=weight[smuon_jet_passc[c_algo][c_wp]],
)
#######################
# Create root files #
#######################
Expand Down

0 comments on commit b0da9ff

Please sign in to comment.