From 58c708eb08a3db2f66bd475d8a4dabbbf6686e4f Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Mon, 30 Sep 2024 18:03:55 +0200 Subject: [PATCH 1/9] Added histograms for ctag fixed WP SF --- .../utils/histogrammer.py | 17 ++- src/BTVNanoCommissioning/utils/plot_utils.py | 74 +++--------- src/BTVNanoCommissioning/utils/selection.py | 107 ++++++++++++++++++ .../workflows/__init__.py | 2 + .../workflows/ctag_Wctt_valid_sf.py | 40 ++++++- 5 files changed, 177 insertions(+), 63 deletions(-) diff --git a/src/BTVNanoCommissioning/utils/histogrammer.py b/src/BTVNanoCommissioning/utils/histogrammer.py index 3c8d81a4..4cb8a000 100644 --- a/src/BTVNanoCommissioning/utils/histogrammer.py +++ b/src/BTVNanoCommissioning/utils/histogrammer.py @@ -1,8 +1,9 @@ from BTVNanoCommissioning.helpers.definitions import definitions, SV_definitions +from BTVNanoCommissioning.utils.selection import btag_wp_dict 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") @@ -391,7 +392,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( diff --git a/src/BTVNanoCommissioning/utils/plot_utils.py b/src/BTVNanoCommissioning/utils/plot_utils.py index e9ba53ad..4d8144f9 100644 --- a/src/BTVNanoCommissioning/utils/plot_utils.py +++ b/src/BTVNanoCommissioning/utils/plot_utils.py @@ -34,22 +34,22 @@ "TTTo2J1L1Nu_CP5_13p6TeV_powheg-pythia8", ], # single top - "Single top": [ - "TbarBQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", - "TBbarQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", - "TWminus_DR_AtLeastOneLepton_CP5_13p6TeV_powheg-pythia8", - "TbarBQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", - "TbarWplus_DR_AtLeastOneLepton_CP5_13p6TeV_powheg-pythia8", +# "Single top": [ +# "TbarBQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", +# "TBbarQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", +# "TWminus_DR_AtLeastOneLepton_CP5_13p6TeV_powheg-pythia8", +# "TbarBQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", +# "TbarWplus_DR_AtLeastOneLepton_CP5_13p6TeV_powheg-pythia8", # decay - "TWminusto4Q_TuneCP5_13p6TeV_powheg-pythia8", - "TWminustoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8", - "TWminusto2L2Nu_TuneCP5_13p6TeV_powheg-pythia8", - "TbarWplusto4Q_TuneCP5_13p6TeV_powheg-pythia8", - "TbarWplustoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8", - "TbarWplusto2L2Nu_TuneCP5_13p6TeV_powheg-pythia8", - "TBbarQ_t-channel_4FS_TuneCP5_13p6TeV_powheg-madspin-pythia8", - "TbarBQ_t-channel_4FS_TuneCP5_13p6TeV_powheg-madspin-pythia8", - ], +# "TWminusto4Q_TuneCP5_13p6TeV_powheg-pythia8", +# "TWminustoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8", +# "TWminusto2L2Nu_TuneCP5_13p6TeV_powheg-pythia8", +# "TbarWplusto4Q_TuneCP5_13p6TeV_powheg-pythia8", +# "TbarWplustoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8", +# "TbarWplusto2L2Nu_TuneCP5_13p6TeV_powheg-pythia8", +# "TBbarQ_t-channel_4FS_TuneCP5_13p6TeV_powheg-madspin-pythia8", +# "TbarBQ_t-channel_4FS_TuneCP5_13p6TeV_powheg-madspin-pythia8", +# ], # diboson "VV": [ "WW_TuneCP5_13p6TeV-pythia8", @@ -82,49 +82,7 @@ "WtoLNu-4Jets_3J_TuneCP5_13p6TeV_madgraphMLM-pythia8", ], # QCD - "QCD": [ - "QCD_PT-15to30_TuneCP5_13p6TeV_pythia8", - "QCD_PT-30to50_TuneCP5_13p6TeV_pythia8", - "QCD_PT-50to80_TuneCP5_13p6TeV_pythia8", - "QCD_PT-50to80_TuneCP5_13p6TeV_pythia8", - "QCD_PT-80to120_TuneCP5_13p6TeV_pythia8", - "QCD_PT-120to170_TuneCP5_13p6TeV_pythia8", - "QCD_PT-170to300_TuneCP5_13p6TeV_pythia8", - "QCD_PT-170to300_TuneCP5_13p6TeV_pythia8", - "QCD_PT-300to470_TuneCP5_13p6TeV_pythia8", - "QCD_PT-300to470_TuneCP5_13p6TeV_pythia8", - "QCD_PT-470to600_TuneCP5_13p6TeV_pythia8", - "QCD_PT-470to600_TuneCP5_13p6TeV_pythia8", - "QCD_PT-600to800_TuneCP5_13p6TeV_pythia8", - "QCD_PT-600to800_TuneCP5_13p6TeV_pythia8", - "QCD_PT-800to1000_TuneCP5_13p6TeV_pythia8", - "QCD_PT-800to1000_TuneCP5_13p6TeV_pythia8", - "QCD_PT-1000to1400_TuneCP5_13p6TeV_pythia8", - "QCD_PT-1000to1400_TuneCP5_13p6TeV_pythia8", - "QCD_PT-1400to1800_TuneCP5_13p6TeV_pythia8", - "QCD_PT-1400to1800_TuneCP5_13p6TeV_pythia8", - "QCD_PT-1800to2400_TuneCP5_13p6TeV_pythia8", - "QCD_PT-1800to2400_TuneCP5_13p6TeV_pythia8", - "QCD_PT-2400to3200_TuneCP5_13p6TeV_pythia8", - "QCD_PT-2400to3200_TuneCP5_13p6TeV_pythia8", - "QCD_PT-3200_TuneCP5_13p6TeV_pythia8", - "QCD_PT-3200_TuneCP5_13p6TeV_pythia8", - ], - # QCD muon enriched - "QCD($\\mu$)": [ - "QCD_PT-15to20_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-20to30_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-30to50_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-50to80_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-80to120_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-120to170_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-170to300_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-300to470_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-470to600_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-600to800_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-800to1000_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - "QCD_PT-1000_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", - ], + } ### copy functions coffea.hist.plotratio https://github.com/CoffeaTeam/coffea/blob/master/coffea/hist/plot.py to boost-hist ################ diff --git a/src/BTVNanoCommissioning/utils/selection.py b/src/BTVNanoCommissioning/utils/selection.py index dc4e36c5..79b10fd1 100644 --- a/src/BTVNanoCommissioning/utils/selection.py +++ b/src/BTVNanoCommissioning/utils/selection.py @@ -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": [ diff --git a/src/BTVNanoCommissioning/workflows/__init__.py b/src/BTVNanoCommissioning/workflows/__init__.py index 51f8208f..64cdf3ab 100644 --- a/src/BTVNanoCommissioning/workflows/__init__.py +++ b/src/BTVNanoCommissioning/workflows/__init__.py @@ -73,6 +73,8 @@ # 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") diff --git a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py index e21f3d78..8452b31f 100644 --- a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py +++ b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py @@ -27,6 +27,8 @@ mu_idiso, ele_mvatightid, softmu_mask, + btag_wp, + btag_wp_dict ) @@ -102,6 +104,7 @@ 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 @@ -109,6 +112,10 @@ def process_shift(self, events, shift_name): muNeEmSum = 0.7 muonpTratioCut = 0.4 isolepdz, isolepdxy, isolepsip3d = 0.01, 0.002, 2 + ### remove muNeEmSum for cutbased + if "cutbased_WcM" == self.selMod: + muNeEmSum = 1.0 + muonpTratioCut = 0.6 elif "WcE" in self.selMod or "semittE" in self.selMod: triggers = ["Ele32_WPTight_Gsf_L1DoubleEG"] isEle = True @@ -122,11 +129,13 @@ def process_shift(self, events, shift_name): histoname = { "WcM": "ctag_Wc_sf", "WcE": "ectag_Wc_sf", + "cutbased_WcM": "ctag_Wc_sf", + "cutbased_WcE": "ectag_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 = { @@ -383,9 +392,19 @@ def process_shift(self, events, shift_name): osss = 1 ossswrite = shmu.charge * ssmu.charge * -1 + smuon_jet_passc = {} + c_algos = [] + c_wps = [] if "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: @@ -517,7 +536,9 @@ def process_shift(self, events, shift_name): flatten(ssmu[histname.replace("soft_l_", "")]), weight=weight, ) - elif "mujet_" in histname: + elif "mujet_" in histname and not any( + c_algo in histname for c_algo in c_algos + ): h.fill( syst, smflav, @@ -617,7 +638,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: @@ -626,6 +647,17 @@ def process_shift(self, events, shift_name): ak.values_astype(events[event_level].Pileup.nTrueInt, int), weight=weight, ) + if "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 # ####################### From 64401acf015826b08c0d3e6f19fa9fa4c280204b Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Mon, 30 Sep 2024 18:15:29 +0200 Subject: [PATCH 2/9] restoring plotutils --- src/BTVNanoCommissioning/utils/plot_utils.py | 74 +++++++++++++++----- 1 file changed, 58 insertions(+), 16 deletions(-) diff --git a/src/BTVNanoCommissioning/utils/plot_utils.py b/src/BTVNanoCommissioning/utils/plot_utils.py index 4d8144f9..e9ba53ad 100644 --- a/src/BTVNanoCommissioning/utils/plot_utils.py +++ b/src/BTVNanoCommissioning/utils/plot_utils.py @@ -34,22 +34,22 @@ "TTTo2J1L1Nu_CP5_13p6TeV_powheg-pythia8", ], # single top -# "Single top": [ -# "TbarBQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", -# "TBbarQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", -# "TWminus_DR_AtLeastOneLepton_CP5_13p6TeV_powheg-pythia8", -# "TbarBQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", -# "TbarWplus_DR_AtLeastOneLepton_CP5_13p6TeV_powheg-pythia8", + "Single top": [ + "TbarBQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", + "TBbarQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", + "TWminus_DR_AtLeastOneLepton_CP5_13p6TeV_powheg-pythia8", + "TbarBQ_t-channel_4FS_CP5_13p6TeV_powheg-madspin-pythia8", + "TbarWplus_DR_AtLeastOneLepton_CP5_13p6TeV_powheg-pythia8", # decay -# "TWminusto4Q_TuneCP5_13p6TeV_powheg-pythia8", -# "TWminustoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8", -# "TWminusto2L2Nu_TuneCP5_13p6TeV_powheg-pythia8", -# "TbarWplusto4Q_TuneCP5_13p6TeV_powheg-pythia8", -# "TbarWplustoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8", -# "TbarWplusto2L2Nu_TuneCP5_13p6TeV_powheg-pythia8", -# "TBbarQ_t-channel_4FS_TuneCP5_13p6TeV_powheg-madspin-pythia8", -# "TbarBQ_t-channel_4FS_TuneCP5_13p6TeV_powheg-madspin-pythia8", -# ], + "TWminusto4Q_TuneCP5_13p6TeV_powheg-pythia8", + "TWminustoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8", + "TWminusto2L2Nu_TuneCP5_13p6TeV_powheg-pythia8", + "TbarWplusto4Q_TuneCP5_13p6TeV_powheg-pythia8", + "TbarWplustoLNu2Q_TuneCP5_13p6TeV_powheg-pythia8", + "TbarWplusto2L2Nu_TuneCP5_13p6TeV_powheg-pythia8", + "TBbarQ_t-channel_4FS_TuneCP5_13p6TeV_powheg-madspin-pythia8", + "TbarBQ_t-channel_4FS_TuneCP5_13p6TeV_powheg-madspin-pythia8", + ], # diboson "VV": [ "WW_TuneCP5_13p6TeV-pythia8", @@ -82,7 +82,49 @@ "WtoLNu-4Jets_3J_TuneCP5_13p6TeV_madgraphMLM-pythia8", ], # QCD - + "QCD": [ + "QCD_PT-15to30_TuneCP5_13p6TeV_pythia8", + "QCD_PT-30to50_TuneCP5_13p6TeV_pythia8", + "QCD_PT-50to80_TuneCP5_13p6TeV_pythia8", + "QCD_PT-50to80_TuneCP5_13p6TeV_pythia8", + "QCD_PT-80to120_TuneCP5_13p6TeV_pythia8", + "QCD_PT-120to170_TuneCP5_13p6TeV_pythia8", + "QCD_PT-170to300_TuneCP5_13p6TeV_pythia8", + "QCD_PT-170to300_TuneCP5_13p6TeV_pythia8", + "QCD_PT-300to470_TuneCP5_13p6TeV_pythia8", + "QCD_PT-300to470_TuneCP5_13p6TeV_pythia8", + "QCD_PT-470to600_TuneCP5_13p6TeV_pythia8", + "QCD_PT-470to600_TuneCP5_13p6TeV_pythia8", + "QCD_PT-600to800_TuneCP5_13p6TeV_pythia8", + "QCD_PT-600to800_TuneCP5_13p6TeV_pythia8", + "QCD_PT-800to1000_TuneCP5_13p6TeV_pythia8", + "QCD_PT-800to1000_TuneCP5_13p6TeV_pythia8", + "QCD_PT-1000to1400_TuneCP5_13p6TeV_pythia8", + "QCD_PT-1000to1400_TuneCP5_13p6TeV_pythia8", + "QCD_PT-1400to1800_TuneCP5_13p6TeV_pythia8", + "QCD_PT-1400to1800_TuneCP5_13p6TeV_pythia8", + "QCD_PT-1800to2400_TuneCP5_13p6TeV_pythia8", + "QCD_PT-1800to2400_TuneCP5_13p6TeV_pythia8", + "QCD_PT-2400to3200_TuneCP5_13p6TeV_pythia8", + "QCD_PT-2400to3200_TuneCP5_13p6TeV_pythia8", + "QCD_PT-3200_TuneCP5_13p6TeV_pythia8", + "QCD_PT-3200_TuneCP5_13p6TeV_pythia8", + ], + # QCD muon enriched + "QCD($\\mu$)": [ + "QCD_PT-15to20_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-20to30_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-30to50_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-50to80_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-80to120_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-120to170_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-170to300_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-300to470_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-470to600_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-600to800_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-800to1000_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + "QCD_PT-1000_MuEnrichedPt5_TuneCP5_13p6TeV_pythia8", + ], } ### copy functions coffea.hist.plotratio https://github.com/CoffeaTeam/coffea/blob/master/coffea/hist/plot.py to boost-hist ################ From d2b06e27a34dedddf97235bde8d48de58eba1683 Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Wed, 9 Oct 2024 15:38:21 +0200 Subject: [PATCH 3/9] black reformatting --- .../utils/histogrammer.py | 6 +++--- .../workflows/__init__.py | 8 ++++++-- .../workflows/ctag_Wctt_valid_sf.py | 19 +++++++++++-------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/BTVNanoCommissioning/utils/histogrammer.py b/src/BTVNanoCommissioning/utils/histogrammer.py index 4cb8a000..b82cbd56 100644 --- a/src/BTVNanoCommissioning/utils/histogrammer.py +++ b/src/BTVNanoCommissioning/utils/histogrammer.py @@ -397,8 +397,8 @@ def histogrammer(events, workflow, campaign="Summer22"): # 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: + 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, @@ -406,7 +406,7 @@ def histogrammer(events, workflow, campaign="Summer22"): 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( diff --git a/src/BTVNanoCommissioning/workflows/__init__.py b/src/BTVNanoCommissioning/workflows/__init__.py index 64cdf3ab..04714bf4 100644 --- a/src/BTVNanoCommissioning/workflows/__init__.py +++ b/src/BTVNanoCommissioning/workflows/__init__.py @@ -73,8 +73,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") +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") diff --git a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py index 8452b31f..42fee2aa 100644 --- a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py +++ b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py @@ -28,7 +28,7 @@ ele_mvatightid, softmu_mask, btag_wp, - btag_wp_dict + btag_wp_dict, ) @@ -135,7 +135,9 @@ def process_shift(self, events, shift_name): "semittE": "ectag_Wc_sf", # same histogram representation as W+c } _hist_event_dict = ( - {"": None} if self.noHist else histogrammer(events, histoname[self.selMod], self._campaign) + {"": None} + if self.noHist + else histogrammer(events, histoname[self.selMod], self._campaign) ) output = { @@ -400,11 +402,12 @@ def process_shift(self, events, shift_name): 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() + c_wps = btag_wp_dict[self._campaign][c_algo]["c"].keys() for c_wp in c_wps: - if not 'No' in c_wp: + if not "No" in c_wp: smuon_jet_passc[c_algo][c_wp] = btag_wp( - smuon_jet, self._campaign, c_algo, "c", c_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: @@ -537,7 +540,7 @@ def process_shift(self, events, shift_name): weight=weight, ) elif "mujet_" in histname and not any( - c_algo in histname for c_algo in c_algos + c_algo in histname for c_algo in c_algos ): h.fill( syst, @@ -638,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, - ak.values_astype(events[event_level].PV.npvs,int), + ak.values_astype(events[event_level].PV.npvs, int), weight=weight, ) if not isRealData: @@ -650,7 +653,7 @@ def process_shift(self, events, shift_name): if "Wc" in self.selMod: for c_algo in c_algos: for c_wp in c_wps: - if not 'No' in c_wp: + if not "No" in c_wp: output[f"mujet_pt_{c_algo}{c_wp}"].fill( syst, smflav[smuon_jet_passc[c_algo][c_wp]], From 635001df049cd3e2402159b3f672d78aa489d932 Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Wed, 11 Dec 2024 17:16:52 +0100 Subject: [PATCH 4/9] Adding CI for fixed WP workflow --- .github/workflows/ctag_Wc_workflow.yml | 33 +++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ctag_Wc_workflow.yml b/.github/workflows/ctag_Wc_workflow.yml index a8d51cf1..e0e841f2 100644 --- a/.github/workflows/ctag_Wc_workflow.yml +++ b/.github/workflows/ctag_Wc_workflow.yml @@ -133,4 +133,35 @@ jobs: elif [[ $string == *"ci:weight_only"* ]]; then 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 \ No newline at end of file + 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 \ No newline at end of file From 03e611180362323b8a86648ef22e09c5229c7d82 Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Wed, 11 Dec 2024 17:19:48 +0100 Subject: [PATCH 5/9] removing --- src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py index dc4f4686..9d89be66 100644 --- a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py +++ b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py @@ -115,7 +115,6 @@ def process_shift(self, events, shift_name): ### remove muNeEmSum for cutbased if "cutbased_WcM" == self.selMod: muNeEmSum = 1.0 - muonpTratioCut = 0.4 elif "WcE" in self.selMod or "semittE" in self.selMod: triggers = ["Ele32_WPTight_Gsf_L1DoubleEG"] isEle = True From 54f79a32484e7971fc68c4b688025bbba4ddb323 Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Wed, 11 Dec 2024 17:20:48 +0100 Subject: [PATCH 6/9] uniform requirement for shape and fixed WP analyses --- src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py index 9d89be66..0dea12c4 100644 --- a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py +++ b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py @@ -110,11 +110,11 @@ def process_shift(self, events, shift_name): 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 - ### remove muNeEmSum for cutbased - if "cutbased_WcM" == self.selMod: - muNeEmSum = 1.0 elif "WcE" in self.selMod or "semittE" in self.selMod: triggers = ["Ele32_WPTight_Gsf_L1DoubleEG"] isEle = True From 825f0138d3cfefb6a52333c1b41ef29611df886c Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Wed, 11 Dec 2024 18:28:38 +0100 Subject: [PATCH 7/9] new hist only for cutbased wf --- src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py index 0dea12c4..21af8227 100644 --- a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py +++ b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py @@ -128,8 +128,8 @@ def process_shift(self, events, shift_name): histoname = { "WcM": "ctag_Wc_sf", "WcE": "ectag_Wc_sf", - "cutbased_WcM": "ctag_Wc_sf", - "cutbased_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 } @@ -396,7 +396,7 @@ def process_shift(self, events, shift_name): smuon_jet_passc = {} c_algos = [] c_wps = [] - if "Wc" in self.selMod: + 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: @@ -649,7 +649,7 @@ def process_shift(self, events, shift_name): ak.values_astype(events[event_level].Pileup.nTrueInt, int), weight=weight, ) - if "Wc" in self.selMod: + if "cutbased_Wc" in self.selMod: for c_algo in c_algos: for c_wp in c_wps: if not "No" in c_wp: From 6b33da340d09a5de2ce7e78d474b73b60b97c6b1 Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Mon, 16 Dec 2024 17:21:08 +0100 Subject: [PATCH 8/9] fixing pipeline --- src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py index 21af8227..2e36d713 100644 --- a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py +++ b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py @@ -538,9 +538,7 @@ def process_shift(self, events, shift_name): flatten(ssmu[histname.replace("soft_l_", "")]), weight=weight, ) - elif "mujet_" in histname and not any( - c_algo in histname for c_algo in c_algos - ): + elif "mujet_" in histname and histname.replace("mujet_", "") in smuon_jet.fields: h.fill( syst, smflav, From 00262aaedeba3b2eaf50c1e5db298b66e49eeba0 Mon Sep 17 00:00:00 2001 From: Agostino De Iorio Date: Mon, 16 Dec 2024 17:36:42 +0100 Subject: [PATCH 9/9] fixing formatting --- src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py index 2e36d713..74d2658e 100644 --- a/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py +++ b/src/BTVNanoCommissioning/workflows/ctag_Wctt_valid_sf.py @@ -538,7 +538,10 @@ def process_shift(self, events, shift_name): flatten(ssmu[histname.replace("soft_l_", "")]), weight=weight, ) - elif "mujet_" in histname and histname.replace("mujet_", "") in smuon_jet.fields: + elif ( + "mujet_" in histname + and histname.replace("mujet_", "") in smuon_jet.fields + ): h.fill( syst, smflav,