ATLAS Offline Software
JetRecoSteering.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
3 from JetRecConfig.StandardSmallRJets import AntiKt4EMPFlow, AntiKt4LCTopo, AntiKt4EMTopo, AntiKt4Truth
4 from JetRecConfig.StandardLargeRJets import AntiKt10LCTopo_noVR, AntiKt10UFOCSSKSoftDrop_trigger
5 from JetRecConfig.JetRecConfig import JetRecCfg
6 
7 def addTruthPileupJetsToOutputCfg(flags, toAOD=True, toESD=True):
8  result = ComponentAccumulator()
9 
10  jetdefs = ["InTimeAntiKt4TruthJets", "OutOfTimeAntiKt4TruthJets"]
11 
12  jetList = []
13  for jetdef in jetdefs:
14  if f"xAOD::JetContainer#{jetdef}" in flags.Input.TypedCollections:
15  jetList += [ f"xAOD::JetContainer#{jetdef}" ,
16  f"xAOD::AuxContainerBase!#{jetdef}Aux.-PseudoJet.-constituentLinks.-constituentWeights"]
17 
18  from OutputStreamAthenaPool.OutputStreamConfig import addToESD, addToAOD
19  if toESD:
20  result.merge(addToESD(flags, jetList))
21  if toAOD:
22  result.merge(addToAOD(flags, jetList))
23 
24  return result
25 
26 
27 def addJetsToOutputCfg(flags,jetdefs, toAOD=True, toESD=True):
28  """Write out the jet containers as defined by jetdefs (a list of JetDefinition).
29 
30  In Run3 we don't write out jets in AOD : this function is left for convenience and testing purpose.
31  """
32  result = ComponentAccumulator()
33 
34  #--------------------------------------------------------------
35  # Build output container list.
36  #--------------------------------------------------------------
37  jetList = []
38 
39  for jetdef in jetdefs:
40  jetList += [ f"xAOD::JetContainer#{jetdef.fullname()}" ,
41  f"xAOD::JetAuxContainer#{jetdef.fullname()}Aux.-PseudoJet"]
42  # Not sure if this trigger special AuxContainer is obsolete in Run3 ?
43  # if trigger:
44  # auxprefix = "Trig"
45  # jetAODList += [ f"xAOD::Jet{auxprefix}AuxContainer#{jetdef.fullname()}Aux." ,
46 
47  # Store event shapes when jets are being stored to output
48  jetList += ["xAOD::EventShape#Kt4EMPFlowEventShape",
49  "xAOD::EventShapeAuxInfo#Kt4EMPFlowEventShapeAux.",
50  "xAOD::EventShape#Kt4EMPFlowNeutEventShape",
51  "xAOD::EventShapeAuxInfo#Kt4EMPFlowNeutEventShapeAux.",
52  "xAOD::EventShape#Kt4EMPFlowPUSBEventShape",
53  "xAOD::EventShapeAuxInfo#Kt4EMPFlowPUSBEventShapeAux.",
54  "xAOD::EventShape#Kt4EMTopoOriginEventShape",
55  "xAOD::EventShapeAuxInfo#Kt4EMTopoOriginEventShapeAux.",
56  "xAOD::EventShape#Kt4LCTopoOriginEventShape",
57  "xAOD::EventShapeAuxInfo#Kt4LCTopoOriginEventShapeAux."]
58 
59  from OutputStreamAthenaPool.OutputStreamConfig import addToESD, addToAOD
60  if toESD:
61  result.merge(addToESD(flags, jetList))
62  if toAOD:
63  result.merge(addToAOD(flags, jetList))
64 
65  return result
66 
67 def JetRecoSteeringCfg(flags):
68  result = ComponentAccumulator()
69 
70  # the Standard list of jets to run :
71  jetdefs = [AntiKt4EMTopo, AntiKt4EMPFlow, AntiKt4LCTopo, AntiKt4Truth, AntiKt10LCTopo_noVR, AntiKt10UFOCSSKSoftDrop_trigger]
72 
73  # We're in Reco job : propagate this info to the runIII jet config
74  # (see JetConfigFlags.py for motivations on this way of doing)
75 
76  #--------------------------------------------------------------
77  # Create the jet algs from the jet definitions
78  #--------------------------------------------------------------
79  for jd in jetdefs:
80  result.merge(JetRecCfg(flags, jd))
81 
82  if flags.Output.doWriteAOD and flags.Jet.WriteToAOD:
83  result.merge(addJetsToOutputCfg(flags, jetdefs, toAOD=True, toESD=False))
84  if flags.Output.doWriteESD:
85  jetdefs.remove(AntiKt10UFOCSSKSoftDrop_trigger)
86  result.merge(addJetsToOutputCfg(flags, jetdefs, toAOD=False, toESD=True))
87 
88  return result
89 
90 def JetRecoSteeringTest(flags=None):
91 
92  if flags is None:
93  from AthenaConfiguration.AllConfigFlags import initConfigFlags
94  flags = initConfigFlags()
95 
96  from AthenaConfiguration.TestDefaults import defaultTestFiles, defaultConditionsTags
97  flags.Input.Files = defaultTestFiles.AOD_RUN3_MC
98  flags.IOVDb.GlobalTag = defaultConditionsTags.RUN3_MC
99 
100  # We have to set the production step, which PFFlow muon linking uses for autoconfiguration.
101  from AthenaConfiguration.Enums import ProductionStep
102  flags.Common.ProductionStep=ProductionStep.Derivation
103 
104  flags.fillFromArgs()
105  flags.lock()
106 
107  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
108  acc = MainServicesCfg(flags)
109 
110  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
111  acc.merge(PoolReadCfg(flags))
112 
113  # Setup calorimeter geometry, which is needed for jet reconstruction
114  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
115  acc.merge(LArGMCfg(flags))
116 
117  from TileGeoModel.TileGMConfig import TileGMCfg
118  acc.merge(TileGMCfg(flags))
119 
120  acc.merge(JetRecoSteeringCfg(flags))
121 
122  # We also need to build links between the newly
123  # created jet constituents (GlobalFE)
124  # and electrons,photons,muons and taus
125  from eflowRec.PFCfg import PFGlobalFlowElementLinkingCfg
126  acc.merge(PFGlobalFlowElementLinkingCfg(flags))
127 
128  acc.run()
129 
130 if __name__=="__main__":
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.JetRecoSteering.JetRecoSteeringTest
def JetRecoSteeringTest(flags=None)
Definition: JetRecoSteering.py:90
python.JetRecoSteering.JetRecoSteeringCfg
def JetRecoSteeringCfg(flags)
Definition: JetRecoSteering.py:67
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.JetRecoSteering.addJetsToOutputCfg
def addJetsToOutputCfg(flags, jetdefs, toAOD=True, toESD=True)
Definition: JetRecoSteering.py:27
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
python.OutputStreamConfig.addToESD
def addToESD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:127
python.JetRecoSteering.addTruthPileupJetsToOutputCfg
def addTruthPileupJetsToOutputCfg(flags, toAOD=True, toESD=True)
Definition: JetRecoSteering.py:7
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.OutputStreamConfig.addToAOD
def addToAOD(flags, itemOrList, **kwargs)
Definition: OutputStreamConfig.py:142
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
PFCfg.PFGlobalFlowElementLinkingCfg
def PFGlobalFlowElementLinkingCfg(inputFlags, **kwargs)
Definition: PFCfg.py:468
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7