From c8bbeb26ee09a6b07e7bc31ea90a6809f5974fea Mon Sep 17 00:00:00 2001
From: Christos Anastopoulos <christos.anastopoulos@cern.ch>
Date: Mon, 10 Jul 2023 21:28:54 +0200
Subject: [PATCH] TrigEgammaFastElectronReAlgo keep only the faster default

TrigEgammaFastElectronReAlgo keep only the faster default
---
 .../python/TrigEgammaFastElectronConfig.py    |  1 -
 .../src/TrigEgammaFastElectronReAlgo.cxx      | 92 ++++++-------------
 .../src/TrigEgammaFastElectronReAlgo.h        |  4 -
 .../HLT/Egamma/TrigEgammaConfigFlags.py       |  3 -
 4 files changed, 28 insertions(+), 72 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigEgammaRec/python/TrigEgammaFastElectronConfig.py b/Trigger/TrigAlgorithms/TrigEgammaRec/python/TrigEgammaFastElectronConfig.py
index e20ac2199173..04f9a49ba2a2 100644
--- a/Trigger/TrigAlgorithms/TrigEgammaRec/python/TrigEgammaFastElectronConfig.py
+++ b/Trigger/TrigAlgorithms/TrigEgammaRec/python/TrigEgammaFastElectronConfig.py
@@ -28,7 +28,6 @@ def fastElectronFexAlgCfg(flags, name="EgammaFastElectronFex_1", rois="EMRoIs"):
                                          CaloTrackdEoverPHigh=999.0,
                                          RCalBarrelFace=1470.0*mm,
                                          ZCalEndcapFace=3800.0*mm,
-                                         useCaloInfoInExtrap=flags.Trigger.egamma.useCaloInfoInExtrap,
                                          ParticleCaloExtensionTool=extTool,
                                          ElectronsName=recordable("HLT_FastElectrons"),
                                          RoIs=rois,
