From 52df7318776291db5c95772121bae5e50913043a Mon Sep 17 00:00:00 2001
From: adbailey <adam.bailey@cern.ch>
Date: Fri, 29 Jun 2018 14:47:06 +0200
Subject: [PATCH] Added read handle to MvaTESVariableDecorator

Former-commit-id: 665fe8b82f33627cf37fb8b497b80d72dc80b157
---
 .../tauRec/python/TauAlgorithmsHolder.py      |  3 +-
 Reconstruction/tauRec/python/TauRecBuilder.py | 39 ++++++++++++++++---
 .../Root/MvaTESVariableDecorator.cxx          | 25 ++++++++----
 .../tauRecTools/MvaTESVariableDecorator.h     |  4 +-
 4 files changed, 57 insertions(+), 14 deletions(-)

diff --git a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
index 084637ecc057..1784b376ab10 100644
--- a/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
+++ b/Reconstruction/tauRec/python/TauAlgorithmsHolder.py
@@ -736,7 +736,8 @@ def getTauGenericPi0Cone():
 def getMvaTESVariableDecorator():
     _name = sPrefix + 'MvaTESVariableDecorator'
     from tauRecTools.tauRecToolsConf import MvaTESVariableDecorator
-    MvaTESVariableDecorator = MvaTESVariableDecorator(name = _name)
+    MvaTESVariableDecorator = MvaTESVariableDecorator(name = _name,
+                                                      Key_vertexInputContainer=_DefaultVertexContainer)
     cached_instances[_name] = MvaTESVariableDecorator
     return MvaTESVariableDecorator
 
diff --git a/Reconstruction/tauRec/python/TauRecBuilder.py b/Reconstruction/tauRec/python/TauRecBuilder.py
index bb06aade2996..1e32b19ba574 100644
--- a/Reconstruction/tauRec/python/TauRecBuilder.py
+++ b/Reconstruction/tauRec/python/TauRecBuilder.py
@@ -156,10 +156,41 @@ class TauRecCoreBuilder ( TauRecConfigured ) :
 
             if self.doPi0Clus: 
                 tools.append(taualgs.getPi0ClusterScaler())
-                # tools.append(taualgs.getPi0ScoreCalculator())
+                tools.append(taualgs.getPi0ScoreCalculator())
                 # SWITCHED OFF SELECTOR< SINCE NO CHARGED PFOS AVAILABLE ATM
-                # tools.append(taualgs.getPi0Selector())
+                tools.append(taualgs.getPi0Selector())
+
+            tools.append(taualgs.getEnergyCalibrationLC(correctEnergy=False, correctAxis=True, postfix='_onlyAxis'))
 
+            # PanTau:
+            # if tauFlags.doPanTau() :
+            # import PanTauAlgs.JobOptions_Main_PanTau as pantau
+            # tools.append(pantau.getPanTau())
+ 
+            # these tools need pantau info
+            tools.append(taualgs.getCombinedP4FromRecoTaus())
+            tools.append(taualgs.getMvaTESVariableDecorator())
+            # tools.append(taualgs.getMvaTESEvaluator())
+
+            # if tauFlags.doRunTauDiscriminant():
+               # tools.append(taualgs.getTauIDVarCalculator())
+               # tools.append(taualgs.getTauJetBDTEvaluator("TauJetBDT1P", weightsFile="vars2016_pt_gamma_1p_isofix.root", minNTracks=0, maxNTracks=1)) #update config?
+               # tools.append(taualgs.getTauJetBDTEvaluator("TauJetBDT3P", weightsFile="vars2016_pt_gamma_3p_isofix.root", minNTracks=2, maxNTracks=1000)) #update config?
+               # tools.append(taualgs.getTauWPDecoratorJetBDT())
+               # tools.append(taualgs.getTauJetBDTEvaluator("TauEleBDT_def", weightsFile="", outputVarName="BDTEleScore"))#just inits values
+               # tools.append(taualgs.getTauJetBDTEvaluator("TauEleBDT_bar", 
+                                                           # weightsFile="EleBDT1PBar.root", minNTracks=1, maxAbsTrackEta=1.37, 
+                                                           # outputVarName="BDTEleScore")) #update config?
+                # tools.append(taualgs.getTauJetBDTEvaluator("TauEleBDT_end1", 
+                                                           # weightsFile="EleBDT1PEnd1.root", minNTracks=1, minAbsTrackEta=1.37, 
+                                                           # maxAbsTrackEta=2.0, outputVarName="BDTEleScore")) #update config?
+                # tools.append(taualgs.getTauJetBDTEvaluator("TauEleBDT_end23", 
+                                                           # weightsFile="EleBDT1PEnd23.root", minNTracks=1, minAbsTrackEta=2.0, 
+                                                           # maxAbsTrackEta=3.0, outputVarName="BDTEleScore")) #update config?
+                # tools.append(taualgs.getTauWPDecoratorEleBDT())
+                # tools.append(taualgs.getTauEleOLRDecorator())
+                
+            
             ################################
 
             from tauRec.tauRecFlags import tauFlags
