8 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
9 from AthenaConfiguration.ComponentFactory
import CompFactory
10 from AthenaConfiguration.Enums
import LHCPeriod
13 jetContextName =
'CustomVtx'
14 PrefixForHggCollection =
"Hgg"
15 HggVertexContainerName = PrefixForHggCollection+
"PrimaryVertices"
16 def customVtxContext(prevflags):
17 context = prevflags.Jet.Context.default.clone(
18 Vertices = HggVertexContainerName,
19 GhostTracks =
"PseudoJetGhostTrack",
20 GhostTracksLabel =
"GhostTrack",
21 TVA =
"JetTrackVtxAssoc"+jetContextName,
22 JetTracks =
"JetSelectedTracks"+jetContextName,
23 JetTracksQualityCuts =
"JetSelectedTracks"+jetContextName+
"_trackSelOpt"
26 flags.addFlag(f
"Jet.Context.{jetContextName}", customVtxContext)
29 """Jet reconstruction needed for HIGG1D1"""
35 PrefixForHggCollection =
"Hgg"
36 HggVertexContainerName = PrefixForHggCollection+
"PrimaryVertices"
37 CustomPFJetContainerName =
"AntiKt4EMPFlowCustomVtxJets"
39 from JetRecConfig.StandardJetConstits
import stdInputExtDic, JetInputExternal,JetInputConstit, JetInputConstitSeq, JetConstitModifier, xAODType
40 from JetRecConfig.StandardSmallRJets
import AntiKt4EMPFlow
41 from JetRecConfig.JetDefinition
import JetDefinition
42 from JetRecTools
import JetRecToolsConfig
as jrtcfg
43 from JetMomentTools
import JetMomentToolsConfig
44 from JetRecConfig.StandardJetConstits
import stdConstitDic, stdContitModifDic
45 from JetRecConfig.StandardJetContext
import propFromContext, inputsFromContext
46 from JetRecConfig.JetInputConfig
import buildEventShapeAlg
49 jetContextName =
'CustomVtx'
50 context = ConfigFlags.Jet.Context[jetContextName]
52 def replaceItems(tup,orgName,newName):
54 for i, item
in enumerate(newList):
56 newList[i] = item.replace(orgName,newName)
57 print(
"Updated ", orgName,
" to ", newName )
59 print(
"Failed to update ", orgName,
" to ", newName )
62 def updateCalibSequence(tup):
64 if ConfigFlags.GeoModel.Run
is LHCPeriod.Run3:
65 rhoname =
"Kt4EMPFlowNeutEventShape"
67 rhoname =
"Kt4EMPFlowCustomVtxEventShape"
69 for i, item
in enumerate(newList):
71 calibspecs = item.split(
":")
72 calib, calibcontext, data_type = calibspecs[:3]
75 calibseq = calibspecs[3]
76 pvname = HggVertexContainerName
77 finalCalibString = f
"CalibCustomVtx:{calibcontext}:{data_type}:{calibseq}:{rhoname}:{pvname}"
78 if len(calibspecs)>6: finalCalibString = f
"{finalCalibString}:{calibspecs[6]}"
79 newList[i] = finalCalibString
80 print(finalCalibString)
82 print(
"Failed to update calib sequence" )
87 modsCustomVtx = AntiKt4EMPFlow.modifiers
88 modsCustomVtx = updateCalibSequence(modsCustomVtx)
89 modsCustomVtx = replaceItems(modsCustomVtx,
"TrackMoments",
"TrackMomentsCustomVtx")
90 modsCustomVtx = replaceItems(modsCustomVtx,
"TrackSumMoments",
"TrackSumMomentsCustomVtx")
91 modsCustomVtx = replaceItems(modsCustomVtx,
"JVF",
"JVFCustomVtx")
92 modsCustomVtx = replaceItems(modsCustomVtx,
"JVT",
"JVTCustomVtx")
93 modsCustomVtx = replaceItems(modsCustomVtx,
"Charge",
"ChargeCustomVtx")
95 ghostCustomVtx = AntiKt4EMPFlow.ghostdefs
98 stdConstitDic[
"TrackCustomVtx"] = JetInputConstit(
"TrackCustomVtx", xAODType.TrackParticle,
"JetSelectedTracksCustomVtx" )
101 stdConstitDic[
"GPFlowCustomVtx"] = JetInputConstitSeq(
"GPFlowCustomVtx", xAODType.FlowElement,[
"CorrectPFOCustomVtx",
"CHSCustomVtx"] ,
'GlobalParticleFlowObjects',
'CHSGCustomVtxParticleFlowObjects',
104 stdContitModifDic[
"CorrectPFOCustomVtx"] = JetConstitModifier(
"CorrectPFOCustomVtx",
"CorrectPFOTool",
107 WeightPFOTool= CompFactory.getComp(
"CP::WeightPFOTool")(
"weightPFO") )
110 stdContitModifDic[
"CHSCustomVtx"] = JetConstitModifier(
"CHSCustomVtx",
"ChargedHadronSubtractionTool",
114 UseTrackToVertexTool=
True,
119 AntiKt4EMPFlowCustomVtx = JetDefinition(
"AntiKt",0.4,stdConstitDic.GPFlowCustomVtx,
121 context = jetContextName,
122 ghostdefs = ghostCustomVtx,
123 modifiers = modsCustomVtx+(
"JetPtAssociation",
"QGTaggingCustomVtx",
"fJVTCustomVtx",
"NNJVTCustomVtx",
"CaloEnergiesClus",
"JetPileupLabel"),
127 def getUsedInVertexFitTrackDecoratorAlgCustomVtx(jetdef, jetmod):
128 """ Create the alg to decorate the used-in-fit information for AMVF """
129 context = jetdef._contextDic
131 from InDetUsedInFitTrackDecoratorTool.UsedInVertexFitTrackDecoratorConfig
import getUsedInVertexFitTrackDecoratorAlg
133 vertexDeco=
'TTVA_AMVFVertices_forHiggs',
134 weightDeco=
'TTVA_AMVFWeights_forHiggs')
139 stdInputExtDic[context[
'Vertices']] = JetInputExternal( context[
'Vertices'], xAODType.Vertex )
141 stdInputExtDic[
"JetSelectedTracksCustomVtx"] = JetInputExternal(
"JetSelectedTracksCustomVtx", xAODType.TrackParticle,
142 prereqs= [ f
"input:{context['Tracks']}" ],
143 algoBuilder =
lambda jdef,_ : jrtcfg.getTrackSelAlg(jdef, trackSelOpt=
False,
144 DecorDeps=[
"TTVA_AMVFWeights_forHiggs",
"TTVA_AMVFVertices_forHiggs"] )
147 stdInputExtDic[
"JetTrackUsedInFitDecoCustomVtx"] = JetInputExternal(
"JetTrackUsedInFitDecoCustomVtx", xAODType.TrackParticle,
148 prereqs= [ f
"input:{context['Tracks']}" ,
149 f
"input:{context['Vertices']}"],
150 algoBuilder = getUsedInVertexFitTrackDecoratorAlgCustomVtx
153 stdInputExtDic[
"JetTrackVtxAssocCustomVtx"] = JetInputExternal(
"JetTrackVtxAssocCustomVtx", xAODType.TrackParticle,
154 algoBuilder =
lambda jdef,_ : jrtcfg.getJetTrackVtxAlg(jdef._contextDic, algname=
"jetTVACustomVtx",
155 WorkingPoint=
"Nonprompt_All_MaxWeight",
156 AMVFVerticesDeco=
'TTVA_AMVFVertices_forHiggs',
157 AMVFWeightsDeco=
'TTVA_AMVFWeights_forHiggs'),
158 prereqs = [
"input:JetTrackUsedInFitDecoCustomVtx", f
"input:{context['Vertices']}" ] )
160 stdInputExtDic[
"EventDensityCustomVtx"] = JetInputExternal(
"EventDensityCustomVtx",
"EventShape", algoBuilder = buildEventShapeAlg,
161 containername =
lambda jetdef, _ :
"Kt4"+jetdef.inputdef.label+
"CustomVtxEventShape",
162 prereqs =
lambda jetdef : [
"input:"+jetdef.inputdef.name] )
164 from JetRecConfig.StandardJetMods
import stdJetModifiers
165 from JetRecConfig.JetDefinition
import JetModifier
166 from JetCalibTools
import JetCalibToolsConfig
168 stdJetModifiers.update(
170 CalibCustomVtx = JetModifier(
"JetCalibrationTool",
"jetcalib_jetcoll_calibseqCustomVtx",
171 createfn=JetCalibToolsConfig.getJetCalibToolFromString,
175 JVFCustomVtx = JetModifier(
"JetVertexFractionTool",
"jvfCustomVtx",
177 modspec =
"CustomVtx",
178 prereqs = [
"input:JetTrackVtxAssocCustomVtx",
"mod:TrackMomentsCustomVtx", f
"input:{context['Vertices']}"] ,
179 JetContainer = CustomPFJetContainerName),
181 JVTCustomVtx = JetModifier(
"JetVertexTaggerTool",
"jvtCustomVtx",
183 modspec =
"CustomVtx",
184 prereqs = [
"mod:JVFCustomVtx" ],JetContainer = CustomPFJetContainerName),
186 NNJVTCustomVtx = JetModifier(
"JetVertexNNTagger",
"nnjvtCustomVtx",
188 prereqs = [
"mod:JVFCustomVtx" ],JetContainer = CustomPFJetContainerName),
190 OriginSetPVCustomVtx = JetModifier(
"JetOriginCorrectionTool",
"origin_setpvCustomVtx",
191 modspec =
"CustomVtx",
192 prereqs = [
"mod:JVFCustomVtx" ],JetContainer = CustomPFJetContainerName, OnlyAssignPV=
True),
194 TrackMomentsCustomVtx = JetModifier(
"JetTrackMomentsTool",
"trkmomsCustomVtx",
196 modspec =
"CustomVtx",
197 prereqs = [
"input:JetTrackVtxAssocCustomVtx",
"ghost:Track" ],JetContainer = CustomPFJetContainerName),
199 TrackSumMomentsCustomVtx = JetModifier(
"JetTrackSumMomentsTool",
"trksummomsCustomVtx",
201 modspec =
"CustomVtx",
202 prereqs = [
"input:JetTrackVtxAssocCustomVtx",
"ghost:Track" ],JetContainer = CustomPFJetContainerName),
204 ChargeCustomVtx = JetModifier(
"JetChargeTool",
"jetchargeCustomVtx",
205 prereqs = [
"ghost:Track" ]),
208 QGTaggingCustomVtx = JetModifier(
"JetQGTaggerVariableTool",
"qgtaggingCustomVtx",
210 modspec =
"CustomVtx",
211 prereqs =
lambda _,jdef :
212 [
"input:JetTrackVtxAssocCustomVtx",
"mod:TrackMomentsCustomVtx"] +
213 ([
"mod:JetPtAssociation"]
if not jdef._cflags.Input.isMC
else []),
214 JetContainer = CustomPFJetContainerName),
216 fJVTCustomVtx = JetModifier(
"JetForwardPFlowJvtTool",
"fJVTCustomVtx",
218 modspec =
"CustomVtx",
219 prereqs = [
"input:JetTrackVtxAssocCustomVtx",
"input:EventDensityCustomVtx",f
"input:{context['Vertices']}",
"mod:NNJVTCustomVtx"],
220 JetContainer = CustomPFJetContainerName),
223 from JetRecConfig.JetRecConfig
import JetRecCfg
225 acc.merge(
JetRecCfg(ConfigFlags,AntiKt4EMPFlowCustomVtx))
230 """Event cleaning and jet cleaning for HIGG1D1"""
234 from DerivationFrameworkJetEtMiss.JetCommonConfig
import AddJvtDecorationAlgCfg
235 acc.merge(
AddJvtDecorationAlgCfg(ConfigFlags, algName =
"JvtPassDecorCustomVtxAlg", jetContainer=
'AntiKt4EMPFlowCustomVtx'))
237 from DerivationFrameworkTau.TauCommonConfig
import AddTauAugmentationCfg
242 from AssociationUtils.AssociationUtilsConfig
import OverlapRemovalToolCfg
246 acc.addSequence(CompFactory.AthSequencer(
'EventCleanSeq', Sequential=
True))
247 acc.addSequence(CompFactory.AthSequencer(
'EventCleanLockSeq', Sequential=
True))
249 outputLabel =
'DFCommonJets_passOR'
251 tauLabel =
'DFTauLoose'
252 orTool = acc.popToolsAndMerge(
OverlapRemovalToolCfg(ConfigFlags, outputLabel=outputLabel, bJetLabel=bJetLabel))
253 algOR = CompFactory.OverlapRemovalGenUseAlg(
'OverlapRemovalGenUseAlg_CustomVtx',
254 JetKey=
"AntiKt4EMPFlowCustomVtxJets",
255 OverlapLabel=outputLabel,
256 OverlapRemovalTool=orTool,
259 acc.addEventAlgo(algOR,
'EventCleanSeq')
262 lockOR = CompFactory.DerivationFramework.LockDecorations \
263 (
'OverlapRemovalLockDecorAlg_CustomVtx',
265 'Electrons.selected',
266 'Electrons.' + outputLabel,
268 'Muons.' + outputLabel,
270 'Photons.' + outputLabel,
271 'AntiKt4EMPFlowCustomVtxJets.selected',
272 'AntiKt4EMPFlowCustomVtxJets.' + outputLabel,
274 acc.addEventAlgo(lockOR,
'EventCleanLockSeq')
276 from JetSelectorTools.JetSelectorToolsConfig
import EventCleaningToolCfg, JetCleaningToolCfg
277 workingPoints = [
'Loose',
'Tight']
279 for wp
in workingPoints:
280 cleaningLevel = wp +
"Bad"
282 jetCleaningTool = acc.popToolsAndMerge(
285 name=
"JetCleaningCustomVtxTool_" + cleaningLevel,
286 jetdef=
"AntiKt4EMPFlowCustomVtxJets",
287 cleaningLevel=cleaningLevel,
288 useDecorations=
False,
291 acc.addPublicTool(jetCleaningTool)
293 ecTool = acc.popToolsAndMerge(
296 ecTool.JetCleanPrefix =
"DFCommonJets_"
297 ecTool.JetContainer =
"AntiKt4EMPFlowCustomVtxJets"
298 ecTool.JetCleaningTool = jetCleaningTool
299 acc.addPublicTool(ecTool)
303 eventCleanAlg = CompFactory.EventCleaningTestAlg(
304 "EventCleaningCustomVtxTestAlg_" + wp,
305 EventCleaningTool=ecTool,
306 JetCollectionName=
"AntiKt4EMPFlowCustomVtxJets",
307 EventCleanPrefix=
"DFCommonJetsCustomVtx_",
308 CleaningLevel=cleaningLevel,
311 acc.addEventAlgo(eventCleanAlg,
'EventCleanSeq')