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