ATLAS Offline Software
HIGlobalConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4 from AthenaConfiguration.ComponentFactory import CompFactory
5 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
6 
7 def HITowerWeightToolCfg(flags, name="WeightTool", **kwargs):
8  """Configures HITowerWeightTool"""
10 
11  if "InputFile" not in kwargs:
12  from HIJetRec.HIJetRecUtilsCA import getHIClusterGeoWeightFile
13  kwargs.setdefault("InputFile", getHIClusterGeoWeightFile(flags))
14  kwargs.setdefault("ApplyCorrection", flags.HeavyIon.Jet.ApplyTowerEtaPhiCorrection)
15  kwargs.setdefault("ConfigDir", 'HIJetCorrection/')
16 
17  acc.setPrivateTools(CompFactory.HITowerWeightTool(name, **kwargs))
18  return acc
19 
20 def HIEventShapeMapToolCfg(flags, name="HIEventShapeMapTool", **kwargs):
21  """Configures HIEventShapeMapTool"""
22  acc = ComponentAccumulator()
23  acc.setPrivateTools(CompFactory.HIEventShapeMapTool(name, **kwargs))
24  return acc
25 
26 def HIEventShapeFillerToolCfg(flags, name="HIEventShapeFillerTool", **kwargs):
27  """Configures HIEventShapeFillerTool"""
28  acc = ComponentAccumulator()
29  if "EventShapeMapTool" not in kwargs:
30  eventShapeMapTool = acc.popToolsAndMerge(HIEventShapeMapToolCfg(flags, name="HIEventShapeMapTool"))
31  kwargs.setdefault("EventShapeMapTool", eventShapeMapTool)
32  kwargs.setdefault("UseClusters", False)
33  if kwargs["UseClusters"]:
34  #Add weight tool to filler tool
35  TWTool=acc.popToolsAndMerge(HITowerWeightToolCfg(flags, name="WeightTool"))
36  kwargs.setdefault("TowerWeightTool", TWTool)
37 
38  acc.setPrivateTools(CompFactory.HIEventShapeFillerTool(name, **kwargs))
39  return acc
40 
41 def HIEventShapeMakerCfg(flags, name="HIEventShapeMaker", doWeighted=False, **kwargs):
42  """Configures HIEventShapeMaker, either with weights (for HIJets) or without weight (for HIGlobal)"""
43  acc = ComponentAccumulator()
44 
45  # merge dependencies
46  from CaloRec.CaloRecoConfig import CaloRecoCfg
47  acc.merge(CaloRecoCfg(flags))
48  from CaloRec.CaloTowerMakerConfig import CaloTowerMakerCfg
49  towerMaker = acc.getPrimaryAndMerge(CaloTowerMakerCfg(flags))
50 
51  kwargs.setdefault("NaviTowerKey", towerMaker.TowerContainerName)
52  kwargs.setdefault("InputTowerKey", "")
53  kwargs.setdefault("OutputContainerKey", "HIEventShape")
54  if "HIEventShapeFillerTool" not in kwargs:
55  name_esft="HIEventShapeFillerTool_Weighted" if doWeighted else "HIEventShapeFillerTool"
56  eventShapeTool = acc.popToolsAndMerge(HIEventShapeFillerToolCfg(flags,
57  name=name_esft,
58  UseClusters=doWeighted))
59  kwargs.setdefault("HIEventShapeFillerTool",eventShapeTool)
60 
61  acc.addEventAlgo(CompFactory.HIEventShapeMaker(name, **kwargs))
62  return acc
63 
64 def HIEventShapeSummaryToolCfg(flags, name="HIEventShapeSummaryTool", **kwargs):
65  """Configures HIEventShapeSummaryTool"""
66  acc = ComponentAccumulator()
67 
68  # TODO configure MBTS &FWD conversion once available
69  kwargs.setdefault("SubCalos", ['FCal','EMCal','HCal','ALL'])
70  kwargs.setdefault("Samplings", ['FCAL0','FCAL1','FCAL2'])
71  kwargs.setdefault("DoPositiveNegativeSides", False)
72 
73  acc.setPrivateTools(CompFactory.HIEventShapeSummaryTool(name, **kwargs))
74  return acc
75 
76 def HIGlobalRecCfg(flags):
77  """Configures Heavy Ion Global quantities """
78  acc = ComponentAccumulator()
79 
80  shapeKey=flags.HeavyIon.Global.EventShape
81  output = [ f"xAOD::HIEventShapeContainer#{shapeKey}", f"xAOD::HIEventShapeAuxContainer#{shapeKey}Aux."]
82 
83  kwargs_hies=dict()
84  if flags.HeavyIon.Global.doEventShapeSummary:
85  summaryKey = "CaloSums"
86  summaryTool = acc.popToolsAndMerge(HIEventShapeSummaryToolCfg(flags))
87  kwargs_hies["SummaryTool"] = summaryTool
88  kwargs_hies["SummaryContainerKey"] = summaryKey
89  output.extend([ f"xAOD::HIEventShapeContainer#{summaryKey}", f"xAOD::HIEventShapeAuxContainer#{summaryKey}Aux."])
90 
91  acc.merge(HIEventShapeMakerCfg(flags, **kwargs_hies))
92 
93  acc.merge(addToESD(flags, output))
94  acc.merge(addToAOD(flags, output))
95 
96  return acc
97 
98 
99 if __name__ == "__main__":
100  from AthenaConfiguration.AllConfigFlags import initConfigFlags
101  from AthenaConfiguration.TestDefaults import defaultConditionsTags, defaultGeometryTags, defaultTestFiles
102  flags = initConfigFlags()
103  flags.Input.Files = [defaultTestFiles.d + "/RecJobTransformTests/data18_hi.00367384.physics_HardProbes.daq.RAW._lb0145._SFO-8._0001.data"]
104  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
105  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN2_DATA
106  flags.Exec.MaxEvents=5
107  flags.Concurrency.NumThreads=1
108 
109  flags.fillFromArgs() # enable unit tests to switch only parts of reco: python -m HIRecConfig.HIRecConfig HeavyIon.doGlobal = 0 and so on
110  flags.lock()
111 
112  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
113  acc = MainServicesCfg(flags)
114  from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
115  acc.merge(ByteStreamReadCfg(flags))
116 
117  acc.merge(HIGlobalRecCfg(flags))
118  from AthenaCommon.Constants import DEBUG
119  acc.getEventAlgo("HIEventShapeMaker").OutputLevel=DEBUG
120 
121  acc.printConfig(withDetails=True, summariseProps=True)
122  flags.dump()
123 
124  import sys
125  sys.exit(acc.run().isFailure())
HIGlobalConfig.HITowerWeightToolCfg
def HITowerWeightToolCfg(flags, name="WeightTool", **kwargs)
Definition: HIGlobalConfig.py:7
python.CaloRecoConfig.CaloRecoCfg
def CaloRecoCfg(flags, clustersname=None)
Definition: CaloRecoConfig.py:9
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
HIJetRecUtilsCA.getHIClusterGeoWeightFile
def getHIClusterGeoWeightFile(flags)
Definition: HIJetRecUtilsCA.py:7
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
HIGlobalConfig.HIEventShapeMapToolCfg
def HIEventShapeMapToolCfg(flags, name="HIEventShapeMapTool", **kwargs)
Definition: HIGlobalConfig.py:20
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
HIGlobalConfig.HIEventShapeSummaryToolCfg
def HIEventShapeSummaryToolCfg(flags, name="HIEventShapeSummaryTool", **kwargs)
Definition: HIGlobalConfig.py:64
python.OutputStreamConfig.addToESD
def addToESD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:127
HIGlobalConfig.HIEventShapeFillerToolCfg
def HIEventShapeFillerToolCfg(flags, name="HIEventShapeFillerTool", **kwargs)
Definition: HIGlobalConfig.py:26
python.CaloTowerMakerConfig.CaloTowerMakerCfg
def CaloTowerMakerCfg(flags)
Definition: CaloTowerMakerConfig.py:7
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.OutputStreamConfig.addToAOD
def addToAOD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:142
HIGlobalConfig.HIEventShapeMakerCfg
def HIEventShapeMakerCfg(flags, name="HIEventShapeMaker", doWeighted=False, **kwargs)
Definition: HIGlobalConfig.py:41
HIGlobalConfig.HIGlobalRecCfg
def HIGlobalRecCfg(flags)
Definition: HIGlobalConfig.py:76