5 JetMomentToolsConfig: A helper module for configuring jet moment
6 tools, in support of JetRecConfig.JetModConfig.
10 IMPORTANT : all the getXYZTool(jetdef, modspec) functions are meant to be used as callback from the main JetRecConfig module
11 when we need to convert definitions of tools into the actual tools. At this point the functions are invoked as
13 Hence they have jetdef and modspec arguments even if not needed in every case.
16 from AthenaCommon
import Logging
17 jetmomentlog = Logging.logging.getLogger(
'JetMomentToolsConfig')
19 from AthenaConfiguration.ComponentFactory
import CompFactory
20 from AthenaConfiguration.Enums
import LHCPeriod
22 from xAODBase.xAODType
import xAODType
26 """returns a InDetTrackSelectionTool configured with the jet context corresponding to trkOpt
28 from JetRecTools.JetRecToolsConfig
import getIDTrackSelectionTool
37 useUncalibConstits =
False
38 if jetdef.inputdef.basetype==xAODType.CaloCluster:
39 builtFromEMClusters = jetdef.inputdef.inputname
in [
"CaloCalTopoClusters",
"HLT_CaloTopoClustersFS"]
and jetdef.inputdef.modifiers==[
"EM"]
40 useUncalibConstits =
not builtFromEMClusters
41 elif (jetdef.inputdef.basetype==xAODType.ParticleFlow
or jetdef.inputdef.basetype==xAODType.FlowElement):
42 useUncalibConstits =
True
44 raise ValueError(
"EM scale momentum not defined for input type {}".
format(jetdef.inputdef.basetype))
46 emscalemom = CompFactory.JetEMScaleMomTool(
47 "emscalemom_{}".
format(jetdef.basename),
48 UseUncalibConstits = useUncalibConstits,
49 JetContainer = jetdef.fullname(),
67 cfourmom = CompFactory.JetConstitFourMomTool(
"constitfourmom_{0}".
format(jetdef.basename))
68 if "LCTopo" in jetdef.basename
or "EMTopo" in jetdef.basename:
69 cfourmom.JetScaleNames = [
"DetectorEtaPhi"]
70 if "HLT_" in jetdef.fullname():
71 cfourmom.AltConstitColls = [
""]
72 cfourmom.AltConstitScales = [0]
73 cfourmom.AltJetScales = [
"JetConstitScaleMomentum"]
75 clstate =
"CALIBRATED" if "LCTopo" in jetdef.basename
else "UNCALIBRATED"
76 cfourmom.AltConstitColls = [jetdef.inputdef.inputname]
77 cfourmom.AltConstitScales = [CaloClusterStates[clstate]]
78 cfourmom.AltJetScales = [
""]
81 elif "PFlow" in jetdef.basename
or "UFO" in jetdef.basename:
82 cfourmom.JetScaleNames = [
"DetectorEtaPhi"]
83 cfourmom.AltConstitColls = [
""]
84 cfourmom.AltConstitScales = [0]
85 cfourmom.AltJetScales = [
"JetConstitScaleMomentum"]
91 trkopt = modspec
or jetdef.context
92 trackingKeys = jetdef._cflags.Jet.Context[trkopt]
93 jvf = CompFactory.JetVertexFractionTool(
95 VertexContainer = trackingKeys[
"Vertices"],
96 AssociatedTracks = trackingKeys[
"GhostTracksLabel"],
97 TrackVertexAssociation = trackingKeys[
"TVA"],
98 TrackParticleContainer = trackingKeys[
"Tracks"],
100 SuppressInputDependence =
True,
101 UseOriginVertex = jetdef.byVertex
108 jvt = CompFactory.JetVertexTaggerTool(
110 VertexContainer = jetdef._cflags.Jet.Context[modspec
or jetdef.context][
"Vertices"],
111 SuppressInputDependence =
True,
112 UseOriginVertex = jetdef.byVertex
118 nnjvt = CompFactory.getComp(
"JetPileupTag::JetVertexNNTagger")(
120 VertexContainer = jetdef._cflags.Jet.Context[modspec
or jetdef.context][
"Vertices"],
121 SuppressInputDependence =
True
128 trkopt = modspec
or jetdef.context
129 trackingKeys = jetdef._cflags.Jet.Context[trkopt]
131 trackmoments = CompFactory.JetTrackMomentsTool(
133 VertexContainer = trackingKeys[
"Vertices"],
134 AssociatedTracks = trackingKeys[
"GhostTracksLabel"],
135 TrackVertexAssociation = trackingKeys[
"TVA"],
136 TrackMinPtCuts = [500, 1000],
138 DoPFlowMoments =
'PFlow' in jetdef.fullname()
or 'UFO' in jetdef.fullname() ,
143 trkopt = modspec
or jetdef.context
144 trackingKeys = jetdef._cflags.Jet.Context[trkopt]
147 tracksummoments = CompFactory.JetTrackSumMomentsTool(
149 VertexContainer = trackingKeys[
"Vertices"],
150 AssociatedTracks = trackingKeys[
"GhostTracksLabel"],
151 TrackVertexAssociation = trackingKeys[
"TVA"],
152 RequireTrackPV =
True,
153 TrackSelector = jettrackselloose
155 return tracksummoments
160 origin_setpv = CompFactory.JetOriginCorrectionTool(
162 VertexContainer = jetdef._cflags.Jet.Context[modspec
or jetdef.context][
"Vertices"],
163 OriginCorrectedName =
"",
171 from JetRecConfig.JetDefinition
import buildJetAlgName
173 truthJetAlg =
buildJetAlgName(jetdef.algorithm, jetdef.radius)+
'Truth'+
str(modspec)+
'Jets'
175 jetPtAssociation = CompFactory.JetPtAssociationTool(
'jetPtAssociation',
176 MatchingJetContainer = truthJetAlg,
177 AssociationName =
"GhostTruth")
179 return jetPtAssociation
183 trkopt = modspec
or jetdef.context
184 trackingKeys = jetdef._cflags.Jet.Context[trkopt]
186 qgtagging = CompFactory.JetQGTaggerVariableTool(
'qgtagging',
187 VertexContainer = trackingKeys[
"Vertices"],
188 TrackVertexAssociation = trackingKeys[
"TVA"],
197 from JetCalibTools
import JetCalibToolsConfig
198 calibString =
"AnalysisLatest:mc:JetArea_Residual_EtaJES"
199 if( modspec
and modspec ==
"CustomVtx" ) :
200 if jetdef._cflags.GeoModel.Run
is LHCPeriod.Run3:
201 calibString =
"AnalysisLatest:mc:JetArea_Residual_EtaJES:Kt4EMPFlowNeutEventShape:HggPrimaryVertices"
203 calibString =
"AnalysisLatest:mc:JetArea_Residual_EtaJES:Kt4EMPFlowCustomVtxEventShape:HggPrimaryVertices"
206 wPFOTool = CompFactory.getComp(
'CP::WeightPFOTool')(
"fJVT__wPFO")
208 trackingKeys = jetdef._cflags.Jet.Context[modspec
or jetdef.context]
210 fJVTTool = CompFactory.JetForwardPFlowJvtTool(
"fJVT",
211 verticesName = trackingKeys[
"Vertices"],
212 TrackVertexAssociation = trackingKeys[
"TVA"],
213 WeightPFOTool = wPFOTool,
214 JetCalibrationTool = jetCalibrationTool,
215 FEName = jetdef.inputdef.containername,
217 FjvtRawName =
"DFCommonJets_fJvt",
225 from JetCalibTools
import JetCalibToolsConfig
228 wPFOTool = CompFactory.getComp(
'CP::WeightPFOTool')(
"bJVT__wPFO")
230 trackingKeys = jetdef._cflags.Jet.Context[modspec
or jetdef.context]
232 bJVTTool = CompFactory.JetBalancePFlowJvtTool(
'bJVT',
233 verticesName = trackingKeys[
"Vertices"],
234 TrackVertexAssociation = trackingKeys[
"TVA"],
235 WeightPFOTool = wPFOTool,
236 JetCalibrationTool = jetCalibrationTool,
237 FEName = jetdef.inputdef.containername,
239 BjvtRawName =
'DFCommonJets_bJvt',