Skip to content
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

Photons histEFT #421

Open
wants to merge 151 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
231a5f8
Basic photon selection
bryates Apr 13, 2023
94ba9ca
Saving single photon pT
bryates Apr 20, 2023
3a74343
edited photon selection category to include kinematic cuts
abasnet97 Jun 8, 2023
fb442bb
edited 2los CR category
abasnet97 Jun 8, 2023
f704e98
modified photon selection furthermore
abasnet97 Jun 12, 2023
58d2662
Merge all recent master changes to photon branch
abasnet97 Jun 12, 2023
0837563
changed photon ID from tight to medium for now
abasnet97 Jun 12, 2023
c594dfe
More flake8 fixes
kmohrman Mar 25, 2023
2ec1020
More flake8 fixes..
kmohrman Mar 26, 2023
439e92f
Basic photon selection
bryates Apr 13, 2023
d0748bc
Saving single photon pT
bryates Apr 20, 2023
58c9f63
Adding ttgamma selection
bryates Jun 15, 2023
cc6fcc9
more photon selection edits
abasnet97 Jun 21, 2023
2f5cc8c
Add cutBased hist, medium photon ID
bryates Jun 21, 2023
ff5b88c
Merge branch 'photons' of github.com:TopEFT/topcoffea into photons
bryates Jun 21, 2023
ed17052
Relaxed veto
bryates Jun 22, 2023
44b5fe1
Fixed typo
bryates Jun 22, 2023
7f55206
editing the processor to include relaxed cutBasedID for photon
abasnet97 Jun 29, 2023
18f210d
fixing typo in selection.py
abasnet97 Jun 29, 2023
cb0a510
Working version
bryates Jun 30, 2023
9511813
fix masks
bryates Jun 30, 2023
1855fb3
merged changes from master after topcoffea refactoring
abasnet97 Sep 18, 2023
e38731b
added new files related to photon gen processor
abasnet97 Oct 19, 2023
4c02a90
new edits to gen level processor
abasnet97 Dec 11, 2023
178aec4
modify genlepflav mask
abasnet97 Dec 11, 2023
573ae6c
several modifications to photon object and event selections
abasnet97 Feb 27, 2024
eda50d7
implemented ttgamma ttbar overlap removal
abasnet97 Mar 12, 2024
f80b263
added genParentage
abasnet97 Mar 12, 2024
0117164
major changes to overlap removal implementation and other cleanups
abasnet97 Apr 15, 2024
54085ea
added a helper script to make njet-nbjet histogram
abasnet97 May 2, 2024
d754dec
added a helper function to make jet_bjet plot
abasnet97 Jun 20, 2024
7c7e73d
updated processor file to include new control regions for ttgamma work
abasnet97 Jun 20, 2024
3911341
updated event and object selection to include CR selections for ttgam…
abasnet97 Jun 20, 2024
19d051e
removing ttgamma and Zgamma from conversion samples list
abasnet97 Jun 20, 2024
98f5df9
Adding photon SFs and systematic
bryates Jun 21, 2024
e2ced76
Use `photonSFs` branch of topcoffea
bryates Jun 21, 2024
7a705e6
Fix some lint issues
bryates Jun 21, 2024
5a17f4d
Remove stray print
bryates Jun 21, 2024
e9c4c78
Removing unused masks
bryates Jun 24, 2024
285aef2
TTGamma is now a signal process, TTG->ttA
bryates Jun 28, 2024
bf52a61
Pull latest datacard maker, update categories
bryates Jun 28, 2024
98bfa02
Zero our missing sumw2
bryates Jun 28, 2024
86113a4
Merge branch 'master' into photons_rebase
bryates Jul 1, 2024
4003f38
Fix lint, move gen processor to histEFT
bryates Jul 1, 2024
d5a61ea
More lint
bryates Jul 1, 2024
1b18c4b
Yet more lint
bryates Jul 1, 2024
2485b1a
Fix typos
bryates Jul 1, 2024
695e231
Lint again!
bryates Jul 1, 2024
501a834
Never-ending lint
bryates Jul 1, 2024
22ef77b
Add `ttA` to processes
bryates Jul 1, 2024
77a8ea7
Processor runs now
bryates Jul 1, 2024
1f2a507
Merge branch 'photons_histEFT' into photon_dc
bryates Jul 1, 2024
fb66108
Use new `EGamma_SF2D_err` hists
bryates Jul 2, 2024
047aad7
Load photon SFs, still load lepton SFs in those channels
bryates Jul 2, 2024
c33e8c6
Simplify 2l category
bryates Jul 2, 2024
ccae998
Back to main TopCoffea branch
bryates Jul 2, 2024
ba4b98f
Fix some comment typos
bryates Jul 3, 2024
5aa2036
Fix typo in 2l
bryates Jul 3, 2024
780e38c
Back to main TopCoffea branch
bryates Jul 3, 2024
380d4f3
Replace prune with slice
bryates Jul 10, 2024
da40fc5
Fixed CI yields, removed (hopefully) unneeded code
bryates Jul 10, 2024
b85714b
Merge branch 'photons_histEFT' into photon_dc
bryates Jul 11, 2024
b5aa458
Update photon SR
bryates Jul 16, 2024
c42728c
Clean up run script
bryates Jul 16, 2024
fb4a267
Better 2l cats
bryates Jul 18, 2024
6015877
Switch to medium SFs
bryates Jul 29, 2024
018157b
Restored missing overlap functions
bryates Jul 30, 2024
519ff51
Checkout `photon_seedveto` on TopCoffea
bryates Jul 30, 2024
8491d25
Fix lint
bryates Jul 30, 2024
ef20b9a
Working pxiel seed veto and CSEV
bryates Jul 30, 2024
b826e72
Fix lint space at end
bryates Jul 30, 2024
beafecf
Fix lint indents
bryates Jul 30, 2024
31225ac
Merge branch 'master' into photons_histEFT
bryates Jul 30, 2024
1832dfa
Add photon categories
bryates Aug 14, 2024
24536db
Added ttgamma categories to ref json
bryates Aug 14, 2024
84edb0b
Update main.yml
bryates Sep 5, 2024
ee7a0db
Fix typo in photon error propagation
bryates Sep 5, 2024
84c2cb0
Yields after applying new photon vetoes (pixel and CSEV)
bryates Sep 5, 2024
72e0e0e
Yields after TopCoffea correction-lib updates
bryates Sep 5, 2024
30b3af4
Merge branch 'master' into photons_histEFT_rebase
bryates Nov 18, 2024
4c77311
Small changes for photon channels
bryates Nov 19, 2024
7415ccb
Merge branch 'photons_histEFT' into photon_dc
bryates Nov 19, 2024
9ae1951
Merge branch 'photons_histEFT' into photon_dc
bryates Nov 19, 2024
fb6238d
"Fix" for 2los photon channels
bryates Nov 21, 2024
30eacf4
Add `TTGamma_private`
bryates Nov 22, 2024
14ceef4
Skip `renormfact` since we never used it
bryates Nov 25, 2024
bca3988
Merge branch 'master' into photons_histEFT
bryates Dec 4, 2024
b1e716a
adding a new plotting helper script. will add the changes to analysis…
abasnet97 Jan 22, 2025
adabbab
lint fix
abasnet97 Jan 22, 2025
c2089dc
Some TTGamma files missing
bryates Jan 23, 2025
fc9e8f2
Merge branch 'photons_histEFT' into photon_dc
bryates Jan 23, 2025
2d64ee8
Latest IM changes
bryates Jan 23, 2025
61b479f
wc ranges from master
bryates Jan 23, 2025
febd140
Fixed ttA typo
bryates Jan 23, 2025
ce27be4
added new histograms relevant to non-prompt photon estimation
abasnet97 Jan 26, 2025
4d17ed9
Merge branch 'photons_histEFT' of https://github.com/TopEFT/topeft in…
abasnet97 Jan 26, 2025
0efd8cb
adding prompt subtraction samples for photons
abasnet97 Jan 26, 2025
90157cf
a new helper function to aid histogram filling
abasnet97 Jan 26, 2025
03c0e8f
updated corrections, event and object selection scripts to handle non…
abasnet97 Jan 26, 2025
56448ea
adding numpy files for photon FR and kMC
abasnet97 Jan 26, 2025
a625eff
lint fixes
abasnet97 Jan 26, 2025
90d52da
more lint fixes cause why not
abasnet97 Jan 26, 2025
e524a53
temporarily comment out photon_pt_eta hist
abasnet97 Jan 28, 2025
d1294ea
massive overhaul of photon selection and analysis channels
abasnet97 Jan 28, 2025
8e16511
clean the processor and add nonprompt fakerate as event weight
abasnet97 Jan 28, 2025
630d4a2
added photon fakerate and kMC numpy files
abasnet97 Jan 30, 2025
b1ec71d
adding ISR/FSR split of photons in ZGamma sample
abasnet97 Jan 30, 2025
07b0530
fix lint
abasnet97 Jan 30, 2025
ddad937
bringing photon_pt_eta histogram back
abasnet97 Jan 31, 2025
8d481f8
added modifications to perform nonprompt estimation of photons
abasnet97 Jan 31, 2025
56cb888
lint fixes
abasnet97 Jan 31, 2025
f866b86
possible attempt at fixing CI
abasnet97 Jan 31, 2025
b04ddb3
new photon FRs and kMC factors after including EFT signal samples
abasnet97 Feb 10, 2025
117c382
editing processor to handle eft weights for 2D histogram
abasnet97 Feb 11, 2025
eb6520a
further edits to the nonprompt mc stat uncertainty propagation
abasnet97 Feb 12, 2025
5e0ea7c
lint fixes
abasnet97 Feb 12, 2025
3ec217e
Merge pull request #420 from TopEFT/photon_dc
abasnet97 Feb 12, 2025
fb42fc1
adding EFT sig samples in prompt photon subtraction list
abasnet97 Feb 12, 2025
135f3a0
Merge branch 'photons_histEFT' of https://github.com/TopEFT/topeft in…
abasnet97 Feb 12, 2025
1f5554d
modifications to datacard_tools for photon channels
abasnet97 Feb 12, 2025
51e2829
Merging master
bryates Feb 14, 2025
258fab5
Missing calls
bryates Feb 14, 2025
81a4e4d
Merge branch 'master' into photons_histEFT_master2
bryates Feb 14, 2025
4f93da2
Indent
bryates Feb 14, 2025
3c9f638
Turn off debug messages
bryates Feb 14, 2025
8f3a250
Photon systs only when flag is set
bryates Feb 14, 2025
4006c45
Fix typo
bryates Feb 14, 2025
9caecd2
Should all work
bryates Feb 14, 2025
60213b9
Photon channels
bryates Feb 14, 2025
3882dd4
Fixed processor
bryates Feb 14, 2025
6424d8b
Removed comment
bryates Feb 14, 2025
641247e
Lint
bryates Feb 14, 2025
80d5187
Undo change
bryates Feb 14, 2025
9c78263
Remove 2los_ph from cat lst
bryates Feb 14, 2025
7c116b3
Fix CR name
bryates Mar 3, 2025
3276a6e
Add 0m b mask for CR
bryates Mar 3, 2025
d4c27ce
Add sf and of
bryates Mar 3, 2025
83eb2e2
More channel updates
bryates Mar 4, 2025
a23f37e
Fixed flavor channels
bryates Mar 5, 2025
f9faf23
modified appl axes names and channel list json
abasnet97 Mar 5, 2025
6658b39
some minor modifications to datacard tools
abasnet97 Mar 5, 2025
2991ffe
adding ST TWG sample to non prompt photon subtraction list
abasnet97 Mar 5, 2025
4696058
adding 1jet diboson uncertainty (temporary fix to make ttA datacards)
abasnet97 Mar 5, 2025
c89284a
lint fixes
abasnet97 Mar 5, 2025
f37da9b
adding jsons for UL17 and UL16APV ttgamma EFT samples and modifying c…
abasnet97 Mar 5, 2025
369552b
adding photon mask on ch_lst_test json
abasnet97 Mar 7, 2025
7724993
including photon relevant code block inside the ttA_analysis flag
abasnet97 Mar 12, 2025
444baaa
bit more restructuring of the analysis processor
abasnet97 Mar 12, 2025
828e76e
remove photon_pt_eta 2D hist once they serve their purpose
abasnet97 Mar 13, 2025
be8bb08
lint fixes
abasnet97 Mar 13, 2025
7018870
added nEvents and nGenEvents info to ttgamma jsons
abasnet97 Mar 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
326 changes: 251 additions & 75 deletions analysis/topeft_run2/analysis_processor.py

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions analysis/topeft_run2/datacards_post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
parser.add_argument("-z", "--set-up-offZdivision", action="store_true", help = "Copy the ptz and lj0pt cards with 3l offZ division.")
parser.add_argument("-t", "--tau-flag", action="store_true", help = "Copy the ptz, lj0pt, and ptz_wtau cards for tau channels.")
parser.add_argument("-f", "--fwd-flag", action="store_true", help = "Copy the ptz, lj0pt, and lt cards for forward channels.")
parser.add_argument("-a", "--tta-flag", action="store_true", help = "Copy the ptz, lj0pt, and lt cards for forward channels.")

