Skip to content
Snippets Groups Projects
Commit 5fd50008 authored by Victor Hugo Ruelas Rivera's avatar Victor Hugo Ruelas Rivera
Browse files

Add PFlow to small-R jet output branches

parent 52fb6d1a
No related branches found
No related tags found
No related merge requests found
Showing with 35 additions and 36 deletions
# A bit repetitive but avoids extracting the list
# from a specific file format
objtypes = [
"reco4Jet",
"reco4PFlowJet",
"reco10TopoJet",
"reco10UFOJet",
"vrJet",
......@@ -17,7 +17,7 @@ objtypes = [
container_map = {
"DAOD_PHYS": {
"reco4Jet": "AntiKt4EMPFlowJets",
"reco4PFlowJet": "AntiKt4EMPFlowJets",
"reco10TopoJet": "AntiKt10LCTopoTrimmedPtFrac5SmallR20Jets",
"reco10UFOJet": "AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets",
"vrJet": "AntiKtVR30Rmax4Rmin02PV0TrackJets",
......@@ -31,7 +31,7 @@ container_map = {
"truthSMParticles": "TruthBosonsWithDecayParticles",
},
"DAOD_PHYSLITE": {
"reco4Jet": "AnalysisJets",
"reco4PFlowJet": "AnalysisJets",
"reco10TopoJet": "",
"reco10UFOJet": "AnalysisLargeRJets",
"vrJet": "",
......@@ -63,7 +63,7 @@ def get_container_names(flags):
outputs = inputs
else:
outputs = dict(
reco4Jet=f"Analysis{inputs['reco4Jet']}_%SYS%",
reco4PFlowJet=f"Analysis{inputs['reco4PFlowJet']}_%SYS%",
reco10UFOJet=f"Analysis{inputs['reco10UFOJet']}_%SYS%",
muons=f"Analysis{inputs['muons']}_%SYS%",
electrons=f"Analysis{inputs['electrons']}_%SYS%",
......
......@@ -16,7 +16,9 @@ def dihiggs_analysis_cfg(
cfg.merge(
resolved_cfg(
flags,
smalljetkey=containers["outputs"]["reco4Jet"].replace("%SYS%", "NOSYS"),
smalljetkey=containers["outputs"]["reco4PFlowJet"].replace(
"%SYS%", "NOSYS"
),
)
)
cfg.merge(event_counter_cfg("n_resolved"))
......
......@@ -28,7 +28,7 @@ def get_h5_cfg(flags):
output=output,
)
)
jetcol = get_container_names(flags)["outputs"]["reco4Jet"]
jetcol = get_container_names(flags)["outputs"]["reco4PFlowJet"]
types = {}
primitives = []
if flags.Analysis.n_h5_jets > 0:
......@@ -109,7 +109,7 @@ def _get_truth_types(flags):
associations[matchbar] = f"parent{parent}Link/barcode"
types[matchbar] = 'INT'
cascade_types = [] if physlite else ["B","W"]
cascade_types = [] if physlite else ["B", "W"]
for cascade_type in cascade_types:
key = f"nTopTo{cascade_type}Children"
types[key] = "UCHAR"
......
......@@ -47,17 +47,14 @@ def minituple_cfg(flags, trigger_chains, do_PRW=False):
tree_branches = []
tree_branches += get_event_info_branches(
flags, do_PRW, trigger_chains
)
tree_branches += get_event_info_branches(flags, do_PRW, trigger_chains)
objects_out = {
"electrons": ("el", get_electron_branches),
"photons": ("ph", get_photon_branches),
"muons": ("mu", get_muon_branches),
"electrons": ("el", get_electron_branches),
"photons": ("ph", get_photon_branches),
"muons": ("mu", get_muon_branches),
}
for objtype, (prefix, branch_getter) in objects_out.items():
if flags(f"Analysis.write_{objtype}"):
tree_branches += branch_getter(
flags,
......@@ -68,8 +65,8 @@ def minituple_cfg(flags, trigger_chains, do_PRW=False):
if flags.Analysis.write_small_R_jets:
tree_branches += get_small_R_jet_branches(
flags,
input_container=containers["reco4Jet"],
output_prefix="recojet_antikt4"
input_container=containers["reco4PFlowJet"],
output_prefix="recojet_antikt4PFlow",
)
# Use this to directly read b-tagging information
# Note that the indices can get out of sync with
......@@ -78,7 +75,7 @@ def minituple_cfg(flags, trigger_chains, do_PRW=False):
tree_branches += get_small_R_bjet_branches(
flags,
input_container="BTagging_AntiKt4EMPFlow",
output_prefix="recojet_antikt4"
output_prefix="recojet_antikt4PFlow",
)
if flags.Analysis.write_large_R_Topo_jets:
......@@ -101,7 +98,7 @@ def minituple_cfg(flags, trigger_chains, do_PRW=False):
tree_branches += get_small_R_truthjet_branches(
flags,
input_container=containers["truth4Jet"],
output_prefix="truthjet_antikt4",
output_prefix="truthjet_antikt4PFlow",
)
if flags.Input.isMC and flags.Analysis.write_truth_large_R_jets:
......@@ -134,14 +131,14 @@ def minituple_cfg(flags, trigger_chains, do_PRW=False):
cfg.merge(tree_cfg(flags, branches=tree_branches))
if flags.Analysis.dump_output_branchlist:
outf_sub = flags.Analysis.out_file.replace('root','txt')
if '/' in outf_sub:
outf_dir, outf_sub = outf_sub.rsplit('/',1)
outf_sub = flags.Analysis.out_file.replace("root", "txt")
if "/" in outf_sub:
outf_dir, outf_sub = outf_sub.rsplit("/", 1)
branches_fname = f"{outf_dir}/output-branches-{outf_sub}"
else:
branches_fname = f"output-branches-{outf_sub}"
with open(branches_fname,'w') as branches_f:
with open(branches_fname, "w") as branches_f:
for b in tree_branches:
branches_f.write(f"{b}\n")
......
......@@ -58,7 +58,7 @@ def update_metadata(path):
md.metAccessLevel = cached["level"]
def has_metadata(flags,path=Path('metadata.json')):
def has_metadata(flags, path=Path('metadata.json')):
if not path.is_file():
return False
with open(path) as meta:
......
......@@ -17,7 +17,7 @@ def truth_info_cfg(
if flags.Analysis.do_small_R_jets and not flags.Input.isPHYSLITE:
cfg.merge(jet_parent_decorator_cfg(
flags,
jet_collection=containers["inputs"]["reco4Jet"],
jet_collection=containers["inputs"]["reco4PFlowJet"],
name_prefix="smallR",
match_dr=0.3
))
......
......@@ -13,7 +13,7 @@ def jet_sequence_cfg(
cfg = ComponentAccumulator()
jet_sequence = makeJetAnalysisSequence(
flags.Analysis.DataType,
jetCollection=containers["inputs"]["reco4Jet"],
jetCollection=containers["inputs"]["reco4PFlowJet"],
postfix="smallR",
deepCopyOutput=False,
shallowViewOutput=True,
......@@ -61,8 +61,8 @@ def jet_sequence_cfg(
)
jet_sequence.configure(
inputName=containers["inputs"]["reco4Jet"],
outputName=containers["outputs"]["reco4Jet"],
inputName=containers["inputs"]["reco4PFlowJet"],
outputName=containers["outputs"]["reco4PFlowJet"],
)
cfg.addSequence(CompFactory.AthSequencer(jet_sequence.getName()))
......
......@@ -8,8 +8,8 @@ def muon_sequence_cfg(flags, containers):
muon_sequence = makeMuonAnalysisSequence(
flags.Analysis.DataType,
workingPoint="Medium.NonIso",
postfix="medium",
workingPoint="Loose.NonIso",
postfix="loose",
deepCopyOutput=False,
shallowViewOutput=True,
ptSelectionOutput=True,
......
......@@ -22,7 +22,7 @@ def overlap_sequence_cfg(
overlapInputNames[objtype] = containers["outputs"][objtype]
if flags.Analysis.do_small_R_jets:
overlapInputNames["jets"] = containers["outputs"]["reco4Jet"]
overlapInputNames["jets"] = containers["outputs"]["reco4PFlowJet"]
do_fatJet_OR = False
if flags.Analysis.write_large_R_Topo_jets:
......
......@@ -43,18 +43,18 @@ class BranchManager(object):
"%SYS%" in _input_container
and self.systematics_option == SystOption.NO_SYST
):
_input_container = _input_container.replace("_%SYS%",self.syst_str())
_input_container = _input_container.replace("_%SYS%", self.syst_str())
return _input_container
def output_string(self,var):
def output_string(self, var):
# Handle case where output prefix is ''
return (
f"{self.full_input_container()}.{var} -> "
f"{self.full_output_prefix()}{var}"
)
def add_four_mom_branches(self,do_mass):
self.variables += ["pt","eta","phi"]
def add_four_mom_branches(self, do_mass):
self.variables += ["pt", "eta", "phi"]
if do_mass:
self.variables += ["m"]
......
......@@ -35,7 +35,7 @@ def get_event_info_branches(flags, do_PRW, trigger_chains):
]:
eventinfo_branches.variables += [
f"{truthpart}_{var}"
for var in ["pt","eta","phi","m"]
for var in ["pt", "eta", "phi", "m"]
]
if flags.Analysis.write_large_R_Topo_jets and flags.Analysis.write_VR_jets:
......
......@@ -6,7 +6,7 @@ def consolidate_systematics_regex(regex_list):
syst_regex = '.*'
else:
for r in regex_list:
invalid = ['','.*','NOSYS','^$']
invalid = ['', '.*', 'NOSYS', '^$']
if r in invalid:
raise ValueError(f"'{r}' in systematics regex is invalid")
# Start with match for empty string i.e. NOSYS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment