Skip to content

Commit

Permalink
Merge pull request #326 from TopEFT/fixing_triggerSFs
Browse files Browse the repository at this point in the history
Fixing trigger s fs
  • Loading branch information
kmohrman authored Oct 8, 2022
2 parents 2c3ed79 + 4a2b49a commit 3b78eb0
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 38 deletions.
2 changes: 1 addition & 1 deletion analysis/topEFT/remake_ci_ref_datacard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ time python run.py ../../topcoffea/json/test_samples/UL17_private_ttH_for_CI.jso

# Run the datacard maker
printf "\nRunning the datacard maker...\n"
python make_cards.py histos/new_ref_histos_np.pkl.gz -d test --var-lst lj0pt --do-nuisance --ch-lst "2lss_p_4j"
python make_cards.py histos/new_ref_histos_np.pkl.gz -d test --var-lst lj0pt --do-nuisance --ch-lst "2lss_p_4j" --selected-wcs-ref "test/selectedWCs_ref_ci.json"
60 changes: 30 additions & 30 deletions analysis/topEFT/test/UL17_private_ttH_for_CI_yields.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
{
"ttH": {
"2los_CRZ": [
3.568628921257262,
1.737702243543952e-15
3.6013954659391016,
1.7456616582331738e-15
],
"2los_CRtt": [
2.5161539272973537,
1.4591275897253677e-15
2.5388233022438964,
1.4656858810463726e-15
],
"2lss_4t_m": [
3.0736132378314984,
1.6126839934657064e-15
3.1435787822294485,
1.6309357060506927e-15
],
"2lss_4t_p": [
3.6813352473529166,
1.7649294542642184e-15
3.7420866589328288,
1.7794327801569266e-15
],
"2lss_CR": [
18.80298678998092,
3.988761661408503e-15
19.146007937932982,
4.024980528545953e-15
],
"2lss_CRflip": [
2.6942859387398137,
1.5098941716898306e-15
2.707043740801609,
1.5134647247246886e-15
],
"2lss_m": [
23.22703815043837,
4.433243470164428e-15
23.682668066496856,
4.4765143439568236e-15
],
"2lss_p": [
23.989549291308276,
4.5054244417521616e-15
24.440765932219325,
4.547598057930502e-15
],
"3l_CR": [
4.752881139772658,
2.0054098475699952e-15
4.772573921479915,
2.009560096069231e-15
],
"3l_m_offZ_1b": [
6.3800730629350415,
2.323472263863943e-15
6.42741990265889,
2.332077629814368e-15
],
"3l_m_offZ_2b": [
5.282620280004518,
2.1142160409230014e-15
5.333346294667595,
2.1243425995124588e-15
],
"3l_onZ_1b": [
2.793554511394608,
1.537457932516196e-15
2.8117193341293754,
1.5424484201679816e-15
],
"3l_onZ_2b": [
2.732272025502592,
1.5205007343364154e-15
2.750308558314415,
1.5255111158977448e-15
],
"3l_p_offZ_1b": [
7.046522062944005,
2.441811160914784e-15
7.092221393371435,
2.4497163937435352e-15
],
"3l_p_offZ_2b": [
6.342596404910116,
2.31663815530528e-15
6.380737738650005,
2.323593290328085e-15
],
"4l": [
0.693835886282074,
Expand Down
1 change: 1 addition & 0 deletions analysis/topEFT/test/selectedWCs_ref_ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ttH": ["cptb", "ctq1", "cbW", "cpQ3", "cpQM", "cQq13", "ctp", "cQq81", "cQq83", "ctW", "ctq8", "cpt", "ctG", "ctZ", "cQq11"]}
7 changes: 4 additions & 3 deletions analysis/topEFT/test/ttx_multileptons-2lss_p_4j_lj0pt.txt

Large diffs are not rendered by default.

Binary file modified topcoffea/data/triggerSF/triggerSF_2016.pkl.gz
Binary file not shown.
Binary file modified topcoffea/data/triggerSF/triggerSF_2016APV.pkl.gz
Binary file not shown.
Binary file modified topcoffea/data/triggerSF/triggerSF_2017.pkl.gz
Binary file not shown.
Binary file modified topcoffea/data/triggerSF/triggerSF_2018.pkl.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion topcoffea/modules/YieldTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def get_yld_dict(self,hin_dict,year=None,njets=False,lepflav=False):
# Find the yields
yld_dict = {}
proc_lst = self.get_cat_lables(hin_dict,"sample")
if "flipsUL17" not in proc_lst: proc_lst = proc_lst + ["flipsUL16","flipsUL16APV","flipsUL17","flipsUL18"] # Very bad workaround for _many_ reasons
#if "flipsUL17" not in proc_lst: proc_lst = proc_lst + ["flipsUL16","flipsUL16APV","flipsUL17","flipsUL18"] # Very bad workaround for _many_ reasons.. leaving it in since it's useful for getting yields of the full pkl file (but we don't need it for e.g. the CI, so leave it commented), note this entire class is a mess and should be totally rewritten before the next analysis
print("proc_lst",proc_lst)
for proc in proc_lst:
p = self.get_short_name(proc)
Expand Down
2 changes: 1 addition & 1 deletion topcoffea/modules/comp_datacard.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def strip(fname='ttx_multileptons-2lss_p_2b.txt'):
line = line.split()[1:]
line = [float(l) for l in line]
rate = line
elif any([re.findall('\.\d*', str(l)) for l in line]) and '*' not in line and '#' not in line:
elif any([re.findall(r'\.\d*', str(l)) for l in line]) and '*' not in line and '#' not in line:
line = line.split()[2:]
if len(line) == 0: continue
line = [str(l) for l in line]
Expand Down
7 changes: 5 additions & 2 deletions topcoffea/modules/corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,15 @@ def GetTriggerSF(year, events, lep0, lep1):
SF_em=np.where((events.is2l & events.is_em),LoadTriggerSF(year,ch='2l',flav='em')[syst](lep0.pt,lep1.pt),1.0)
SF_mm=np.where((events.is2l & events.is_mm),LoadTriggerSF(year,ch='2l',flav='mm')[syst](lep0.pt,lep1.pt),1.0)
#3l
'''
SF_eee=np.where((events.is3l & events.is_eee),LoadTriggerSF(year,ch='3l',flav='eee')[syst](lep0.pt,lep0.eta),1.0)
SF_eem=np.where((events.is3l & events.is_eem),LoadTriggerSF(year,ch='3l',flav='eem')[syst](lep0.pt,lep0.eta),1.0)
SF_emm=np.where((events.is3l & events.is_emm),LoadTriggerSF(year,ch='3l',flav='emm')[syst](lep0.pt,lep0.eta),1.0)
SF_mmm=np.where((events.is3l & events.is_mmm),LoadTriggerSF(year,ch='3l',flav='mmm')[syst](lep0.pt,lep0.eta),1.0)
ls.append(SF_ee*SF_em*SF_mm*SF_eee*SF_eem*SF_emm*SF_mmm)
'''
ls.append(SF_ee*SF_em*SF_mm)
ls[1]=np.where(ls[1]==1.0,0.0,ls[1]) # stat unc. down
events['trigger_sf']=ls[0] #nominal
events['trigger_sfDown']=ls[0]-np.sqrt(ls[1]*ls[1]+0.02*0.02)
events['trigger_sfUp']=ls[0]+np.sqrt(ls[1]*ls[1]+0.02*0.02)
events['trigger_sfDown']=ls[0]-np.sqrt(ls[1]*ls[1]+ls[0]*0.02*ls[0]*0.02)
events['trigger_sfUp']=ls[0]+np.sqrt(ls[1]*ls[1]+ls[0]*0.02*ls[0]*0.02)

0 comments on commit 3b78eb0

Please sign in to comment.