Check warning on line 47 in analysis/topeft_run2/datacards_post_processing.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/datacards_post_processing.py#L47

Added line #L47 was not covered by tests
args = parser.parse_args()

###### Print out general info ######
Expand Down Expand Up @@ -110,6 +111,8 @@
import_sr_ch_lst = select_ch_lst["TAU_CH_LST_SR"]
if args.fwd_flag:
import_sr_ch_lst = select_ch_lst["FWD_CH_LST_SR"]
if args.tta_flag:
import_sr_ch_lst = select_ch_lst["TTA_CH_LST_SR"]

Check warning on line 115 in analysis/topeft_run2/datacards_post_processing.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/datacards_post_processing.py#L114-L115

Added lines #L114 - L115 were not covered by tests

CATSELECTED = []

Expand All @@ -133,6 +136,8 @@
channelname = lep_ch_name + "_" + jet + "j_ptz_wtau"
elif args.fwd_flag and ("fwd" in lep_ch_name or "2lss_p" in lep_ch_name or "2lss_m" in lep_ch_name):
channelname = lep_ch_name + "_" + jet + "j_lt"
elif args.tta_flag and ("photon" in lep_ch_name or "2los_ph" in lep_ch_name):
channelname = lep_ch_name + "_" + jet + "j_photon_pt"

