From 78953114405ce2e056c50c24f2a670ac421811db Mon Sep 17 00:00:00 2001
From: Roshan Joshi <roshan.joshi@cern.ch>
Date: Wed, 18 May 2022 19:51:59 +0200
Subject: [PATCH] Added flowchart for VR track jet reconstruction in
 ModuleOverview.md and switched from TrackVertexAssociationTool to
 JetTrackVtxAssoAlg for track to vertex association while reconstructing
 PV0Tracks

Added flowchart for VR track jet reconstruction in ModuleOverview.md and switched to JetTrackVtxAssoAlg from TrackVertexAssociationTool for track to vertex association while reconstructing PV0Tracks
---
 .../JetRecTools/python/JetRecToolsConfig.py   | 13 ++--
 .../python/HLT/Jet/JetTrackingConfig.py       |  8 +--
 .../python/HLT/Jet/docs/ModuleOverview.md     | 65 +++++++++++++++++++
 3 files changed, 74 insertions(+), 12 deletions(-)

diff --git a/Reconstruction/Jet/JetRecTools/python/JetRecToolsConfig.py b/Reconstruction/Jet/JetRecTools/python/JetRecToolsConfig.py
index 72184ccacb2..38a1957c5b4 100644
--- a/Reconstruction/Jet/JetRecTools/python/JetRecToolsConfig.py
+++ b/Reconstruction/Jet/JetRecTools/python/JetRecToolsConfig.py
@@ -98,7 +98,7 @@ def getJetTrackVtxAlg( trkOpt,   algname="jetTVA", **ttva_overide):
 
 
 
-def getPV0TrackVertexAssocTool(trkOpt="", theSequence=None):
+def getPV0TrackVertexAssoAlg(trkOpt="", theSequence=None):
     if trkOpt: "_{}".format(trkOpt)
     from TrackVertexAssociationTool.getTTVAToolForReco import getTTVAToolForReco
     from JetRecConfig.StandardJetContext import jetContextDic
@@ -106,15 +106,16 @@ def getPV0TrackVertexAssocTool(trkOpt="", theSequence=None):
     trkProperties = jetContextDic[trkOpt]
     tvatool = getTTVAToolForReco("trackjettvassoc",
                                 WorkingPoint = "Nonprompt_All_MaxWeight",
-                                TrackContName = trkProperties["JetTracksQualityCuts"],
+                                TrackContName = trkProperties["JetTracks"],
                                 VertexContName = trkProperties["Vertices"],
                                 returnCompFactory = True,
                                 add2Seq = theSequence,
-                                addDecoAlg = isAthenaRelease(),
+                                addDecoAlg = False, #setting this to True causes error in reconstruction because of there not being aux store associated with one of the decorations
+                                                    #It has also been set to false in buildPV0TrackSel function in JetRecConfig/python/JetInputConfig.py 
                                 )
 