@@ -314,9 +345,7 @@ class TauRecVariablesProcessor ( TauRecConfigured ) :
             if tauFlags.doPanTau() :
                 import PanTauAlgs.JobOptions_Main_PanTau as pantau
                 tools.append(pantau.getPanTau())
-                pass
-
-
+            
             #these tools need pantau info
             tools.append(taualgs.getCombinedP4FromRecoTaus())
             tools.append(taualgs.getMvaTESVariableDecorator())
diff --git a/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx b/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx
index ce7dbacbf60a..eb6ff9a67b7b 100644
--- a/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx
+++ b/Reconstruction/tauRecTools/Root/MvaTESVariableDecorator.cxx
@@ -23,6 +23,11 @@ MvaTESVariableDecorator::~MvaTESVariableDecorator()
 {
 }
 
+StatusCode MvaTESVariableDecorator::initialize(){
+  ATH_CHECK( m_vertexInputContainer.initialize() );
+  return StatusCode::SUCCESS;
+}
+
 //_____________________________________________________________________________
 StatusCode MvaTESVariableDecorator::eventInitialize()
 {
@@ -30,18 +35,24 @@ StatusCode MvaTESVariableDecorator::eventInitialize()
   m_mu = m_xEventInfo->averageInteractionsPerCrossing();
 
   m_nVtxPU = 0;
-  if(evtStore()->contains<xAOD::VertexContainer>("PrimaryVertices")){
-    ATH_CHECK(evtStore()->retrieve(m_xVertexContainer, "PrimaryVertices"));  
-    for (auto xVertex : *m_xVertexContainer)
-    if (xVertex->vertexType() == xAOD::VxType::PileUp)
-      m_nVtxPU++;
-  }
-  else {
+  // Get the primary vertex container from StoreGate
+  SG::ReadHandle<xAOD::VertexContainer> vertexInHandle( m_vertexInputContainer );
+  if (!vertexInHandle.isValid()) {
+    ATH_MSG_ERROR ("Could not retrieve HiveDataObj with key " << vertexInHandle.key());
     if(m_emitVertexWarning) {
       ATH_MSG_WARNING("No xAOD::VertexContainer, setting nVtxPU to 0");
       m_emitVertexWarning=false;
     }
     m_nVtxPU=0;
+    // return StatusCode::FAILURE;
+  }
+  else{
+    m_xVertexContainer = vertexInHandle.cptr();
+    ATH_MSG_VERBOSE("  read: " << vertexInHandle.key() << " = " << "..." );
+    for (auto xVertex : *m_xVertexContainer){
+      if (xVertex->vertexType() == xAOD::VxType::PileUp)
+	m_nVtxPU++;
+    }
   }
 
   return StatusCode::SUCCESS;
diff --git a/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h b/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h
index eee755bd3754..77e9dd63c60f 100644
--- a/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h
+++ b/Reconstruction/tauRecTools/tauRecTools/MvaTESVariableDecorator.h
@@ -21,6 +21,7 @@ class MvaTESVariableDecorator
   MvaTESVariableDecorator(const std::string& name="MvaTESVariableDecorator");
   virtual ~MvaTESVariableDecorator();
     
+  StatusCode initialize();
   StatusCode eventInitialize();
   StatusCode execute(xAOD::TauJet& xTau);
   StatusCode executeCaloClus(xAOD::TauJet&, xAOD::CaloClusterContainer&) { return StatusCode::SUCCESS; }
@@ -32,7 +33,8 @@ class MvaTESVariableDecorator
   int m_mu; //!
   int m_nVtxPU; //!
   bool m_emitVertexWarning=true; //!
-  
+
+  SG::ReadHandleKey<xAOD::VertexContainer> m_vertexInputContainer{this,"Key_vertexInputContainer", "PrimaryVertices", "input vertex container key"};
 };
 
 
-- 
GitLab