Check warning on line 140 in analysis/topeft_run2/datacards_post_processing.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/datacards_post_processing.py#L139-L140

Added lines #L139 - L140 were not covered by tests
else:
channelname = lep_ch_name + "_" + jet + "j_lj0pt"
CATSELECTED.append(channelname)
Expand Down
19 changes: 19 additions & 0 deletions analysis/topeft_run2/fullR2_run_genphoton.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This script runs the wq run script with all of the settings appropriate for making SR histos for the full R2 analysis

# Name the output
#OUT_NAME="example_name"
OUT_NAME="12112023_genphotonstudies_2lOS_ttTo2L2Nu_ttgDilep_genPartFlavLeptons_v12"

# Build the run command for filling SR histos
#CFGS="../../input_samples/cfgs/mc_signal_samples_NDSkim.cfg,
CFGS="../../input_samples/cfgs/mc_background_samples_NDSkim.cfg" #,../../input_samples/cfgs/data_samples_NDSkim.cfg"
OPTIONS="--hist-list photon -s 50000 -x futures -o $OUT_NAME" # For analysis

# Build the run command for filling CR histos
#CFGS="../../input_samples/cfgs/mc_signal_samples_NDSkim.cfg,../../input_samples/cfgs/mc_background_samples_NDSkim.cfg,../../input_samples/cfgs/mc_background_samples_cr_NDSkim.cfg,../../input_samples/cfgs/data_samples_NDSkim.cfg"
#OPTIONS="--hist-list cr --skip-sr --do-systs --do-np --wc-list ctG -o $OUT_NAME" # For CR plots

# Run the processor over all Run2 samples
RUN_COMMAND="time python run_analysis_genPhoton.py $CFGS $OPTIONS"
printf "\nRunning the following command:\n$RUN_COMMAND\n\n"
$RUN_COMMAND
221 changes: 221 additions & 0 deletions analysis/topeft_run2/genProcessor_photon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
#gen processor written for photon studies
#Created on October 6, 2023

#!/usr/bin/env python
import numpy as np
import awkward as ak
np.seterr(divide='ignore', invalid='ignore', over='ignore')
from coffea import processor

Check warning on line 8 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L5-L8

Added lines #L5 - L8 were not covered by tests

import hist
from topcoffea.modules.paths import topcoffea_path
from topcoffea.modules.histEFT import HistEFT
import topcoffea.modules.eft_helper as efth

Check warning on line 13 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L10-L13

Added lines #L10 - L13 were not covered by tests

from topeft.modules.paths import topeft_path
import topeft.modules.event_selection as te_es
import topeft.modules.object_selection as te_os

Check warning on line 17 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L15-L17

Added lines #L15 - L17 were not covered by tests

from topcoffea.modules.get_param_from_jsons import GetParam
get_tc_param = GetParam(topcoffea_path("params/params.json"))
get_te_param = GetParam(topeft_path("params/params.json"))

Check warning on line 21 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L19-L21

Added lines #L19 - L21 were not covered by tests

class AnalysisProcessor(processor.ProcessorABC):

Check warning on line 23 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L23

Added line #L23 was not covered by tests

def __init__(self, processs, wc_names_lst=[], hist_lst=None, ecut_threshold=None, do_errors=False, do_systematics=False, split_by_lepton_flavor=False, skip_signal_regions=False, skip_control_regions=False, muonSyst='nominal', dtype=np.float32):

Check warning on line 25 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L25

Added line #L25 was not covered by tests

self._processs = processs
self._wc_names_lst = wc_names_lst
self._dtype = dtype

Check warning on line 29 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L27-L29

Added lines #L27 - L29 were not covered by tests

# Create the histograms
proc_axis = hist.axis.StrCategory([], name="process", growth=True)
chan_axis = hist.axis.StrCategory([], name="channel", growth=True)
syst_axis = hist.axis.StrCategory([], name="systematic", label=r"Systematic Uncertainty", growth=True)
appl_axis = hist.axis.StrCategory([], name="appl", label=r"AR/SR", growth=True)
self._accumulator = {

Check warning on line 36 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L32-L36

Added lines #L32 - L36 were not covered by tests
"genphoton_pt" : HistEFT(proc_axis, hist.axis.Regular(10, 0, 200), label="$p_{T}$ $Gen\gamma$ (GeV)", wc_names=wc_names_lst),
"genlep_pt" : HistEFT(proc_axis, hist.axis.Regular(20, 0 ,200), label="$p_{T}$ $Gen lepton$ (GeV)", wc_names=wc_names_lst),
}

