Skip to content
Snippets Groups Projects
Commit dd5fb103 authored by Ines Ochoa's avatar Ines Ochoa :cat2: Committed by Melissa Yexley
Browse files

protections against incomplete scenario strings, fix in case of missing...

protections against incomplete scenario strings, fix in case of missing thresholds, dynamic determination of pt cut for DIPZ
parent 84a17f39
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ rgx_pattern = re.compile(pattern_dipz)
def get_kin_args_from_matchdict(groupdict):
""" Get kinematic cuts on jets for DIPZ MLPL hypo """
if groupdict['ptlo'] is None: # then default filtering for pt
if not groupdict['ptlo']: # then default filtering for pt
groupdict['ptlo'] = '20'
groupdict['pthi'] = ''
......@@ -33,9 +33,9 @@ def get_kin_args_from_matchdict(groupdict):
def get_mult_args_from_matchdict(groupdict):
"""Get jet multiplicity for DIPZ MLPL hypo """
if groupdict['N'] is None:
groupdict['N'] = '2'
if not groupdict['N']:
raise ValueError('DIPZ scenario requires a pre-defined jet multiplicity.')
condargs = []
......@@ -47,12 +47,12 @@ def get_mult_args_from_matchdict(groupdict):
def get_dipz_mlpl_from_matchdict(groupdict, njets):
"""Get DIPz WP, capacity (njets) and decorator names"""
if groupdict['WP'] is None: # scale factor of -0.1 applied by default
groupdict['WP'] = '-inf'
if not groupdict['WP'] :
raise ValueError('DIPZ scenario requires a pre-defined working point cut on MLPL.')
condargs = []
vals = defaults('dipz_mlpl', lo = groupdict['WP'])
vals = defaults('dipz_mlpl', lo = groupdict['WP']) # Note: scale factor of -0.1 applied by default
vals['decName_z']='dipz20231122_z'
vals['decName_sigma']='dipz20231122_negLogSigma2'
vals['capacity']=njets
......@@ -71,6 +71,11 @@ def scenario_dipz(scenario, chainPartInd):
'routing error, module %s: bad scenario %s' % (__name__, scenario)
m = rgx_pattern.match(scenario)
assert m is not None, \
'scenario_dipz.py - regex part %s does not match scenario %s' % (
pattern_dipz, scenario)
groupdict = m.groupdict()
# list for the repeatedCondition parameters, FilterParams and their indices
......@@ -83,7 +88,7 @@ def scenario_dipz(scenario, chainPartInd):
## Get kinematic cuts, number of jets, DIPZ cut, ...
condargs_kin = get_kin_args_from_matchdict(groupdict)
chooseN = float(get_mult_args_from_matchdict(groupdict)[0][1]['min']) # TODO improve
chooseN = float(get_mult_args_from_matchdict(groupdict)[0][1]['min'])
condargs = get_dipz_mlpl_from_matchdict(groupdict, str(chooseN))
## DIPz condition for N jets
......
......@@ -75,7 +75,9 @@ def _preselJetHypoToolFromDict(flags, mainChainDict, doBJetSel=False):
findAllJets = ['1'+el if len(el) == 1 else el for el in findAllJets]
nAllJets = sum(int(i[:-1]) for i in findAllJets)
nCentralJets = sum(int(i[:-1]) if 'c' in i else 0 for i in findAllJets)
assert nAllJets == nCentralJets, "Your preselection has a DIPZ part but not only central jets were required. Please investigate."
findAllPts = re.findall(r'[jacf](?P<ptcut>\d+)', presel_cut_str)
ptCut = min(float(i) for i in findAllPts)
assert nAllJets == nCentralJets, "Your preselection has a DIPZ part but not only central jets were required. This isn't currently supported. Please investigate."
preselCommonJetParts = dict(JetChainParts_Default)
......@@ -99,6 +101,7 @@ def _preselJetHypoToolFromDict(flags, mainChainDict, doBJetSel=False):
assert matched is not None, "Impossible to extract preselection cut for \'{0}\' substring. Please investigate.".format(p)
cut_dict = matched.groupdict()
if hasDIPZsel: cut_dict['region'] = 'c'
if hasDIPZsel: cut_dict['cut'] = ptCut
if 'mult' not in cut_dict.keys(): cut_dict['mult'] = ''
if 'emfc' not in cut_dict.keys(): cut_dict['emfc'] = ''
......@@ -119,7 +122,7 @@ def _preselJetHypoToolFromDict(flags, mainChainDict, doBJetSel=False):
threshold='0'
chainPartName=f'j0_{hyposcenario}'
elif scenario == "Z":
hyposcenario=f'Z{dipzwp}XX{nCentralJets}c'
hyposcenario=f'Z{dipzwp}XX{nCentralJets}c{cut}'
prefilt = cut_dict['prefilt']
if prefilt != '': prefilters.append(prefilt)
threshold='0'
......
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