From ad735f488576da4b981a32676c5b4398f01615ed Mon Sep 17 00:00:00 2001
From: xiaozhon Huang <xiaozhong.huang@cern.ch>
Date: Tue, 1 Dec 2020 15:03:34 +0000
Subject: [PATCH] tauRecTools: retrive the clusters via decorated
 vertexedClusters

Previously, we have to retrieve the clusters from the seed jet, and
correct the four momentum of cluster to point at the tau primary vertex.
Since the clusters corrected to point at tau primary vertex is now
decorated to the tau candidate, we could retrieve the clusters directly.
---
 .../tauRec/python/TauAlgorithmsHolder.py      |  5 +-
 .../tauRecTools/Root/CaloClusterVariables.cxx | 24 ++----
 .../tauRecTools/Root/HelperFunctions.cxx      | 15 ++++
 .../Root/TauSubstructureVariables.cxx         | 83 +++++++------------
 .../Root/TauVertexedClusterDecorator.cxx      |  9 +-
 .../tauRecTools/src/TauClusterFinder.cxx      |  2 +
 .../tauRecTools/CaloClusterVariables.h        |  7 +-
 .../tauRecTools/tauRecTools/HelperFunctions.h |  2 +
 .../tauRecTools/TauSubstructureVariables.h    | 32 ++++---
 .../python/TrigTauAlgorithmsHolder.py         | 36 +++++++-
 .../TrigTauRec/python/TrigTauRecConfig.py     | 22 +++++
 .../TrigTauRec/python/TrigTauRecConfigMT.py   | 16 ++++
 .../TrigEDMConfig/python/TriggerEDMRun2.py    |  2 +-
 13 files changed, 154 insertions(+), 101 deletions(-)

diff --git a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
index 6583d4f1c67..36736c80953 100644
--- a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
+++ b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
@@ -310,10 +310,7 @@ def getTauSubstructure():
         return cached_instances[_name]
     
     from tauRecTools.tauRecToolsConf import TauSubstructureVariables
-    TauSubstructureVariables = TauSubstructureVariables(  name = _name,
-                                                          TauVertexCorrection = getTauVertexCorrection(),
-                                                          UseSubtractedCluster = tauFlags.useSubtractedCluster()
-                                                       )
+    TauSubstructureVariables = TauSubstructureVariables(name = _name)
     
     cached_instances[_name] = TauSubstructureVariables
     return TauSubstructureVariables
diff --git a/Reconstruction/tauRecTools/Root/CaloClusterVariables.cxx b/Reconstruction/tauRecTools/Root/CaloClusterVariables.cxx
index 40b79ac312d..80eb6274a4a 100644
--- a/Reconstruction/tauRecTools/Root/CaloClusterVariables.cxx
+++ b/Reconstruction/tauRecTools/Root/CaloClusterVariables.cxx
@@ -4,6 +4,9 @@
 
 #include "tauRecTools/CaloClusterVariables.h"
 #include "tauRecTools/HelperFunctions.h"
+
+#include "xAODCaloEvent/CaloVertexedTopoCluster.h"
+
 #include <cmath>
 
 const double CaloClusterVariables::DEFAULT = -1111.;
@@ -21,31 +24,20 @@ m_aveEffRadius(DEFAULT),
 m_totMass(DEFAULT),
 m_effMass(DEFAULT),
 m_totEnergy(DEFAULT),
