Skip to content

Commit

Permalink
feat: clean up MET
Browse files Browse the repository at this point in the history
  • Loading branch information
Ming-Yan committed Apr 12, 2024
1 parent 55fb72a commit 3326b21
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 165 deletions.
2 changes: 1 addition & 1 deletion src/BTVNanoCommissioning/helpers/xsection.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
},
{
"process_name": "WtoLNu-4Jets_TuneCP5_13p6TeV_madgraphMLM-pythia8",
"cross_section": "54860",
"cross_section": "63199.9",
"DAS": "/WtoLNu-4Jets_TuneCP5_13p6TeV_madgraphMLM-pythia8/Run3Summer22NanoAODv11-126X_mcRun3_2022_realistic_v2-v2/NANOAODSIM",
"energy": "13.6",
"comment": "from TOP-22-012",
Expand Down
3 changes: 2 additions & 1 deletion src/BTVNanoCommissioning/utils/correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def JME_shifts(
ak.values_astype(corrected_polar_met(*metinfo).pt, np.float32),
ak.values_astype(corrected_polar_met(*metinfo).phi, np.float32),
)
met["orig_pt"], met["orig_phi"] = nocorrmet["pt"], nocorrmet["pt"]
met["orig_pt"], met["orig_phi"] = nocorrmet["pt"], nocorrmet["phi"]
if systematic != False:

if systematic != "JERC_split":
Expand Down Expand Up @@ -691,6 +691,7 @@ def JME_shifts(
if "jetveto" in correct_map.keys():
events.Jet = update(events.Jet, {"veto": jetveto(events, correct_map)})
shifts += [({"Jet": jets, "MET": met}, None)]
print("in shift", met.pt)
return shifts


Expand Down
2 changes: 1 addition & 1 deletion src/BTVNanoCommissioning/utils/histogrammer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def histogrammer(events, workflow):
## Common variables
flav_axis = Hist.axis.IntCategory([0, 1, 4, 5, 6], name="flav", label="Genflavour")
syst_axis = Hist.axis.StrCategory([], name="syst", growth=True)
pt_axis = Hist.axis.Regular(300, 0, 3000, name="pt", label=" $p_{T}$ [GeV]")
pt_axis = Hist.axis.Regular(300, 0, 300, name="pt", label=" $p_{T}$ [GeV]")
jpt_axis = Hist.axis.Regular(300, 0, 3000, name="pt", label=" $p_{T}$ [GeV]")
softlpt_axis = Hist.axis.Regular(25, 0, 25, name="pt", label=" $p_{T}$ [GeV]")
mass_axis = Hist.axis.Regular(50, 0, 300, name="mass", label=" $p_{T}$ [GeV]")
Expand Down
1 change: 0 additions & 1 deletion src/BTVNanoCommissioning/workflows/QCD_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def process_shift(self, events, shift_name):
pseval = correctionlib.CorrectionSet.from_file(
f"src/BTVNanoCommissioning/data/Prescales/ps_weight_{triggers[0]}_run{run_num}.json"
)
print(triggers[0])
psweight = pseval["prescaleWeight"].evaluate(
selev.run,
f"HLT_{triggers[0]}",
Expand Down
29 changes: 9 additions & 20 deletions src/BTVNanoCommissioning/workflows/ctag_Wc_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,26 +240,15 @@ def process_shift(self, events, shift_name):
(dilep_mass.mass < 80) | (dilep_mass.mass > 100)
)

if int(self._year) > 2020:
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
else:
MET = ak.zip(
{
"pt": events.PuppiMET.pt,
"eta": ak.zeros_like(events.PuppiMET.pt),
"phi": events.PuppiMET.phi,
"mass": ak.zeros_like(events.PuppiMET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
Wmass = MET + iso_muon
# modified to transverse mass
req_mtw = (
Expand Down
29 changes: 9 additions & 20 deletions src/BTVNanoCommissioning/workflows/ctag_dileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,15 @@ def process_shift(self, events, shift_name):
(dilep_mass.mass < 75) | (dilep_mass.mass > 105)
)

if int(self._year) > 2020:
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
else:
MET = ak.zip(
{
"pt": events.PuppiMET.pt,
"eta": ak.zeros_like(events.PuppiMET.pt),
"phi": events.PuppiMET.phi,
"mass": ak.zeros_like(events.PuppiMET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
req_MET = MET.pt > 40

event_level = (
Expand Down
29 changes: 9 additions & 20 deletions src/BTVNanoCommissioning/workflows/ctag_eWc_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,26 +229,15 @@ def process_shift(self, events, shift_name):
ak.count(dilep_mu.pt, axis=1) + ak.count(dilep_ele.pt, axis=1) != 2
)

if int(self._year) > 2020:
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
else:
MET = ak.zip(
{
"pt": events.PuppiMET.pt,
"eta": ak.zeros_like(events.PuppiMET.pt),
"phi": events.PuppiMET.phi,
"mass": ak.zeros_like(events.PuppiMET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
Wmass = MET + iso_ele
req_Wmass = Wmass.mass > 55

Expand Down
29 changes: 9 additions & 20 deletions src/BTVNanoCommissioning/workflows/ctag_edileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,26 +208,15 @@ def process_shift(self, events, shift_name):
(dilep_mass.mass < 75) | (dilep_mass.mass > 105)
)

if int(self._year) > 2020:
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
else:
MET = ak.zip(
{
"pt": events.PuppiMET.pt,
"eta": ak.zeros_like(events.PuppiMET.pt),
"phi": events.PuppiMET.phi,
"mass": ak.zeros_like(events.PuppiMET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
req_MET = MET.pt > 40

event_level = (
Expand Down
29 changes: 9 additions & 20 deletions src/BTVNanoCommissioning/workflows/ctag_emdileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,26 +254,15 @@ def process_shift(self, events, shift_name):
| ((iso_mu[:, 0] + iso_ele[:, 0]).mass > 105)
)

if int(self._year) > 2020:
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
else:
MET = ak.zip(
{
"pt": events.PuppiMET.pt,
"eta": ak.zeros_like(events.PuppiMET.pt),
"phi": events.PuppiMET.phi,
"mass": ak.zeros_like(events.PuppiMET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
req_MET = MET.pt > 40

event_level = (
Expand Down
29 changes: 9 additions & 20 deletions src/BTVNanoCommissioning/workflows/ctag_ettsemilep_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,26 +246,15 @@ def process_shift(self, events, shift_name):
ak.count(dilep_mu.pt, axis=1) + ak.count(dilep_ele.pt, axis=1) != 2
)

if int(self._year) > 2020:
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
else:
MET = ak.zip(
{
"pt": events.PuppiMET.pt,
"eta": ak.zeros_like(events.PuppiMET.pt),
"phi": events.PuppiMET.phi,
"mass": ak.zeros_like(events.PuppiMET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
Wmass = MET + iso_ele
req_Wmass = Wmass.mass > 55

Expand Down
30 changes: 9 additions & 21 deletions src/BTVNanoCommissioning/workflows/ctag_semileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,27 +258,15 @@ def process_shift(self, events, shift_name):
req_dilepmass = (dilep_mass.mass > 12.0) & (
(dilep_mass.mass < 80) | (dilep_mass.mass > 100)
)

if int(self._year) > 2020:
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
else:
MET = ak.zip(
{
"pt": events.PuppiMET.pt,
"eta": ak.zeros_like(events.PuppiMET.pt),
"phi": events.PuppiMET.phi,
"mass": ak.zeros_like(events.PuppiMET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
Wmass = MET + iso_muon
req_Wmass = Wmass.mass > 55

Expand Down
31 changes: 11 additions & 20 deletions src/BTVNanoCommissioning/workflows/ttsemilep_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,26 +177,17 @@ def process_shift(self, events, shift_name):
jetindx = jetindx[:, :4]

## other cuts
if int(self._year) > 2020:
MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)
else:
MET = ak.zip(
{
"pt": events.PuppiMET.pt,
"eta": ak.zeros_like(events.PuppiMET.pt),
"phi": events.PuppiMET.phi,
"mass": ak.zeros_like(events.PuppiMET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)

MET = ak.zip(
{
"pt": events.MET.pt,
"eta": ak.zeros_like(events.MET.pt),
"phi": events.MET.phi,
"mass": ak.zeros_like(events.MET.pt),
},
with_name="PtEtaPhiMLorentzVector",
)

req_MET = MET.pt > 50

event_level = ak.fill_none(
Expand Down

0 comments on commit 3326b21

Please sign in to comment.