# Set the list of hists to fill
if hist_lst is None:

Check warning on line 42 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L42

Added line #L42 was not covered by tests
# If the hist list is none, assume we want to fill all hists
self._hist_lst = list(self._accumulator.keys())

Check warning on line 44 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L44

Added line #L44 was not covered by tests
else:
# Otherwise, just fill the specified subset of hists
for hist_to_include in hist_lst:
if hist_to_include not in self._accumulator.keys():
raise Exception(f"Error: Cannot specify hist \"{hist_to_include}\", it is not defined in the processor.")
self._hist_lst = hist_lst # Which hists to fill

Check warning on line 50 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L47-L50

Added lines #L47 - L50 were not covered by tests

# Set the booleans
self._do_errors = do_errors # Whether to calculate and store the w**2 coefficients

Check warning on line 53 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L53

Added line #L53 was not covered by tests

@property
def accumulator(self):
return self._accumulator

Check warning on line 57 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L55-L57

Added lines #L55 - L57 were not covered by tests

@property
def columns(self):
return self._columns

Check warning on line 61 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L59-L61

Added lines #L59 - L61 were not covered by tests

# Main function: run on a given dataset
def process(self, events):

Check warning on line 64 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L64

Added line #L64 was not covered by tests

### Dataset parameters ###
dataset = events.metadata["dataset"]

Check warning on line 67 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L67

Added line #L67 was not covered by tests

isData = self._processs[dataset]["isData"]
histAxisName = self._processs[dataset]["histAxisName"]
year = self._processs[dataset]["year"]
xsec = self._processs[dataset]["xsec"]
sow = self._processs[dataset]["nSumOfWeights"]

Check warning on line 73 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L69-L73

Added lines #L69 - L73 were not covered by tests

if isData: raise Exception("Error: This processor is not for data")

Check warning on line 75 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L75

Added line #L75 was not covered by tests

### Get gen particles collection ###
genPart = events.GenPart
genJet = events.GenJet

Check warning on line 79 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L78-L79

Added lines #L78 - L79 were not covered by tests

## reco ele and muon collection ###
ele = events.Electron
mu = events.Muon

Check warning on line 83 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L82-L83

Added lines #L82 - L83 were not covered by tests

is_final_mask = genPart.hasFlags(["fromHardProcess","isLastCopy"])

Check warning on line 85 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L85

Added line #L85 was not covered by tests

################## gen matched lepton selection #######################
#genEle_mask = np.abs(ele.matched_gen.pdgId)==11
#genEle_mask = abs(genPart.pdgId) == 11
ele_genpartFlavmask = ((ele.genPartFlav == 1) | (ele.genPartFlav == 15))
mu_genpartFlavmask = ((mu.genPartFlav == 1) | (mu.genPartFlav == 15))

Check warning on line 91 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L90-L91

Added lines #L90 - L91 were not covered by tests
#genEle = genPart[is_final_mask & genEle_mask]
#genMu_mask = np.abs(mu.matched_gen.pdgId)==13
#genMu_mask = abs(genPart.pdgId) == 13
#genMu = genPart[is_final_mask & genMu_mask]
genEle = ele[ele_genpartFlavmask]
genMu = mu[mu_genpartFlavmask]
genleps = ak.concatenate([genEle,genMu],axis=1)
genlep_pt_mask = genleps.pt > 20 #Require that the lepton pt be at least 20 GeV.
genlep_eta_mask = abs(genleps.eta)<2.4 #Require that the lepton be within 2.4 eta
genlep_pt_eta_mask = ak.fill_none(ak.pad_none((genlep_pt_mask & genlep_eta_mask),1),False)
genleps = genleps[genlep_pt_eta_mask]
genleps_ptsorted = genleps[ak.argsort(genleps.pt,axis=-1,ascending=False)]
genleps_ptsorted_padded = ak.pad_none(genleps_ptsorted, 2)
pt2515 = (ak.any(genleps_ptsorted_padded[:,0:1].pt>25,axis=1) & ak.any(genleps_ptsorted_padded[:,1:2].pt>15,axis=1)) #Require that the leading(sub-leading) lepton pT be at least 25(15)GeV.

Check warning on line 105 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L96-L105

Added lines #L96 - L105 were not covered by tests
#genleps_ptsorted_padded = genleps_ptsorted_padded[pt2515]
genl0 = genleps_ptsorted_padded[:,0]
genl1 = genleps_ptsorted_padded[:,1]

Check warning on line 108 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L107-L108