-    jettvassoc = CompFactory.TrackVertexAssociationTool("trackjetTTVAtool",
-            TrackParticleContainer = trkProperties["JetTracksQualityCuts"],
+    jettvassoc = CompFactory.JetTrackVtxAssoAlg("trackjetTVAAlg",
+            TrackParticleContainer = trkProperties["JetTracks"],
             TrackVertexAssociation = "PV0"+trkProperties["TVA"],
             VertexContainer        = trkProperties["Vertices"],
             TrackVertexAssoTool    = tvatool
@@ -125,7 +126,7 @@ def getPV0TrackSelAlg(tvaTool, trkOpt="default"):
     from JetRecConfig.StandardJetContext import jetContextDic
     trkProperties = jetContextDic[trkOpt]
     pv0trackselalg = CompFactory.PV0TrackSelectionAlg("pv0tracksel_trackjet",
-            InputTrackContainer = trkProperties["JetTracksQualityCuts"],
+            InputTrackContainer = trkProperties["JetTracks"],
             VertexContainer = trkProperties["Vertices"],
             OutputTrackContainer = "PV0"+trkProperties["JetTracks"],
             TVATool = tvaTool,
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Jet/JetTrackingConfig.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Jet/JetTrackingConfig.py
index 2ea46eff796..a9ebf70cea4 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Jet/JetTrackingConfig.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Jet/JetTrackingConfig.py
@@ -211,13 +211,9 @@ def jetTTVA( signature, jetseq, trkopt, config, verticesname=None, adaptiveVerte
 
     from AthenaConfiguration.AllConfigFlags import ConfigFlags
     if ConfigFlags.Trigger.Jet.doVRJets:
-        jettrackselalg = jrtcfg.getTrackSelAlg( trkopt, trackSelOpt=True )
-        jetseq += conf2toConfigurable( jettrackselalg )
-        pv0_jettvassoc, pv0_ttvatool = jrtcfg.getPV0TrackVertexAssocTool(trkopt, jetseq)
-        pv0jettrkprepalg    = CompFactory.JetAlgorithm("pv0jetalg_TrackPrep"+trkopt,
-                                                        Tools = [ pv0_jettvassoc ])
+        pv0_jettvassoc, pv0_ttvatool = jrtcfg.getPV0TrackVertexAssoAlg(trkopt, jetseq)
         pv0trackselalg = jrtcfg.getPV0TrackSelAlg(pv0_ttvatool, trkopt)
-        jetseq += conf2toConfigurable( pv0jettrkprepalg )
+        jetseq += conf2toConfigurable( pv0_jettvassoc )
         jetseq += conf2toConfigurable( pv0trackselalg )
 
     # make sure we output only the key,value related to tracks (otherwise, alg duplication issues)
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Jet/docs/ModuleOverview.md b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Jet/docs/ModuleOverview.md
index e1c14edc65d..d8b3735b42c 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Jet/docs/ModuleOverview.md
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Jet/docs/ModuleOverview.md
@@ -68,6 +68,71 @@ This scheduling is basically handled by menu construction. As a rule of thumb, w
 
 </details>
 
+<details>
+<summary> Flowchart for VR track jet reconstruction</summary>
+
+Variable Radius (VR) track jets are useful in b-tagging of large-R jets. A large-R jet can be b-tagged by performing b-tagging on the VR track jets associated with it. The association method that is commonly used is ghost association.
+
+The flowchart that follows details the steps in VR track jet reconstruction. The logic behind the steps is as follows: In order to reconstruct a jet, we need a `JetDefinition`. The JetDefinition requires an input constituent, which in this case would be the primary vertex tracks. So we need to perform track selection to get the required tracks. Using these tracks we create a VR track jet JetDefinition, which is then used to create VR track jet reconstruction sequence.
+
+```mermaid
+flowchart TD;
+
+	subgraph JetRecToolsConfig.py
+		PV0TrkInputCont[/Pre reqs: JetSelectedTracks_ftf, HLT_IDVertex_FS/]
+		TVA["Use TrackVertexAssociationTool (TVA) <br> on these tracks and vertices"]
+		PV0TrkInputCont--getPV0TrackVertexAssoAlg-->TVA
+		PV0TrkSelAlg[Use PV0TrackSelectionAlg <br> on same tracks and vertices with the TVA]
+		TVA-- getPV0TrackSelAlg-->PV0TrkSelAlg
+	end
+
+	subgraph JetTrackingConfig.py
+		TrkRecoSeq[Set up reco sequence <br> for standard tracks]
+		TrkOutCont[/JetSelectedTracks_ftf/]
+		TrkOutCont-->PV0TrkInputCont
+		TrkRecoSeq-->TrkOutCont
+		TrkTool_And_Alg[Get TVA Tool & <br> PV0TrackSelectionAlg]
+		TVA-->TrkTool_And_Alg
+		TrkOutCont-.-TrkTool_And_Alg
+		PV0TrkSelAlg-->TrkTool_And_Alg
+		TrkTool_And_Alg --Add the tool and alg to reco seq-->PV0TrkOutCont
+		PV0TrkOutCont[/Output Container: PV0JetSelectedTracks_ftf/]
+	end
+
+	subgraph defineVRTrackJets
+		InputConstit[/"JetInputConstit: PV0Track <br> (xAOD type TrackParticle)"/]
+		PV0TrkOutCont--Source Container -->InputConstit
+		Parameters[/Rmax, Rmin, VR mass scale, min pt, etc./]
+		JetDef[Create JetDefinition for VR track jets]
+		Parameters --> JetDef
+		InputConstit-->JetDef
+	end
+
+	subgraph VRJetRecoSequence
+		VRJetRecoSeqEmpty[Empty reco sequence]
+		VRJetDef[JetDefinition for VR track jets]
+		VRJetRecoSeqEmpty-->VRJetDef
+		JetDef-->VRJetDef
+		SolveDependencies[Resolve dependencies of JetDefinition <br> using `solveDependencies`]
+		VRJetDef-->SolveDependencies
+		ConstitPJAlg[Get constituent PseudoJet alg <br> & add it to reco sequence]
+		SolveDependencies-->ConstitPJAlg
+		UpdateAttrib[Update name of pseudo jet container <br> in JetDefinition <br> that will be used in jet finding]
+		ConstitPJAlg-->UpdateAttrib
+		VRTrkJetRecoSeq[Get VR track jet reco alg <br> & add it to the reco sequence]
+		ReturnObj[Return reco seq, jet def]
+		VRTrkJetRecoSeq-->ReturnObj
+	end
+
+	subgraph JetRecConfig.py
+		JetRecAlg["Call getJetRecAlg <br> which sets up jet building with fastjet <br> (internally calls JetClusterer)"]
+		UpdateAttrib-.Updated JetDef.->JetRecAlg
+		JetRecAlg-->VRTrkJetRecoSeq
+	end
+
+```
+</details>
+
 [GenerateJetChainDefs](../GenerateJetChainDefs.py)
 -----
 
-- 
GitLab