Skip to content

Commit

Permalink
fixed: add negtive weights in bg_rec
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangyi15 committed Jul 28, 2023
1 parent b3a563d commit a56b7e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
8 changes: 5 additions & 3 deletions tf_pwa/config_loader/data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import os
import re
import warnings

import numpy as np
Expand Down Expand Up @@ -107,10 +108,11 @@ def particle_item():
return new_order

def get_weight_sign(self, idx):
negtive_idx = self.dic.get("negtive_idx", ["bg"])
negtive_idx = self.dic.get("negtive_idx", ["bg*"])
weight_sign = 1
if idx in negtive_idx:
weight_sign = -1
for i in negtive_idx:
if re.match(i, idx):
weight_sign = -1
return weight_sign

def get_data(self, idx) -> dict:
Expand Down
10 changes: 2 additions & 8 deletions tf_pwa/config_loader/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,7 @@ def _cal_partial_wave(
if ref_amp is not None:
norm_frac_ref = n_data / np.sum(total_weight_ref)
else:
if isinstance(w_bkg, float):
n_sig = n_data - w_bkg * data_shape(bg)
else:
n_sig = n_data + np.sum(w_bkg)
n_sig = n_data + np.sum(w_bkg)
norm_frac = n_sig / np.sum(total_weight)
if ref_amp is not None:
norm_frac_ref = n_sig / np.sum(total_weight_ref)
Expand Down Expand Up @@ -522,10 +519,7 @@ def _cal_partial_wave(
cut_function(phsp_rec) * total_weight_ref * norm_frac_ref
)
if bg is not None:
if isinstance(w_bkg, float):
bg_weight = [w_bkg] * data_shape(bg)
else:
bg_weight = -w_bkg
bg_weight = -w_bkg
bg_dict["sideband_weights"] = (
cut_function(bg) * bg_weight
) # sideband weight
Expand Down

0 comments on commit a56b7e6

Please sign in to comment.