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
27 target_jetReco = f
"_for_{jetRecoDict['jetDefStr']}"
30 associationName =
"%s_DR8Assoc" % (clustersKey)
31 jetDef_seed0 = jetDef_unsub.clone()
32 jetDef_seed0.suffix = jetDef_unsub.suffix.replace(
"Unsubtracted",
"seed0"+target_jetReco)
33 jetDef_seed0.radius = 0.2
34 jetsFullName_seed0 = jetDef_seed0.fullname()
37 stdJetModifiers.update(
39 HLTHIJetAssoc = JetModifier(
"HIJetDRAssociationTool",
"HIJetDRAssociation", ContainerKey=clustersKey, DeltaR=0.8, AssociationName=associationName),
43 jetDef_seed0.modifiers=[
45 JetModifier(
"HIJetMaxOverMeanTool",
"HIJetMaxOverMean"+target_jetReco, JetContainer = jetsFullName_seed0),
46 JetModifier(
"HIJetDiscriminatorTool",
"HIJetDiscriminator", MaxOverMeanCut = 4, MinimumETMaxCut=3000),
52 if jetRecoDict[
"jetCalib"].endswith(
"IS")
and not flags.Input.isMC:
54 calib_seq +=
"_Insitu"
58 jetDef_seed1 = jetDef_unsub.clone()
59 jetDef_seed1.suffix = jetDef_seed0.suffix.replace(
"_seed0",
"_seed1")
60 jetDef_seed1.radius = 0.2
61 jetDef_seed1.modifiers=[
"HLTHIJetAssoc",
"HLTHIJetConstSub_iter0:iter0",
"HLTHIJetSeedCalib:{}___{}".
format(calib_seq, JES_is_data),
"Filter:25000"]
64 jetDef_final = jetDef_unsub.clone()
65 jetDef_final.suffix = jetDef_unsub.suffix.replace(
"_Unsubtracted",
"")
66 jetDef_final.modifiers=[
"HLTHIJetConstSub_iter1:iter1",
"HLTHIJetJetConstMod_iter1",
"HLTHIJetCalib:{}___{}".
format(calib_seq, JES_is_data),
"Sort",
"Filter:20000"]
69 "unsub": (jetDef_unsub.fullname(), jetDef_unsub),
70 "seed0": (jetDef_seed0.fullname(), jetDef_seed0),
71 "seed1": (jetDef_seed1.fullname(), jetDef_seed1),
72 "final": (jetDef_final.fullname(), jetDef_final),
80 eventShapeMapToolKey=
"HLTHIEventShapeMapTool"
81 theMapTool=CompFactory.HIEventShapeMapTool(eventShapeMapToolKey)
84 EventShapeKey=
'HLTHIEventShapeWeighted'
85 ESAlg_W=CompFactory.HIEventShapeMaker(
"ESAlg_W")
86 ESAlg_W.OutputContainerKey=EventShapeKey
87 ESAlg_W.InputTowerKey=clustersKey
88 ESAlg_W.NaviTowerKey=towerKey
91 ESFiller=CompFactory.HIEventShapeFillerTool(
"WeightedFiller")
92 ESFiller.UseClusters=
True
95 TWTool=CompFactory.HITowerWeightTool()
96 TWTool.ApplyCorrection=
True
97 TWTool.ConfigDir=
'HIJetCorrection/'
98 from HIJetRec.HIJetRecUtilsCA
import getHIClusterGeoWeightFile
101 ESFiller.TowerWeightTool=TWTool
102 ESFiller.EventShapeMapTool=theMapTool
104 ESAlg_W.HIEventShapeFillerTool=ESFiller
105 acc.addEventAlgo(ESAlg_W)
107 return acc, EventShapeKey, theMapTool
111 from JetRecConfig.StandardJetMods
import stdJetModifiers
112 stdJetModifiers.update(
113 HLTHIJetCalib = JetModifier(
"JetCalibrationTool",
114 "HLTHICalibTool_{modspec}",
115 JetCollection=
lambda _, modspec: modspec.split(
'___')[2]
if len(modspec.split(
'___')) > 2
else "AntiKt4HI",
116 PrimaryVerticesContainerName=
"",
117 ConfigFile=
'JES_MC16_HI_Jan2021_5TeV.config',
118 CalibSequence=
lambda _, modspec: modspec.split(
'___')[0],
119 IsData=
lambda _, modspec: modspec.split(
'___')[1] ==
'True'),
122 stdJetModifiers.update(
123 HLTHIJetSeedCalib = JetModifier(
"JetCalibrationTool",
124 "HLTHISeedCalibTool_{modspec}",
125 JetCollection=
"AntiKt2HI",
126 PrimaryVerticesContainerName=
"",
127 ConfigFile=
'JES_MC16_HI_Jan2021_5TeV.config',
128 CalibSequence=
lambda _, modspec: modspec.split(
'___')[0],
129 IsData=
lambda _, modspec: modspec.split(
'___')[1] ==
'True'),
133 """This build the standard heavy ion style jet.
135 This is similar to JetRecConfig.getJetDefAlgs(). However due to how the alg flow is organized in the
136 chain steps, we can't use this function directly.
138 - construct a JetDefinition
139 - use lower-level function in JetRecConfig with this JetDefinition to get the necessary algs and build our sequence manually.
144 if jetRecoDict[
"ionopt"] ==
"noion":
145 raise ValueError(
"Jet reco for heavy ion called without a ion option!")
147 dataSource =
"mc" if configFlags.Input.isMC
else "data"
149 jetHIEvtShapeSequence, eventShapeKey, eventShapeMapTool =
jetHIEventShapeSequenceCA(configFlags, clustersKey=clustersKey, towerKey=towerKey)
150 acc.merge(jetHIEvtShapeSequence)
152 jetNamePrefix = JetRecoCommon.getHLTPrefix()
153 jetDef = JetRecoCommon.defineHIJets(jetRecoDict,clustersKey=clustersKey,prefix=jetNamePrefix,suffix=
"_Unsubtracted")
154 jetsFullName_Unsub = jetDef.fullname()
157 jet_collection_name = jetsFullName_Unsub.split(
'_')[1].
replace(
"Jets",
"")
160 pjgalg = CompFactory.PseudoJetAlgorithm(
162 InputContainer = clustersKey,
163 OutputContainer =
"PseudoJet"+clustersKey,
165 SkipNegativeEnergy =
False,
166 TreatNegativeEnergyAsGhost=
True
168 acc.addEventAlgo(pjgalg)
169 finalpjs =
str(pjgalg.OutputContainer)
172 jetDef._internalAtt[
'finalPJContainer'] = finalpjs
175 from JetRec
import JetOnlineMon
179 jetRecAlg =
getHIJetRecAlg(jetDef, jetsFullName_Unsub, monTool=monTool)
180 acc.addEventAlgo(jetRecAlg)
182 associationName =
"%s_DR8Assoc" % (clustersKey)
184 jetsInUnsub = jetsFullName_Unsub
188 if jetRecoDict[
"jetCalib"].endswith(
"IS")
and (dataSource==
"data"):
190 calib_seq +=
"_Insitu"
192 target_jetReco = f
'_for_{jetRecoDict["jetDefStr"]}'
195 jetDef_seed0 = jetDef.clone()
196 jetDef_seed0.suffix = jetDef.suffix.replace(
"Unsubtracted",
"seed0"+target_jetReco)
197 jetDef_seed0.radius = 0.2
198 jetsFullName_seed0 = jetDef_seed0.fullname()
199 jetDef_seed0.modifiers=[
200 JetModifier(
"HIJetDRAssociationTool",
"HIJetDRAssociation", ContainerKey=clustersKey, DeltaR=0.8, AssociationName=associationName),
201 JetModifier(
"HIJetMaxOverMeanTool",
"HIJetMaxOverMean"+target_jetReco, JetContainer = jetsFullName_seed0),
202 JetModifier(
"HIJetDiscriminatorTool",
"HIJetDiscriminator", MaxOverMeanCut = 4, MinimumETMaxCut=3000),
206 copySeed0Alg =
getJetCopyAlg(jetsin=jetsInUnsub,jetsoutdef=jetDef_seed0,decorations=[],shallowcopy=
False,shallowIO=
False,monTool=monTool)
207 acc.addEventAlgo(copySeed0Alg)
210 iter0=
HLTAddIteration(configFlags, jetsFullName_seed0, eventShapeKey, clustersKey, map_tool=eventShapeMapTool, assoc_name=associationName, suffix=
"iter0"+target_jetReco)
211 acc.addEventAlgo(
HLTRunTools([iter0],
"jetalgHI_iter0"+target_jetReco))
212 modulator0=iter0.Modulator
213 subtractor0=iter0.Subtractor
215 HLTMakeSubtractionTool(configFlags, iter0.OutputEventShapeKey, Modulator=modulator0, EventShapeMapTool=eventShapeMapTool, Subtractor=subtractor0, label=
"HLTHIJetConstSub_iter0"+target_jetReco)
217 cluster_key_iter0_deep=clustersKey+
"_iter0_temp"+target_jetReco
218 happy_iter0_Tool =
ApplySubtractionToClustersHLT(configFlags, EventShapeKey=
"HLTHIEventShapeWeighted_iter0"+target_jetReco, ClusterKey=clustersKey, OutClusterKey=cluster_key_iter0_deep, Modulator=modulator0, EventShapeMapTool=eventShapeMapTool, Subtractor=subtractor0, SetMoments=
False, ApplyOriginCorrection=
False)
219 acc.addEventAlgo(
HLTRunTools([happy_iter0_Tool],
"jetalgHI_clusterSub_iter0"+target_jetReco))
221 GetConstituentsModifierToolHLT(configFlags, name=
"HIJetConstituentModifierTool", ClusterKey=cluster_key_iter0_deep, ApplyOriginCorrection=
False, label=
"HLTHIJetJetConstMod_iter0"+target_jetReco)
224 jetDef_seed1 = jetDef.clone()
225 jetDef_seed1.suffix = jetDef_seed0.suffix.replace(
"_seed0",
"_seed1")
226 jetDef_seed1.radius = 0.2
227 jetDef_seed1.modifiers=[
"HLTHIJetAssoc", f
"HLTHIJetConstSub_iter0{target_jetReco}:iter0",
"HLTHIJetSeedCalib:{}___{}".
format(calib_seq, JES_is_data),
"Filter:25000"]
228 jetsFullName_seed1 = jetDef_seed1.fullname()
229 copySeed1Alg =
getJetCopyAlg(jetsin=jetsInUnsub,jetsoutdef=jetDef_seed1,decorations=[],shallowcopy=
False,shallowIO=
False,monTool=monTool)
230 acc.addEventAlgo(copySeed1Alg)
232 iter1=
HLTAddIteration(configFlags, jetsFullName_seed1, eventShapeKey, clustersKey, map_tool=eventShapeMapTool, assoc_name=associationName, sub_tool=subtractor0, suffix=
"iter1"+target_jetReco)
233 iter1.OutputEventShapeKey=
"HLTHIEventShape_iter1"+target_jetReco
234 modulator1=iter1.Modulator
235 subtractor1=iter1.Subtractor
237 HLTMakeSubtractionTool(configFlags, iter1.OutputEventShapeKey, Modulator=modulator1, EventShapeMapTool=eventShapeMapTool, label=
"HLTHIJetConstSub_iter1"+target_jetReco)
239 acc.addEventAlgo(
HLTRunTools([iter1],
"jetalgHI_clusterSub_egamma"+target_jetReco))
242 cluster_key_final_deep=clustersKey+
"_final"+target_jetReco
243 subToClusterTool =
ApplySubtractionToClustersHLT(configFlags, EventShapeKey=
"HLTHIEventShape_iter1"+target_jetReco, ClusterKey=clustersKey, OutClusterKey=cluster_key_final_deep, Modulator=modulator1, EventShapeMapTool=eventShapeMapTool, Subtractor=subtractor1, SetMoments=
False, ApplyOriginCorrection=
False)
244 acc.addEventAlgo(
HLTRunTools([subToClusterTool],
"jetalgHI_clusterSub"+target_jetReco))
246 GetConstituentsModifierToolHLT(configFlags, name=
"HIJetConstituentModifierTool", ClusterKey=cluster_key_final_deep, ApplyOriginCorrection=
False, label=
"HLTHIJetJetConstMod_iter1"+target_jetReco)
248 jetDef_final = jetDef.clone()
249 jetDef_final.suffix = jetDef.suffix.replace(
"_Unsubtracted",
"")
250 jetDef_final.modifiers=[f
"HLTHIJetConstSub_iter1{target_jetReco}:iter1",
"HLTHIJetJetConstMod_iter1"+target_jetReco,
"HLTHIJetCalib:{}___{}___{}".
format(calib_seq, JES_is_data, jet_collection_name),
"Sort",
"Filter:20000"]
251 copyAlg_final=
getJetCopyAlg(jetsin=jetsInUnsub,jetsoutdef=jetDef_final,decorations=[],shallowcopy=
False,shallowIO=
False,monTool=monTool)
252 acc.addEventAlgo(copyAlg_final)
254 jetsFinal =
recordable(jetDef_final.fullname())
258 return acc, jetsOut, jetDef_final
262 theAlg = CompFactory.JetAlgorithm(algoName)
263 theAlg.Tools = toollist
268 """Returns the configured HIJetRecAlg instance corresponding to jetdef
270 IMPORTANT : jetdef must have its dependencies solved (i.e. it must result from solveDependencies() )
272 pjContNames = jetdef._internalAtt[
'finalPJContainer']
273 jclust = CompFactory.JetClusterer(
275 JetAlgorithm = jetdef.algorithm,
276 JetRadius = jetdef.radius,
277 PtMin = jetdef.ptmin,
278 InputPseudoJets = pjContNames,
280 JetInputType =
int(jetdef.inputdef.jetinputtype),
284 mods = JetRecConfig.getJetModifierTools(jetdef)
287 jra = CompFactory.JetRecAlg(
288 "jetrecalg_"+jetname,
291 OutputContainer = jetname,
295 jra.MonTool = monTool
301 out_shape_name=shape_name
302 if 'suffix' in kwargs.keys() : out_shape_name+=
'_' + kwargs[
'suffix']
303 mod_shape_key=out_shape_name+
'_Modulate'
306 if 'modulator' in kwargs.keys() : mod_tool=kwargs[
'modulator']
308 log.info(
"In HLTAddIteration function, HIUEModulatorTool is created using HLTMakeModulatorTool with mod_shape_key = {}".
format(mod_shape_key) )
311 if 'map_tool' in kwargs.keys() : map_tool=kwargs[
'map_tool']
313 map_tool=CompFactory.HIEventShapeMapTool()
315 if 'sub_tool' in kwargs.keys() : sub_tool=kwargs[
'sub_tool']
317 from HIJetRec.HIJetRecUtilsCA
import getHIClusterGeoWeightFile
320 HIJetClusterSubtractorTool=CompFactory.HIJetClusterSubtractorTool
322 sub_tool.UseSamplings=
False
324 if 'assoc_name' in kwargs.keys() : assoc_name=kwargs[
'assoc_name']
326 log.info(
"In HLTAddIteration function, HIJetDRAssociationTool is created with clustersKey= {}".
format(clustersKey) )
327 assoc=CompFactory.HIJetDRAssociationTool(
"HIJetDRAssociation")
328 assoc.ContainerKey=clustersKey
330 assoc.AssociationName=
"%s_DR8Assoc" % (clustersKey)
331 assoc_name=assoc.AssociationName
333 HIEventShapeJetIteration=CompFactory.HIEventShapeJetIteration
336 iter_tool.InputEventShapeKey=shape_name
337 iter_tool.OutputEventShapeKey=out_shape_name
338 iter_tool.AssociationKey=assoc_name
339 iter_tool.CaloJetSeedContainerKey=seed_container
340 iter_tool.Subtractor=sub_tool
341 iter_tool.ModulationScheme=1
342 iter_tool.RemodulateUE=
True
343 iter_tool.Modulator=mod_tool
344 iter_tool.ShallowCopy=
False
345 iter_tool.ModulationEventShapeKey=mod_shape_key
346 iter_tool.EventShapeMapTool=map_tool
352 if 'harmonics' in kwargs.keys() :
353 for n
in kwargs[
'harmonics'] :
354 tname =
str(tname) +
str(
'_V%d' % n)
358 tname=
'NullUEModulator'
359 HIUEModulatorTool=CompFactory.HIUEModulatorTool
362 for n
in [2,3,4] : setattr(mod,
'DoV%d' % n,
False)
366 harmonics = kwargs.pop(
'harmonics', [2, 3, 4])
369 if 'suffix' in kwargs.keys():
370 tname +=
'_' + kwargs[
'suffix']
372 if len(harmonics) == 0:
375 HIUEModulatorTool=CompFactory.HIUEModulatorTool
377 mod.EventShapeKey=mod_key
381 attr_name=
'DoV%d' % n
382 setattr(mod,attr_name,val)
384 if 'label' in kwargs.keys():
385 label = kwargs[
'label']
386 stdJetModifiers[label] = JetModifier(
392 EventShapeKey=mod_key)
397 from HIJetRec.HIJetRecUtilsCA
import getHIClusterGeoWeightFile
400 HIJetClusterSubtractorTool = CompFactory.HIJetClusterSubtractorTool
402 sub_tool.UseSamplings =
False
410 'EventShapeKey': shapeKey,
412 'EventShapeMapTool': CompFactory.HIEventShapeMapTool(),
414 'MomentName':
'HLTJetSubtractedScale{}Momentum'.
format(moment_name),
415 'SetMomentOnly': momentOnly,
416 'ApplyOriginCorrection':
True,
419 suffix = shapeKey.toStringProperty()
420 if momentOnly
is True:
421 suffix +=
'_' + moment_name
423 alg_props.update(kwargs)
425 label = alg_props.pop(
'label',
None)
427 HIJetConstituentSubtractionTool = CompFactory.HIJetConstituentSubtractionTool
430 stdJetModifiers[label] = JetModifier(
431 "HIJetConstituentSubtractionTool",
432 "HLTHICS_HLTHIEventShapeWeighted_{modspec}",
433 Modulator=subtr.Modulator,
434 EventShapeMapTool=subtr.EventShapeMapTool,
435 Subtractor=subtr.Subtractor,
436 EventShapeKey=subtr.EventShapeKey,
437 MomentName=subtr.MomentName,
438 SetMomentOnly=subtr.SetMomentOnly,
439 ApplyOriginCorrection=
True)
443 def HLTHIClusterGetter(dummyFlags, tower_key="CombinedTower", cell_key="AllCalo", cluster_key="HLT_HIClusters") :
444 """Function to equip HLT HI cluster builder from towers and cells, adds to output AOD stream"""
446 HIClusterMaker=CompFactory.HIClusterMaker
448 theAlg.InputTowerKey=tower_key
449 theAlg.CaloCellContainerKey=cell_key
450 theAlg.OutputContainerKey=cluster_key
458 'EventShapeKey':
"HLTHIEventShape_iter1",
459 'ClusterKey':
"HLT_HIClusters",
461 'EventShapeMapTool': CompFactory.HIEventShapeMapTool(),
463 'ApplyOriginCorrection':
True,
468 alg_props.update(kwargs)
470 toolName = alg_props.pop(
'toolName',
'HIClusterSubtraction')
472 HIClusterSubtraction = CompFactory.HIClusterSubtraction
481 'ClusterKey':
"HLT_HIClusters",
482 'ApplyOriginCorrection':
True,
486 alg_props.update(kwargs)
488 toolName = alg_props.pop(
'name',
'HIJetConstituentModifierTool')
489 label = alg_props.pop(
'label',
None)
491 HIJetConstituentModifierTool = CompFactory.HIJetConstituentModifierTool
494 stdJetModifiers[label] = JetModifier(
495 "HIJetConstituentModifierTool",
496 "HLTHIJetConstituentModifierTool_{modspec}",
497 ClusterKey=cmod.ClusterKey,
498 Subtractor=cmod.Subtractor,
499 ApplyOriginCorrection=cmod.ApplyOriginCorrection)