4 from AthenaCommon.Logging
import logging
5 logging.getLogger().
info(
"Importing %s",__name__)
6 log = logging.getLogger(__name__)
8 from ..Config.ChainConfigurationBase
import ChainConfigurationBase
10 from .JetRecoSequencesConfig
import JetRecoDataDeps
12 from .JetMenuSequencesConfig
import (
13 jetCaloHypoMenuSequenceGenCfg,
14 jetRoITrackJetTagHypoMenuSequenceGenCfg,
15 jetFSTrackingHypoMenuSequenceGenCfg,
16 jetCaloRecoMenuSequenceGenCfg,
17 jetCaloPreselMenuSequenceGenCfg,
18 jetHICaloHypoMenuSequenceGenCfg,
20 from .ExoticJetSequencesConfig
import jetEJsMenuSequenceGenCfg, jetCRVARMenuSequenceGenCfg,jetCRMenuSequenceGenCfg
22 from .
import JetRecoCommon
23 from .
import JetPresel
25 from TrigEDMConfig.TriggerEDM
import recordable
38 self.
dict = copy.deepcopy(chainDict)
53 jChainParts = JetRecoCommon.jetChainParts(self.
chainPart)
61 for ip,p
in enumerate(jChainParts):
63 if len(p[
'exotHypo']) > 1:
64 raise RuntimeError(
'emerging chains currently not configurable with more than one emerging selection!')
68 if 'perf' in p[
'addInfo']:
72 verify_null_str = [ p[k]!=
'' for k
in [
'jvt',
'momCuts',
'timing',
'bsel',
'bTag',
'tausel']]
73 verify_null_list = [ p[k]!=[]
for k
in [
'prefilters',
'exotHypo'] ]
75 p[
'trkpresel']!=
'nopresel' or p[
'hypoScenario']!=
'simple'
76 or any(verify_null_str)
or any(verify_null_list)
80 raise RuntimeError(f
'Invalid jet \'perf\' chain "{self.chainName}": No additional selection is permitted!')
82 l1th = p[
'L1threshold']
84 raise RuntimeError(
'Cannot configure a jet chain with different L1 thresholds')
87 if p[
"trkpresel"]!=
"nopresel" and ip+1!=len(jChainParts):
88 log.error(
"Likely inconsistency encountered in preselection specification for %s",self.
chainName)
89 raise RuntimeError(
"Preselection %s specified earlier than in the last chainPart!",p[
"trkpresel"])
94 self.
recoDict = JetRecoCommon.extractRecoDict(jChainParts)
112 log.debug(
"Assembling chain %s", self.
chainName)
120 chainSteps.append( jetHICaloHypoStep )
121 elif self.
recoDict[
"trkopt"]==
"roiftf":
124 raise RuntimeError(
"RoI FTF jet tracking requested with no jet preselection to provide RoIs")
127 chainSteps.append( jetPreselStep )
131 chainSteps.append( jetRoITrackJetTagHypoStep )
132 elif self.
recoDict[
"trkopt"]==
"ftf":
136 chainSteps.append( caloRecoStep )
138 roitrkPreselStep = self.getEmptyStep(2,
'RoIFTFEmptyStep')
142 chainSteps.append( jetPreselStep )
144 if re.match(
r'.*(b\d\d|bg\d\d|bgtwo\d\d)|.*Z|.*gntau', self.
trkpresel):
149 roitrkPreselStep=self.getEmptyStep(2,
'RoIFTFEmptyStep')
151 chainSteps.append(roitrkPreselStep)
154 chainSteps.append( jetFSTrackingHypoStep )
158 chainSteps.append( jetCaloHypoStep )
163 chainSteps+= [EJsStep]
166 chainSteps+= [ CRVARStep]
169 chainSteps+= [self.getEmptyStep(2,
'RoIFTFEmptyStep'), CRStep]
171 myChain = self.buildChain(chainSteps)
182 stepName = f
"MainStep_jet_{self.recoDict['jetDefStr']}"
187 jetStep = self.getStep(flags, stepName, [jetCaloHypoMenuSequenceGenCfg], isPerf=self.
isPerf, **self.
jetDefDict)
191 stepName = f
"MainStep_HIjet_{self.recoDict['jetDefStr']}"
195 jetStep = self.getStep(
196 flags, stepName, [jetHICaloHypoMenuSequenceGenCfg],
202 stepName =
"MainStep_jet_"+self.
recoDict[
'jetDefStr']
206 jetStep = self.getStep(
207 flags, stepName, [jetFSTrackingHypoMenuSequenceGenCfg],
214 clusterCalib = self.
recoDict[
"clusterCalib"]
215 stepName =
"CaloRecoPTStep_jet_"+clusterCalib
217 return self.getStep(flags, stepName, [jetCaloRecoMenuSequenceGenCfg], clusterCalib=clusterCalib)
222 assert 'recoAlg' in self.
trkpresel_parsed_reco.
keys(),
"Impossible to find \'recoAlg\' key in last chain dictionary for preselection"
225 assert matched_reco
is not None,
"Impossible to get matched reco algorithm for jet trigger preselection The reco expression {0} seems to be impossible to be parsed.".
format(self.
trkpresel_parsed_reco[
'recoAlg'])
228 preselRecoDict = JetPresel.getPreselRecoDict(matched_reco.group())
231 preselJetsOut, preselJetDef = preselJetDefDict[
"final"]
233 stepName =
"PreselStep_jet_"+preselRecoDict[
'jetDefStr']
234 jetStep = self.getStep(flags, stepName, [jetCaloPreselMenuSequenceGenCfg], **preselJetDefDict)
236 return preselJetDef, jetStep
240 stepName =
"RoIFTFStep_jet_sel_"+self.
recoDict[
'jetDefStr']
241 return self.getStep(flags, stepName, [jetRoITrackJetTagHypoMenuSequenceGenCfg], jetDef=preselJetDef, isPresel=
False)
246 assert 'recoAlg' in self.
trkpresel_parsed_reco.
keys(),
"Impossible to find \'recoAlg\' key in last chain dictionary for preselection"
248 matched_reco = re.match(
250 assert matched_reco
is not None,
"Impossible to get matched reco algorithm for jet trigger preselection The reco expression {0} seems to be impossible to be parsed.".
format(
254 preselRecoDict = JetPresel.getPreselRecoDict(matched_reco.group(),roiftf=
True)
256 assert preselRecoDict[
'trkopt'] ==
'roiftf',
'getJetRoITrackJetTagPreselChainStep: you requested a RoI tracking preselection but the reco dictionary has \'trkopt\' set to {0}'.
format(preselRecoDict[
'trkopt'])
258 stepName =
"RoIFTFStep_jet_"+self.
recoDict[
'jetDefStr']
259 return self.getStep(flags, stepName, [jetRoITrackJetTagHypoMenuSequenceGenCfg], jetDef=jetDef, isPresel=
True)
264 if 'emerging' in exotdictstring
and (
'dR' not in exotdictstring \
265 or 'PTF' not in exotdictstring):
266 log.error(
'Misconfiguration of exotic jet chain - need dR and PTF options')
268 if 'trackless' in exotdictstring
and 'dR' not in exotdictstring:
269 log.error(
'Misconfiguration of trackless exotic jet chain - need dR option')
273 if 'emerging' in exotdictstring:
276 elif 'trackless' in exotdictstring:
281 log.error(
'Misconfiguration of trackless exotic jet chain - need emerging or trackless selection')
284 log.debug(
"Running exotic jets with ptf: " +
str(ptf) +
"\tdR: " +
str(dr) +
"\ttrackless: " +
str(trackless) +
"\thypo: " + exotdictstring)
288 return self.getStep(flags, stepName, [jetEJsMenuSequenceGenCfg], jetsIn=jetCollectionName)
292 if 'calratiovar' in exotdictstring:
294 if 'calratiovarrmbib' in exotdictstring:
295 doBIBremoval =
int(1)
297 doBIBremoval =
int(0)
299 log.error(
'Misconfiguration of trackless exotic jet chain - need calratiovar selection')
302 log.debug(
"Running exotic jets with MinjetlogR: " +
str(MinjetlogR) +
"\t BIB rm " +
str(doBIBremoval) +
"\thypo: " + exotdictstring)
304 return self.getStep(flags,
"CRVARStep", [jetCRVARMenuSequenceGenCfg], jetsIn=jetCollectionName)
308 if 'calratio' in exotdictstring
and (
'calratiovar' not in exotdictstring):
310 if 'calratiormbib' in exotdictstring:
311 doBIBremoval =
int(1)
313 doBIBremoval =
int(0)
315 log.error(
'Misconfiguration of trackless exotic jet chain - need calratio selection')
318 log.debug(
"Running exotic jets with MinjetlogR: " +
str(MinjetlogR) +
"\t BIB rm " +
str(doBIBremoval) +
"\thypo: " + exotdictstring)
320 return self.getStep(flags,
"CRStep", [jetCRMenuSequenceGenCfg], jetsIn=jetCollectionName)