@@ -350,6 +350,8 @@ def _build_objects(self, events):
350350 FirstFatjet = ak .firsts (good_fatjets [:, 0 :1 ])
351351 SecondFatjet = ak .firsts (good_fatjets [:, 1 :2 ])
352352
353+ bjet_selector = (jets .delta_r (candidatefj ) > 0.8 ) & (abs (jets .eta ) < 2.5 )
354+
353355 objects = {
354356 "muons" : muons ,
355357 "good_muons" : good_muons ,
@@ -381,6 +383,7 @@ def _build_objects(self, events):
381383 "jet2" : jet2 ,
382384 "FirstFatjet" : FirstFatjet ,
383385 "SecondFatjet" : SecondFatjet ,
386+ "bjet_selector" : bjet_selector ,
384387 }
385388
386389 return objects
@@ -414,6 +417,8 @@ def _derive_variables(self, events, objects):
414417 FirstFatjet = objects ["FirstFatjet" ]
415418 SecondFatjet = objects ["SecondFatjet" ]
416419
420+ bjet_selector = objects ["bjet_selector" ]
421+
417422 # VH jet
418423 minDeltaR = ak .argmin (candidatelep_p4 .delta_r (good_fatjets ), axis = 1 ) # similar to fj_idx_lep but without keepdims
419424 fatJetIndices = ak .local_index (good_fatjets , axis = 1 )
@@ -445,7 +450,6 @@ def _derive_variables(self, events, objects):
445450 lep_miso = candidatelep .miniPFRelIso_all # miniso for candidate lepton
446451
447452 # OBJECT: b-jets (only for jets with abs(eta)<2.5)
448- bjet_selector = (jets .delta_r (candidatefj ) > 0.8 ) & (abs (jets .eta ) < 2.5 )
449453 ak4_bjet_candidate = jets [bjet_selector ]
450454
451455 # OBJECT: VBF variables
@@ -522,7 +526,6 @@ def _derive_variables(self, events, objects):
522526 "fj_eta" : candidatefj .eta ,
523527 "fj_phi" : candidatefj .phi ,
524528 "fj_mass" : candidatefj .msdcorr ,
525- "fj_idx_lep" : fj_idx_lep ,
526529 "VH_fj" : VH_fj ,
527530 "ak4_outside_ak8" : ak4_outside_ak8 ,
528531 "n_loose_taus_mu" : n_loose_taus_mu ,
@@ -588,7 +591,6 @@ def _derive_variables(self, events, objects):
588591 "loose_lep1_pt" : ak .firsts (muons [loose_muons1 ][ak .argsort (muons [loose_muons1 ].pt , ascending = False )]).pt ,
589592 "msk_leptonic_taus" : msk_leptonic_taus ,
590593 "fj_mass_raw" : good_fatjets [fj_idx_lep ].mass ,
591- "bjet_selector" : bjet_selector ,
592594 }
593595
594596 if self .isMC :
@@ -600,7 +602,7 @@ def _derive_variables(self, events, objects):
600602
601603 def _apply_JEC (self , events , objects , variables ):
602604
603- fj_idx_lep = variables ["fj_idx_lep" ]
605+ fj_idx_lep = objects ["fj_idx_lep" ]
604606 candidatefj = objects ["candidatefj" ]
605607 jec_shifted_fatjetvars = objects ["jec_shifted_fatjetvars" ]
606608 jmsr_shifted_fatjetvars = objects ["jmsr_shifted_fatjetvars" ]
@@ -827,7 +829,7 @@ def _store_MCweights(self, dataset, events, objects, variables):
827829
828830 candidatelep = objects ["candidatelep" ]
829831 jets = objects ["jets" ]
830- bjet_selector = variables ["bjet_selector" ]
832+ bjet_selector = objects ["bjet_selector" ]
831833
832834 for ch in self ._channels :
833835 if self ._year in ("2016" , "2017" ):
@@ -1005,9 +1007,9 @@ def process(self, events: ak.Array):
10051007 (pf_cands , gen_parts_eta_phi , gen_parts_pt_mass , ak8_jets , bgen_parts_eta_phi , genlep ) = getLPweights (
10061008 dataset ,
10071009 events [selection_ch ],
1008- variables ["candidatefj" ][selection_ch ],
1009- variables ["fj_idx_lep" ][selection_ch ],
1010- variables ["candidatelep_p4" ][selection_ch ],
1010+ objects ["candidatefj" ][selection_ch ],
1011+ objects ["fj_idx_lep" ][selection_ch ],
1012+ objects ["candidatelep_p4" ][selection_ch ],
10111013 )
10121014
10131015 lpvars = {}
@@ -1048,7 +1050,7 @@ def process(self, events: ak.Array):
10481050 pnet_vars = runInferenceTriton (
10491051 self .tagger_resources_path ,
10501052 events [selection_ch ],
1051- variables ["fj_idx_lep" ][selection_ch ],
1053+ objects ["fj_idx_lep" ][selection_ch ],
10521054 model_name = model_name ,
10531055 )
10541056 pnet_df = self .ak_to_pandas (pnet_vars )
0 commit comments