diff --git a/Trigger/TrigAlgorithms/TrigEgammaRec/src/TrigEgammaFastElectronReAlgo.cxx b/Trigger/TrigAlgorithms/TrigEgammaRec/src/TrigEgammaFastElectronReAlgo.cxx
index 811819261b00..d13d43e6aa93 100644
--- a/Trigger/TrigAlgorithms/TrigEgammaRec/src/TrigEgammaFastElectronReAlgo.cxx
+++ b/Trigger/TrigAlgorithms/TrigEgammaRec/src/TrigEgammaFastElectronReAlgo.cxx
@@ -290,74 +290,38 @@ bool TrigEgammaFastElectronReAlgo::extrapolate(
     const xAOD::TrigEMCluster* clus, const xAOD::TrackParticle* trk,
     double& etaAtCalo, double& phiAtCalo) const {
 
-  if (m_useCaloInfoInExtrap) {
-    // use the provided EM cluster to "guide" the extrapolation
-
-    // 1st figure which layer we  want to shoot at
-    // in this case we chose between EMB2 or EME2
-    // given the cluster.
-    std::vector<CaloSampling::CaloSample> samples;
-    if (clus->energy(CaloSampling::CaloSample::EME2) >
-        clus->energy(CaloSampling::CaloSample::EMB2)) {
-      samples.push_back(CaloSampling::CaloSample::EME2);
-    } else {
-      samples.push_back(CaloSampling::CaloSample::EMB2);
-    }
-
-    // create the surfaces we want to reach.
-    // Aka either a cylinder for EME2 or a disc for EMB2
-    std::vector<std::unique_ptr<Trk::Surface>> caloSurfaces =
-        m_caloExtensionTool->caloSurfacesFromLayers(samples, clus->eta(),
-                                                    caloDD);
+  // use the provided EM cluster to "guide" the extrapolation
+  // 1st figure which layer we  want to shoot at
+  // in this case we chose between EMB2 or EME2
+  // given the cluster.
+  std::vector<CaloSampling::CaloSample> samples;
+  if (clus->energy(CaloSampling::CaloSample::EME2) >
+      clus->energy(CaloSampling::CaloSample::EMB2)) {
+    samples.push_back(CaloSampling::CaloSample::EME2);
+  } else {
+    samples.push_back(CaloSampling::CaloSample::EMB2);
+  }
 
-    // And then try to reach them
-    const auto extension = m_caloExtensionTool->surfaceCaloExtension(
-        ctx, trk->perigeeParameters(), samples, caloSurfaces,
-        Trk::nonInteracting);
+  // create the surfaces we want to reach.
+  // Aka either a cylinder for EME2 or a disc for EMB2
+  std::vector<std::unique_ptr<Trk::Surface>> caloSurfaces =
+      m_caloExtensionTool->caloSurfacesFromLayers(samples, clus->eta(), caloDD);
 
-    if (extension.empty()) {
-      ATH_MSG_VERBOSE("extrapolator failed 1");
-      return false;
-    }
-    // We target exactly one EMB2 or EME2  (the vector has 1 entry if not empty)
-    etaAtCalo = extension[0].second->position().eta();
-    phiAtCalo = extension[0].second->position().phi();
+  // And then try to reach them
+  const auto extension = m_caloExtensionTool->surfaceCaloExtension(
+      ctx, trk->perigeeParameters(), samples, caloSurfaces,
+      Trk::nonInteracting);
 
-    ATH_MSG_VERBOSE("Hit sampling :" << extension.at(0).first << " at eta : "
-                                     << etaAtCalo << " at phi : " << phiAtCalo);
-  } else {
-    // Do the extrapolation to the full calo volume with
-    // navigation and possible material effects. Then just pick
-    // the intersection with the EMB2/EME2 sample
-    CaloExtensionHelpers::LayersToSelect layersToSelect;
-    layersToSelect.insert(CaloSampling::CaloSample::EMB2);
-    layersToSelect.insert(CaloSampling::CaloSample::EME2);
-    // extrapolate track using tool
-    // get calo extension
-    std::unique_ptr<Trk::CaloExtension> caloExtension =
-        m_caloExtensionTool->caloExtension(ctx, *trk);
-    if (!caloExtension || caloExtension->caloLayerIntersections().empty()) {
-      ATH_MSG_VERBOSE("extrapolator failed 1");
-      return false;
-    }
-    // extract eta/phi in EM2
-    CaloExtensionHelpers::EtaPhiPerLayerVector intersections;
-    CaloExtensionHelpers::midPointEtaPhiPerLayerVector(
-        *caloExtension, intersections, &layersToSelect);
-    if (intersections.empty()) {
-      ATH_MSG_VERBOSE("extrapolator failed 2");
-      return false;
-    }
-    // pick the correct sample in case of ambiguity
-    std::tuple<CaloSampling::CaloSample, double, double> etaPhiTuple =
-        intersections.front();
-    if (intersections.size() == 2)
-      if (clus->energy(CaloSampling::CaloSample::EME2) >
-          clus->energy(CaloSampling::CaloSample::EMB2))
-        etaPhiTuple = intersections.back();
-    etaAtCalo = std::get<1>(etaPhiTuple);
-    phiAtCalo = std::get<2>(etaPhiTuple);
+  if (extension.empty()) {
+    ATH_MSG_VERBOSE("extrapolator failed 1");
+    return false;
   }
+  // We target exactly one EMB2 or EME2  (the vector has 1 entry if not empty)
+  etaAtCalo = extension[0].second->position().eta();
+  phiAtCalo = extension[0].second->position().phi();
+
+  ATH_MSG_VERBOSE("Hit sampling :" << extension.at(0).first << " at eta : "
+                                   << etaAtCalo << " at phi : " << phiAtCalo);
 
   return true;
 }
diff --git a/Trigger/TrigAlgorithms/TrigEgammaRec/src/TrigEgammaFastElectronReAlgo.h b/Trigger/TrigAlgorithms/TrigEgammaRec/src/TrigEgammaFastElectronReAlgo.h
index 3e48c6ee3586..5e713b310aeb 100644
--- a/Trigger/TrigAlgorithms/TrigEgammaRec/src/TrigEgammaFastElectronReAlgo.h
+++ b/Trigger/TrigAlgorithms/TrigEgammaRec/src/TrigEgammaFastElectronReAlgo.h
@@ -90,10 +90,6 @@ class TrigEgammaFastElectronReAlgo : public AthReentrantAlgorithm  {
     Gaudi::Property<float> m_RCAL {this,  "RCalBarrelFace",  1470.0*Gaudi::Units::mm , "Radius of inner face of the barrel calorimeter"};
     Gaudi::Property<float> m_ZCAL {this,  "ZCalEndcapFace",     3800.0*Gaudi::Units::mm, "z of the inner face of endcap calorimeter"};
 
-    Gaudi::Property<bool> m_useCaloInfoInExtrap{
-        this, "useCaloInfoInExtrap", true,
-        "use knowledge of the cluster in extrapolation"};
-
     //
     ToolHandle<Trk::IParticleCaloExtensionTool> m_caloExtensionTool{
         this, "ParticleCaloExtensionTool",
diff --git a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Egamma/TrigEgammaConfigFlags.py b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Egamma/TrigEgammaConfigFlags.py
index 8e52421a9e47..6f72876dcb41 100644
--- a/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Egamma/TrigEgammaConfigFlags.py
+++ b/Trigger/TriggerCommon/TriggerMenuMT/python/HLT/Egamma/TrigEgammaConfigFlags.py
@@ -22,9 +22,6 @@ def createTrigEgammaConfigFlags():
     flags.addFlag('Trigger.egamma.Calib.precCaloMVAVersion'  , 'egammaMVACalib/online/v7')
     flags.addFlag('Trigger.egamma.Calib.precEgammaMVAVersion', 'egammaMVACalib/online/v7')
 
-    # calo info in extrap
-    flags.addFlag('Trigger.egamma.useCaloInfoInExtrap', True) #(is default now)
-
     return flags
 
 
-- 
GitLab