From 89aee06936565000c9456bffc75d67adc4e309e4 Mon Sep 17 00:00:00 2001
From: Bertrand Martin <martindl@cern.ch>
Date: Thu, 5 Nov 2020 16:57:23 +0100
Subject: [PATCH 1/2] tauRecTools: drop "TauEtaCalib" 4-momentum calibration

Hello,

This MR is dropping the "TauEtaCalib" 4-momentum calibration from the tau reconstruction.
This is a calo-only calibration which is almost identical to the "TauEnergyScale" calibration, except that a tiny correction is applied to the reconstructed calo-only eta to compensate for a tiny average bias (correction derived w.r.t. truth tau visible eta).
Given the poor calo-only angular resolution, an absolute eta correction of at most 0.005 on eta is irrelevant in terms of tau performance.
We could consider deploying an MVA regression at xAOD level to improve the angular resolution, so we don't need this intermediate momentum calibration in the reconstruction.
Benefit: there will be one less tool scheduled (we used to call this tool twice), and a bunch of floats are no longer saved in the xAOD.
In the few places where we were using the TauEtaCalib calibration, we are now using the TauEnergyScale calibration.

This MR affects a number of xAOD output variables, but the changes are very small and under control.
For instance, for our final MVA pt, the relative change in the average pt is ~2.5e-4.
The "TauEtaCalib" variables are now 0. Same for TauJetParameters::TESCalibConstant and TauJetParameters::TESOffset (not useful to keep).
The rest is noise.
```
Py:diff-root         INFO  [TauJetsAux.BDTJetScoreSigTrans]: 38 leaves differ
Py:diff-root         INFO  [TauJetsAux.RNNEleScore]: 2 leaves differ
Py:diff-root         INFO  [TauJetsAux.RNNEleScoreSigTrans]: 30 leaves differ
Py:diff-root         INFO  [TauJetsAux.RNNJetScore]: 3 leaves differ
Py:diff-root         INFO  [TauJetsAux.RNNJetScoreSigTrans]: 35 leaves differ
Py:diff-root         INFO  [TauJetsAux.TESCalibConstant]: 64 leaves differ
Py:diff-root         INFO  [TauJetsAux.eta]: 14 leaves differ
Py:diff-root         INFO  [TauJetsAux.etaFinalCalib]: 14 leaves differ
Py:diff-root         INFO  [TauJetsAux.etaPanTauCellBased]: 14 leaves differ
Py:diff-root         INFO  [TauJetsAux.etaTauEtaCalib]: 64 leaves differ
Py:diff-root         INFO  [TauJetsAux.mPanTauCellBased]: 8 leaves differ
Py:diff-root         INFO  [TauJetsAux.phiTauEtaCalib]: 64 leaves differ
Py:diff-root         INFO  [TauJetsAux.pt]: 63 leaves differ
Py:diff-root         INFO  [TauJetsAux.ptFinalCalib]: 63 leaves differ
Py:diff-root         INFO  [TauJetsAux.ptPanTauCellBased]: 14 leaves differ
Py:diff-root         INFO  [TauJetsAux.ptTauEtaCalib]: 64 leaves differ
Py:diff-root         INFO  [TauJetsAuxDyn.eta_combined]: 40 leaves differ
Py:diff-root         INFO  [TauJetsAuxDyn.m_combined]: 39 leaves differ
Py:diff-root         INFO  [TauJetsAuxDyn.pt_combined]: 63 leaves differ
```

I've minimally updated TrigTauAlgorithmsHolder.py. Further cleanup of deprecated TauCalibrateLC options could be done in TrigTauRecConfig.py and TrigTauRecConfigMT.py, but I would leave this to trigger experts.
Let me just mention the tool name should be unique to distinguish the "caloOnly=True" and "caloOnly=False" cases: currently, a first TauCalibrateLC tool will be configured, and then reused regardless of the caloOnly setting.
https://gitlab.cern.ch/atlas/athena/-/blob/master/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py#L113

Cheers,
Bertrand
---
 .../PanTauAlgs/Root/PanTauProcessor.cxx       |   4 +-
 .../tauRec/python/TauAlgorithmsHolder.py      |   2 -
 Reconstruction/tauRec/python/TauRecBuilder.py |   2 +-
 Reconstruction/tauRec/python/TauRecRunner.py  |   2 -
 .../Root/CombinedP4FromRecoTaus.cxx           |  10 +-
 .../tauRecTools/Root/TauCalibrateLC.cxx       | 164 +++++++-----------
 .../tauRecTools/tauRecTools/TauCalibrateLC.h  |   3 -
 .../python/TrigTauAlgorithmsHolder.py         |   7 +-
 8 files changed, 72 insertions(+), 122 deletions(-)