Added lines #L107 - L108 were not covered by tests

#pt2515 = (ak.any(genleps_ptsorted_padded[:,0:1].pt>25,axis=1) & ak.any(genleps_ptsorted_padded[:,1:2].pt>15,axis=1)) #Require that the leading(sub-leading) lepton pT be at least 25(15)GeV.

genleps_num_mask = ak.num(genleps_ptsorted) == 2 #Require that there are exactly 2 gen_matched leptons

Check warning on line 112 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L112

Added line #L112 was not covered by tests
#genleps_chargesum_zero = ak.fill_none(((genl0.charge + genl1.charge)==0),False) #Require that the two leptons are of opposite signs
genleps_chargesum_zero = (np.sign(genl0.pdgId) == - np.sign(genl1.pdgId))
genleps_chargesum_zero = ak.fill_none(genleps_chargesum_zero, False)

Check warning on line 115 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L114-L115

Added lines #L114 - L115 were not covered by tests
#genleps_final_mask = (genleps_num_mask & pt2515 & genleps_chargesum_zero)


invmass_ll = (genl0+genl1).mass
mll_min20 = ak.fill_none((invmass_ll > 20),False) #Require that the invariant mass of the lepton pairs be at least 20 GeV.
all_genleps_mask = (genleps_num_mask & pt2515 & genleps_chargesum_zero & mll_min20)

Check warning on line 121 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L119-L121

Added lines #L119 - L121 were not covered by tests

## gen Photon selection ##
genPh_mask = abs(genPart.pdgId) == 22
genPhoton = genPart[is_final_mask & genPh_mask]
is_clean_photon = te_os.isClean(genPhoton, genEle,drmin=0.4) & te_os.isClean(genPhoton,genMu,drmin=0.4) #photon isolation from leps
genPhoton = genPhoton[is_clean_photon]

Check warning on line 127 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L124-L127

Added lines #L124 - L127 were not covered by tests

events['genPhoton'] = genPhoton
te_es.GenPhotonSelection(events) #Require photon pt be 20 GeV and abs(eta) be 1.44
genPhoton = genPhoton[events.genPhoton_pT_eta_mask]

Check warning on line 131 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L129-L131

Added lines #L129 - L131 were not covered by tests

genphoton_num_mask = ak.num(genPhoton) == 1 #Require that there is exactly 1 photon

Check warning on line 133 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L133

Added line #L133 was not covered by tests



############### Jet object selection #####################
genJet_pT_eta_mask = ((genJet.pt > 30) & (abs(genJet.eta) < 2.44))
genJet_pT_eta_mask = ak.fill_none(ak.pad_none(genJet_pT_eta_mask,1),False)
genjet = genJet[genJet_pT_eta_mask] #Require that the jet pt be at least 30 GeV.
is_clean_jet = te_os.isClean(genjet, genEle, drmin=0.4) & te_os.isClean(genjet, genMu, drmin=0.4) & te_os.isClean(genjet, genPhoton, drmin=0.1)
genjet_clean = genjet[is_clean_jet]

Check warning on line 142 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L138-L142

Added lines #L138 - L142 were not covered by tests

genjets_num_mask = ak.num(genjet_clean) >= 1 #Require that there is at least 1 jet

Check warning on line 144 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L144

Added line #L144 was not covered by tests

################## Gen matched b jets selection ########################
genbJets_mask = np.abs(genjet_clean.hadronFlavour)==5 #bjet selection from genJet collection
genbJets = genJet[genbJets_mask]
genbJets_pT_eta_mask = ((genbJets.pt > 30) & (abs(genbJets.eta) < 2.44))
genbJets_pT_eta_mask = ak.fill_none(ak.pad_none(genbJets_pT_eta_mask,1),False)
genbJets = genbJets[genbJets_pT_eta_mask]

Check warning on line 151 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L147-L151

Added lines #L147 - L151 were not covered by tests

#gen bJet multiplicity mask
genbJets_num_mask = ak.num(genbJets) >= 1 #Require that there is at least 1 btagged jet

Check warning on line 154 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L154

Added line #L154 was not covered by tests

################### Define dense axis variables #######################
genphoton_pt = ak.fill_none(ak.firsts(genPhoton.pt),-1) #highest pt in the genphoton collection
genl0pt = ak.fill_none(ak.firsts(genleps_ptsorted.pt),-1) #highest pt in the genlep collection

Check warning on line 158 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L157-L158

Added lines #L157 - L158 were not covered by tests

# Dictionary of dense axis values
dense_axis_dict = {

Check warning on line 161 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L161

Added line #L161 was not covered by tests
"genphoton_pt" : genphoton_pt,
"genlep_pt" : genl0pt,
}

