From 50372fc17c32287f4f0edc0abe72517c1b6770e6 Mon Sep 17 00:00:00 2001
From: Debo <debottam.bakshi.gupta@cern.ch>
Date: Mon, 30 Mar 2020 17:17:06 +0200
Subject: [PATCH 1/2] modifying precisionElectronHypo so it can explicitly pass
 event context

---
 .../ITrigEgammaPrecisionElectronHypoTool.h    |  6 ++---
 .../TrigEgammaPrecisionElectronHypoAlgMT.cxx  |  2 +-
 ...TrigEgammaPrecisionElectronHypoToolInc.cxx | 23 +++++++++++--------
 .../TrigEgammaPrecisionElectronHypoToolInc.h  |  7 +++---
 ...rigEgammaPrecisionElectronHypoToolMult.cxx |  4 ++--
 .../TrigEgammaPrecisionElectronHypoToolMult.h |  4 ++--
 6 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h b/Trigger/TrigHypothesis/TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h
index 4009eb2f8682..deced12f265f 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 #ifndef TRIGEGAMMAHYPO_ITRIGPRECISIONELECTRONHYPOTOOL_H
 #define TRIGEGAMMAHYPO_ITRIGPRECISIONELECTRONHYPOTOOL_H 1
@@ -44,13 +44,13 @@ class ITrigEgammaPrecisionElectronHypoTool
    * There will be many tools called often to perform this quick operation and we do not want to pay for polymorphism which we do not need to use.
    * Will actually see when N obj hypos will enter the scene
    **/
-  virtual StatusCode decide( std::vector<ElectronInfo>& input )  const = 0;
+  virtual StatusCode decide( std::vector<ElectronInfo>& input, const EventContext& ctx)  const = 0;
 
   /**
    * @brief Makes a decision for a single object
    * The decision needs to be returned
    **/ 
-  virtual bool decide( const ElectronInfo& i ) const = 0;
+  virtual bool decide( const ElectronInfo& i,const EventContext& ctx ) const = 0;
 
 
 
diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoAlgMT.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoAlgMT.cxx
index 6a1dc2d7e60f..8c90e35cbd80 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoAlgMT.cxx
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoAlgMT.cxx
@@ -95,7 +95,7 @@ StatusCode TrigEgammaPrecisionElectronHypoAlgMT::execute( const EventContext& co
 
    
   for ( auto& tool: m_hypoTools ) {
-    ATH_CHECK( tool->decide( toolInput ) );
+    ATH_CHECK( tool->decide( toolInput, context ) );
   }
  
   ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.cxx
index f3b753a92662..5f1a27f7bb59 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.cxx
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.cxx
@@ -16,7 +16,8 @@ TrigEgammaPrecisionElectronHypoToolInc::TrigEgammaPrecisionElectronHypoToolInc(
 		    const std::string& name, 
 		    const IInterface* parent ) 
   : base_class( type, name, parent ),
-    m_decisionId( HLT::Identifier::fromToolName( name ) ) {
+    m_decisionId( HLT::Identifier::fromToolName( name ) ) 
+   {
         declareProperty("ElectronLHSelector"        ,m_egammaElectronLHTool   );
     }
 
@@ -52,7 +53,7 @@ StatusCode TrigEgammaPrecisionElectronHypoToolInc::initialize()  {
 TrigEgammaPrecisionElectronHypoToolInc::~TrigEgammaPrecisionElectronHypoToolInc(){}
 
 
-bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& input ) const {
+bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& input,const EventContext& ctx) const {
 
   bool pass = false;
 
@@ -66,7 +67,7 @@ bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionE
   auto monitorIt    = Monitored::Group( m_monTool, 
 					       dEta, dPhi, 
                                                etaBin, monEta,
-					       monPhi,PassedCuts );
+					       monPhi,PassedCuts);
  // when leaving scope it will ship data to monTool
   PassedCuts = PassedCuts + 1; //got called (data in place)
 
@@ -85,6 +86,7 @@ bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionE
   // fill local variables for RoI reference position
   double etaRef = roiDescriptor->eta();
   double phiRef = roiDescriptor->phi();
+  ATH_MSG_DEBUG("etaRef: "<<etaRef);
   // correct phi the to right range ( probably not needed anymore )   
   if ( fabs( phiRef ) > M_PI ) phiRef -= 2*M_PI; // correct phi if outside range
 
@@ -92,8 +94,11 @@ bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionE
   auto pClus = input.electron->caloCluster();
   
   float absEta = fabs( pClus->eta() );
-  const int cutIndex = findCutIndex( absEta );
   
+  ATH_MSG_DEBUG("absEta: "<<absEta);
+
+  const int cutIndex = findCutIndex( absEta );
+  ATH_MSG_DEBUG("cutIndex: "<<cutIndex);  
 
   
   dEta =  pClus->eta() - etaRef;
@@ -141,12 +146,11 @@ bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionE
   PassedCuts = PassedCuts + 1; // ET_em
   
  
-// This is the last step. So pass is going to be the result of isEM
+// This is the last step. So pass is going to be the result of LH
   asg::AcceptData accept =  m_egammaElectronLHTool->accept(input.electron); 
   pass = (bool) accept;
 
-  std::bitset<32> isEMdecision = m_egammaElectronLHTool->accept(input.electron).getCutResultInvertedBitSet();
-  ATH_MSG_DEBUG("isEM Result bitset: " << isEMdecision);
+  ATH_MSG_DEBUG("AthenaLHSelectorTool: TAccept = " << pass);
 
 
   float Rhad1(0), Rhad(0), Reta(0), Rphi(0), e277(0), weta2c(0), //emax2(0), 
@@ -199,7 +203,6 @@ bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionE
   ATH_MSG_DEBUG( "  fracm  " << fracm ) ;
 
 
-
   if ( !pass ){
       ATH_MSG_DEBUG("REJECT Likelihood failed");
   } else {
@@ -223,10 +226,10 @@ int TrigEgammaPrecisionElectronHypoToolInc::findCutIndex( float eta ) const {
 }
 
 
-StatusCode TrigEgammaPrecisionElectronHypoToolInc::decide( std::vector<ElectronInfo>& input )  const {
+StatusCode TrigEgammaPrecisionElectronHypoToolInc::decide( std::vector<ElectronInfo>& input,const EventContext& ctx )  const {
   for ( auto& i: input ) {
     if ( passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
-      if ( decide( i ) ) {
+      if ( decide( i,ctx ) ) {
 	addDecisionID( m_decisionId, i.decision );
       }
     }
diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.h b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.h
index 59e4d3a56fa4..4dd4b9552886 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.h
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.h
@@ -17,7 +17,6 @@
 #include "PATCore/AcceptData.h"
 #include "EgammaAnalysisInterfaces/IAsgElectronLikelihoodTool.h"
 
-
 /**
  * @class Implementation of the precision selection for electrons
  * @brief 
@@ -32,9 +31,8 @@ class TrigEgammaPrecisionElectronHypoToolInc : public extends<AthAlgTool, ITrigE
   virtual ~TrigEgammaPrecisionElectronHypoToolInc();
   virtual StatusCode initialize() override;
 
-  virtual StatusCode decide( std::vector<ITrigEgammaPrecisionElectronHypoTool::ElectronInfo>& input )  const override;
-
-  virtual bool decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& i ) const override;
+  virtual StatusCode decide( std::vector<ITrigEgammaPrecisionElectronHypoTool::ElectronInfo>& input, const EventContext& ctx )  const override;
+  virtual bool decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& i, const EventContext& ctx  ) const override;
 
  private:
   HLT::Identifier m_decisionId;
@@ -48,6 +46,7 @@ class TrigEgammaPrecisionElectronHypoToolInc : public extends<AthAlgTool, ITrigE
   ToolHandle< GenericMonitoringTool > m_monTool { this, "MonTool", "", "Monitoring tool" };
   ToolHandle<IAsgElectronLikelihoodTool> m_egammaElectronLHTool;  
   int findCutIndex( float eta ) const;
+
 }; 
 
 #endif //> !TRIGEGAMMAHYPO_TRIGPRECISIONELECTRONPRECISIONHYPOTOOL_H
diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolMult.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolMult.cxx
index 554c5f8f6896..6bb22e720b5f 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolMult.cxx
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolMult.cxx
@@ -23,7 +23,7 @@ StatusCode TrigEgammaPrecisionElectronHypoToolMult::initialize() {
   return StatusCode::SUCCESS;
 }
 
-StatusCode TrigEgammaPrecisionElectronHypoToolMult::decide( std::vector<ITrigEgammaPrecisionElectronHypoTool::ElectronInfo>& input )  const {
+StatusCode TrigEgammaPrecisionElectronHypoToolMult::decide( std::vector<ITrigEgammaPrecisionElectronHypoTool::ElectronInfo>& input, const EventContext& ctx)  const {
   HLT::Index2DVec passingSelection( m_subTools.size() );
   ATH_MSG_DEBUG( "Applying selection of multiplicity " << m_subTools.size() );
 
@@ -32,7 +32,7 @@ StatusCode TrigEgammaPrecisionElectronHypoToolMult::decide( std::vector<ITrigEga
     size_t electronIndex{ 0 };
     for ( auto iIter =  input.begin(); iIter != input.end(); ++iIter, ++electronIndex ) {
       if ( passed( m_decisionId.numeric(), iIter->previousDecisionIDs ) ) {
-	if ( tool->decide( *iIter ) ) 
+	if ( tool->decide( *iIter,ctx) ) 
 	  passingSelection[ cutIndex ].push_back( electronIndex );
       }
     }
diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolMult.h b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolMult.h
index 005af9134ea5..ef35ffc4e2b3 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolMult.h
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolMult.h
@@ -29,9 +29,9 @@ class TrigEgammaPrecisionElectronHypoToolMult : public extends<AthAlgTool, ITrig
   virtual ~TrigEgammaPrecisionElectronHypoToolMult();
   virtual StatusCode initialize() override;
 
-  virtual StatusCode decide( std::vector<ITrigEgammaPrecisionElectronHypoTool::ElectronInfo>& input )  const override;
+  virtual StatusCode decide( std::vector<ITrigEgammaPrecisionElectronHypoTool::ElectronInfo>& input, const EventContext& ctx )  const override;
 
-  virtual bool decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& ) const override { 
+  virtual bool decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo&,const EventContext& ) const override { 
     REPORT_MESSAGE(MSG::ERROR) << "this method should never be called";
     return false;
   }
-- 
GitLab


From efa289fb6cdf7557641b035afd7fb7d907e622a2 Mon Sep 17 00:00:00 2001
From: Debo <debottam.bakshi.gupta@cern.ch>
Date: Mon, 30 Mar 2020 22:05:00 +0200
Subject: [PATCH 2/2] removing currently unused context to avoid warning

---
 .../TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h | 4 ++--
 .../src/TrigEgammaPrecisionElectronHypoToolInc.cxx            | 4 ++--
 .../src/TrigEgammaPrecisionElectronHypoToolInc.h              | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h b/Trigger/TrigHypothesis/TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h
index deced12f265f..4ccc848b6409 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/ITrigEgammaPrecisionElectronHypoTool.h
@@ -44,13 +44,13 @@ class ITrigEgammaPrecisionElectronHypoTool
    * There will be many tools called often to perform this quick operation and we do not want to pay for polymorphism which we do not need to use.
    * Will actually see when N obj hypos will enter the scene
    **/
-  virtual StatusCode decide( std::vector<ElectronInfo>& input, const EventContext& ctx)  const = 0;
+  virtual StatusCode decide( std::vector<ElectronInfo>& input, const EventContext& )  const = 0;
 
   /**
    * @brief Makes a decision for a single object
    * The decision needs to be returned
    **/ 
-  virtual bool decide( const ElectronInfo& i,const EventContext& ctx ) const = 0;
+  virtual bool decide( const ElectronInfo& i,const EventContext& ) const = 0;
 
 
 
diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.cxx b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.cxx
index 5f1a27f7bb59..783d566736e3 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.cxx
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.cxx
@@ -53,7 +53,7 @@ StatusCode TrigEgammaPrecisionElectronHypoToolInc::initialize()  {
 TrigEgammaPrecisionElectronHypoToolInc::~TrigEgammaPrecisionElectronHypoToolInc(){}
 
 
-bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& input,const EventContext& ctx) const {
+bool TrigEgammaPrecisionElectronHypoToolInc::decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& input,const EventContext& ) const {
 
   bool pass = false;
 
@@ -229,7 +229,7 @@ int TrigEgammaPrecisionElectronHypoToolInc::findCutIndex( float eta ) const {
 StatusCode TrigEgammaPrecisionElectronHypoToolInc::decide( std::vector<ElectronInfo>& input,const EventContext& ctx )  const {
   for ( auto& i: input ) {
     if ( passed ( m_decisionId.numeric(), i.previousDecisionIDs ) ) {
-      if ( decide( i,ctx ) ) {
+      if ( decide( i, ctx ) ) {
 	addDecisionID( m_decisionId, i.decision );
       }
     }
diff --git a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.h b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.h
index 4dd4b9552886..9050559e8474 100644
--- a/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.h
+++ b/Trigger/TrigHypothesis/TrigEgammaHypo/src/TrigEgammaPrecisionElectronHypoToolInc.h
@@ -31,8 +31,8 @@ class TrigEgammaPrecisionElectronHypoToolInc : public extends<AthAlgTool, ITrigE
   virtual ~TrigEgammaPrecisionElectronHypoToolInc();
   virtual StatusCode initialize() override;
 
-  virtual StatusCode decide( std::vector<ITrigEgammaPrecisionElectronHypoTool::ElectronInfo>& input, const EventContext& ctx )  const override;
-  virtual bool decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& i, const EventContext& ctx  ) const override;
+  virtual StatusCode decide( std::vector<ITrigEgammaPrecisionElectronHypoTool::ElectronInfo>& input, const EventContext& )  const override;
+  virtual bool decide( const ITrigEgammaPrecisionElectronHypoTool::ElectronInfo& i, const EventContext& ) const override;
 
  private:
   HLT::Identifier m_decisionId;
-- 
GitLab