-m_effEnergy(DEFAULT),
-m_useSubtractedCluster(true){
+m_effEnergy(DEFAULT) {
 }
 
 //*******************************************
 // update/fill the cluster based variables
 //*******************************************
 
-bool CaloClusterVariables::update(const xAOD::TauJet& pTau, const ToolHandle<ITauVertexCorrection>& tauVertexCorrection) {
+bool CaloClusterVariables::update(const xAOD::TauJet& pTau) {
     
-    if (! pTau.jetLink().isValid()) return false;
-
-    const xAOD::Jet* jetSeed = pTau.jet();
-    const xAOD::Vertex* jetVertex = tauVertexCorrection->getJetVertex(*jetSeed);
-
-    const xAOD::Vertex* tauVertex = nullptr;
-    if (pTau.vertexLink().isValid()) tauVertex = pTau.vertex();
- 
-    std::vector<const xAOD::CaloCluster*> clusterList;
-    StatusCode sc = tauRecTools::GetJetClusterList(jetSeed, clusterList, m_useSubtractedCluster);
+    const auto& vertexedClusterList = pTau.vertexedClusters();
 
     std::vector<TLorentzVector> clusterP4Vector;
-    for (const xAOD::CaloCluster* cluster : clusterList) {
-      TLorentzVector clusterP4 = tauVertexCorrection->getVertexCorrectedP4(*cluster, tauVertex, jetVertex);
-      clusterP4Vector.push_back(clusterP4);
+    for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList) {
+      clusterP4Vector.push_back(vertexedCluster.p4());
     }
 
     this->m_numConstit = (int) clusterP4Vector.size();
diff --git a/Reconstruction/tauRecTools/Root/HelperFunctions.cxx b/Reconstruction/tauRecTools/Root/HelperFunctions.cxx
index 9f08effc721..ceba5edcb3c 100644
--- a/Reconstruction/tauRecTools/Root/HelperFunctions.cxx
+++ b/Reconstruction/tauRecTools/Root/HelperFunctions.cxx
@@ -15,6 +15,21 @@ namespace tauRecTools {
   ANA_MSG_SOURCE(msgHelperFunction, "HelperFunction")
 }
 
+
+
+TLorentzVector tauRecTools::getTauAxis(const xAOD::TauJet& tau, bool doVertexCorrection) {
+  TLorentzVector tauAxis;
+  if (doVertexCorrection && tau.vertexLink().isValid()) {
+    tauAxis = tau.p4(xAOD::TauJetParameters::IntermediateAxis);
+  }
+  else {
+    tauAxis = tau.p4(xAOD::TauJetParameters::DetectorAxis);
+  }
+ 
+  return tauAxis;
+}
+
+
 //________________________________________________________________________________
 xAOD::TauTrack::TrackFlagType tauRecTools::isolateClassifiedBits(xAOD::TauTrack::TrackFlagType flag){
   const int flagsize=sizeof(flag)*8;
diff --git a/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx b/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx
index e15156219c4..6e850c2f0ac 100644
--- a/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx
+++ b/Reconstruction/tauRecTools/Root/TauSubstructureVariables.cxx
@@ -20,26 +20,11 @@
 #include "tauRecTools/TauSubstructureVariables.h"
 #include "tauRecTools/HelperFunctions.h"
 
-#define GeV 1000
 const float TauSubstructureVariables::DEFAULT = -1111.;
 
-
-
 TauSubstructureVariables::TauSubstructureVariables( const std::string& name )
   : TauRecToolBase(name) {
-  declareProperty("UseSubtractedCluster", m_useSubtractedCluster = true);
-}
-
-
-
-TauSubstructureVariables::~TauSubstructureVariables() {
-}
-
-
-
-StatusCode TauSubstructureVariables::initialize() {
-  ATH_CHECK(m_tauVertexCorrection.retrieve()); 
-  return StatusCode::SUCCESS;
+  declareProperty("VertexCorrection", m_doVertexCorrection = true);
 }
 
 
@@ -47,9 +32,8 @@ StatusCode TauSubstructureVariables::initialize() {
 StatusCode TauSubstructureVariables::execute(xAOD::TauJet& pTau) const {
 
   CaloClusterVariables CaloClusterVariablesTool;
-  CaloClusterVariablesTool.setIncSub(m_useSubtractedCluster);
 
-  bool isFilled = CaloClusterVariablesTool.update(pTau, m_tauVertexCorrection);
+  bool isFilled = CaloClusterVariablesTool.update(pTau);
 
   if (!isFilled) {
     ATH_MSG_DEBUG("problem in calculating calo cluster variables -> will be set to -1111");
@@ -84,33 +68,24 @@ StatusCode TauSubstructureVariables::execute(xAOD::TauJet& pTau) const {
   double clusELead = DEFAULT;
   double clusESubLead = DEFAULT;
 
-  if (! pTau.jetLink().isValid()) {
-    ATH_MSG_ERROR("Tau jet link is invalid.");
-    return StatusCode::FAILURE;
-  }
-  const xAOD::Jet *jetSeed = pTau.jet();
-  
-  const xAOD::Vertex* jetVertex = m_tauVertexCorrection->getJetVertex(*jetSeed);
-  
-  const xAOD::Vertex* tauVertex = nullptr;
-  if (pTau.vertexLink().isValid()) tauVertex = pTau.vertex();
-
-  TLorentzVector tauAxis = m_tauVertexCorrection->getTauAxis(pTau);
-
-  std::vector<const xAOD::CaloCluster*> vClusters;
-  ATH_CHECK(tauRecTools::GetJetClusterList(jetSeed, vClusters, m_useSubtractedCluster));
-  
-  for (auto cluster : vClusters){
-    totalEnergy += cluster->e();
+  TLorentzVector tauAxis = tauRecTools::getTauAxis(pTau, m_doVertexCorrection);
+
+  // TODO: check which scale is needed here
+  // p4 from cluster is at LC scale, p4 from vertexedCluster is at LC/EM scale for LC/EM seed jets
+  std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList = pTau.vertexedClusters();
+  for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList){
+    TLorentzVector clusterP4 = vertexedCluster.p4();
+
+    totalEnergy += clusterP4.E();
 		
-    TLorentzVector clusterP4 = m_tauVertexCorrection->getVertexCorrectedP4(*cluster, tauVertex, jetVertex);
-    dr = tauAxis.DeltaR(clusterP4);    
+    dr = tauAxis.DeltaR(clusterP4); 
     
     if (0.2 <= dr && dr < 0.4) {
 	  calo_iso += clusterP4.Et();
     }
     else if (dr < 0.2) {
-	  double clusEnergyBE = ( cluster->energyBE(0) + cluster->energyBE(1) + cluster->energyBE(2) );
+      const xAOD::CaloCluster& cluster = vertexedCluster.clust();
+	  double clusEnergyBE = ( cluster.energyBE(0) + cluster.energyBE(1) + cluster.energyBE(2) );
 		    
 	  if (clusEnergyBE > clusELead) {
 	    //change current leading cluster to subleading
@@ -137,16 +112,19 @@ StatusCode TauSubstructureVariables::execute(xAOD::TauJet& pTau) const {
   }
 
   // now sort cluster by energy
-  std::sort(vClusters.begin(), vClusters.end(), DefCaloClusterCompare());
+  auto compare = [](const xAOD::CaloVertexedTopoCluster& left, const xAOD::CaloVertexedTopoCluster& right) {
+    return left.e() > right.e();
+  };
+  std::sort(vertexedClusterList.begin(), vertexedClusterList.end(), compare);
 
   // determine energy sum of leading 2 and leading 3 clusters
   float sum2LeadClusterE = 0.;
-  if(vClusters.size()>0) {
-    sum2LeadClusterE = vClusters.at(0)->e();
-    if(vClusters.size()>1) sum2LeadClusterE += vClusters.at(1)->e();
+  if(vertexedClusterList.size()>0) {
+    sum2LeadClusterE = vertexedClusterList.at(0).e();
+    if(vertexedClusterList.size()>1) sum2LeadClusterE += vertexedClusterList.at(1).e();
   }
   float sum3LeadClusterE = sum2LeadClusterE;
-  if(vClusters.size()>2) sum3LeadClusterE += vClusters.at(2)->e();
+  if(vertexedClusterList.size()>2) sum3LeadClusterE += vertexedClusterList.at(2).e();
 
   if (totalEnergy != 0.) {
     pTau.setDetail(xAOD::TauJetParameters::lead2ClusterEOverAllClusterE, (sum2LeadClusterE / totalEnergy) );
@@ -160,15 +138,18 @@ StatusCode TauSubstructureVariables::execute(xAOD::TauJet& pTau) const {
   float EMEnergy(0.);
   float HADEnergy(0.);
 
-  for (auto cl : vClusters) {
-    float clEnergy = cl->e();
+  for (const xAOD::CaloVertexedTopoCluster& vertexedCluster : vertexedClusterList) {
+    // It is at EM/LC scale for EM/LC seed jets
+    float clEnergy = vertexedCluster.e();
 
-    //Calculate the fractions of energy in different calorimeter layers
-    float PreSampler = cl->eSample(CaloSampling::PreSamplerB) + cl->eSample(CaloSampling::PreSamplerE);
-    float EMLayer1   = cl->eSample(CaloSampling::EMB1) + cl->eSample(CaloSampling::EME1);
-    float EMLayer2   = cl->eSample(CaloSampling::EMB2) + cl->eSample(CaloSampling::EME2);
+    const xAOD::CaloCluster& cluster = vertexedCluster.clust();
+    
+    // Calculate the fractions of energy in different calorimeter layers
+    float PreSampler = cluster.eSample(CaloSampling::PreSamplerB) + cluster.eSample(CaloSampling::PreSamplerE);
+    float EMLayer1   = cluster.eSample(CaloSampling::EMB1) + cluster.eSample(CaloSampling::EME1);
+    float EMLayer2   = cluster.eSample(CaloSampling::EMB2) + cluster.eSample(CaloSampling::EME2);
 
-    float Energy = cl->rawE();
+    float Energy = cluster.rawE();
     float PSSF = Energy != 0 ? (PreSampler + EMLayer1) / Energy : 0;
     float EM2F = Energy != 0 ? EMLayer2 / Energy : 0;
     float EMF = PSSF + EM2F;
diff --git a/Reconstruction/tauRecTools/Root/TauVertexedClusterDecorator.cxx b/Reconstruction/tauRecTools/Root/TauVertexedClusterDecorator.cxx
index 59bfe77f723..b3357e50c71 100644
--- a/Reconstruction/tauRecTools/Root/TauVertexedClusterDecorator.cxx
+++ b/Reconstruction/tauRecTools/Root/TauVertexedClusterDecorator.cxx
@@ -25,7 +25,7 @@ StatusCode TauVertexedClusterDecorator::initialize() {
     ATH_MSG_INFO("Set the cluster state to UNCALIBRATED");
     m_clusterState = xAOD::CaloCluster::State::UNCALIBRATED;
   } 
-  else {
+  else if (! inTrigger()) {
     ATH_MSG_ERROR("Seed jet " << m_seedJet << " not supported !");
     return StatusCode::FAILURE;
   }
@@ -75,13 +75,16 @@ StatusCode TauVertexedClusterDecorator::execute(xAOD::TauJet& tau) const {
   std::vector<xAOD::CaloVertexedTopoCluster> vertexedClusterList;
   for (const xAOD::IParticle* particle : particleList) {
     const xAOD::CaloCluster* cluster = static_cast<const xAOD::CaloCluster*>(particle);
-
+    
     if (vertex) {
       vertexedClusterList.emplace_back(*cluster, m_clusterState, vertex->position());
     }
-    else {
+    else if (!inTrigger()) {
       vertexedClusterList.emplace_back(*cluster, m_clusterState);
     }
+    else {
+      vertexedClusterList.emplace_back(*cluster);
+    }
   }
 
   SG::AuxElement::Accessor<std::vector<xAOD::CaloVertexedTopoCluster>> vertexedClustersAcc("VertexedClusters");
diff --git a/Reconstruction/tauRecTools/src/TauClusterFinder.cxx b/Reconstruction/tauRecTools/src/TauClusterFinder.cxx
index 69ec43a62e0..35aba358877 100644
--- a/Reconstruction/tauRecTools/src/TauClusterFinder.cxx
+++ b/Reconstruction/tauRecTools/src/TauClusterFinder.cxx
@@ -20,6 +20,8 @@ TauRecToolBase(name) {
 
 
 StatusCode TauClusterFinder::execute(xAOD::TauJet& tau) const {
+  tau.clearClusterLinks();
+    
   if (! tau.jetLink().isValid()) {
     ATH_MSG_ERROR("Tau jet link is invalid.");
     return StatusCode::FAILURE;
diff --git a/Reconstruction/tauRecTools/tauRecTools/CaloClusterVariables.h b/Reconstruction/tauRecTools/tauRecTools/CaloClusterVariables.h
index 8a55a68489b..f0d1636a7b5 100644
--- a/Reconstruction/tauRecTools/tauRecTools/CaloClusterVariables.h
+++ b/Reconstruction/tauRecTools/tauRecTools/CaloClusterVariables.h
@@ -26,9 +26,7 @@ public:
     ~CaloClusterVariables() {
     }
 
-    bool update(const xAOD::TauJet& pTau, const ToolHandle<ITauVertexCorrection>& handle); //!< update the internal variables for the given tau
-
-    void setIncSub(bool flag) {m_useSubtractedCluster=flag;}
+    bool update(const xAOD::TauJet& pTau); //!< update the internal variables for the given tau
 
     // ID Variables
     unsigned int numConstituents() { return (unsigned int) m_numConstit; }
@@ -59,9 +57,6 @@ private:
 
     // Calculate the geometrical center of the tau constituents
     TLorentzVector calculateTauCentroid(int nConst, const std::vector<TLorentzVector>& clusterP4Vector);
-
-    // use shower subtracted clusters with PFlow jet seeds
-    bool m_useSubtractedCluster;
 };
 
 //-------------------------------------------------------------------------
diff --git a/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h b/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h
index 28122100371..763799a7cfa 100644
--- a/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h
+++ b/Reconstruction/tauRecTools/tauRecTools/HelperFunctions.h
@@ -24,6 +24,8 @@ namespace tauRecTools
 {
   ANA_MSG_HEADER(msgHelperFunction)
 
+  TLorentzVector getTauAxis(const xAOD::TauJet& tau, bool doVertexCorrection = true);
+
   TLorentzVector GetConstituentP4(const xAOD::JetConstituent& constituent);
 
   const StatusCode GetJetClusterList(const xAOD::Jet* jet, std::vector<const xAOD::CaloCluster*> &clusterList, bool useSubtractedCluster);
diff --git a/Reconstruction/tauRecTools/tauRecTools/TauSubstructureVariables.h b/Reconstruction/tauRecTools/tauRecTools/TauSubstructureVariables.h
index 11012f49bfe..9589a039af3 100644
--- a/Reconstruction/tauRecTools/tauRecTools/TauSubstructureVariables.h
+++ b/Reconstruction/tauRecTools/tauRecTools/TauSubstructureVariables.h
@@ -6,9 +6,8 @@
 #define TAUREC_TAUSUBSTRUCTUREBUILDER_H
 
 #include "tauRecTools/TauRecToolBase.h"
-#include "tauRecTools/ITauVertexCorrection.h"
 
-#include "AsgTools/ToolHandle.h"
+#include <string>
 
 /**
  * @brief Calculate variables from the tau substructure.
@@ -18,26 +17,23 @@
  * 
  */
 
-class TauSubstructureVariables : public TauRecToolBase
-{
-    public: 
-	    ASG_TOOL_CLASS2(TauSubstructureVariables, TauRecToolBase, ITauToolBase)
-        
-        static const float DEFAULT;
+class TauSubstructureVariables : public TauRecToolBase {
 
-        TauSubstructureVariables(const std::string& name="TauSubstructureVariables");
+public: 
 
-        ~TauSubstructureVariables();
+  ASG_TOOL_CLASS2(TauSubstructureVariables, TauRecToolBase, ITauToolBase)
+  
+  TauSubstructureVariables(const std::string& name="TauSubstructureVariables");
 
-        virtual StatusCode initialize() override;
-        virtual StatusCode execute(xAOD::TauJet& pTau) const override;
+  virtual ~TauSubstructureVariables() = default;
 
-    private:
-	// use shower subtracted clusters with PFlow jet seeds
-	bool m_useSubtractedCluster;
-  
-    ToolHandle<ITauVertexCorrection> m_tauVertexCorrection { this, 
-      "TauVertexCorrection", "TauVertexCorrection", "Tool to perform the vertex correction"};
+  virtual StatusCode execute(xAOD::TauJet& pTau) const override;
+
+  static const float DEFAULT;
+
+private:
+
+  bool m_doVertexCorrection;
 };
 
 #endif
diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
index 6b7a3da19b9..d7a5d98d0d4 100644
--- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
+++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
@@ -377,8 +377,7 @@ def getTauSubstructure():
     
     from tauRecTools.tauRecToolsConf import TauSubstructureVariables
     TauSubstructureVariables = TauSubstructureVariables(  name = _name,
-                                                          TauVertexCorrection = getTauVertexCorrection()
-                                                        )
+                                                          VertexCorrection = doVertexCorrection)
     
     cached_instances[_name] = TauSubstructureVariables
     return TauSubstructureVariables
@@ -713,6 +712,39 @@ def getTauTrackFinder(applyZ0cut=False, maxDeltaZ0=2, noSelector = False, prefix
     cached_instances[_name] = TauTrackFinder      
     return TauTrackFinder
 
+
+# Associate the cluster in jet constituents to the tau candidate
+def getTauClusterFinder():
+    _name = sPrefix + 'TauClusterFinder'
+
+    if _name in cached_instances:
+        return cached_instances[_name]
+  
+    from tauRecTools.tauRecToolsConf import TauClusterFinder
+    TauClusterFinder = TauClusterFinder(name = _name,
+                                        JetVertexCorrection = False)
+
+    cached_instances[_name] = TauClusterFinder
+    return TauClusterFinder
+
+
+def getTauVertexedClusterDecorator():
+    from tauRecTools.tauRecToolsConf import TauVertexedClusterDecorator
+
+    _name = sPrefix + 'TauVertexedClusterDecorator'
+    
+    if _name in cached_instances:
+        return cached_instances[_name]
+  
+    myTauVertexedClusterDecorator = TauVertexedClusterDecorator(name = _name,
+                                                                SeedJet = "",
+                                                                VertexCorrection = doVertexCorrection,
+                                                                JetVertexCorrection = False)
+    
+    cached_instances[_name] = myTauVertexedClusterDecorator
+    return myTauVertexedClusterDecorator
+
+
 ########################################################################
 # TauTrackClassifier
 def getTauTrackClassifier():
diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfig.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfig.py
index 4298178c422..61d165b21ca 100644
--- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfig.py
+++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfig.py
@@ -34,6 +34,8 @@ class TrigTauRecMerged_Tau (TrigTauRecMerged) :
             tools.append(taualgs.getTauVertexFinder(doUseTJVA=False)) #don't use TJVA by default
             tools.append(taualgs.getTauAxis())
             tools.append(taualgs.getTauTrackFinder())
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             tools.append(taualgs.getEnergyCalibrationLC())
             tools.append(taualgs.getCellVariables(cellConeSize=0.4))
             
@@ -90,6 +92,8 @@ class TrigTauRecMerged_Tau2012 (TrigTauRecMerged) :
             tools.append(taualgs.getTauVertexFinder(doUseTJVA=False)) #don't use TJVA by default
             tools.append(taualgs.getTauAxis())
             tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=2))
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             tools.append(taualgs.getEnergyCalibrationLC())
 
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))  #cellConeSize 0.2!!
@@ -143,6 +147,9 @@ class TrigTauRecMerged_TauPreselection (TrigTauRecMerged) :
             # Insert bypass later?
             # Count tracks with deltaZ0 cut of 2mm for 2016 and 1mm for 2017-2018 (see ATR-15845)
             tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=1, noSelector=False))
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -205,6 +212,9 @@ class TrigTauRecMerged_TauFTK (TrigTauRecMerged) :
             # Count tracks with deltaZ0 cut of 2mm -> Need to remove quality criteria for fast-tracks here
             # Insert bypass later?
             tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=2, noSelector = False))
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -260,6 +270,9 @@ class TrigTauRecMerged_TauCaloOnly (TrigTauRecMerged) :
             tools.append(taualgs.getJetSeedBuilder())
             # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
             tools.append(taualgs.getTauAxis())
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC(caloOnly=True))
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -304,6 +317,9 @@ class TrigTauRecMerged_TauCaloOnlyMVA (TrigTauRecMerged) :
             tools.append(taualgs.getJetSeedBuilder())
             # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
             tools.append(taualgs.getTauAxis())
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC(caloOnly=True))
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -356,6 +372,9 @@ class TrigTauRecMerged_TauPrecision (TrigTauRecMerged) :
             tools.append(taualgs.getTauAxis())
             # Count tracks with deltaZ0 cut of 2mm for 2016 and 1mm for 2017-2018 (see ATR-15845)
             tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=1))
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -440,6 +459,9 @@ class TrigTauRecMerged_TauPrecisionMVA (TrigTauRecMerged) :
                 # tightened to 0.75 mm for tracktwoMVA (until the track BDT can be used)
                 tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=0.75, prefix='TrigTauTightDZ_'))            
 
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to calo TES
             tools.append(taualgs.getEnergyCalibrationLC())
 
diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py
index 3eba0a9e3e0..675072af222 100644
--- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py
+++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py
@@ -22,6 +22,9 @@ class TrigTauRecMerged_TauCaloOnly (TrigTauRecMergedMT) :
             tools.append(taualgs.getJetSeedBuilder())
             # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
             tools.append(taualgs.getTauAxis())
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC(caloOnly=True))
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -55,6 +58,9 @@ class TrigTauRecMerged_TauCaloOnlyMVA (TrigTauRecMergedMT) :
             tools.append(taualgs.getJetSeedBuilder())
             # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
             tools.append(taualgs.getTauAxis())
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC(caloOnly=True))
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -94,6 +100,9 @@ class TrigTauRecMerged_TauPreselection (TrigTauRecMergedMT) :
             # Insert bypass later?
             # Count tracks with deltaZ0 cut of 2mm for 2016 and 1mm for 2017-2018 (see ATR-15845)
             tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=1, noSelector=False))
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -137,6 +146,9 @@ class TrigTauRecMerged_TauPrecision (TrigTauRecMergedMT) :
             tools.append(taualgs.getTauAxis())
             # Count tracks with deltaZ0 cut of 2mm for 2016 and 1mm for 2017-2018 (see ATR-15845)
             tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=1))
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
             # Calibrate to TES
             tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
@@ -201,6 +213,10 @@ class TrigTauRecMerged_TauPrecisionMVA (TrigTauRecMergedMT) :
             else:
                 # tightened to 0.75 mm for tracktwoMVA (until the track BDT can be used)
                 tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=0.75, prefix='TrigTauTightDZ_'))            
+            
+            # Decorate the clusters
+            tools.append(taualgs.getTauClusterFinder())
+            tools.append(taualgs.getTauVertexedClusterDecorator())
 
             if doTrackBDT:                
                 # BDT track classification
diff --git a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun2.py b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun2.py
index cccc53d349e..49fc8d4055e 100644
--- a/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun2.py
+++ b/Trigger/TriggerCommon/TrigEDMConfig/python/TriggerEDMRun2.py
@@ -89,7 +89,7 @@ UnusedProperties = ["Likelihood", "SafeLikelihood", "BDTEleScore", "BDTJetScoreS
                     "vetoFlags", "isTauFlags", "trackFlags", "trackFilterProngs", "trackFilterQuality", "trackEtaStrip", "trackPhiStrip",
                     "TauJetVtxFraction", "LeadClusterFrac", "UpsilonCluster", "ClustersMeanSecondLambda", "ClustersMeanEMProbability", 
                     "ClustersMeanCenterLambda", "ClustersMeanPresamplerFrac", "mu", "nVtxPU", "ClustersMeanFirstEngDens", "nModifiedIsolationTracks",
-                    "NUMWIDETRACK", "NUMTRACK", "MU", "absipSigLeadTrk" ]
+                    "NUMWIDETRACK", "NUMTRACK", "MU", "absipSigLeadTrk", "VertexedClusters" ]
 
 UnusedFourMom = ["ptIntermediateAxis", "etaIntermediateAxis", "phiIntermediateAxis", "mIntermediateAxis",
                  "ptTauEtaCalib", "etaTauEtaCalib", "phiTauEtaCalib", "mTauEtaCalib", "EM_TES_scale"]
-- 
GitLab