diff --git a/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx
index 4b2ea4de6ae6..60168c8a08b4 100644
--- a/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx
+++ b/Reconstruction/PanTau/PanTauAlgs/Root/PanTauProcessor.cxx
@@ -246,8 +246,8 @@ StatusCode      PanTau::PanTauProcessor::executePanTau(xAOD::TauJet& pTau, xAOD:
 
 
 void PanTau::PanTauProcessor::fillDefaultValuesToTau(xAOD::TauJet* tauJet) {
-    //default four momentum set to previous calibration state: TauEtaCalib
-    TLorentzVector defaultP4 = tauJet->p4(xAOD::TauJetParameters::TauEtaCalib);
+    //default four momentum set to previous calibration state: TauEnergyScale
+    TLorentzVector defaultP4 = tauJet->p4();
     tauJet->setP4(xAOD::TauJetParameters::PanTauCellBased, defaultP4.Pt(), defaultP4.Eta(), defaultP4.Phi(), defaultP4.M());
     
     //charged
diff --git a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
index 0868a8ec7684..4af9f47c078b 100644
--- a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
+++ b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
@@ -97,8 +97,6 @@ def getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix=''):
     from tauRecTools.tauRecToolsConf import TauCalibrateLC
     TauCalibrateLC = TauCalibrateLC(name = _name,
                                     calibrationFile = "TES_MC16a_prelim.root",
-                                    doEnergyCorrection = correctEnergy,
-                                    doAxisCorrection = correctAxis,
                                     doPtResponse = True,
                                     Key_vertexInputContainer = _DefaultVertexContainer 
                                     )
diff --git a/Reconstruction/tauRec/python/TauRecBuilder.py b/Reconstruction/tauRec/python/TauRecBuilder.py
index fc5db0cff396..babd167eec20 100644
--- a/Reconstruction/tauRec/python/TauRecBuilder.py
+++ b/Reconstruction/tauRec/python/TauRecBuilder.py
@@ -67,7 +67,7 @@ class TauRecCoreBuilder ( TauRecConfigured ) :
             if not doMVATrackClassification and doRNNTrackClassification:
                 tools.append(taualgs.getTauTrackRNNClassifier())
             if jobproperties.Beam.beamType()!="cosmics":
-                tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+                tools.append(taualgs.getEnergyCalibrationLC())
             
             tools.append(taualgs.getCellVariables())
             tools.append(taualgs.getElectronVetoVars())
diff --git a/Reconstruction/tauRec/python/TauRecRunner.py b/Reconstruction/tauRec/python/TauRecRunner.py
index f87386826433..e019d11f5865 100644
--- a/Reconstruction/tauRec/python/TauRecRunner.py
+++ b/Reconstruction/tauRec/python/TauRecRunner.py
@@ -56,8 +56,6 @@ class TauRecRunner ( TauRecRunConfigured ) :
         tools.append(taualgs.getTauCommonCalcVars())
         tools.append(taualgs.getTauSubstructure())
 
-        tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=False, correctAxis=True, postfix='_onlyAxis'))
-
         # PanTau:
         if tauFlags.doPanTau() :
             import PanTauAlgs.JobOptions_Main_PanTau as pantau