#### Get weights ###
# Extract the EFT quadratic coefficients and optionally use them to calculate the coefficients on the w**2 quartic function
# eft_coeffs is never Jagged so convert immediately to numpy for ease of use.
eft_coeffs = ak.to_numpy(events["EFTfitCoefficients"]) if hasattr(events, "EFTfitCoefficients") else None
if eft_coeffs is not None:

Check warning on line 170 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L169-L170

Added lines #L169 - L170 were not covered by tests
# Check to see if the ordering of WCs for this process matches what want
if self._processs[dataset]["WCnames"] != self._wc_names_lst:
eft_coeffs = efth.remap_coeffs(self._processs[dataset]["WCnames"], self._wc_names_lst, eft_coeffs)
eft_w2_coeffs = efth.calc_w2_coeffs(eft_coeffs,self._dtype) if (self._do_errors and eft_coeffs is not None) else None

Check warning on line 174 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L172-L174

Added lines #L172 - L174 were not covered by tests

#If this is not an eft process, get the genWeight
if eft_coeffs is None: genw = events["genWeight"]
else: genw = np.ones_like(events["event"])
lumi = 1000.0*get_tc_param(f"lumi_{year}")
event_weight = lumi*(xsec/sow)*genw

Check warning on line 180 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L177-L180

Added lines #L177 - L180 were not covered by tests

#Final mask relevant to the "category" we are interested in.
#genph_2lOS_mask = (genleps_num_mask & genleps_chargesum_zero & genjets_num_mask & genbJets_num_mask & events.genPhoton_pT_eta_mask & genphoton_num_mask)
genphoton_2lOS_mask = (all_genleps_mask & genjets_num_mask & genbJets_num_mask & genphoton_num_mask)
nogenphoton_2lOS_mask = (all_genleps_mask & genjets_num_mask & genbJets_num_mask)

Check warning on line 185 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L184-L185

Added lines #L184 - L185 were not covered by tests

##### Loop over the hists we want to fill ###########

hout = self.accumulator.identity()

Check warning on line 189 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L189

Added line #L189 was not covered by tests

for dense_axis_name, dense_axis_vals in dense_axis_dict.items():

Check warning on line 191 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L191

Added line #L191 was not covered by tests

#Mask out the none values
isnotnone_mask = (ak.fill_none((dense_axis_vals != None),False))

Check warning on line 194 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L194

Added line #L194 was not covered by tests
#all_cuts_mask = ak.any(genph_2lOS_mask,axis=1)# & isnotnone_mask)
if dense_axis_name == "genphoton_pt":
all_cuts_mask = genphoton_2lOS_mask
elif dense_axis_name == "genlep_pt":
all_cuts_mask = nogenphoton_2lOS_mask
dense_axis_vals_cut = dense_axis_vals[all_cuts_mask]
event_weights_cut = event_weight[all_cuts_mask]
eft_coeffs_cut = eft_coeffs
if eft_coeffs is not None: eft_coeffs_cut = eft_coeffs[all_cuts_mask]
eft_w2_coeffs_cut = eft_w2_coeffs
if eft_w2_coeffs is not None: eft_w2_coeffs_cut = eft_w2_coeffs[all_cuts_mask]

Check warning on line 205 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L196-L205

Added lines #L196 - L205 were not covered by tests

# Fill the histos
axes_fill_info_dict = {

Check warning on line 208 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L208

Added line #L208 was not covered by tests
dense_axis_name : dense_axis_vals_cut,
"process" : histAxisName,
"weight" : event_weights_cut,
"eft_coeff" : eft_coeffs_cut,
"eft_err_coeff" : eft_w2_coeffs_cut,
}

hout[dense_axis_name].fill(**axes_fill_info_dict)

Check warning on line 216 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L216

Added line #L216 was not covered by tests

return hout

Check warning on line 218 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L218

Added line #L218 was not covered by tests

def postprocess(self, accumulator):
return accumulator

Check warning on line 221 in analysis/topeft_run2/genProcessor_photon.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/genProcessor_photon.py#L220-L221

Added lines #L220 - L221 were not covered by tests
16 changes: 13 additions & 3 deletions analysis/topeft_run2/make_cr_and_sr_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@


