diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/CMakeLists.txt b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/CMakeLists.txt
index 6bdd7e30959afb3b3b8682bc270cbfd0d3fdae78..fa3659bf451ee152a37a3d6fe0ce835720698536 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/CMakeLists.txt
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/CMakeLists.txt
@@ -16,9 +16,11 @@ atlas_depends_on_subdirs(
    Event/xAOD/xAODJet
    Event/xAOD/xAODMuon
    Event/xAOD/xAODTracking
+   Event/xAOD/FourMomUtils
    PhysicsAnalysis/DerivationFramework/DerivationFrameworkInterfaces
    Tracking/TrkVertexFitter/TrkVKalVrtFitter
    Tracking/TrkVertexFitter/TrkVertexFitterInterfaces
+   Tracking/TrkVertexFitter/TrkVertexAnalysisUtils
    Trigger/TrigAnalysis/TrigDecisionTool
    PRIVATE
    GaudiKernel
@@ -42,8 +44,8 @@ atlas_add_component( DerivationFrameworkHiggs
    DerivationFrameworkHiggs/*.h src/*.cxx src/components/*.cxx
    INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
    LINK_LIBRARIES ${CLHEP_LIBRARIES} ${ROOT_LIBRARIES} AthenaBaseComps
-   xAODEgamma xAODJet xAODMuon xAODTracking TrkVKalVrtFitterLib
-   TrkVertexFitterInterfaces TrigDecisionToolLib xAODEventInfo
+   xAODEgamma xAODJet xAODMuon xAODTracking FourMomUtils TrkVKalVrtFitterLib
+   TrkVertexFitterInterfaces TrkVertexAnalysisUtilsLib TrigDecisionToolLib xAODEventInfo
    GaudiKernel VxVertex xAODTrigger PhotonVertexSelection AthContainers
    TruthConvertersLib TruthRivetToolsLib TruthUtils PathResolver EgammaAnalysisInterfacesLib )
 
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/DerivationFrameworkHiggs/MergedElectronDetailsDecorator.h b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/DerivationFrameworkHiggs/MergedElectronDetailsDecorator.h
index 21bf2d00bd62edd2b29969eed84a94a27f619579..6ad62d6083a307ea2fc3504be85d01c34e22da21 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/DerivationFrameworkHiggs/MergedElectronDetailsDecorator.h
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/DerivationFrameworkHiggs/MergedElectronDetailsDecorator.h
@@ -1,10 +1,10 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
-// Tool to decorate the Electrons object with additional information for merged electron ID 
+// Tool to decorate the Electrons object with additional information for merged electron ID
 // Authors: A.Morley
-	
+
 #ifndef DerivationFrameworkHiggs_MergedElectronDetailsDecorator_H
 #define DerivationFrameworkHiggs_MergedElectronDetailsDecorator_H
 
@@ -19,14 +19,21 @@
 #include "DerivationFrameworkInterfaces/IAugmentationTool.h"
 
 #include "xAODTracking/TrackParticleContainer.h"
+#include "xAODEgamma/ElectronContainer.h"
 #include "xAODCaloEvent/CaloClusterContainer.h"
 
+namespace Trk{
+  class V0Tools;
+  class IVertexFitter;
+}
+
+
 class IEMExtrapolationTools;
 
 namespace DerivationFramework {
-  
+
   class MergedElectronDetailsDecorator : public AthAlgTool, public IAugmentationTool {
-        
+
   public:
     MergedElectronDetailsDecorator(const std::string& t, const std::string& n, const IInterface* p);
     ~MergedElectronDetailsDecorator();
@@ -37,13 +44,20 @@ namespace DerivationFramework {
   private:
 
     void fillMatchDetails( std::vector<float>& trkMatchTrk, const  xAOD::TrackParticle* tp, const xAOD::CaloCluster* cluster) const;
+    int  nSiHits( const xAOD::TrackParticle * tp ) const;
+    void fillTrackDetails(const xAOD::Electron* el) const;
+    void fillVertexDetails(const xAOD::Electron* el) const;
+    void fillClusterDetails(const xAOD::Electron* el) const;
+
 
-    ToolHandle<IEMExtrapolationTools> m_emExtrapolationTool; 
+    ToolHandle<IEMExtrapolationTools> m_emExtrapolationTool;
+    ToolHandle<Trk::IVertexFitter>    m_VertexFitter;
+    ToolHandle<Trk::V0Tools>          m_V0Tools;
 
     float m_minET;
-    
+
   }; /// class
-  
+
 } /// namespace
 
 #endif
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/share/HIGG1D2.py b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/share/HIGG1D2.py
index 63a624d2945a84bf4a341a979b2eb91db4f34dd0..8b0e2abcbe28586ba8119124ee9f9af30f98845c 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/share/HIGG1D2.py
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/share/HIGG1D2.py
@@ -1,6 +1,6 @@
 #====================================================================
 # HIGG1D2.py
-# This requires the reductionConf flag HIGG1D2 in Reco_tf.py   
+# This requires the reductionConf flag HIGG1D2 in Reco_tf.py
 #====================================================================
 
 from DerivationFrameworkCore.DerivationFrameworkMaster import *
@@ -29,7 +29,7 @@ if DerivationFrameworkIsMonteCarlo:
 
 
 #====================================================================
-# SKIMMING TOOLS 
+# SKIMMING TOOLS
 #====================================================================
 
 
@@ -38,7 +38,7 @@ print "HIGG1D2.py SkipTriggerRequirement: ",  SkipTriggerRequirement
 TriggerExp = []
 TriggerMerged = []
 if not SkipTriggerRequirement:
-   
+
    try:
      year=int(rec.projectName()[4:6])
      if year > 18 :
@@ -50,18 +50,18 @@ if not SkipTriggerRequirement:
    print "HIGG1D2.py: Setting up trigger requirement for year 20" + str(year)
    if year==17 or year==18:
      TriggerMerged          = ["HLT_e25_mergedtight_g35_medium_Heg","HLT_e30_mergedtight_g35_medium_Heg","HLT_2g50_loose_L12EM20VH","HLT_e24_lhmedium_nod0_L1EM20VH_g25_medium","HLT_g35_medium_g25_medium_L12EM20VH"]
-     TriggerExp             = [ 
+     TriggerExp             = [
                                "HLT_g25_medium_mu24", #photon muon
                                "HLT_g15_loose_2mu10_msonly", #photon dimuon
                                "HLT_g35_loose_L1EM24VHI_mu15_mu2noL1", # photon dimuon
                                "HLT_g35_loose_L1EM24VHI_mu18",  #photon muon
-                               "HLT_g35_tight_icalotight_L1EM24VHI_mu15noL1_mu2noL1", # photon dimuon 
+                               "HLT_g35_tight_icalotight_L1EM24VHI_mu15noL1_mu2noL1", # photon dimuon
                                "HLT_g35_tight_icalotight_L1EM24VHI_mu18noL1", # photon muon
-                               "HLT_2mu14", #dimuon 
+                               "HLT_2mu14", #dimuon
                                "HLT_mu22_mu8noL1", #dimuon
                                "HLT_mu26_ivarmedium", #single muon
-                               "HLT_mu50", 
-                               "HLT_mu60_0eta105_msonly", 
+                               "HLT_mu50",
+                               "HLT_mu60_0eta105_msonly",
                                "HLT_e26_lhtight_nod0_ivarloose", #single electron
                                "HLT_e60_lhmedium_nod0",
                                "HLT_e140_lhloose_nod0",
@@ -79,18 +79,18 @@ if not SkipTriggerRequirement:
    elif year==16:
      #2016
      TriggerMerged          = ["HLT_g35_loose_g25_loose","HLT_g35_medium_g25_medium","HLT_e20_lhmedium_nod0_g35_loose"]
-     TriggerExp             = [ 
+     TriggerExp             = [
                                "HLT_g25_medium_mu24", #photon muon
                                "HLT_g15_loose_2mu10_msonly", #photon dimuon
                                "HLT_g35_loose_L1EM22VHI_mu15noL1_mu2noL1", # photon dimuon
                                "HLT_g35_loose_L1EM22VHI_mu18noL1",  #photon muon
                                "HLT_2mu10",
-                               "HLT_2mu14", #dimuon 
+                               "HLT_2mu14", #dimuon
                                "HLT_mu22_mu8noL1", #dimuon
                                "HLT_mu20_mu8noL1",
                                "HLT_mu24_ivarmedium", #single muon
                                "HLT_mu26_ivarmedium",
-                               "HLT_mu50", 
+                               "HLT_mu50",
                                "HLT_e24_lhtight_nod0_ivarloose", #single electron
                                "HLT_e26_lhtight_nod0_ivarloose",
                                "HLT_e60_lhmedium_nod0",
@@ -104,17 +104,17 @@ if not SkipTriggerRequirement:
                                "HLT_g140_loose", #single photon
                                "HLT_g300_etcut"  #single photon
                               ]
-   elif year ==15: 
+   elif year ==15:
      #2015
      TriggerMerged          = ["HLT_g35_loose_g25_loose","HLT_e20_lhmedium_g35_loose"]
-     TriggerExp             = [ 
+     TriggerExp             = [
                                "HLT_g25_medium_mu24", #photon muon
                                "HLT_g15_loose_2mu10_msonly", #photon dimuon
-                               "HLT_2mu10", #dimuon 
+                               "HLT_2mu10", #dimuon
                                "HLT_mu18_mu8noL1", #dimuon
                                "HLT_mu20_iloose_L1MU15", #single muon
-                               "HLT_mu40", 
-                               "HLT_mu60_0eta105_msonly", 
+                               "HLT_mu40",
+                               "HLT_mu60_0eta105_msonly",
                                "HLT_e24_lhmedium_L1EM20VH", #single electron
                                "HLT_e60_lhmedium",
                                "HLT_e120_lhloose",
@@ -125,7 +125,7 @@ if not SkipTriggerRequirement:
                                "HLT_g200_etcut"  #single photon
                               ]
    else:
-     print "HIGG1D2.py : Year not supported -- results might be ugly. Year : ", year 
+     print "HIGG1D2.py : Year not supported -- results might be ugly. Year : ", year
      SkipTriggerRequirement =  True
 
 
@@ -142,7 +142,7 @@ MergedElectronIsEM = CfgMgr.AsgElectronIsEMSelector("MergedElectronIsEM",
                                              isEMMask=egammaPID.ElectronTightHLT,
                                              ConfigFile="ElectronPhotonSelectorTools/trigger/rel21_20161021/ElectronIsEMMergedTightSelectorCutDefs.conf")
 ToolSvc += MergedElectronIsEM
-    
+
 
 from DerivationFrameworkHiggs.DerivationFrameworkHiggsConf import DerivationFramework__SkimmingToolHIGG1
 HIGG1D2SkimmingTool = DerivationFramework__SkimmingToolHIGG1(
@@ -167,9 +167,9 @@ HIGG1D2SkimmingTool = DerivationFramework__SkimmingToolHIGG1(
                                  IncludeHighPtPhotonElectronPreselection = True,
                                  MinimumPhotonPt = 7.5*GeV,
                                  MinimumElectronPt = 7.5*GeV,
-                                 MinimumMuonPt = 7.5*GeV,   
-                                 MaxMuonEta = 2.7,     
-                                 RemoveCrack = False,    
+                                 MinimumMuonPt = 7.5*GeV,
+                                 MaxMuonEta = 2.7,
+                                 RemoveCrack = False,
                                  MaxEta = 2.5,
                                  MergedElectronCutTool = MergedElectronIsEM
                                  )
@@ -265,7 +265,7 @@ truth_cond_finalState = '(TruthParticles.status == 1 && TruthParticles.barcode <
 truth_expression = '('+truth_cond_1+' || '+truth_cond_2 +' || '+truth_cond_3 +' || '+truth_cond_4+') || ('+truth_cond_finalState+')'
 
 from DerivationFrameworkMCTruth.DerivationFrameworkMCTruthConf import DerivationFramework__GenericTruthThinning
-HIGG1D2TruthThinningTool = DerivationFramework__GenericTruthThinning(name                    = "HIGG1D2TruthThinningTool", 
+HIGG1D2TruthThinningTool = DerivationFramework__GenericTruthThinning(name                    = "HIGG1D2TruthThinningTool",
                                                                       ThinningService         = "HIGG1D2ThinningSvc",
                                                                       ParticleSelectionString = truth_expression,
                                                                       PreserveDescendants     = False,
@@ -283,18 +283,24 @@ print "HIGG1D2.py thinningTools", thinningTools
 
 
 #====================================================================
-# AugmentationTools 
+# AugmentationTools
 #====================================================================
 
 from egammaTrackTools.egammaTrackToolsFactories import EMExtrapolationTools
-egammaExtrapolationTool = EMExtrapolationTools(name = 'egammaExtrapolationTool')
+egammaExtrapolationTool = EMExtrapolationTools(name = 'egammaExtrapolationTool',
+                                               NarrowDeltaEta = 0.5,
+                                               NarrowDeltaPhi = 0.5,
+                                               NarrowDeltaPhiBrem = 1.5)
+
 ToolSvc += egammaExtrapolationTool
 
+include('DerivationFrameworkHiggs/configureVertexFitter.py')
 
 from DerivationFrameworkHiggs.DerivationFrameworkHiggsConf import DerivationFramework__MergedElectronDetailsDecorator
 HIGG1D2MergedElectronDetailsDecorator = DerivationFramework__MergedElectronDetailsDecorator(
                                  name = "HIGG1D2MergedElectronDetailsDecorator",
-                                 EMExtrapolationTool = egammaExtrapolationTool
+                                 EMExtrapolationTool = egammaExtrapolationTool,
+                                 VertexFitterTool = TrkVKalVrtFitter
                                  )
 
 ToolSvc += HIGG1D2MergedElectronDetailsDecorator
@@ -307,7 +313,7 @@ print HIGG1D2MergedElectronDetailsDecorator
 HIGG1D2Seq = CfgMgr.AthSequencer("HIGG1D2Sequence")
 
 #====================================================================
-# CREATE THE DERIVATION KERNEL ALGORITHM AND PASS THE ABOVE TOOLS  
+# CREATE THE DERIVATION KERNEL ALGORITHM AND PASS THE ABOVE TOOLS
 #====================================================================
 
 # The name of the kernel (LooseSkimKernel in this case) must be unique to this derivation
@@ -333,7 +339,7 @@ replaceAODReducedJets(reducedJetList,HIGG1D2Seq,"HIGG1D2Jets")
 DerivationFrameworkJob += HIGG1D2Seq
 
 #====================================================================
-# SET UP STREAM   
+# SET UP STREAM
 #====================================================================
 streamName = derivationFlags.WriteDAOD_HIGG1D2Stream.StreamName
 fileName   = buildFileName( derivationFlags.WriteDAOD_HIGG1D2Stream )
@@ -381,7 +387,7 @@ HIGG1D2SlimmingHelper.ExtraVariables = ["PhotonsAux.DFCommonPhotonsIsEMTightPtIn
                                         "AntiKt4EMTopoJets.JetEMScaleMomentum_pt.JetEMScaleMomentum_eta.JetEMScaleMomentum_phi.JetEMScaleMomentum_m.PartonTruthLabelID.Jvt.JVFCorr.JvtRpt.ConstituentScale",
                                         "AntiKt4EMPFlowJets.JetEMScaleMomentum_pt.JetEMScaleMomentum_eta.JetEMScaleMomentum_phi.JetEMScaleMomentum_m.PartonTruthLabelID.Jvt.JVFCorr.JvtRpt.ConstituentScale",
                                         "CombinedMuonTrackParticles.z0.vz.definingParametersCovMatrix",
-                                        "BTagging_AntiKt4EMTopo.MV1_discriminant",                                        
+                                        "BTagging_AntiKt4EMTopo.MV1_discriminant",
                                         "ExtrapolatedMuonTrackParticles.z0.vz.definingParametersCovMatrix",
                                         "MuonTruthParticles.truthOrigin.truthType"]
 
diff --git a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/src/MergedElectronDetailsDecorator.cxx b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/src/MergedElectronDetailsDecorator.cxx
index 88251f9613007f45bdca6fb32c3882c6cd42d5b4..bd48d8ef902e788dc5f62328a4a6c194d79933c6 100644
--- a/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/src/MergedElectronDetailsDecorator.cxx
+++ b/PhysicsAnalysis/DerivationFramework/DerivationFrameworkHiggs/src/MergedElectronDetailsDecorator.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -9,41 +9,64 @@
 #include "xAODCaloEvent/CaloClusterContainer.h"
 
 #include "egammaInterfaces/IEMExtrapolationTools.h"
+#include "TrkVertexFitterInterfaces/IVertexFitter.h"
+#include "TrkVertexAnalysisUtils/V0Tools.h"
+#include "FourMomUtils/P4Helpers.h"
+
 #include <vector>
 
 namespace DerivationFramework {
-  
+
   MergedElectronDetailsDecorator::MergedElectronDetailsDecorator(const std::string& t, const std::string& n, const IInterface* p):
     AthAlgTool(t,n,p),
     m_emExtrapolationTool("EMExtrapolationTools"),
+    m_VertexFitter("Trk::TrkVkalVrtFitter"),
+    m_V0Tools("Trk::V0Tools"),
     m_minET(5000)
   {
     declareInterface<DerivationFramework::IAugmentationTool>(this);
     declareProperty("EMExtrapolationTool",m_emExtrapolationTool);
+    declareProperty("VertexFitterTool",m_VertexFitter);
+    declareProperty("V0Tools",m_V0Tools);
     declareProperty("MinET",m_minET);
   }
-  
+
   MergedElectronDetailsDecorator::~MergedElectronDetailsDecorator() {}
-  
-  
+
+
   StatusCode MergedElectronDetailsDecorator::initialize() {
-    
+
     ATH_MSG_INFO("Initialize " );
 
     if (m_emExtrapolationTool.retrieve().isFailure()) {
-      ATH_MSG_FATAL("Failed to retrieve tool: " << m_emExtrapolationTool); 
-      return StatusCode::FAILURE; 
-    } 
+      ATH_MSG_FATAL("Failed to retrieve tool: " << m_emExtrapolationTool);
+      return StatusCode::FAILURE;
+    }
     ATH_MSG_INFO("Retrieved tool: " << m_emExtrapolationTool);
 
+    if (m_VertexFitter.retrieve().isFailure()) {
+      ATH_MSG_FATAL("Failed to retrieve tool: " << m_VertexFitter);
+      return StatusCode::FAILURE;
+    }
+    ATH_MSG_INFO("Retrieved tool: " << m_VertexFitter);
+
+    if (m_V0Tools.retrieve().isFailure()) {
+      ATH_MSG_FATAL("Failed to retrieve tool: " << m_V0Tools);
+      return StatusCode::FAILURE;
+    }
+    ATH_MSG_INFO("Retrieved tool: " << m_V0Tools);
+
+
+
+
     return StatusCode::SUCCESS;
   }
-  
+
   StatusCode MergedElectronDetailsDecorator::finalize(){
     return StatusCode::SUCCESS;
   }
-  
-  StatusCode MergedElectronDetailsDecorator::addBranches() const{    
+
+  StatusCode MergedElectronDetailsDecorator::addBranches() const{
 
     // Retrieve the xAOD event info
     const xAOD::ElectronContainer *electrons = nullptr;
@@ -54,128 +77,255 @@ namespace DerivationFramework {
     }
 
     for( const auto& el : *electrons ){
-      
-      std::vector<float> trkMatchTrkP_dEta1(el->nTrackParticles(),-999);
-      std::vector<float> trkMatchTrkP_dEta2(el->nTrackParticles(),-999);
-      std::vector<float> trkMatchTrkP_dPhi1(el->nTrackParticles(),-999);
-      std::vector<float> trkMatchTrkP_dPhi2(el->nTrackParticles(),-999);
-      std::vector<float> trkMatchTrkLM_dEta1(el->nTrackParticles(),-999);
-      std::vector<float> trkMatchTrkLM_dEta2(el->nTrackParticles(),-999);
-      std::vector<float> trkMatchTrkLM_dPhi1(el->nTrackParticles(),-999);
-      std::vector<float> trkMatchTrkLM_dPhi2(el->nTrackParticles(),-999);
-
-      auto caloCluster =  el->caloCluster();
-
-      if( caloCluster && caloCluster->pt() > m_minET ){ 
-        std::vector<float> trkMatch(8,-999);
-        for( unsigned int i(0); i < el->nTrackParticles(); ++i ){
-          auto trackParticle = el->trackParticle( i );
-          if(trackParticle){        
-            fillMatchDetails( trkMatch, trackParticle, caloCluster);
-            trkMatchTrkP_dEta1[i]  = trkMatch[0];
-            trkMatchTrkP_dEta2[i]  = trkMatch[1];
-            trkMatchTrkP_dPhi1[i]  = trkMatch[2];
-            trkMatchTrkP_dPhi2[i]  = trkMatch[3];
-            trkMatchTrkLM_dEta1[i] = trkMatch[4];
-            trkMatchTrkLM_dEta2[i] = trkMatch[5];
-            trkMatchTrkLM_dPhi1[i] = trkMatch[6];
-            trkMatchTrkLM_dPhi2[i] = trkMatch[7];
-          }
-        }  
-      }
-
-      el->auxdecor<std::vector<float>>("TrackMatchingP_dEta1") = trkMatchTrkP_dEta1;
-      el->auxdecor<std::vector<float>>("TrackMatchingP_dEta2") = trkMatchTrkP_dEta2;
-      el->auxdecor<std::vector<float>>("TrackMatchingP_dPhi1") = trkMatchTrkP_dPhi1;
-      el->auxdecor<std::vector<float>>("TrackMatchingP_dPhi2") = trkMatchTrkP_dPhi2;
-      el->auxdecor<std::vector<float>>("TrackMatchingLM_dEta1") = trkMatchTrkLM_dEta1;
-      el->auxdecor<std::vector<float>>("TrackMatchingLM_dEta2") = trkMatchTrkLM_dEta2;
-      el->auxdecor<std::vector<float>>("TrackMatchingLM_dPhi1") = trkMatchTrkLM_dPhi1;
-      el->auxdecor<std::vector<float>>("TrackMatchingLM_dPhi2") = trkMatchTrkLM_dPhi2;
-   
-
-      std::vector<float> subCluster_E;
-      std::vector<float> subCluster_dEta;
-      std::vector<float> subCluster_dPhi;
-
-      static SG::AuxElement::Accessor<std::vector<ElementLink<xAOD::CaloClusterContainer> > > clusterLinksAcc("constituentClusterLinks");
-      if(caloCluster && clusterLinksAcc.isAvailable(*caloCluster) ){
-        std::vector<ElementLink<xAOD::CaloClusterContainer> >  clusterLinks = clusterLinksAcc(*caloCluster);
-        for( auto link : clusterLinks){
-          if( link.isValid() ){
-            subCluster_E.push_back( (*link)->e() );
-            subCluster_dEta.push_back( caloCluster->eta() - (*link)->eta() );
-            float dphi =  caloCluster->phi() - (*link)->phi();
-            while( dphi > TMath::Pi() )
-              dphi -= TMath::Pi() * 2; 
-            while( dphi < -TMath::Pi() )
-              dphi += TMath::Pi() * 2;
-            subCluster_dPhi.push_back(dphi);
-          }
-        }
-      }
-      el->auxdecor<std::vector<float>>("SubCluster_E") = subCluster_E;
-      el->auxdecor<std::vector<float>>("SubCluster_dEta") = subCluster_dEta;
-      el->auxdecor<std::vector<float>>("SubCluster_dPhi") = subCluster_dPhi;
+      fillTrackDetails(el);
+      fillVertexDetails(el);
+      fillClusterDetails(el);
     }
 
     return StatusCode::SUCCESS;
 
   } // addBranches
-  
- 
-  void DerivationFramework::MergedElectronDetailsDecorator::fillMatchDetails( std::vector<float>& trkMatchTrk, 
-                                                                              const xAOD::TrackParticle* tp, 
+
+
+  void DerivationFramework::MergedElectronDetailsDecorator::fillMatchDetails( std::vector<float>& trkMatchTrk,
+                                                                              const xAOD::TrackParticle* tp,
                                                                               const xAOD::CaloCluster* cluster) const {
 
+    //Reset values
+    for(unsigned int i(0); i<trkMatchTrk.size(); ++i ){
+      trkMatchTrk[i] = -999;
+    }
+
     std::vector<double>  eta(4, -999.0);
-    std::vector<double>  phi(4, -999.0);   
+    std::vector<double>  phi(4, -999.0);
     std::vector<double>  deltaEta(4, -999.0);
-    std::vector<double>  deltaPhi(4, -999.0);   
-  
-    uint8_t dummy(-1);
-    int nPix = tp->summaryValue( dummy, xAOD::numberOfPixelHits )? dummy :-1;
-    int nPix_DS = tp->summaryValue( dummy, xAOD::numberOfPixelDeadSensors )? dummy :-1;
-    int nSCT = tp->summaryValue( dummy, xAOD::numberOfSCTHits )? dummy :-1; 
-    int nSCT_DS = tp->summaryValue( dummy, xAOD::numberOfSCTDeadSensors )? dummy :-1;
-
-    bool isTRT = nPix + nPix_DS + nSCT + nSCT_DS < 7 ? true : false;
-   
-    if(isTRT) 
-      return; 
-
-    if(m_emExtrapolationTool->matchesAtCalo (cluster, 
-                                           tp, 
+    std::vector<double>  deltaPhi(4, -999.0);
+
+    bool isTRT = nSiHits(tp) < 7 ? true : false;
+
+    // Dont bother to extrapolate TRT only tracks
+    if(isTRT)
+      return;
+
+
+    if(m_emExtrapolationTool->matchesAtCalo (cluster,
+                                           tp,
                                            isTRT,
-                                           Trk::alongMomentum, 
+                                           Trk::alongMomentum,
                                            eta,
                                            phi,
-                                           deltaEta, 
-                                           deltaPhi, 
+                                           deltaEta,
+                                           deltaPhi,
                                            IEMExtrapolationTools::fromPerigee)) // Perigee
     {
-      trkMatchTrk[0] = deltaEta[1];   
-      trkMatchTrk[1] = deltaEta[2];   
-      trkMatchTrk[2] = deltaPhi[1];   
-      trkMatchTrk[3] = deltaPhi[2];   
+      trkMatchTrk[0] = deltaEta[1];
+      trkMatchTrk[1] = deltaEta[2];
+      trkMatchTrk[2] = deltaPhi[1];
+      trkMatchTrk[3] = deltaPhi[2];
     }
-    
-    if(m_emExtrapolationTool->matchesAtCalo (cluster, 
-                                           tp, 
+
+    if(m_emExtrapolationTool->matchesAtCalo (cluster,
+                                           tp,
                                            isTRT,
-                                           Trk::alongMomentum, 
+                                           Trk::alongMomentum,
                                            eta,
                                            phi,
-                                           deltaEta, 
-                                           deltaPhi, 
+                                           deltaEta,
+                                           deltaPhi,
                                            IEMExtrapolationTools::fromLastMeasurement)) //Last Measurement
     {
-      trkMatchTrk[4] = deltaEta[1];   
-      trkMatchTrk[5] = deltaEta[2];   
-      trkMatchTrk[6] = deltaPhi[1];   
-      trkMatchTrk[7] = deltaPhi[2];   
+      trkMatchTrk[4] = deltaEta[1];
+      trkMatchTrk[5] = deltaEta[2];
+      trkMatchTrk[6] = deltaPhi[1];
+      trkMatchTrk[7] = deltaPhi[2];
     }
 
+    if(m_emExtrapolationTool->matchesAtCalo (cluster,
+                                           tp,
+                                           isTRT,
+                                           Trk::alongMomentum,
+                                           eta,
+                                           phi,
+                                           deltaEta,
+                                           deltaPhi,
+                                           IEMExtrapolationTools::fromPerigeeRescaled)) //Last Measurement
+    {
+      trkMatchTrk[8] = deltaPhi[2];
+    }
   }
 
+
+  int  DerivationFramework::MergedElectronDetailsDecorator::nSiHits( const xAOD::TrackParticle * tp ) const
+  {
+    uint8_t dummy(-1);
+    int nPix = tp->summaryValue( dummy, xAOD::numberOfPixelHits )? dummy : 0;
+    int nPix_DS = tp->summaryValue( dummy, xAOD::numberOfPixelDeadSensors )? dummy : 0;
+    int nSCT = tp->summaryValue( dummy, xAOD::numberOfSCTHits )? dummy : 0;
+    int nSCT_DS = tp->summaryValue( dummy, xAOD::numberOfSCTDeadSensors )? dummy : 0;
+    return nPix + nPix_DS + nSCT + nSCT_DS;
+  }
+
+
+  void DerivationFramework::MergedElectronDetailsDecorator::fillTrackDetails(const xAOD::Electron* el) const
+  {
+    std::vector<float> trkMatchTrkP_dEta1(el->nTrackParticles(),-999);
+    std::vector<float> trkMatchTrkP_dEta2(el->nTrackParticles(),-999);
+    std::vector<float> trkMatchTrkP_dPhi1(el->nTrackParticles(),-999);
+    std::vector<float> trkMatchTrkP_dPhi2(el->nTrackParticles(),-999);
+    std::vector<float> trkMatchTrkLM_dEta1(el->nTrackParticles(),-999);
+    std::vector<float> trkMatchTrkLM_dEta2(el->nTrackParticles(),-999);
+    std::vector<float> trkMatchTrkLM_dPhi1(el->nTrackParticles(),-999);
+    std::vector<float> trkMatchTrkLM_dPhi2(el->nTrackParticles(),-999);
+    std::vector<float> trkMatchTrkR_dPhi2(el->nTrackParticles(),-999);
+
+    auto caloCluster =  el->caloCluster();
+    if( caloCluster && caloCluster->pt() > m_minET ){
+      std::vector<float> trkMatch(9,-999);
+      for( unsigned int i(0); i < el->nTrackParticles(); ++i ){
+        auto trackParticle = el->trackParticle( i );
+        if(trackParticle){
+          fillMatchDetails( trkMatch, trackParticle, caloCluster);
+          trkMatchTrkP_dEta1[i]  = trkMatch[0];
+          trkMatchTrkP_dEta2[i]  = trkMatch[1];
+          trkMatchTrkP_dPhi1[i]  = trkMatch[2];
+          trkMatchTrkP_dPhi2[i]  = trkMatch[3];
+          trkMatchTrkLM_dEta1[i] = trkMatch[4];
+          trkMatchTrkLM_dEta2[i] = trkMatch[5];
+          trkMatchTrkLM_dPhi1[i] = trkMatch[6];
+          trkMatchTrkLM_dPhi2[i] = trkMatch[7];
+          trkMatchTrkR_dPhi2[i]  = trkMatch[8];
+        }
+      }
+    }
+
+    el->auxdecor<std::vector<float>>("TrackMatchingP_dEta1") = trkMatchTrkP_dEta1;
+    el->auxdecor<std::vector<float>>("TrackMatchingP_dEta2") = trkMatchTrkP_dEta2;
+    el->auxdecor<std::vector<float>>("TrackMatchingP_dPhi1") = trkMatchTrkP_dPhi1;
+    el->auxdecor<std::vector<float>>("TrackMatchingP_dPhi2") = trkMatchTrkP_dPhi2;
+    el->auxdecor<std::vector<float>>("TrackMatchingLM_dEta1") = trkMatchTrkLM_dEta1;
+    el->auxdecor<std::vector<float>>("TrackMatchingLM_dEta2") = trkMatchTrkLM_dEta2;
+    el->auxdecor<std::vector<float>>("TrackMatchingLM_dPhi1") = trkMatchTrkLM_dPhi1;
+    el->auxdecor<std::vector<float>>("TrackMatchingLM_dPhi2") = trkMatchTrkLM_dPhi2;
+    el->auxdecor<std::vector<float>>("TrackMatchingR_dPhi2")  = trkMatchTrkR_dPhi2;
+  }
+
+  void DerivationFramework::MergedElectronDetailsDecorator::fillClusterDetails(const xAOD::Electron* el) const
+  {
+    auto caloCluster =  el->caloCluster();
+
+    std::vector<float> subCluster_E;
+    std::vector<float> subCluster_dEta;
+    std::vector<float> subCluster_dPhi;
+
+    static SG::AuxElement::Accessor<std::vector<ElementLink<xAOD::CaloClusterContainer> > > clusterLinksAcc("constituentClusterLinks");
+    if(caloCluster && clusterLinksAcc.isAvailable(*caloCluster) ){
+      std::vector<ElementLink<xAOD::CaloClusterContainer> >  clusterLinks = clusterLinksAcc(*caloCluster);
+      for( auto link : clusterLinks){
+        if( link.isValid() ){
+          subCluster_E.push_back( (*link)->e() );
+          subCluster_dEta.push_back( caloCluster->eta() - (*link)->eta() );
+          float dphi = P4Helpers::deltaPhi( caloCluster->phi(), (*link)->phi() );
+          subCluster_dPhi.push_back(dphi);
+        }
+      }
+    }
+    el->auxdecor<std::vector<float>>("SubCluster_E") = subCluster_E;
+    el->auxdecor<std::vector<float>>("SubCluster_dEta") = subCluster_dEta;
+    el->auxdecor<std::vector<float>>("SubCluster_dPhi") = subCluster_dPhi;
+  }
+
+
+  void DerivationFramework::MergedElectronDetailsDecorator::fillVertexDetails(const xAOD::Electron* el) const
+  {
+    auto caloCluster =  el->caloCluster();
+
+    float vtxR = -999;
+    float vtxZ = -999;
+    float vtxM = -999;
+    int vtxTrkParticleIndex1 = -999;
+    int vtxTrkParticleIndex2 = -999;
+    float vtxRerr = -999;
+    float vtxZerr = -999;
+    float vtxMerr = -999;
+    float vtxChi2 = -999;
+    int   vtxNdof = -999;
+    float vtxdEta = -999;
+    float vtxdPhi = -999;
+
+    if( caloCluster && caloCluster->pt() > m_minET ){
+      const xAOD::TrackParticle* trk1 = nullptr;
+      const xAOD::TrackParticle* trk2 = nullptr;
+      int trkIndex1 = -999;
+      int trkIndex2 = -999;
+      for( unsigned int i(0); i < el->nTrackParticles(); ++i ){
+        auto trackParticle = el->trackParticle( i );
+        if( nSiHits(trackParticle) >= 7 ) {
+          if ( trk1 == nullptr ){
+            trk1 = trackParticle;
+            trkIndex1 = i;
+          } else if( trk2 == nullptr ){
+            if( trk1->charge() == trackParticle->charge() )
+              continue;
+            trk2 = trackParticle;
+            trkIndex2 = i;
+            break;
+          }
+        }
+      }
+      if( trk2 != nullptr){
+        // fit vertex
+
+        // Take the initial guess as the first tracks global position
+        const Trk::Perigee&  perigeeParameters = trk1->perigeeParameters();
+        Amg::Vector3D  startingPoint = perigeeParameters.position();
+
+        std::vector<const xAOD::TrackParticle*> trksToFit;
+        trksToFit.push_back( trk1 );
+        trksToFit.push_back( trk2 );
+        vtxTrkParticleIndex1 = trkIndex1;
+        vtxTrkParticleIndex2 = trkIndex2;
+
+        xAOD::Vertex* myVertex = m_VertexFitter->fit( trksToFit, startingPoint );
+
+        if(myVertex){
+
+          vtxR    = m_V0Tools->rxy( myVertex );
+          vtxRerr = m_V0Tools->rxyError( myVertex );
+          vtxZ    = myVertex->z();
+          vtxZerr = sqrt( myVertex->covariancePosition()(2,2) );
+
+          std::vector<double> masses = { 0.511e-3, 0.511e-3 };
+          vtxM    = m_V0Tools->invariantMass( myVertex, masses);
+          vtxMerr = m_V0Tools->invariantMassError( myVertex, masses);
+
+          vtxChi2 = myVertex->chiSquared();
+          vtxNdof = myVertex->numberDoF();
+
+          m_emExtrapolationTool->getEtaPhiAtCalo( myVertex, &vtxdEta, &vtxdPhi);
+          
+          vtxdPhi  = P4Helpers::deltaPhi( vtxdPhi, caloCluster->phiBE(2) ); 
+          vtxdEta -= caloCluster->etaBE(2);
+        } else {
+          vtxChi2 = 0;
+          vtxNdof = 0;
+        }
+      }
+    }
+    el->auxdecor<float>("vtxR")    = vtxR;
+    el->auxdecor<float>("vtxRerr") = vtxRerr;
+    el->auxdecor<float>("vtxZ")    = vtxZ;
+    el->auxdecor<float>("vtxZerr") = vtxZerr;
+    el->auxdecor<float>("vtxM")    = vtxM;
+    el->auxdecor<float>("vtxMerr") = vtxMerr;
+    el->auxdecor<int>("vtxTrkParticleIndex1") = vtxTrkParticleIndex1;
+    el->auxdecor<int>("vtxTrkParticleIndex2") = vtxTrkParticleIndex2;
+    el->auxdecor<float>("vtxChi2") = vtxChi2;
+    el->auxdecor<int>("vtxNdof")   = vtxNdof;
+    el->auxdecor<float>("vtxdEta") = vtxdEta;
+    el->auxdecor<float>("vtxdPhi") = vtxdPhi;
+  }
+
+
+
+
 } // namespace