ATLAS Offline Software
HIJetRecConfigCA.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
8 from JetRecConfig.JetDefinition import JetInputConstitSeq, JetInputConstit, xAODType, JetDefinition
9 from JetRecConfig.JetDefinition import JetModifier, JetInputExternal
10 #from JetRecConfig.JetRecConfig import getJetModifierTools
11 from JetRecConfig.StandardJetMods import stdJetModifiers
12 from JetRecConfig import JetRecConfig
13 from JetRecConfig.DependencyHelper import solveDependencies
14 from HIGlobal.HIGlobalConfig import HIEventShapeMakerCfg, HIEventShapeMapToolCfg
15 from AthenaCommon.Logging import logging
16 __log = logging.getLogger('HIJetRecConfigCA')
17 
18 
19 def HIClusterMakerCfg(flags, save=False, **kwargs):
20  """Function to equip HI cluster builder from towers and cells, adds to output AOD stream."""
21 
22  acc = ComponentAccumulator()
23 
24  kwargs.setdefault("CaloCellContainerKey", "AllCalo")
25  kwargs.setdefault("OutputContainerKey", flags.HeavyIon.Jet.Internal.ClusterKey)
26 
27  # get towers
28  from CaloRec.CaloRecoConfig import CaloRecoCfg
29  acc.merge(CaloRecoCfg(flags))
30  from CaloRec.CaloTowerMakerConfig import CaloTowerMakerCfg
31  towerMaker = acc.getPrimaryAndMerge(CaloTowerMakerCfg(flags))
32  tower_key = towerMaker.TowerContainerName
33 
34  HIClusterMaker = CompFactory.HIClusterMaker("HIClusterMaker",
35  InputTowerKey=tower_key,
36  **kwargs)
37 
38  if save:
39  output = ["xAOD::CaloClusterContainer#"+kwargs["OutputContainerKey"],
40  "xAOD::CaloClusterAuxContainer#"+kwargs["OutputContainerKey"]+"Aux."]
41  acc.merge(addToESD(flags, output))
42  acc.merge(addToAOD(flags, output))
43 
44  acc.addEventAlgo(HIClusterMaker, primary=True)
45  return acc
46 
47 
48 def HICaloJetInputConstitSeq(flags, name="HICaloConstit", **kwargs):
49  kwargs.setdefault("objtype", xAODType.CaloCluster)
50  kwargs.setdefault("modifiers", [])
51  kwargs.setdefault("inputname", flags.HeavyIon.Jet.Internal.ClusterKey)
52  kwargs.setdefault("outputname", flags.HeavyIon.Jet.Internal.ClusterKey)
53  kwargs.setdefault("label", "HI")
54 
55  jetConstit = JetInputConstitSeq(name, **kwargs)
56 
57  from JetRecConfig.StandardJetConstits import stdConstitDic
58  stdConstitDic.setdefault(name, jetConstit)
59 
60  return jetConstit
61 
62 
63 def HICaloJetDef(flags, jetradius, **kwargs):
64  """Returns jet definition for calo jets, with already resolved dependencies."""
65 
66  ptmin_dict = {2:7000, 3:7000, 4:7000, 6:7000, 10:50000}
67  if jetradius not in ptmin_dict and "ptmin" not in kwargs:
68  __log.warning("jetradius "+str(jetradius)+" is not in the dictionary for ptmin; setting ptmin to 7000")
69  kwargs.setdefault("ptmin", ptmin_dict.get(jetradius, 7000))
70  kwargs.setdefault("radius", float(jetradius)/10.)
71  kwargs.setdefault("inputdef", HICaloJetInputConstitSeq(flags))
72  kwargs.setdefault("algorithm", "AntiKt")
73  kwargs.setdefault("prefix", "")
74  kwargs.setdefault("suffix", "")
75 
76  return solveDependencies(JetDefinition(**kwargs), flags)
77 
78 
79 def HITrackJetInputConstit(flags, name="HITrack", **kwargs):
80  kwargs.setdefault("objtype", xAODType.TrackParticle)
81  kwargs.setdefault("containername", "JetSelectedTracks")
82 
83  jetConstit = JetInputConstit(name, **kwargs)
84  return jetConstit
85 
86 
87 def HITrackJetDef(flags, jetradius, **kwargs):
88  """Returns jet definition for track jets, with already resolved dependencies."""
89 
90  import JetRecTools.JetRecToolsConfig as jrtcfg
91  JetInputExternal("JetSelectedTracks",
92  xAODType.TrackParticle,
93  # in std context, this is InDetTrackParticles (see StandardJetContext)
94  prereqs=["InDetTrackParticles"],
95  algoBuilder=lambda jdef, _: jrtcfg.getTrackSelAlg(jdef, trackSelOpt=False))
96  kwargs.setdefault("ptmin", 5000)
97  kwargs.setdefault("inputdef", HITrackJetInputConstit(flags))
98 
99  return HICaloJetDef(flags, jetradius=jetradius, **kwargs)
100 
101 
102 def HIPseudoJetAlgCfg(flags, **kwargs):
103  """Creates a pseudo jet algorithm"""
104  acc = ComponentAccumulator()
105 
106  kwargs.setdefault("name", "pjcs"+flags.HeavyIon.Jet.Internal.ClusterKey)
107  kwargs.setdefault("InputContainer", flags.HeavyIon.Jet.Internal.ClusterKey)
108  kwargs.setdefault("OutputContainer", "PseudoJet"+flags.HeavyIon.Jet.Internal.ClusterKey)
109  kwargs.setdefault("Label", "LCTopo")
110  kwargs.setdefault("SkipNegativeEnergy", False)
111  kwargs.setdefault("TreatNegativeEnergyAsGhost", True)
112 
113  acc.addEventAlgo(CompFactory.PseudoJetAlgorithm(**kwargs))
114  return acc
115 
116 
117 def HIPseudoTrackJetAlgCfg(flags, name="TrackPseudoJets", **kwargs):
118  """Creates a pseudo track jet algorithm."""
119  acc = ComponentAccumulator()
120 
121  kwargs.setdefault("InputContainer", "HIJetTracks")
122  kwargs.setdefault("OutputContainer", "PseudoTracks")
123  kwargs.setdefault("Label", "Tracks")
124  kwargs.setdefault("SkipNegativeEnergy", True)
125 
126  acc.addEventAlgo(CompFactory.PseudoJetAlgorithm(name, **kwargs))
127  return acc
128 
129 
130 def HIJetClustererCfg(flags, name="builder", jetDef=None, **kwargs):
131  """Creates a tool for clustering."""
132  acc = ComponentAccumulator()
133 
134  if jetDef is not None:
135  kwargs.setdefault("JetAlgorithm", jetDef.algorithm)
136  kwargs.setdefault("JetRadius", jetDef.radius)
137  kwargs.setdefault("PtMin", jetDef.ptmin)
138  kwargs.setdefault("GhostArea", 0.01)
139  kwargs.setdefault("InputPseudoJets", "PseudoJet"+flags.HeavyIon.Jet.Internal.ClusterKey+"_GhostTracks")
140 
141  acc.setPrivateTools(CompFactory.JetClusterer(name, **kwargs))
142  return acc
143 
144 
145 def HIJetAlgCfg(flags, jetDef, **kwargs):
146  """Creates a jet reconstruction algorithm."""
147  acc = ComponentAccumulator()
148 
149  if "Provider" not in kwargs:
150  jclust = acc.popToolsAndMerge(HIJetClustererCfg(flags, jetDef=jetDef))
151  kwargs.setdefault("Provider", jclust)
152  if "Modifiers" not in kwargs:
153  kwargs.setdefault("Modifiers", JetRecConfig.getJetModifierTools(jetDef))
154  if "OutputContainer" not in kwargs:
155  kwargs.setdefault("OutputContainer", jetDef.fullname())
156  kwargs.setdefault("name", "JRA_build"+kwargs["OutputContainer"])
157 
158  acc.addEventAlgo(CompFactory.JetRecAlg(**kwargs))
159  return acc
160 
161 
162 def HIJetCopierCfg(flags, name="builder_copy", **kwargs):
163  """Creates a tool to copy jets."""
164  acc = ComponentAccumulator()
165 
166  kwargs.setdefault("InputJets", "")
167  kwargs.setdefault("DecorDeps", [])
168  kwargs.setdefault("ShallowCopy", False)
169  kwargs.setdefault("ShallowIO", False)
170 
171  acc.setPrivateTools(CompFactory.JetCopier(name, **kwargs))
172  return acc
173 
174 
175 def HIJetCopyAlgCfg(flags, jetDef_in, jetDef, **kwargs):
176  """Creates an algorithm to copy jets."""
177  acc = ComponentAccumulator()
178 
179  if "Provider" not in kwargs:
180  jcopy = acc.popToolsAndMerge(HIJetCopierCfg(flags, InputJets=jetDef_in.fullname()))
181  kwargs.setdefault("Provider", jcopy)
182 
183  acc.merge(HIJetAlgCfg(flags, jetDef, **kwargs))
184  return acc
185 
186 
187 def updateStdJetModifier(flags, name, **kwargs):
188  """Updates the stdJetModifiers dictionary, based on the provided name.
189  Some of the modifiers expect certain kwargs.
190  Some of the modifiers ignore kwargs which makes the code simpler."""
191 
192  if "Filter:" in name:
193  # already there, do nothing
194  return
195  if "HIJetCalib:" in name:
196  # add generic "HIJetCalib" modifier
197  if "HIJetCalib" not in stdJetModifiers:
198  updateStdJetModifier(flags, "HIJetCalib", **kwargs)
199  return
200  if name in stdJetModifiers:
201  # already there, do nothing
202  return
203 
204  if name == "HIJetAssoc":
205  stdJetModifiers.update(
206  HIJetAssoc=JetModifier("HIJetDRAssociationTool",
207  "HIJetDRAssociation",
208  ContainerKey=flags.HeavyIon.Jet.Internal.ClusterKey,
209  DeltaR=0.8,
210  AssociationName=flags.HeavyIon.Jet.Internal.ClusterKey+"_DR8Assoc"))
211  return
212 
213  if name == "HIJetMaxOverMean":
214  if "jetDef" not in kwargs:
215  __log.warning(
216  "HIJetMaxOverMean needs 'jetDef' in its kwargs; HIJetMaxOverMean is not added to stdJetModifiers")
217  return
218  stdJetModifiers.update(
219  HIJetMaxOverMean=JetModifier("HIJetMaxOverMeanTool",
220  "HIJetMaxOverMean",
221  JetContainer=kwargs["jetDef"].fullname()))
222  return
223 
224  if name == "HIJetDiscrim":
225  stdJetModifiers.update(
226  HIJetDiscrim=JetModifier("HIJetDiscriminatorTool",
227  "HIJetDiscriminator",
228  MaxOverMeanCut=4,
229  MinimumETMaxCut=3000))
230  return
231 
232  if name == "subtr0":
233  if "Modulator" not in kwargs or "EventShapeMapTool" not in kwargs or \
234  "Subtractor" not in kwargs or "EventShapeKey" not in kwargs:
235  __log.warning(
236  "subtr0 needs 'Modulator', 'EventShapeMapTool', 'Subtractor', and 'EventShapeKey' in its kwargs; subtr0 is not added to stdJetModifiers")
237  return
238 
239  stdJetModifiers.update(
240  subtr0=JetModifier("HIJetConstituentSubtractionTool",
241  "HICS_HIEventShapeWeighted_iter0",
242  MomentName="JetSubtractedScaleMomentum",
243  SetMomentOnly=False,
244  ApplyOriginCorrection=True,
245  **kwargs))
246  return
247 
248  if name == "HIJetCalib":
249  stdJetModifiers.update(
250  HIJetCalib=JetModifier("JetCalibrationTool",
251  "HICalibTool_{modspec}",
252  JetCollection=lambda _, modspec: "AntiKt{}HI".format(modspec.split('___')[0]) if modspec.split('___')[0] in flags.HeavyIon.Jet.CaliRValues else "AntiKt4HI",
253  PrimaryVerticesContainerName="",
254  ConfigFile='JES_MC16_HI_Jan2021_5TeV.config', # JES_MC16_HI_Jan2021_5TeV.config JES_MC15c_HI_Nov2016.config
255  CalibSequence=lambda _, modspec: modspec.split('___')[1],
256  IsData=lambda _, modspec: modspec.split('___')[2] == 'True'))
257  return
258 
259  if name == "subtr1":
260  if "Modulator" not in kwargs or "EventShapeMapTool" not in kwargs or \
261  "Subtractor" not in kwargs or "EventShapeKey" not in kwargs:
262  __log.warning(
263  "subtr1 needs 'Modulator', 'EventShapeMapTool', 'Subtractor', and 'EventShapeKey' in its kwargs; subtr1 is not added to stdJetModifiers")
264  return
265 
266  stdJetModifiers.update(
267  subtr1=JetModifier("HIJetConstituentSubtractionTool",
268  "HICS_HIEventShapeWeighted_iter1",
269  MomentName="JetSubtractedScaleMomentum",
270  SetMomentOnly=False,
271  ApplyOriginCorrection=True,
272  **kwargs))
273  return
274 
275  if name == "consmod":
276  if "ClusterKey" not in kwargs or "Subtractor" not in kwargs:
277  __log.warning(
278  "consmod needs 'ClusterKey' and 'Subtractor' in its kwargs; consmod is not added to stdJetModifiers")
279  return
280 
281  stdJetModifiers.update(
282  consmod=JetModifier(
283  "HIJetConstituentModifierTool",
284  "HIJetConstituentModifierTool_final",
285  ApplyOriginCorrection=True,
286  **kwargs))
287  return
288 
289  __log.warning("updateStdJetModifier does not know modifier "+
290  name+"; it is not added to stdJetModifiers")
291  return
292 
293 
294 def HIJetDefCloner(flags, jetDef_in, **kwargs):
295  """Clones jet definitions based on the template.
296  Updates stdJetModifiers if necessary.
297  Overwrites suffix and modifiers, and return jet definition with already resolved dependencies."""
298 
299  jetDef_new = jetDef_in.clone()
300 
301  if "suffix" in kwargs:
302  jetDef_new.suffix = kwargs["suffix"]
303  if "modifiers" in kwargs:
304  jetDef_new.modifiers = []
305  for modifier in kwargs["modifiers"]:
306  updateStdJetModifier(flags, modifier, jetDef=jetDef_new)
307  jetDef_new.modifiers.append(modifier)
308 
309  return solveDependencies(jetDef_new,flags)
310 
311 
313  """Provides modulator tool without any modulations."""
314  acc = ComponentAccumulator()
315  acc.setPrivateTools(CompFactory.HIUEModulatorTool('NullUEModulator',
316  EventShapeKey='',
317  DoV2=False,
318  DoV3=False,
319  DoV4=False))
320  return acc
321 
322 
323 def HIModulatorCfg(flags, mod_key, suffix=None, **kwargs):
324  """Provides modulator tool."""
325 
326  kwargs.setdefault("harmonics", flags.HeavyIon.Jet.HarmonicsForSubtraction)
327  if len(kwargs["harmonics"]) == 0:
328  return NullModulatorCfg()
329  acc = ComponentAccumulator()
330  kwargs.setdefault("name", "Modulator_"+mod_key+
331  "".join(["_V"+str(h) for h in kwargs["harmonics"]]))
332  if suffix is not None:
333  kwargs["name"] += '_'+suffix
334  kwargs.setdefault("DoV2", 2 in kwargs["harmonics"])
335  kwargs.setdefault("DoV3", 3 in kwargs["harmonics"])
336  kwargs.setdefault("DoV4", 4 in kwargs["harmonics"])
337  del kwargs["harmonics"]
338  kwargs.setdefault("EventShapeKey", mod_key)
339 
340  acc.setPrivateTools(CompFactory.HIUEModulatorTool(**kwargs))
341 
342  if 'label' in kwargs:
343  label = kwargs['label']
344  for key in kwargs:
345  if key not in ["name", "DoV2", "DoV3", "DoV4", "EventShapeKey"]:
346  del kwargs[key]
347 
348  stdJetModifiers[label] = JetModifier("HIUEModulatorTool", **kwargs)
349 
350  return acc
351 
352 
353 def HIJetClusterSubtractorCfg(flags, name="HIJetClusterSubtractor", **kwargs):
354  """Provides tool for cluster subtraction."""
355  acc = ComponentAccumulator()
356 
357  kwargs.setdefault("ConfigDir", "HIJetCorrection/")
358  kwargs.setdefault("UseSamplings", False)
359  if "InputFile" not in kwargs:
360  from HIJetRec.HIJetRecUtilsCA import getHIClusterGeoWeightFile
361  kwargs.setdefault("InputFile", getHIClusterGeoWeightFile(flags))
362 
363  acc.setPrivateTools(CompFactory.HIJetClusterSubtractorTool(name, **kwargs))
364  return acc
365 
366 
367 def HIJetCellSubtractorCfg(flags, name="HIJetCellSubtractor", **kwargs):
368  """Provides tool for cell subtraction."""
369  acc = ComponentAccumulator()
370 
371  acc.setPrivateTools(CompFactory.HIJetCellSubtractorTool(name, **kwargs))
372  return acc
373 
374 
375 def HIJetSubtractorCfg(flags, useClusters, **kwargs):
376  """Common function for clsuter and cell subtraction configuration."""
377 
378  if useClusters:
379  return HIJetClusterSubtractorCfg(flags, **kwargs)
380  else:
381  return HIJetCellSubtractorCfg(flags, **kwargs)
382 
383 
384 def HIEventShapeJetIterationCfg(flags, suffix=None, useClusters=True, **kwargs):
385  """Provides tool for event shape iteration.
386  Also saves some tool, so they can be used later."""
387  acc = ComponentAccumulator()
388 
389  kwargs.setdefault("InputEventShapeKey", "HIEventShape_Weighted")
390  kwargs.setdefault("CaloJetSeedContainerKey", "")
391 
392  out_shape_name = kwargs["InputEventShapeKey"]
393  if suffix is not None:
394  out_shape_name += '_'+suffix
395  mod_shape_key = out_shape_name+'_Modulate'
396 
397  if 'Modulator' not in kwargs:
398  modulator = acc.popToolsAndMerge(HIModulatorCfg(
399  flags, mod_key=mod_shape_key, suffix=suffix))
400  kwargs.setdefault('Modulator', modulator)
401  if "Subtractor" not in kwargs:
402  sub_tool = acc.popToolsAndMerge(HIJetSubtractorCfg(flags, useClusters))
403  kwargs.setdefault("Subtractor", sub_tool)
404  if "EventShapeMapTool" not in kwargs:
405  map_tool = acc.popToolsAndMerge(HIEventShapeMapToolCfg(flags))
406  kwargs.setdefault("EventShapeMapTool", map_tool)
407  kwargs.setdefault("OutputEventShapeKey", out_shape_name)
408  kwargs.setdefault("AssociationKey", flags.HeavyIon.Jet.Internal.ClusterKey+"_DR8Assoc")
409  kwargs.setdefault("ModulationScheme", 1)
410  kwargs.setdefault("RemodulateUE", True)
411  kwargs.setdefault("ShallowCopy", False)
412  kwargs.setdefault("ModulationEventShapeKey", mod_shape_key)
413  kwargs.setdefault("TrackJetSeedContainerKey", "")
414 
415  acc.setPrivateTools(CompFactory.HIEventShapeJetIteration(
416  "HIJetIteration_"+out_shape_name, **kwargs))
417 
418  # save some tools for later
419  jm_dict = {"Modulator": kwargs["Modulator"],
420  "EventShapeMapTool": kwargs["EventShapeMapTool"],
421  "Subtractor": kwargs["Subtractor"],
422  "EventShapeKey": kwargs["OutputEventShapeKey"]}
423 
424  return jm_dict, acc
425 
426 
427 def HITrackSelAlgCfg(flags, name="TrackSelAlgHI", **kwargs):
428  """Provides track selection algorithm for track jet reconstruction."""
429  acc = ComponentAccumulator()
430 
431  if "TrackSelector" not in kwargs:
432  from InDetConfig.InDetTrackSelectionToolConfig import HI_InDetTrackSelectionToolForHITrackJetsCfg
433  tracksel = acc.popToolsAndMerge(HI_InDetTrackSelectionToolForHITrackJetsCfg(flags))
434  kwargs.setdefault("TrackSelector", tracksel)
435  kwargs.setdefault("InputContainer", "InDetTrackParticles")
436  kwargs.setdefault("OutputContainer", "HIJetTracks")
437  kwargs.setdefault("DecorDeps", [])
438 
439  acc.addEventAlgo(CompFactory.JetTrackSelectionAlg(name, **kwargs))
440  return acc
441 
442 
443 def HICaloClusterMomentsCfg(flags, name="HIClusterMoments", **kwargs):
444  """Provides tool for cluster moments."""
445  acc = ComponentAccumulator()
446 
447  kwargs.setdefault("MinBadLArQuality", 4000)
448  kwargs.setdefault("MomentsNames", ["CENTER_MAG",
449  "LONGITUDINAL",
450  "FIRST_ENG_DENS",
451  "SECOND_ENG_DENS",
452  "ENG_FRAC_EM",
453  "ENG_FRAC_MAX",
454  "ENG_FRAC_CORE",
455  "ENG_BAD_CELLS",
456  "N_BAD_CELLS",
457  "N_BAD_CELLS_CORR",
458  "BAD_CELLS_CORR_E",
459  "BADLARQ_FRAC",
460  "ENG_POS",
461  "SIGNIFICANCE",
462  "CELL_SIGNIFICANCE",
463  "CELL_SIG_SAMPLING",
464  "AVG_LAR_Q",
465  "AVG_TILE_Q",
466  "ENG_BAD_HV_CELLS",
467  "N_BAD_HV_CELLS"])
468 
469  acc.setPrivateTools(CompFactory.CaloClusterMomentsMaker(name, **kwargs))
470  return acc
471 
472 
473 def HISubtractionToCellsCfg(flags, name="HIClusterSubtraction", **kwargs):
474  """Provides tool for cell subtraction.
475  Re-uses tool for cluster subtraction."""
476 
477  return HISubtractionToClustersCfg(flags, name, useClusters=False, **kwargs)
478 
479 
480 def HISubtractionToClustersCfg(flags, name="HIClusterSubtraction", useClusters=True, **kwargs):
481  """Provides tool for cluster subtraction."""
482  acc = ComponentAccumulator()
483 
484  kwargs.setdefault('EventShapeKey', 'EventShapeKey')
485  kwargs.setdefault('ClusterKey', flags.HeavyIon.Jet.Internal.ClusterKey)
486  kwargs.setdefault('OutClusterKey', 'ClusterKey_deep')
487  kwargs.setdefault('UpdateOnly', False)
488  kwargs.setdefault('ApplyOriginCorrection', True)
489  kwargs.setdefault('SetMoments', False)
490  if 'Modulator' not in kwargs:
491  modulator = acc.popToolsAndMerge(NullModulatorCfg())
492  kwargs.setdefault('Modulator', modulator)
493  if "EventShapeMapTool" not in kwargs:
494  map_tool = acc.popToolsAndMerge(HIEventShapeMapToolCfg(flags))
495  kwargs.setdefault("EventShapeMapTool", map_tool)
496  if "Subtractor" not in kwargs:
497  sub_tool = acc.popToolsAndMerge(HIJetSubtractorCfg(flags, useClusters))
498  kwargs.setdefault("Subtractor", sub_tool)
499  if kwargs["SetMoments"] and "ClusterCorrectionTools" not in kwargs:
500  clusterCorrectionTools = acc.popToolsAndMerge(
501  HICaloClusterMomentsCfg(flags, "HIClusterMoments"))
502  kwargs.setdefault("ClusterCorrectionTools", [clusterCorrectionTools])
503 
504  acc.setPrivateTools(CompFactory.HIClusterSubtraction(name, **kwargs))
505  return acc
506 
507 
508 def HIJetRecCfg(flags):
509  """Configures Heavy Ion Jet reconstruction."""
510  acc = ComponentAccumulator()
511 
512  # get HIClusters
513  acc.merge(HIClusterMakerCfg(flags))
514 
515  # get weighted event shape
516  eventshapeKey = "HIEventShapeWeighted"
517  acc.merge(HIEventShapeMakerCfg(flags,
518  name="HIEventShapeMaker_Weighted",
519  doWeighted=True,
520  InputTowerKey=flags.HeavyIon.Jet.Internal.ClusterKey,
521  OutputContainerKey=eventshapeKey))
522 
523  # get jet definition
524  # R=0.2 calojets are use as seeds for UE subtraction
525  jetDef2 = HICaloJetDef(flags, jetradius=2, suffix="_Unsubtracted")
526 
527  # get jet definitions for physics
528  jetDef = []
529  jetRlist = flags.HeavyIon.Jet.RValues #Default [0.2,0.4], Others R's should be build in Derivations or pass in preExec
530  for jetR in jetRlist:
531  jetDef.append(HICaloJetDef(flags, jetradius=jetR, suffix="_Unsubtracted"))
532  __log.info("HI Jet Collection for Reco: "+jetDef[-1].fullname())
533 
534  # get calo pseudojets
535  acc.merge(HIPseudoJetAlgCfg(flags))
536 
537  # HIJetTracks are used for GhostTracks association and later to build TrackJets seeds
538  pseudoTrkJetCont = "HIJetTracks"
539  pseudoGhostTrks = "PseudoJetGhostTracks"
540 
541  acc.merge(HITrackSelAlgCfg(flags, OutputContainer=pseudoTrkJetCont))
542  acc.merge(HIPseudoTrackJetAlgCfg(
543  flags, name="GhostTrackPseudoJets", InputContainer=pseudoTrkJetCont, OutputContainer=pseudoGhostTrks, Label="GhostTrack"))
544 
545 
546 
547  pjContNames = ["PseudoJet"+flags.HeavyIon.Jet.Internal.ClusterKey,pseudoGhostTrks]
548 
549  mergeAlg = CompFactory.PseudoJetMerger(
550  "PJmerge_HIGhostTrack",
551  InputPJContainers = pjContNames,
552  OutputContainer = "PseudoJet"+flags.HeavyIon.Jet.Internal.ClusterKey+"_GhostTracks"
553  )
554  acc.addEventAlgo(mergeAlg)
555 
556  # build jets
557  acc.merge(HIJetAlgCfg(flags, jetDef=jetDef2))
558  for jd in jetDef:
559  acc.merge(HIJetAlgCfg(flags, jetDef=jd))
560 
561  # copy unsubtracted jets; create seed0
562  jetDef_seed0 = HIJetDefCloner(flags, jetDef_in=jetDef2,
563  suffix="_seed0",
564  modifiers=["HIJetAssoc", "HIJetMaxOverMean", "HIJetDiscrim", "Filter:5000"])
565  acc.merge(HIJetCopyAlgCfg(flags, jetDef2, jetDef_seed0))
566 
567  # first iteration, iter0
568  jm_dict0, acc_iter0 = HIEventShapeJetIterationCfg(flags,
569  suffix="iter0",
570  InputEventShapeKey=eventshapeKey,
571  CaloJetSeedContainerKey=jetDef_seed0.fullname())
572  iter0 = acc.popToolsAndMerge(acc_iter0)
573  acc.addEventAlgo(CompFactory.JetAlgorithm("jetalgHI_iter0", Tools=[iter0]))
574 
575  # jet modifier from the first iteration
576  updateStdJetModifier(flags, "subtr0", **jm_dict0)
577 
578  # set jet energy scale configuration
579  calib_seq = "EtaJES"
580  if not flags.Input.isMC:
581  calib_seq += "_Insitu"
582 
583  # copy jets from the first iteration; create seed1
584  jetDef_seed1 = HIJetDefCloner(flags, jetDef_in=jetDef2,
585  suffix="_seed1",
586  modifiers=["HIJetAssoc", "subtr0", "HIJetCalib:{}___{}___{}".format(2, calib_seq, not flags.Input.isMC), "Filter:{}".format(flags.HeavyIon.Jet.SeedPtMin)])
587  acc.merge(HIJetCopyAlgCfg(flags, jetDef2, jetDef_seed1))
588 
589  # configuring track jets, seeds for second iteration
590  if flags.HeavyIon.Jet.doTrackJetSeed:
591  pseudoTrks = "PseudoTracks"
592 
593  acc.merge(HIPseudoTrackJetAlgCfg(
594  flags, InputContainer=pseudoTrkJetCont, OutputContainer=pseudoTrks))
595 
596  jetDef_trk = HITrackJetDef(flags,
597  jetradius=4,
598  modifiers=["HIJetAssoc", "Filter:{}".format(flags.HeavyIon.Jet.TrackJetPtMin),"Sort"])
599  trkJetSeedCont = jetDef_trk.fullname()
600 
601  trkJetClust = acc.popToolsAndMerge(HIJetClustererCfg(flags,
602  jetDef=jetDef_trk,
603  InputPseudoJets=pseudoTrks))
604  acc.merge(HIJetAlgCfg(flags, jetDef_trk, Provider=trkJetClust))
605  else:
606  trkJetSeedCont = ""
607 
608  # second iteration, iter1
609  jm_dict1, acc_iter1 = HIEventShapeJetIterationCfg(flags,
610  suffix="iter1",
611  InputEventShapeKey=eventshapeKey,
612  CaloJetSeedContainerKey=jetDef_seed1.fullname(),
613  TrackJetSeedContainerKey=trkJetSeedCont)
614  iter1 = acc.popToolsAndMerge(acc_iter1)
615  acc.addEventAlgo(CompFactory.JetAlgorithm("jetalgHI_iter1", Tools=[iter1]))
616 
617  # event shape for egamma
618  jm_dict1_eg, acc_iter1_eg = HIEventShapeJetIterationCfg(flags,
619  suffix="iter_egamma",
620  useClusters=False,
621  InputEventShapeKey=flags.HeavyIon.Global.EventShape,
622  OutputEventShapeKey=flags.HeavyIon.Egamma.EventShape,
623  CaloJetSeedContainerKey=jetDef_seed1.fullname())
624  iter1_eg = acc.popToolsAndMerge(acc_iter1_eg)
625  acc.addEventAlgo(CompFactory.JetAlgorithm("jetalgHI_iter1_egamma", Tools=[iter1_eg]))
626 
627  # constituents subtraction for egamma, cell-level
628  cluster_key_eGamma_deep = flags.HeavyIon.Jet.Internal.ClusterKey+"_eGamma_deep"
629  subtrToCelltool = acc.popToolsAndMerge(
631  name="HIClusterSubtraction_egamma",
632  EventShapeKey=jm_dict1_eg["EventShapeKey"],
633  OutClusterKey=cluster_key_eGamma_deep,
634  Modulator=jm_dict1["Modulator"],
635  EventShapeMapTool=jm_dict1["EventShapeMapTool"],
636  SetMoments=True,
637  ApplyOriginCorrection=False)
638  )
639  acc.addEventAlgo(CompFactory.JetAlgorithm("jetalgHI_subtrToCellTool", Tools=[subtrToCelltool]))
640 
641  # jet modifier from the second iteration
642  updateStdJetModifier(flags, "subtr1", **jm_dict1)
643 
644  # constituents subtraction for jets, tower-level
645  subtrToClusterTool = acc.popToolsAndMerge(
647  name="HIClusterSubtraction_final",
648  EventShapeKey=jm_dict1["EventShapeKey"],
649  ClusterKey=cluster_key_eGamma_deep,
650  OutClusterKey=flags.HeavyIon.Jet.ClusterKey,
651  Modulator=jm_dict1["Modulator"],
652  EventShapeMapTool=jm_dict1["EventShapeMapTool"],
653  ApplyOriginCorrection=False)
654  )
655  acc.addEventAlgo(CompFactory.JetAlgorithm(
656  "jetalgHI_subtrToClusterTool", Tools=[subtrToClusterTool]))
657 
658  # jet modifier from the tower-level subtraction
659  updateStdJetModifier(flags, "consmod",
660  ClusterKey=flags.HeavyIon.Jet.ClusterKey,
661  Subtractor=jm_dict1["Subtractor"])
662 
663  # store final version of HIClusters
664  if flags.HeavyIon.Jet.WriteHIClusters:
665  output_hicluster = ["xAOD::CaloClusterContainer#"+flags.HeavyIon.Jet.ClusterKey,
666  "xAOD::CaloClusterAuxContainer#"+flags.HeavyIon.Jet.ClusterKey+"Aux."]
667  acc.merge(addToESD(flags, output_hicluster))
668  acc.merge(addToAOD(flags, output_hicluster))
669 
670  # configure final jets and store them
671  extramods = ["Sort","Width","CaloEnergies","LArHVCorr","CaloQuality","TrackMoments","JVF","JVT"]# adding modifiers to final jets
672  for jd in jetDef:
673  jetDef_final = HIJetDefCloner(flags,
674  jetDef_in=jd,
675  suffix="",
676  modifiers=["subtr1", "consmod", "HIJetCalib:{}___{}___{}".format(str(float(jd.radius)*10).replace('.0',''),calib_seq, not flags.Input.isMC), "Filter:{}".format(flags.HeavyIon.Jet.RecoOutputPtMin)]+extramods)
677  acc.merge(HIJetCopyAlgCfg(flags, jd, jetDef_final))
678 
679  output = ["xAOD::JetContainer#"+jetDef_final.fullname(),
680  "xAOD::JetAuxContainer#"+jetDef_final.fullname()+"Aux.-PseudoJet"]
681  acc.merge(addToESD(flags, output))
682  acc.merge(addToAOD(flags, output))
683 
684  # store track jets
685  if flags.HeavyIon.Jet.doTrackJetSeed:
686  output = ["xAOD::JetContainer#"+jetDef_trk.fullname(),
687  "xAOD::JetAuxContainer#"+jetDef_trk.fullname()+"Aux.-PseudoJet"]
688  acc.merge(addToESD(flags, output))
689  acc.merge(addToAOD(flags, output))
690 
691  return acc
692 
693 
694 if __name__ == "__main__":
695  from AthenaConfiguration.AllConfigFlags import initConfigFlags
696  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
697  flags = initConfigFlags()
698  flags.Input.Files = [defaultTestFiles.d + "/RecJobTransformTests/data18_hi.00367384.physics_HardProbes.daq.RAW._lb0145._SFO-8._0001.data"]
699  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
700  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
701  flags.Exec.MaxEvents = 5
702  flags.Concurrency.NumThreads = 1
703 
704  # enable unit tests to switch only parts of reco such as (note the absence of spaces around equal sign):
705 
706  flags.fillFromArgs()
707  flags.Jet.strictMode = False
708  flags.lock()
709 
710  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
711  acc = MainServicesCfg(flags)
712  from InDetConfig.TrackRecoConfig import InDetTrackRecoCfg
713  acc.merge(InDetTrackRecoCfg(flags))
714 
715 
716 
717  from JetRecConfig.JetRecConfig import JetRecCfg
718  from JetRecConfig.StandardSmallRJets import AntiKt4EMTopo
719  EMjet = AntiKt4EMTopo.clone()
720  EMjet.ghostdefs = ["Track"]
721  acc.merge(JetRecCfg(flags,EMjet))
722 
723  from HIGlobal.HIGlobalConfig import HIGlobalRecCfg
724  acc.merge(HIGlobalRecCfg(flags))
725 
726  acc.merge(HIJetRecCfg(flags))
727 
728  acc.printConfig(withDetails=True, summariseProps=True)
729  flags.dump()
730 
731  import sys
732  sys.exit(acc.run().isFailure())
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
HIJetRecConfigCA.HIJetRecCfg
def HIJetRecCfg(flags)
Definition: HIJetRecConfigCA.py:508
python.CaloRecoConfig.CaloRecoCfg
def CaloRecoCfg(flags, clustersname=None)
Definition: CaloRecoConfig.py:9
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
vtune_athena.format
format
Definition: vtune_athena.py:14
HIJetRecConfigCA.HIModulatorCfg
def HIModulatorCfg(flags, mod_key, suffix=None, **kwargs)
Definition: HIJetRecConfigCA.py:323
HIJetRecUtilsCA.getHIClusterGeoWeightFile
def getHIClusterGeoWeightFile(flags)
Definition: HIJetRecUtilsCA.py:7
HIJetRecConfigCA.updateStdJetModifier
def updateStdJetModifier(flags, name, **kwargs)
Definition: HIJetRecConfigCA.py:187
HIJetRecConfigCA.HIClusterMakerCfg
def HIClusterMakerCfg(flags, save=False, **kwargs)
Definition: HIJetRecConfigCA.py:19
HIJetRecConfigCA.NullModulatorCfg
def NullModulatorCfg()
Definition: HIJetRecConfigCA.py:312
HIJetRecConfigCA.HIJetDefCloner
def HIJetDefCloner(flags, jetDef_in, **kwargs)
Definition: HIJetRecConfigCA.py:294
HIJetRecConfigCA.HISubtractionToClustersCfg
def HISubtractionToClustersCfg(flags, name="HIClusterSubtraction", useClusters=True, **kwargs)
Definition: HIJetRecConfigCA.py:480
HIGlobalConfig.HIEventShapeMapToolCfg
def HIEventShapeMapToolCfg(flags, name="HIEventShapeMapTool", **kwargs)
Definition: HIGlobalConfig.py:20
HIJetRecConfigCA.HIJetSubtractorCfg
def HIJetSubtractorCfg(flags, useClusters, **kwargs)
Definition: HIJetRecConfigCA.py:375
python.InDetTrackSelectionToolConfig.HI_InDetTrackSelectionToolForHITrackJetsCfg
def HI_InDetTrackSelectionToolForHITrackJetsCfg(flags, name="TrackSelHI", **kwargs)
Definition: InDetTrackSelectionToolConfig.py:175
HIJetRecConfigCA.HICaloJetInputConstitSeq
def HICaloJetInputConstitSeq(flags, name="HICaloConstit", **kwargs)
Definition: HIJetRecConfigCA.py:48
HIJetRecConfigCA.HITrackJetDef
def HITrackJetDef(flags, jetradius, **kwargs)
Definition: HIJetRecConfigCA.py:87
HIJetRecConfigCA.HICaloClusterMomentsCfg
def HICaloClusterMomentsCfg(flags, name="HIClusterMoments", **kwargs)
Definition: HIJetRecConfigCA.py:443
HIJetRecConfigCA.HIJetCellSubtractorCfg
def HIJetCellSubtractorCfg(flags, name="HIJetCellSubtractor", **kwargs)
Definition: HIJetRecConfigCA.py:367
HIJetRecConfigCA.HIPseudoJetAlgCfg
def HIPseudoJetAlgCfg(flags, **kwargs)
Definition: HIJetRecConfigCA.py:102
HIJetRecConfigCA.HIJetClusterSubtractorCfg
def HIJetClusterSubtractorCfg(flags, name="HIJetClusterSubtractor", **kwargs)
Definition: HIJetRecConfigCA.py:353
python.JetRecConfig.JetRecCfg
def JetRecCfg(flags, jetdef, returnConfiguredDef=False)
Top level functions returning ComponentAccumulator out of JetDefinition.
Definition: JetRecConfig.py:36
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.DependencyHelper.solveDependencies
def solveDependencies(jetdef0, flags)
Definition: DependencyHelper.py:20
HIJetRecConfigCA.HITrackJetInputConstit
def HITrackJetInputConstit(flags, name="HITrack", **kwargs)
Definition: HIJetRecConfigCA.py:79
python.OutputStreamConfig.addToESD
def addToESD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:127
HIJetRecConfigCA.HITrackSelAlgCfg
def HITrackSelAlgCfg(flags, name="TrackSelAlgHI", **kwargs)
Definition: HIJetRecConfigCA.py:427
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
HIJetRecConfigCA.HICaloJetDef
def HICaloJetDef(flags, jetradius, **kwargs)
Definition: HIJetRecConfigCA.py:63
HIJetRecConfigCA.HIEventShapeJetIterationCfg
def HIEventShapeJetIterationCfg(flags, suffix=None, useClusters=True, **kwargs)
Definition: HIJetRecConfigCA.py:384
HIJetRecConfigCA.HIJetClustererCfg
def HIJetClustererCfg(flags, name="builder", jetDef=None, **kwargs)
Definition: HIJetRecConfigCA.py:130
HIJetRecConfigCA.HIPseudoTrackJetAlgCfg
def HIPseudoTrackJetAlgCfg(flags, name="TrackPseudoJets", **kwargs)
Definition: HIJetRecConfigCA.py:117
HIJetRecConfigCA.HISubtractionToCellsCfg
def HISubtractionToCellsCfg(flags, name="HIClusterSubtraction", **kwargs)
Definition: HIJetRecConfigCA.py:473
HIJetRecConfigCA.HIJetAlgCfg
def HIJetAlgCfg(flags, jetDef, **kwargs)
Definition: HIJetRecConfigCA.py:145
python.TrackRecoConfig.InDetTrackRecoCfg
def InDetTrackRecoCfg(flags)
Main ID tracking config #####################.
Definition: TrackRecoConfig.py:791
python.CaloTowerMakerConfig.CaloTowerMakerCfg
def CaloTowerMakerCfg(flags)
Definition: CaloTowerMakerConfig.py:7
HIJetRecConfigCA.HIJetCopierCfg
def HIJetCopierCfg(flags, name="builder_copy", **kwargs)
Definition: HIJetRecConfigCA.py:162
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.OutputStreamConfig.addToAOD
def addToAOD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:142
HIJetRecConfigCA.HIJetCopyAlgCfg
def HIJetCopyAlgCfg(flags, jetDef_in, jetDef, **kwargs)
Definition: HIJetRecConfigCA.py:175
HIGlobalConfig.HIEventShapeMakerCfg
def HIEventShapeMakerCfg(flags, name="HIEventShapeMaker", doWeighted=False, **kwargs)
Definition: HIGlobalConfig.py:41
str
Definition: BTagTrackIpAccessor.cxx:11
readCCLHist.float
float
Definition: readCCLHist.py:83
HIGlobalConfig.HIGlobalRecCfg
def HIGlobalRecCfg(flags)
Definition: HIGlobalConfig.py:76