SR_CHAN_DICT = {
"2los_SR": [
"2los_ph_3j"
],
"2lss_SR": [
"2lss_4t_m_4j", "2lss_4t_m_5j", "2lss_4t_m_6j", "2lss_4t_m_7j",
"2lss_4t_p_4j", "2lss_4t_p_5j", "2lss_4t_p_6j", "2lss_4t_p_7j",
Expand Down Expand Up @@ -127,6 +130,7 @@
"ttll" : [],
"tttt" : [],
"tXq" : [],
"ttA" : [],
}

# Best fit point from TOP-19-001 with madup numbers for the 10 new WCs
Expand Down Expand Up @@ -234,7 +238,7 @@
elif sample_name in sample_group_map["Triboson"]:
scale_name_for_json = "Triboson"
elif sample_name in sample_group_map["Signal"]:
for proc_str in ["ttH","tllq","ttlnu","ttll","tHq","tttt"]:
for proc_str in ["ttH","tllq","ttlnu","ttll","tHq","tttt","ttA"]:

Check warning on line 241 in analysis/topeft_run2/make_cr_and_sr_plots.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/make_cr_and_sr_plots.py#L241

Added line #L241 was not covered by tests
if proc_str in sample_name:
# This should only match once, but maybe we should put a check to enforce this
scale_name_for_json = proc_str
Expand Down Expand Up @@ -819,7 +823,7 @@

###################### Wrapper function for SR data and mc plots (unblind!) ######################
# Wrapper function to loop over all SR categories and make plots for all variables
def make_all_sr_data_mc_plots(dict_of_hists,year,save_dir_path):
def make_all_sr_data_mc_plots(dict_of_hists,year,save_dir_path,unblind=False):

Check warning on line 826 in analysis/topeft_run2/make_cr_and_sr_plots.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/make_cr_and_sr_plots.py#L826

Added line #L826 was not covered by tests

# Construct list of MC samples
mc_wl = []
Expand Down Expand Up @@ -852,6 +856,7 @@
samples_to_rm_from_mc_hist = []
samples_to_rm_from_data_hist = []
all_samples = yt.get_cat_lables(dict_of_hists,"process",h_name="lj0pt")
#all_samples = yt.get_cat_lables(dict_of_hists,"process",h_name="lj0pt")
mc_sample_lst = utils.filter_lst_of_strs(all_samples,substr_whitelist=mc_wl,substr_blacklist=mc_bl)
data_sample_lst = utils.filter_lst_of_strs(all_samples,substr_whitelist=data_wl,substr_blacklist=data_bl)
for sample_name in all_samples:
Expand Down Expand Up @@ -888,7 +893,7 @@
elif "TTTo" in proc_name or "TTto" in proc_name:
CR_GRP_MAP["Ttbar"].append(proc_name)
elif "TTG" in proc_name:
SR_GRP_MAP["Conv"].append(proc_name)
SR_GRP_MAP["ttA"].append(proc_name)

Check warning on line 896 in analysis/topeft_run2/make_cr_and_sr_plots.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/make_cr_and_sr_plots.py#L896

Added line #L896 was not covered by tests
elif "WWW" in proc_name or "WWZ" in proc_name or "WZZ" in proc_name or "ZZZ" in proc_name:
SR_GRP_MAP["Multiboson"].append(proc_name)
elif "WWTo2L2Nu" in proc_name or "ZZTo4L" in proc_name or "WZTo3LNu" in proc_name:
Expand All @@ -909,6 +914,7 @@
#}
analysis_bins['ptz'] = axes_info['ptz']['variable']
analysis_bins['lj0pt'] = axes_info['lj0pt']['variable']
analysis_bins['photon_pt'] = axes_info['photon_pt']['variable']

Check warning on line 917 in analysis/topeft_run2/make_cr_and_sr_plots.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/make_cr_and_sr_plots.py#L917

Added line #L917 was not covered by tests

# Loop over hists and make plots
skip_lst = ['ptz', 'njets'] # Skip this hist
Expand All @@ -922,6 +928,7 @@
# Extract the MC and data hists
hist_mc_orig = dict_of_hists[var_name].remove("process", samples_to_rm_from_mc_hist)
hist_data_orig = dict_of_hists[var_name].remove("process", samples_to_rm_from_data_hist)
if not unblind: hist_data_orig = hist_mc_orig

Check warning on line 931 in analysis/topeft_run2/make_cr_and_sr_plots.py

View check run for this annotation

Codecov / codecov/patch

analysis/topeft_run2/make_cr_and_sr_plots.py#L931

Added line #L931 was not covered by tests

# Loop over channels
channels_lst = yt.get_cat_lables(dict_of_hists[var_name],"channel")
Expand Down Expand Up @@ -1332,7 +1339,10 @@
# Make the plots
make_all_cr_plots(hin_dict,args.year,args.skip_syst,unit_norm_bool,save_dir_path)
#make_all_sr_plots(hin_dict,args.year,unit_norm_bool,save_dir_path)
# Blinded plots (Asimov data)
#make_all_sr_data_mc_plots(hin_dict,args.year,save_dir_path)
# Unblinded plots (real data)
#make_all_sr_data_mc_plots(hin_dict,args.year,save_dir_path,unblid=True)
#make_all_sr_sys_plots(hin_dict,args.year,save_dir_path)
#make_simple_plots(hin_dict,args.year,save_dir_path)

Expand Down
Loading
Loading