diff --git a/Reconstruction/tauRecTools/Root/CombinedP4FromRecoTaus.cxx b/Reconstruction/tauRecTools/Root/CombinedP4FromRecoTaus.cxx
index 557b5203d509..911af3962d57 100644
--- a/Reconstruction/tauRecTools/Root/CombinedP4FromRecoTaus.cxx
+++ b/Reconstruction/tauRecTools/Root/CombinedP4FromRecoTaus.cxx
@@ -110,7 +110,7 @@ StatusCode CombinedP4FromRecoTaus::initialize() {
 
 
 StatusCode CombinedP4FromRecoTaus::execute(xAOD::TauJet& tau) const {
-  TLorentzVector combinedP4(tau.p4(xAOD::TauJetParameters::TauEtaCalib));
+  TLorentzVector combinedP4(tau.p4(xAOD::TauJetParameters::TauEnergyScale));
   
   // used to store immediate results
   Variables variables;
@@ -162,10 +162,10 @@ bool CombinedP4FromRecoTaus::getUseCaloPtFlag(const xAOD::TauJet& tau) const {
   xAOD::TauJetParameters::DecayMode decayMode = getDecayMode(tau);  
   int decayModeIndex = getDecayModeIndex(decayMode);
 
-  int etaIndex = getEtaIndex(tau.etaTauEtaCalib());
+  int etaIndex = getEtaIndex(tau.etaTauEnergyScale());
   
-  double caloSigma = tau.ptTauEtaCalib() * getCaloResolution(tau.ptTauEtaCalib(), decayModeIndex, etaIndex);
-  double deltaEt = tau.ptFinalCalib() - tau.ptTauEtaCalib();
+  double caloSigma = tau.ptTauEnergyScale() * getCaloResolution(tau.ptTauEnergyScale(), decayModeIndex, etaIndex);
+  double deltaEt = tau.ptFinalCalib() - tau.ptTauEnergyScale();
   
   bool useCaloPt = false;
   
@@ -426,7 +426,7 @@ double CombinedP4FromRecoTaus::getCombinedEt(const double& caloEt,
 
 
 TLorentzVector CombinedP4FromRecoTaus::getCombinedP4(const xAOD::TauJet& tau, Variables& variables) const {
-  const TLorentzVector& caloP4 = tau.p4(xAOD::TauJetParameters::TauEtaCalib);
+  const TLorentzVector& caloP4 = tau.p4(xAOD::TauJetParameters::TauEnergyScale);
   const TLorentzVector& panTauP4 = tau.p4(xAOD::TauJetParameters::PanTauCellBased);
     
   ATH_MSG_DEBUG("Four momentum at calo TES, pt: " << caloP4.Pt() << " eta: " << caloP4.Eta() << 
diff --git a/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx b/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx
index 9bd524bbf030..69e753f80878 100644
--- a/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx
+++ b/Reconstruction/tauRecTools/Root/TauCalibrateLC.cxx
@@ -17,10 +17,7 @@
 TauCalibrateLC::TauCalibrateLC(const std::string& name) :
   TauRecToolBase(name) {
   declareProperty("calibrationFile", m_calibrationFile = "");
-  declareProperty("doEnergyCorrection", m_doEnergyCorr = false);
   declareProperty("doPtResponse", m_doPtResponse = false);
-  declareProperty("doAxisCorrection", m_doAxisCorr = false);
-  declareProperty("usePantauAxis", m_usePantauAxis = false);
   declareProperty("isCaloOnly", m_isCaloOnly = false);
 }
 
@@ -94,7 +91,6 @@ StatusCode TauCalibrateLC::initialize() {
     m_calibFunc[i].resize(m_nEtaBins);
   }
 
-
   for (int i = 0; i < s_nProngBins; i++) {
     histo = dynamic_cast<TH1*>(file->Get(tmpSlopKey[i]));  // get pile-up slope histograms
     if (histo) {
@@ -137,119 +133,85 @@ StatusCode TauCalibrateLC::execute(xAOD::TauJet& pTau) const
   int prongBin = 1; //Mp
   if (pTau.nTracks() <= 1) prongBin = 0; //1p
 
-  // set tau energy scale 
-  if (m_doEnergyCorr) {
-
-    // get detector axis values
-    double absEta = std::abs( pTau.etaDetectorAxis() );
-    int etaBin = m_etaBinHist->GetXaxis()->FindBin(absEta) - 1;
+  // get detector axis values
+  double absEta = std::abs( pTau.etaDetectorAxis() );
+  int etaBin = m_etaBinHist->GetXaxis()->FindBin(absEta) - 1;
         
-    if (etaBin>=m_nEtaBins) etaBin = m_nEtaBins-1; // correction from last bin should be applied on all taus outside stored eta range
+  if (etaBin>=m_nEtaBins) etaBin = m_nEtaBins-1; // correction from last bin should be applied on all taus outside stored eta range
 
-    int nVertex = 0;
+  int nVertex = 0;
     
-    // Obtain pileup
-    if (inTrigger())  { // online: retrieved from EventInfo 
-      SG::ReadDecorHandle<xAOD::EventInfo, float> eventInfoDecorHandle( m_aveIntPerXKey );
-      if (!eventInfoDecorHandle.isPresent()) {
-        ATH_MSG_WARNING ( "EventInfo decoration not available! Will set nVertex = " << m_averageNPV );
-        nVertex = m_averageNPV;
-      }
-      else {
-        nVertex = eventInfoDecorHandle(0);
-        ATH_MSG_DEBUG("AvgInteractions object in tau candidate = " << nVertex);
-      } 
-    }  
-    else { // offline: count the primary vertex container
-      SG::ReadHandle<xAOD::VertexContainer> vertexInHandle( m_vertexInputContainer );
-      if (!vertexInHandle.isValid()) {
-        ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << vertexInHandle.key());
-        return StatusCode::FAILURE;
+  // Obtain pileup
+  if (inTrigger())  { // online: retrieved from EventInfo 
+    SG::ReadDecorHandle<xAOD::EventInfo, float> eventInfoDecorHandle( m_aveIntPerXKey );
+    if (!eventInfoDecorHandle.isPresent()) {
+      ATH_MSG_WARNING ( "EventInfo decoration not available! Will set nVertex = " << m_averageNPV );
+      nVertex = m_averageNPV;
+    }
+    else {
+      nVertex = eventInfoDecorHandle(0);
+      ATH_MSG_DEBUG("AvgInteractions object in tau candidate = " << nVertex);
+    } 
+  }  
+  else { // offline: count the primary vertex container
+    SG::ReadHandle<xAOD::VertexContainer> vertexInHandle( m_vertexInputContainer );
+    if (!vertexInHandle.isValid()) {
+      ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << vertexInHandle.key());
+      return StatusCode::FAILURE;
+    }
+    const xAOD::VertexContainer * vxContainer = vertexInHandle.cptr();
+    for (const auto vertex : *vxContainer) {
+      if (vertex->vertexType() == xAOD::VxType::PileUp) {
+	++nVertex;
       }
-      const xAOD::VertexContainer * vxContainer = vertexInHandle.cptr();
-      for (const auto vertex : *vxContainer) {
-        if (vertex->vertexType() == xAOD::VxType::PileUp) {
-          ++nVertex;
-        }
-      } 
-      ATH_MSG_DEBUG("calculated nVertex " << nVertex );           
     } 
+    ATH_MSG_DEBUG("calculated nVertex " << nVertex );           
+  } 
     
-    double calibConst = 1.0;
+  double calibConst = 1.0;
 
-    double slopeNPV = m_slopeNPVHist[prongBin]->GetBinContent(etaBin + 1);
-    double offset = slopeNPV * (nVertex - m_averageNPV);
+  double slopeNPV = m_slopeNPVHist[prongBin]->GetBinContent(etaBin + 1);
+  double offset = slopeNPV * (nVertex - m_averageNPV);
 
-    // energy response parameterized as a function of pileup-corrected E_LC
-    double energyLC = pTau.p4(xAOD::TauJetParameters::DetectorAxis).E() / GeV; 
-    if(m_doPtResponse) energyLC = pTau.ptDetectorAxis() / GeV;
+  // energy response parameterized as a function of pileup-corrected E_LC
+  double energyLC = pTau.p4(xAOD::TauJetParameters::DetectorAxis).E() / GeV; 
+  if(m_doPtResponse) energyLC = pTau.ptDetectorAxis() / GeV;
 
-    if (energyLC <= 0) {
-      ATH_MSG_DEBUG("tau energy at LC scale is " << energyLC << "--> set energy=0.001");           
-      pTau.setP4(0.001, pTau.eta(), pTau.phi(), pTau.m());
-      return StatusCode::SUCCESS;
-    }
+  if (energyLC <= 0) {
+    ATH_MSG_DEBUG("tau energy at LC scale is " << energyLC << "--> set energy=0.001");           
+    pTau.setP4(0.001, pTau.eta(), pTau.phi(), pTau.m());
+    return StatusCode::SUCCESS;
+  }
 
-    if (energyLC - offset <= 0) {
-      ATH_MSG_DEBUG("after pile-up correction energy would be = " << energyLC - offset << " --> setting offset=0 now!");
-      offset = 0;
-    }
+  if (energyLC - offset <= 0) {
+    ATH_MSG_DEBUG("after pile-up correction energy would be = " << energyLC - offset << " --> setting offset=0 now!");
+    offset = 0;
+  }
       
-    // apply offset correction
-    double energyPileupCorr = energyLC - offset;
+  // apply offset correction
+  double energyPileupCorr = energyLC - offset;
       
-    if (energyPileupCorr > 0 and energyPileupCorr < 10000) // from 0 to 10 TeV
-      {
-	calibConst = m_calibFunc[prongBin][etaBin]->Eval(energyPileupCorr);
+  if (energyPileupCorr > 0 and energyPileupCorr < 10000) // from 0 to 10 TeV
+    {
+      calibConst = m_calibFunc[prongBin][etaBin]->Eval(energyPileupCorr);
 	  
-	if (calibConst <= 0) {
-	  ATH_MSG_DEBUG("calibration constant = " << calibConst);
-	  ATH_MSG_DEBUG("prongBin             = " << prongBin);
-	  ATH_MSG_DEBUG("etaBin               = " << etaBin);
-	  ATH_MSG_DEBUG("energyPileupCorr     = " << energyPileupCorr);
-	  ATH_MSG_DEBUG("energyLC             = " << energyLC);
-	  calibConst = 1.0;
-	}
+      if (calibConst <= 0) {
+	ATH_MSG_DEBUG("calibration constant = " << calibConst);
+	ATH_MSG_DEBUG("prongBin             = " << prongBin);
+	ATH_MSG_DEBUG("etaBin               = " << etaBin);
+	ATH_MSG_DEBUG("energyPileupCorr     = " << energyPileupCorr);
+	ATH_MSG_DEBUG("energyLC             = " << energyLC);
+	calibConst = 1.0;
       }
+    }
       
-    double energyFinal = energyPileupCorr / calibConst;
+  double energyFinal = energyPileupCorr / calibConst;
       
-    if (not m_doPtResponse) energyFinal /= std::cosh(pTau.eta()) ; 
-    pTau.setP4( energyFinal * GeV, pTau.eta(), pTau.phi(), pTau.m());
-
-    ATH_MSG_DEBUG("Energy at LC scale = " << energyLC << " pile-up offset " << offset << " calib. const. = " << calibConst << " final energy = " << energyFinal);
-
-    pTau.setP4(xAOD::TauJetParameters::TauEnergyScale, pTau.pt(), pTau.eta(), pTau.phi(), pTau.m());      
-    pTau.setDetail(xAOD::TauJetParameters::TESCalibConstant, static_cast<float>( calibConst ) );
-    pTau.setDetail(xAOD::TauJetParameters::TESOffset, static_cast<float>( offset * GeV ) );      
-
-  }
-    
-  // final tau axis
-  if (m_doAxisCorr) {
-
-    // get tau intermediate axis values
-    double eta = pTau.etaIntermediateAxis();
-    double absEta = std::abs(eta);
-    double etaCorr = eta;
-    
-    double phi = pTau.phiIntermediateAxis();
-    double phiCorr = phi;
-
-    // TauCalibrateLC should then only be called after Pantau !!
-    if(m_usePantauAxis && std::abs(pTau.etaPanTauCellBased()) < 111) {      
-      etaCorr = pTau.etaPanTauCellBased();
-      phiCorr = pTau.phiPanTauCellBased();      
-    }
-    else if (absEta) {
-      etaCorr = (eta / absEta)*(absEta - m_etaCorrectionHist->GetBinContent(m_etaCorrectionHist->GetXaxis()->FindBin(absEta)));
-    }      
-
-    ATH_MSG_DEBUG("eta " << eta << "; corrected eta = " << etaCorr << " ; phi " << phi << "; corrected phi " << phiCorr );
-    pTau.setP4( pTau.e() / std::cosh( etaCorr ), etaCorr, phiCorr, pTau.m());
-    pTau.setP4(xAOD::TauJetParameters::TauEtaCalib, pTau.pt(), pTau.eta(), pTau.phi(), pTau.m());
-  }
-
+  if (not m_doPtResponse) energyFinal /= std::cosh(pTau.eta()) ; 
+  pTau.setP4( energyFinal * GeV, pTau.eta(), pTau.phi(), pTau.m());
+  pTau.setP4(xAOD::TauJetParameters::TauEnergyScale, pTau.pt(), pTau.eta(), pTau.phi(), pTau.m());
+  ATH_MSG_DEBUG("Energy at LC scale = " << energyLC << " pile-up offset " << offset << " calib. const. = " << calibConst << " final energy = " << energyFinal);
+     
   if (m_isCaloOnly == true && inTrigger()) {
     pTau.setP4(xAOD::TauJetParameters::TrigCaloOnly, pTau.pt(), pTau.eta(), pTau.phi(), pTau.m());
   }
diff --git a/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h b/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h
index 4b3b441498dd..7e9dc8941152 100644
--- a/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h
+++ b/Reconstruction/tauRecTools/tauRecTools/TauCalibrateLC.h
@@ -49,10 +49,7 @@ class TauCalibrateLC : public TauRecToolBase {
     double m_averageNPV=0;
 
     std::string m_calibrationFile; //!< energy calibration file
-    bool m_doEnergyCorr; //!< switch for energy correction
     bool m_doPtResponse; //!< switch for pt response vs pt, if false, use E response vs E
-    bool m_doAxisCorr;   //!< switch for eta correction
-    bool m_usePantauAxis; //!< switch for overwriting calo (eta,phi) with Pantau (eta,phi) 
     bool m_isCaloOnly;   //!< switch for CaloOnly corrections
 
     SG::ReadDecorHandleKey<xAOD::EventInfo> m_aveIntPerXKey {this, 
diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
index 551d1853df18..2460dbb5062e 100644
--- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
+++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
@@ -117,18 +117,13 @@ def getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='', ca
     if _name in cached_instances:
         return cached_instances[_name]
 
-
-##    calibFileName = "TES2015_LC_online.root"
     calibFileName = "TES2016_LC_online.root"
     if caloOnly:
-##        calibFileName = "TES2015_LC_online.root"
         calibFileName = "TES2016_LC_online_inc.root"
     
     from tauRecTools.tauRecToolsConf import TauCalibrateLC
     TauCalibrateLC = TauCalibrateLC(name = _name,
-                                    calibrationFile = calibFileName,
-                                    doEnergyCorrection = correctEnergy,
-                                    doAxisCorrection = correctAxis)
+                                    calibrationFile = calibFileName)
 
     TauCalibrateLC.isCaloOnly = caloOnly
     #Need to empty the vertex key collection in the trigger case
-- 
GitLab


From 0c94018ae67248578bb96f9b6386991b35cfda9f Mon Sep 17 00:00:00 2001
From: Bertrand Martin <martindl@cern.ch>
Date: Thu, 5 Nov 2020 18:57:46 +0100
Subject: [PATCH 2/2] clean up deprecated options in trigger config

---
 .../python/TrigTauAlgorithmsHolder.py         |  6 +++---
 .../TrigTauRec/python/TrigTauRecConfig.py     | 19 ++++++++++---------
 .../TrigTauRec/python/TrigTauRecConfigMT.py   | 12 ++++++------
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
index 2460dbb5062e..b695a47bdc19 100644
--- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
+++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauAlgorithmsHolder.py
@@ -110,9 +110,9 @@ def getTauAxis():
 
 ########################################################################
 # Tau energy calibration
-def getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='', caloOnly=False):
+def getEnergyCalibrationLC(caloOnly=False):
  
-    _name = sPrefix +'EnergyCalibrationLC' + postfix
+    _name = sPrefix +'EnergyCalibrationLC'
     
     if _name in cached_instances:
         return cached_instances[_name]
@@ -128,7 +128,7 @@ def getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='', ca
     TauCalibrateLC.isCaloOnly = caloOnly
     #Need to empty the vertex key collection in the trigger case
     TauCalibrateLC.Key_vertexInputContainer = ""
-            
+
     cached_instances[_name] = TauCalibrateLC                
     return TauCalibrateLC
 
diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfig.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfig.py
index 8585bf1ba90a..4298178c4226 100644
--- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfig.py
+++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfig.py
@@ -34,7 +34,7 @@ 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.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
             tools.append(taualgs.getCellVariables(cellConeSize=0.4))
             
             #tools.append(taualgs.getElectronVetoVars())  #needed?
@@ -90,7 +90,7 @@ 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.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
 
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))  #cellConeSize 0.2!!
 
@@ -98,7 +98,8 @@ class TrigTauRecMerged_Tau2012 (TrigTauRecMerged) :
             tools.append(taualgs.getTauVertexVariables())
             tools.append(taualgs.getTauCommonCalcVars())
             tools.append(taualgs.getTauSubstructure())
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=False, correctAxis=True, postfix='_onlyAxis'))
+            # deprecated
+            #tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=False, correctAxis=True, postfix='_onlyAxis'))
             
             for tool in tools:
                 tool.inTrigger = True
@@ -143,7 +144,7 @@ class TrigTauRecMerged_TauPreselection (TrigTauRecMerged) :
             # 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))
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
             # tools.append(taualgs.getElectronVetoVars())
@@ -205,7 +206,7 @@ class TrigTauRecMerged_TauFTK (TrigTauRecMerged) :
             # Insert bypass later?
             tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=2, noSelector = False))
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
             # tools.append(taualgs.getElectronVetoVars())
@@ -260,7 +261,7 @@ class TrigTauRecMerged_TauCaloOnly (TrigTauRecMerged) :
             # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
             tools.append(taualgs.getTauAxis())
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy', caloOnly=True))
+            tools.append(taualgs.getEnergyCalibrationLC(caloOnly=True))
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
 
@@ -304,7 +305,7 @@ class TrigTauRecMerged_TauCaloOnlyMVA (TrigTauRecMerged) :
             # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
             tools.append(taualgs.getTauAxis())
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy', caloOnly=True))
+            tools.append(taualgs.getEnergyCalibrationLC(caloOnly=True))
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
             # Compute MVA TES (ATR-17649), stores MVA TES as default tau pt()
@@ -356,7 +357,7 @@ class TrigTauRecMerged_TauPrecision (TrigTauRecMerged) :
             # 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))
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
             # tools.append(taualgs.getElectronVetoVars())
@@ -440,7 +441,7 @@ class TrigTauRecMerged_TauPrecisionMVA (TrigTauRecMerged) :
                 tools.append(taualgs.getTauTrackFinder(applyZ0cut=True, maxDeltaZ0=0.75, prefix='TrigTauTightDZ_'))            
 
             # Calibrate to calo TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
 
             if doMVATES:
                 # Compute MVA TES (ATR-17649), stores MVA TES as default tau pt()
diff --git a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py
index be60ad27e4a2..3eba0a9e3e0f 100644
--- a/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py
+++ b/Trigger/TrigAlgorithms/TrigTauRec/python/TrigTauRecConfigMT.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 from TrigTauRec.TrigTauRecConf import TrigTauRecMergedMT
 from TrigTauRec.TrigTauRecMonitoring import tauMonitoringCaloOnly
@@ -23,7 +23,7 @@ class TrigTauRecMerged_TauCaloOnly (TrigTauRecMergedMT) :
             # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
             tools.append(taualgs.getTauAxis())
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy', caloOnly=True))
+            tools.append(taualgs.getEnergyCalibrationLC(caloOnly=True))
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
 
@@ -56,7 +56,7 @@ class TrigTauRecMerged_TauCaloOnlyMVA (TrigTauRecMergedMT) :
             # Set LC energy scale (0.2 cone) and intermediate axis (corrected for vertex: useless at trigger)
             tools.append(taualgs.getTauAxis())
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy', caloOnly=True))
+            tools.append(taualgs.getEnergyCalibrationLC(caloOnly=True))
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
             # Compute MVA TES (ATR-17649), stores MVA TES as default tau pt()
@@ -95,7 +95,7 @@ class TrigTauRecMerged_TauPreselection (TrigTauRecMergedMT) :
             # 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))
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
             # Variables combining tracking and calorimeter information
@@ -138,7 +138,7 @@ class TrigTauRecMerged_TauPrecision (TrigTauRecMergedMT) :
             # 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))
             # Calibrate to TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
             # Calculate cell-based quantities: strip variables, EM and Had energies/radii, centFrac, isolFrac and ring energies
             tools.append(taualgs.getCellVariables(cellConeSize=0.2))
             # Lifetime variables
@@ -207,7 +207,7 @@ class TrigTauRecMerged_TauPrecisionMVA (TrigTauRecMergedMT) :
                 tools.append(taualgs.getTauTrackClassifier())
 
             # Calibrate to calo TES
-            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=True, correctAxis=False, postfix='_onlyEnergy'))
+            tools.append(taualgs.getEnergyCalibrationLC())
 
             if doMVATES:
                 # Compute MVA TES (ATR-17649), stores MVA TES as default tau pt()
-- 
GitLab