-
Notifications
You must be signed in to change notification settings - Fork 37
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
Fix: None padding order, adding otherjets in Wc WF #60
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,9 @@ def process_shift(self, events, shift_name): | |
# muon twiki: https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideMuonIdRun2 | ||
iso_muon = events.Muon[(events.Muon.pt > 30) & mu_idiso(events, self._campaign)] | ||
req_muon = ak.count(iso_muon.pt, axis=1) == 1 | ||
jet_sel = jet_id(events, self._campaign) & ( | ||
ak.all(events.Jet.metric_table(iso_muon) > 0.5, axis=2) | ||
) | ||
iso_muon = ak.pad_none(iso_muon, 1, axis=1) | ||
iso_muon = iso_muon[:, 0] | ||
iso_muindx = ak.mask( | ||
|
@@ -129,9 +132,6 @@ def process_shift(self, events, shift_name): | |
iso_muindx = iso_muindx[:, 0] | ||
|
||
## Jet cuts | ||
jet_sel = jet_id(events, self._campaign) & ( | ||
ak.all(events.Jet.metric_table(iso_muon) > 0.5, axis=2, mask_identity=True) | ||
) | ||
if "DeepJet_nsv" in events.Jet.fields: | ||
jet_sel = jet_sel & (events.Jet.DeepJet_nsv > 0) | ||
event_jet = events.Jet[jet_sel] | ||
|
@@ -140,30 +140,13 @@ def process_shift(self, events, shift_name): | |
## Soft Muon cuts | ||
soft_muon = events.Muon[softmu_mask(events, self._campaign)] | ||
req_softmu = ak.count(soft_muon.pt, axis=1) >= 1 | ||
soft_muon = ak.pad_none(soft_muon, 1, axis=1) | ||
|
||
## Muon-jet cuts | ||
mu_jet = event_jet[ | ||
( | ||
ak.all( | ||
event_jet.metric_table(soft_muon) <= 0.4, axis=2, mask_identity=True | ||
) | ||
) | ||
mujetsel = ( | ||
(ak.all(event_jet.metric_table(soft_muon) <= 0.4, axis=2)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
& ((event_jet.muonIdx1 != -1) | (event_jet.muonIdx2 != -1)) | ||
& ((event_jet.muEF + event_jet.neEmEF) < 0.7) | ||
] | ||
req_mujet = ak.num(mu_jet.pt, axis=1) >= 1 | ||
mu_jet = ak.pad_none(mu_jet, 1, axis=1) | ||
|
||
## store jet index for PFCands, create mask on the jet index | ||
jet_selpf = ( | ||
jet_id(events, self._campaign) | ||
& ( | ||
ak.all( | ||
events.Jet.metric_table(iso_muon) > 0.5, axis=2, mask_identity=True | ||
) | ||
) | ||
& ((events.Jet.muEF + events.Jet.neEmEF) < 0.7) | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No |
||
mujetsel2 = ( | ||
((events.Jet.muEF + events.Jet.neEmEF) < 0.7) | ||
& ( | ||
ak.all( | ||
events.Jet.metric_table(soft_muon) <= 0.4, | ||
|
@@ -173,6 +156,16 @@ def process_shift(self, events, shift_name): | |
) | ||
& ((events.Jet.muonIdx1 != -1) | (events.Jet.muonIdx2 != -1)) | ||
) | ||
soft_muon = ak.pad_none(soft_muon, 1, axis=1) | ||
|
||
## Muon-jet cuts | ||
mu_jet = event_jet[mujetsel] | ||
otherjets = event_jet[~mujetsel] | ||
req_mujet = ak.num(mu_jet.pt, axis=1) >= 1 | ||
mu_jet = ak.pad_none(mu_jet, 1, axis=1) | ||
|
||
## store jet index for PFCands, create mask on the jet index | ||
jet_selpf = (jet_sel) & (mujetsel2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change to |
||
if "DeepJet_nsv" in events.Jet.fields: | ||
jet_selpf = jet_selpf & (events.Jet.DeepJet_nsv > 0) | ||
jetindx = ak.mask(ak.local_index(events.Jet.pt), jet_selpf == True) | ||
|
@@ -260,6 +253,7 @@ def process_shift(self, events, shift_name): | |
ssmu = soft_muon[event_level] | ||
smet = MET[event_level] | ||
smuon_jet = mu_jet[event_level] | ||
sotherjets = otherjets[event_level] | ||
nsoftmu = ak.count(ssmu.pt, axis=1) | ||
nmujet = ak.count(smuon_jet.pt, axis=1) | ||
smuon_jet = smuon_jet[:, 0] | ||
|
@@ -489,10 +483,11 @@ def process_shift(self, events, shift_name): | |
if self.isArray: | ||
# Keep the structure of events and pruned the object size | ||
pruned_ev = events[event_level] | ||
pruned_ev.Jet = sjets | ||
pruned_ev.Muon = shmu | ||
pruned_ev["Jet"] = sjets | ||
pruned_ev["Muon"] = shmu | ||
pruned_ev["MuonJet"] = smuon_jet | ||
pruned_ev["SoftMuon"] = ssmu | ||
pruned_ev["OtherJets"] = sotherjets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you still want to store the jet flag instead of collections on MuonJet & OtherJet? The |
||
pruned_ev["osss"] = osss | ||
if "PFCands" in events.fields: | ||
pruned_ev.PFCands = spfcands | ||
|
@@ -518,7 +513,7 @@ def process_shift(self, events, shift_name): | |
out_branch, | ||
np.where( | ||
(out_branch == "SoftMuon") | ||
| (out_branch == "MuonJet") | ||
# | (out_branch == "MuonJet") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did I understand correctly you want to store PFcands in the |
||
| (out_branch == "dilep") | ||
), | ||
) | ||
|
@@ -528,7 +523,7 @@ def process_shift(self, events, shift_name): | |
"Muon", | ||
"Jet", | ||
"SoftMuon", | ||
"MuonJet", | ||
# "MuonJet", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The kinematics variables will not save, is this done intentionally? |
||
"dilep", | ||
"charge", | ||
"MET", | ||
|
@@ -544,6 +539,7 @@ def process_shift(self, events, shift_name): | |
out_branch, ["Jet_btagDeep*", "Jet_DeepJet*", "PFCands_*", "SV_*"] | ||
) | ||
# write to root files | ||
print("Branches to write:", out_branch) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the check you want to keep when running the code? |
||
with uproot.recreate( | ||
f"tmp/{dataset}_{systematics[0]}_{int(events.metadata['entrystop']/self.chunksize)}.root" | ||
) as fout: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,9 @@ def process_shift(self, events, shift_name): | |
(events.Electron.pt > 34) & ele_mvatightid(events, self._campaign) | ||
] | ||
req_ele = ak.count(iso_ele.pt, axis=1) == 1 | ||
jet_sel = jet_id(events, self._campaign) & ( | ||
ak.all(events.Jet.metric_table(iso_ele) > 0.5, axis=2) | ||
) | ||
Comment on lines
+125
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the additional |
||
iso_ele = ak.pad_none(iso_ele, 1, axis=1) | ||
iso_ele = iso_ele[:, 0] | ||
iso_eindx = ak.mask( | ||
|
@@ -132,9 +135,7 @@ def process_shift(self, events, shift_name): | |
iso_eindx = iso_eindx[:, 0] | ||
|
||
## Jet cuts | ||
jet_sel = jet_id(events, self._campaign) & ( | ||
ak.all(events.Jet.metric_table(iso_ele) > 0.5, axis=2, mask_identity=True) | ||
) | ||
|
||
if "DeepJet_nsv" in events.Jet.fields: | ||
jet_sel = jet_sel & (events.Jet.DeepJet_nsv > 0) | ||
event_jet = events.Jet[jet_sel] | ||
|
@@ -143,37 +144,25 @@ def process_shift(self, events, shift_name): | |
## Soft Muon cuts | ||
soft_muon = events.Muon[softmu_mask(events, self._campaign)] | ||
req_softmu = ak.count(soft_muon.pt, axis=1) >= 1 | ||
mujetsel = (ak.all(event_jet.metric_table(soft_muon) <= 0.4, axis=2)) & ( | ||
(event_jet.muonIdx1 != -1) | (event_jet.muonIdx2 != -1) | ||
) | ||
mujetsel2 = ( | ||
ak.all( | ||
events.Jet.metric_table(soft_muon) <= 0.4, | ||
axis=2, | ||
) | ||
) & ((events.Jet.muonIdx1 != -1) | (events.Jet.muonIdx2 != -1)) | ||
Comment on lines
+147
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
soft_muon = ak.pad_none(soft_muon, 1, axis=1) | ||
|
||
## Muon-jet cuts | ||
mu_jet = event_jet[ | ||
( | ||
ak.all( | ||
event_jet.metric_table(soft_muon) <= 0.4, axis=2, mask_identity=True | ||
) | ||
) | ||
& ((event_jet.muonIdx1 != -1) | (event_jet.muonIdx2 != -1)) | ||
] | ||
mu_jet = event_jet[mujetsel] | ||
otherjets = event_jet[~mujetsel] | ||
req_mujet = ak.num(mu_jet.pt, axis=1) >= 1 | ||
mu_jet = ak.pad_none(mu_jet, 1, axis=1) | ||
|
||
## store jet index for PFCands, create mask on the jet index | ||
jet_selpf = ( | ||
jet_id(events, self._campaign) | ||
& ( | ||
ak.all( | ||
events.Jet.metric_table(iso_ele) > 0.5, axis=2, mask_identity=True | ||
) | ||
) | ||
& ( | ||
ak.all( | ||
events.Jet.metric_table(soft_muon) <= 0.4, | ||
axis=2, | ||
mask_identity=True, | ||
) | ||
) | ||
& ((events.Jet.muonIdx1 != -1) | (events.Jet.muonIdx2 != -1)) | ||
) | ||
jet_selpf = (jet_sel) & (mujetsel2) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the |
||
if "DeepJet_nsv" in events.Jet.fields: | ||
jet_selpf = jet_selpf & (events.Jet.DeepJet_nsv > 0) | ||
jetindx = ak.mask(ak.local_index(events.Jet.pt), jet_selpf == True) | ||
|
@@ -255,6 +244,7 @@ def process_shift(self, events, shift_name): | |
ssmu = soft_muon[event_level] | ||
smet = MET[event_level] | ||
smuon_jet = mu_jet[event_level] | ||
sotherjets = otherjets[event_level] | ||
nsoftmu = ak.count(ssmu.pt, axis=1) | ||
nmujet = ak.count(smuon_jet.pt, axis=1) | ||
smuon_jet = smuon_jet[:, 0] | ||
|
@@ -484,9 +474,10 @@ def process_shift(self, events, shift_name): | |
if self.isArray: | ||
# Keep the structure of events and pruned the object size | ||
pruned_ev = events[event_level] | ||
pruned_ev.Jet = sjets | ||
pruned_ev.Muon = shmu | ||
pruned_ev["Jet"] = sjets | ||
pruned_ev["Muon"] = shmu | ||
pruned_ev["MuonJet"] = smuon_jet | ||
pruned_ev["OtherJets"] = sotherjets | ||
Comment on lines
+477
to
+480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you still want to store the jet flag instead of collections on MuonJet & OtherJet? The |
||
pruned_ev["SoftMuon"] = ssmu | ||
pruned_ev["osss"] = osss | ||
if "PFCands" in events.fields: | ||
|
@@ -513,7 +504,7 @@ def process_shift(self, events, shift_name): | |
out_branch, | ||
np.where( | ||
(out_branch == "SoftMuon") | ||
| (out_branch == "MuonJet") | ||
# | (out_branch == "MuonJet") | ||
Comment on lines
-516
to
+507
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did I understand correctly you want to store PFcands in the |
||
| (out_branch == "dilep") | ||
), | ||
) | ||
|
@@ -523,7 +514,7 @@ def process_shift(self, events, shift_name): | |
"Muon", | ||
"Jet", | ||
"SoftMuon", | ||
"MuonJet", | ||
# "MuonJet", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The kinematics variables will not save, is this done intentionally? |
||
"dilep", | ||
"charge", | ||
"MET", | ||
|
@@ -539,6 +530,7 @@ def process_shift(self, events, shift_name): | |
out_branch, ["Jet_btagDeep*", "Jet_DeepJet*", "PFCands_*", "SV_*"] | ||
) | ||
# write to root files | ||
print("Branches to write:", out_branch) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the check you want to keep when running the code? |
||
with uproot.recreate( | ||
f"tmp/{dataset}_{systematics[0]}_{int(events.metadata['entrystop']/self.chunksize)}.root" | ||
) as fout: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the additional
ak.fill_none
for the selection to avoidNone
in the jet selection. (just to be sureNone
filtered out 😉 )