5 from JetRecConfig
import JetRecConfig
6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
9 from TrigEDMConfig.TriggerEDM
import recordable
11 from .
import JetRecoCommon
12 from JetRecConfig.JetDefinition
import JetModifier
13 from JetRecConfig.JetRecConfig
import getJetCopyAlg
15 from AthenaCommon.Logging
import logging
16 logging.getLogger().
info(
"JetHIConfig LOG: Importing %s",__name__)
17 log = logging.getLogger(__name__)
23 jetNamePrefix = JetRecoCommon.getHLTPrefix()
24 clustersKey = JetRecoCommon.getClustersKey(jetRecoDict)
25 jetDef_unsub = JetRecoCommon.defineHIJets(jetRecoDict,clustersKey=clustersKey,prefix=jetNamePrefix,suffix=
"_Unsubtracted")
26 jetDef_unsub._internalAtt[
'finalPJContainer'] =
"PseudoJet"+clustersKey
29 associationName =
"%s_DR8Assoc" % (clustersKey)
30 jetDef_seed0 = jetDef_unsub.clone()
31 jetDef_seed0.suffix = jetDef_unsub.suffix.replace(
"Unsubtracted",
"seed0")
32 jetDef_seed0.radius = 0.2
33 jetsFullName_seed0 = jetDef_seed0.fullname()
34 stdJetModifiers.update(
36 HLTHIJetAssoc = JetModifier(
"HIJetDRAssociationTool",
"HIJetDRAssociation", ContainerKey=clustersKey, DeltaR=0.8, AssociationName=associationName),
37 HLTHIJetMaxOverMean = JetModifier(
"HIJetMaxOverMeanTool",
"HIJetMaxOverMean", JetContainer = jetsFullName_seed0),
38 HLTHIJetDiscrim = JetModifier(
"HIJetDiscriminatorTool",
"HIJetDiscriminator", MaxOverMeanCut = 4, MinimumETMaxCut=3000),
40 jetDef_seed0.modifiers=[
"HLTHIJetAssoc",
"HLTHIJetMaxOverMean",
"HLTHIJetDiscrim",
"Filter:5000"]
44 if jetRecoDict[
"jetCalib"].endswith(
"IS")
and not flags.Input.isMC:
46 calib_seq +=
"_Insitu"
50 jetDef_seed1 = jetDef_unsub.clone()
51 jetDef_seed1.suffix = jetDef_seed0.suffix.replace(
"_seed0",
"_seed1")
52 jetDef_seed1.radius = 0.2
53 jetDef_seed1.modifiers=[
"HLTHIJetAssoc",
"HLTHIJetConstSub_iter0:iter0",
"HLTHIJetSeedCalib:{}___{}".
format(calib_seq, JES_is_data),
"Filter:25000"]
56 jetDef_final = jetDef_unsub.clone()
57 jetDef_final.suffix = jetDef_unsub.suffix.replace(
"_Unsubtracted",
"")
58 jetDef_final.modifiers=[
"HLTHIJetConstSub_iter1:iter1",
"HLTHIJetJetConstMod_iter1",
"HLTHIJetCalib:{}___{}".
format(calib_seq, JES_is_data),
"Sort",
"Filter:20000"]
61 "unsub": (jetDef_unsub.fullname(), jetDef_unsub),
62 "seed0": (jetDef_seed0.fullname(), jetDef_seed0),
63 "seed1": (jetDef_seed1.fullname(), jetDef_seed1),
64 "final": (jetDef_final.fullname(), jetDef_final),
72 eventShapeMapToolKey=
"HLTHIEventShapeMapTool"
73 theMapTool=CompFactory.HIEventShapeMapTool(eventShapeMapToolKey)
76 EventShapeKey=
'HLTHIEventShapeWeighted'
77 ESAlg_W=CompFactory.HIEventShapeMaker(
"ESAlg_W")
78 ESAlg_W.OutputContainerKey=EventShapeKey
79 ESAlg_W.InputTowerKey=clustersKey
80 ESAlg_W.NaviTowerKey=towerKey
83 ESFiller=CompFactory.HIEventShapeFillerTool(
"WeightedFiller")
84 ESFiller.UseClusters=
True
87 TWTool=CompFactory.HITowerWeightTool()
88 TWTool.ApplyCorrection=
True
89 TWTool.ConfigDir=
'HIJetCorrection/'
90 from HIJetRec.HIJetRecUtilsCA
import getHIClusterGeoWeightFile
93 ESFiller.TowerWeightTool=TWTool
94 ESFiller.EventShapeMapTool=theMapTool
96 ESAlg_W.HIEventShapeFillerTool=ESFiller
97 acc.addEventAlgo(ESAlg_W)
99 return acc, EventShapeKey, theMapTool
103 from JetRecConfig.StandardJetMods
import stdJetModifiers
104 stdJetModifiers.update(
105 HLTHIJetCalib = JetModifier(
"JetCalibrationTool",
106 "HLTHICalibTool_{modspec}",
107 JetCollection=
"AntiKt4HI",
108 PrimaryVerticesContainerName=
"",
109 ConfigFile=
'JES_MC16_HI_Jan2021_5TeV.config',
110 CalibSequence=
lambda _, modspec: modspec.split(
'___')[0],
111 IsData=
lambda _, modspec: modspec.split(
'___')[1] ==
'True'),
114 stdJetModifiers.update(
115 HLTHIJetSeedCalib = JetModifier(
"JetCalibrationTool",
116 "HLTHISeedCalibTool_{modspec}",
117 JetCollection=
"AntiKt2HI",
118 PrimaryVerticesContainerName=
"",
119 ConfigFile=
'JES_MC16_HI_Jan2021_5TeV.config',
120 CalibSequence=
lambda _, modspec: modspec.split(
'___')[0],
121 IsData=
lambda _, modspec: modspec.split(
'___')[1] ==
'True'),
125 """This build the standard heavy ion style jet.
127 This is similar to JetRecConfig.getJetDefAlgs(). However due to how the alg flow is organized in the
128 chain steps, we can't use this function directly.
130 - construct a JetDefinition
131 - use lower-level function in JetRecConfig with this JetDefinition to get the necessary algs and build our sequence manually.
136 if jetRecoDict[
"ionopt"] ==
"noion":
137 raise ValueError(
"Jet reco for heavy ion called without a ion option!")
139 dataSource =
"mc" if configFlags.Input.isMC
else "data"
141 jetHIEvtShapeSequence, eventShapeKey, eventShapeMapTool =
jetHIEventShapeSequenceCA(configFlags, clustersKey=clustersKey, towerKey=towerKey)
142 acc.merge(jetHIEvtShapeSequence)
144 jetNamePrefix = JetRecoCommon.getHLTPrefix()
145 jetDef = JetRecoCommon.defineHIJets(jetRecoDict,clustersKey=clustersKey,prefix=jetNamePrefix,suffix=
"_Unsubtracted")
146 jetsFullName_Unsub = jetDef.fullname()
149 pjgalg = CompFactory.PseudoJetAlgorithm(
151 InputContainer = clustersKey,
152 OutputContainer =
"PseudoJet"+clustersKey,
154 SkipNegativeEnergy =
False,
155 TreatNegativeEnergyAsGhost=
True
157 acc.addEventAlgo(pjgalg)
158 finalpjs =
str(pjgalg.OutputContainer)
161 jetDef._internalAtt[
'finalPJContainer'] = finalpjs
164 from JetRec
import JetOnlineMon
168 jetRecAlg =
getHIJetRecAlg(jetDef, jetsFullName_Unsub, monTool=monTool)
169 acc.addEventAlgo(jetRecAlg)
171 associationName =
"%s_DR8Assoc" % (clustersKey)
173 jetsInUnsub = jetsFullName_Unsub
177 if jetRecoDict[
"jetCalib"].endswith(
"IS")
and (dataSource==
"data"):
179 calib_seq +=
"_Insitu"
182 jetDef_seed0 = jetDef.clone()
183 jetDef_seed0.suffix = jetDef.suffix.replace(
"Unsubtracted",
"seed0")
184 jetDef_seed0.radius = 0.2
185 jetsFullName_seed0 = jetDef_seed0.fullname()
186 stdJetModifiers.update(
188 HLTHIJetAssoc = JetModifier(
"HIJetDRAssociationTool",
"HIJetDRAssociation", ContainerKey=clustersKey, DeltaR=0.8, AssociationName=associationName),
189 HLTHIJetMaxOverMean = JetModifier(
"HIJetMaxOverMeanTool",
"HIJetMaxOverMean", JetContainer = jetsFullName_seed0),
190 HLTHIJetDiscrim = JetModifier(
"HIJetDiscriminatorTool",
"HIJetDiscriminator", MaxOverMeanCut = 4, MinimumETMaxCut=3000),
192 jetDef_seed0.modifiers=[
"HLTHIJetAssoc",
"HLTHIJetMaxOverMean",
"HLTHIJetDiscrim",
"Filter:5000"]
193 copySeed0Alg =
getJetCopyAlg(jetsin=jetsInUnsub,jetsoutdef=jetDef_seed0,decorations=[],shallowcopy=
False,shallowIO=
False,monTool=monTool)
194 acc.addEventAlgo(copySeed0Alg)
197 iter0=
HLTAddIteration(configFlags, jetsFullName_seed0, eventShapeKey, clustersKey, map_tool=eventShapeMapTool, assoc_name=associationName, suffix=
"iter0")
198 acc.addEventAlgo(
HLTRunTools([iter0],
"jetalgHI_iter0"))
199 modulator0=iter0.Modulator
200 subtractor0=iter0.Subtractor
202 HLTMakeSubtractionTool(configFlags, iter0.OutputEventShapeKey, Modulator=modulator0, EventShapeMapTool=eventShapeMapTool, Subtractor=subtractor0, label=
"HLTHIJetConstSub_iter0")
204 cluster_key_iter0_deep=clustersKey+
"_iter0_temp"
205 happy_iter0_Tool =
ApplySubtractionToClustersHLT(configFlags, EventShapeKey=
"HLTHIEventShapeWeighted_iter0", ClusterKey=clustersKey, OutClusterKey=cluster_key_iter0_deep, Modulator=modulator0, EventShapeMapTool=eventShapeMapTool, Subtractor=subtractor0, SetMoments=
False, ApplyOriginCorrection=
False)
206 acc.addEventAlgo(
HLTRunTools([happy_iter0_Tool],
"jetalgHI_clusterSub_iter0"))
208 GetConstituentsModifierToolHLT(configFlags, name=
"HIJetConstituentModifierTool", ClusterKey=cluster_key_iter0_deep, ApplyOriginCorrection=
False, label=
"HLTHIJetJetConstMod_iter0")
211 jetDef_seed1 = jetDef.clone()
212 jetDef_seed1.suffix = jetDef_seed0.suffix.replace(
"_seed0",
"_seed1")
213 jetDef_seed1.radius = 0.2
214 jetDef_seed1.modifiers=[
"HLTHIJetAssoc",
"HLTHIJetConstSub_iter0:iter0",
"HLTHIJetSeedCalib:{}___{}".
format(calib_seq, JES_is_data),
"Filter:25000"]
215 jetsFullName_seed1 = jetDef_seed1.fullname()
216 copySeed1Alg =
getJetCopyAlg(jetsin=jetsInUnsub,jetsoutdef=jetDef_seed1,decorations=[],shallowcopy=
False,shallowIO=
False,monTool=monTool)
217 acc.addEventAlgo(copySeed1Alg)
219 iter1=
HLTAddIteration(configFlags, jetsFullName_seed1, eventShapeKey, clustersKey, map_tool=eventShapeMapTool, assoc_name=associationName, sub_tool=subtractor0, suffix=
"iter1")
220 iter1.OutputEventShapeKey=
"HLTHIEventShape_iter1"
221 modulator1=iter1.Modulator
222 subtractor1=iter1.Subtractor
224 HLTMakeSubtractionTool(configFlags, iter1.OutputEventShapeKey, Modulator=modulator1, EventShapeMapTool=eventShapeMapTool, label=
"HLTHIJetConstSub_iter1")
226 acc.addEventAlgo(
HLTRunTools([iter1],
"jetalgHI_clusterSub_egamma"))
229 cluster_key_final_deep=clustersKey+
"_final"
230 subToClusterTool =
ApplySubtractionToClustersHLT(configFlags, EventShapeKey=
"HLTHIEventShape_iter1", ClusterKey=clustersKey, OutClusterKey=cluster_key_final_deep, Modulator=modulator1, EventShapeMapTool=eventShapeMapTool, Subtractor=subtractor1, SetMoments=
False, ApplyOriginCorrection=
False)
231 acc.addEventAlgo(
HLTRunTools([subToClusterTool],
"jetalgHI_clusterSub"))
233 GetConstituentsModifierToolHLT(configFlags, name=
"HIJetConstituentModifierTool", ClusterKey=cluster_key_final_deep, ApplyOriginCorrection=
False, label=
"HLTHIJetJetConstMod_iter1")
235 jetDef_final = jetDef.clone()
236 jetDef_final.suffix = jetDef.suffix.replace(
"_Unsubtracted",
"")
237 jetDef_final.modifiers=[
"HLTHIJetConstSub_iter1:iter1",
"HLTHIJetJetConstMod_iter1",
"HLTHIJetCalib:{}___{}".
format(calib_seq, JES_is_data),
"Sort",
"Filter:20000"]
238 copyAlg_final=
getJetCopyAlg(jetsin=jetsInUnsub,jetsoutdef=jetDef_final,decorations=[],shallowcopy=
False,shallowIO=
False,monTool=monTool)
239 acc.addEventAlgo(copyAlg_final)
241 jetsFinal =
recordable(jetDef_final.fullname())
244 return acc, jetsOut, jetDef_final
248 theAlg = CompFactory.JetAlgorithm(algoName)
249 theAlg.Tools = toollist
254 """Returns the configured HIJetRecAlg instance corresponding to jetdef
256 IMPORTANT : jetdef must have its dependencies solved (i.e. it must result from solveDependencies() )
258 pjContNames = jetdef._internalAtt[
'finalPJContainer']
259 jclust = CompFactory.JetClusterer(
261 JetAlgorithm = jetdef.algorithm,
262 JetRadius = jetdef.radius,
263 PtMin = jetdef.ptmin,
264 InputPseudoJets = pjContNames,
266 JetInputType =
int(jetdef.inputdef.jetinputtype),
270 mods = JetRecConfig.getJetModifierTools(jetdef)
273 jra = CompFactory.JetRecAlg(
274 "jetrecalg_"+jetname,
277 OutputContainer = jetname,
281 jra.MonTool = monTool
287 out_shape_name=shape_name
288 if 'suffix' in kwargs.keys() : out_shape_name+=
'_' + kwargs[
'suffix']
289 mod_shape_key=out_shape_name+
'_Modulate'
292 if 'modulator' in kwargs.keys() : mod_tool=kwargs[
'modulator']
294 log.info(
"In HLTAddIteration function, HIUEModulatorTool is created using HLTMakeModulatorTool with mod_shape_key = {}".
format(mod_shape_key) )
297 if 'map_tool' in kwargs.keys() : map_tool=kwargs[
'map_tool']
299 map_tool=CompFactory.HIEventShapeMapTool()
301 if 'sub_tool' in kwargs.keys() : sub_tool=kwargs[
'sub_tool']
303 from HIJetRec.HIJetRecUtilsCA
import getHIClusterGeoWeightFile
306 HIJetClusterSubtractorTool=CompFactory.HIJetClusterSubtractorTool
308 sub_tool.UseSamplings=
False
310 if 'assoc_name' in kwargs.keys() : assoc_name=kwargs[
'assoc_name']
312 log.info(
"In HLTAddIteration function, HIJetDRAssociationTool is created with clustersKey= {}".
format(clustersKey) )
313 assoc=CompFactory.HIJetDRAssociationTool(
"HIJetDRAssociation")
314 assoc.ContainerKey=clustersKey
316 assoc.AssociationName=
"%s_DR8Assoc" % (clustersKey)
317 assoc_name=assoc.AssociationName
319 HIEventShapeJetIteration=CompFactory.HIEventShapeJetIteration
322 iter_tool.InputEventShapeKey=shape_name
323 iter_tool.OutputEventShapeKey=out_shape_name
324 iter_tool.AssociationKey=assoc_name
325 iter_tool.CaloJetSeedContainerKey=seed_container
326 iter_tool.Subtractor=sub_tool
327 iter_tool.ModulationScheme=1
328 iter_tool.RemodulateUE=
True
329 iter_tool.Modulator=mod_tool
330 iter_tool.ShallowCopy=
False
331 iter_tool.ModulationEventShapeKey=mod_shape_key
332 iter_tool.EventShapeMapTool=map_tool
338 if 'harmonics' in kwargs.keys() :
339 for n
in kwargs[
'harmonics'] :
340 tname =
str(tname) +
str(
'_V%d' % n)
344 tname=
'NullUEModulator'
345 HIUEModulatorTool=CompFactory.HIUEModulatorTool
348 for n
in [2,3,4] : setattr(mod,
'DoV%d' % n,
False)
352 harmonics = kwargs.pop(
'harmonics', [2, 3, 4])
355 if 'suffix' in kwargs.keys():
356 tname +=
'_' + kwargs[
'suffix']
358 if len(harmonics) == 0:
361 HIUEModulatorTool=CompFactory.HIUEModulatorTool
363 mod.EventShapeKey=mod_key
367 attr_name=
'DoV%d' % n
368 setattr(mod,attr_name,val)
370 if 'label' in kwargs.keys():
371 label = kwargs[
'label']
372 stdJetModifiers[label] = JetModifier(
378 EventShapeKey=mod_key)
383 from HIJetRec.HIJetRecUtilsCA
import getHIClusterGeoWeightFile
386 HIJetClusterSubtractorTool = CompFactory.HIJetClusterSubtractorTool
388 sub_tool.UseSamplings =
False
396 'EventShapeKey': shapeKey,
398 'EventShapeMapTool': CompFactory.HIEventShapeMapTool(),
400 'MomentName':
'HLTJetSubtractedScale{}Momentum'.
format(moment_name),
401 'SetMomentOnly': momentOnly,
402 'ApplyOriginCorrection':
True,
405 suffix = shapeKey.toStringProperty()
406 if momentOnly
is True:
407 suffix +=
'_' + moment_name
409 alg_props.update(kwargs)
411 label = alg_props.pop(
'label',
None)
413 HIJetConstituentSubtractionTool = CompFactory.HIJetConstituentSubtractionTool
416 stdJetModifiers[label] = JetModifier(
417 "HIJetConstituentSubtractionTool",
418 "HLTHICS_HLTHIEventShapeWeighted_{modspec}",
419 Modulator=subtr.Modulator,
420 EventShapeMapTool=subtr.EventShapeMapTool,
421 Subtractor=subtr.Subtractor,
422 EventShapeKey=subtr.EventShapeKey,
423 MomentName=subtr.MomentName,
424 SetMomentOnly=subtr.SetMomentOnly,
425 ApplyOriginCorrection=
True)
429 def HLTHIClusterGetter(dummyFlags, tower_key="CombinedTower", cell_key="AllCalo", cluster_key="HLT_HIClusters") :
430 """Function to equip HLT HI cluster builder from towers and cells, adds to output AOD stream"""
432 HIClusterMaker=CompFactory.HIClusterMaker
434 theAlg.InputTowerKey=tower_key
435 theAlg.CaloCellContainerKey=cell_key
436 theAlg.OutputContainerKey=cluster_key
444 'EventShapeKey':
"HLTHIEventShape_iter1",
445 'ClusterKey':
"HLT_HIClusters",
447 'EventShapeMapTool': CompFactory.HIEventShapeMapTool(),
449 'ApplyOriginCorrection':
True,
454 alg_props.update(kwargs)
456 toolName = alg_props.pop(
'toolName',
'HIClusterSubtraction')
458 HIClusterSubtraction = CompFactory.HIClusterSubtraction
467 'ClusterKey':
"HLT_HIClusters",
468 'ApplyOriginCorrection':
True,
472 alg_props.update(kwargs)
474 toolName = alg_props.pop(
'name',
'HIJetConstituentModifierTool')
475 label = alg_props.pop(
'label',
None)
477 HIJetConstituentModifierTool = CompFactory.HIJetConstituentModifierTool
480 stdJetModifiers[label] = JetModifier(
481 "HIJetConstituentModifierTool",
482 "HLTHIJetConstituentModifierTool_{modspec}",
483 ClusterKey=cmod.ClusterKey,
484 Subtractor=cmod.Subtractor,
485 ApplyOriginCorrection=cmod.ApplyOriginCorrection)