From 4d5f9432685437ebb83f7ea90c7dbd001f0c9be2 Mon Sep 17 00:00:00 2001
From: Tomasz Bold <tomasz.bold@gmail.com>
Date: Tue, 21 Jul 2020 11:57:27 +0100
Subject: [PATCH] TauShoot tool made const

---
 .../tauRecTools/Root/TauRecToolBase.cxx       |  2 +-
 .../tauRecTools/src/TauShotFinder.cxx         | 16 +++++++-------
 .../tauRecTools/src/TauShotFinder.h           | 12 +++++-----
 .../src/TauShotVariableHelpers.cxx            | 22 +++++++++----------
 .../tauRecTools/src/TauShotVariableHelpers.h  | 20 ++++++++---------
 .../tauRecTools/tauRecTools/ITauToolBase.h    |  4 ++--
 .../tauRecTools/tauRecTools/TauRecToolBase.h  |  2 +-
 7 files changed, 39 insertions(+), 39 deletions(-)

diff --git a/Reconstruction/tauRecTools/Root/TauRecToolBase.cxx b/Reconstruction/tauRecTools/Root/TauRecToolBase.cxx
index 576467c47f4..90cc2dd212c 100644
--- a/Reconstruction/tauRecTools/Root/TauRecToolBase.cxx
+++ b/Reconstruction/tauRecTools/Root/TauRecToolBase.cxx
@@ -174,7 +174,7 @@ StatusCode TauRecToolBase::executeRNNTrackClassifier(xAOD::TauJet&, xAOD::TauTra
   return StatusCode::FAILURE;
 }
 
-StatusCode TauRecToolBase::executeShotFinder(xAOD::TauJet& /*pTau*/, xAOD::CaloClusterContainer& /*shotClusterContainer*/, xAOD::PFOContainer& /*PFOContainer*/ ) {
+StatusCode TauRecToolBase::executeShotFinder(xAOD::TauJet& /*pTau*/, xAOD::CaloClusterContainer& /*shotClusterContainer*/, xAOD::PFOContainer& /*PFOContainer*/ ) const {
   ATH_MSG_ERROR("function not implemented");
   return StatusCode::FAILURE;
 }
diff --git a/Reconstruction/tauRecTools/src/TauShotFinder.cxx b/Reconstruction/tauRecTools/src/TauShotFinder.cxx
index a95a09b78ba..86bcd266035 100644
--- a/Reconstruction/tauRecTools/src/TauShotFinder.cxx
+++ b/Reconstruction/tauRecTools/src/TauShotFinder.cxx
@@ -61,7 +61,7 @@ StatusCode TauShotFinder::finalize()
 }
 
 StatusCode TauShotFinder::executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& tauShotClusterContainer,
-					    xAOD::PFOContainer& tauShotPFOContainer) {
+					    xAOD::PFOContainer& tauShotPFOContainer) const {
 
     ATH_MSG_DEBUG("execute");
     // Any tau needs to have shot PFO vectors. Set empty vectors before nTrack cut
@@ -103,7 +103,7 @@ StatusCode TauShotFinder::executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloCluste
         if( !( samp == CaloCell_ID::EMB1 || samp == CaloCell_ID::EME1 ) ) continue;
         cells.push_back(*cellItr);
     }
-    // sort cells in descending pt 
+    // sort cells in descending pt    
     std::sort(cells.begin(),cells.end(),ptSort(*this));
     
     //---------------------------------------------------------------------
@@ -268,8 +268,8 @@ StatusCode TauShotFinder::executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloCluste
 }
 
 std::vector<const CaloCell*> TauShotFinder::getNeighbours(const CaloCellContainer* pCellContainer, 
-                                           const CaloCell* cell, 
-                                           int maxDepth)
+							  const CaloCell* cell, 
+							  int maxDepth) const
 {
     std::vector<const CaloCell*> cells;
     this->addNeighbours(pCellContainer,cell,cells,0,maxDepth,true);  //next
@@ -282,7 +282,7 @@ void TauShotFinder::addNeighbours(const CaloCellContainer* pCellContainer,
                                   std::vector<const CaloCell*>& cells,
                                   int depth,
                                   int maxDepth,
-                                  bool next)
+                                  bool next) const
 {
     depth++; 
     if( depth > maxDepth ) return;
@@ -306,7 +306,7 @@ void TauShotFinder::addNeighbours(const CaloCellContainer* pCellContainer,
     } 
 }
 
-bool TauShotFinder::isPhiNeighbour(IdentifierHash cell1Hash, IdentifierHash cell2Hash, bool next){
+bool TauShotFinder::isPhiNeighbour(IdentifierHash cell1Hash, IdentifierHash cell2Hash, bool next) const{
     std::vector<IdentifierHash> neigHashes;
     if( next ) m_calo_id->get_neighbours(cell1Hash,LArNeighbours::nextInPhi,neigHashes);
     else       m_calo_id->get_neighbours(cell1Hash,LArNeighbours::prevInPhi,neigHashes);
@@ -317,7 +317,7 @@ bool TauShotFinder::isPhiNeighbour(IdentifierHash cell1Hash, IdentifierHash cell
     return false;
 }
 
-float TauShotFinder::getEtaBin(float seedEta){
+float TauShotFinder::getEtaBin(float seedEta) const {
     float absSeedEta=std::abs(seedEta);
     if(absSeedEta < 0.80)      return 0; // Central Barrel
     else if(absSeedEta<1.39) return 1; // Outer Barrel
@@ -326,7 +326,7 @@ float TauShotFinder::getEtaBin(float seedEta){
     else return 4;                           // endcap, coarse granularity
 }
 
-float TauShotFinder::getNPhotons(int etaBin, float seedEnergy) {
+float TauShotFinder::getNPhotons(int etaBin, float seedEnergy) const {
     // no photon counting in crack region, e.g. [1.39, 1.51]
     if(etaBin==2) return 0;
 
diff --git a/Reconstruction/tauRecTools/src/TauShotFinder.h b/Reconstruction/tauRecTools/src/TauShotFinder.h
index 3ad67adf06a..b0a70569b20 100644
--- a/Reconstruction/tauRecTools/src/TauShotFinder.h
+++ b/Reconstruction/tauRecTools/src/TauShotFinder.h
@@ -21,7 +21,7 @@ public:
     virtual ~TauShotFinder();
 
     virtual StatusCode initialize() override;
-    virtual StatusCode executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& tauShotCaloClusContainer, xAOD::PFOContainer& tauShotPFOContainer) override;
+    virtual StatusCode executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& tauShotCaloClusContainer, xAOD::PFOContainer& tauShotPFOContainer) const override;
     virtual StatusCode finalize() override;
 
 private:
@@ -42,23 +42,23 @@ private:
     };
 
     /** @brief get neighbour cells */
-    std::vector<const CaloCell*> getNeighbours(const CaloCellContainer*,const CaloCell*,int /*maxDepth*/);
+    std::vector<const CaloCell*> getNeighbours(const CaloCellContainer*,const CaloCell*,int /*maxDepth*/) const;
 
     void addNeighbours(const CaloCellContainer*,
                        const CaloCell* cell,
                        std::vector<const CaloCell*>& cells,
                        int depth,
                        int maxDepth,
-                       bool next);
+                       bool next) const;
 
-    bool isPhiNeighbour(IdentifierHash cell1Hash, IdentifierHash cell2Hash, bool next);
+    bool isPhiNeighbour(IdentifierHash cell1Hash, IdentifierHash cell2Hash, bool next) const;
 
     /** @brief get eta bin */
-    float getEtaBin(float /*seedEta*/);
+    float getEtaBin(float /*seedEta*/) const;
   
     /** @brief get NPhotons in shot */
     float getNPhotons(int /*etaBin*/, 
-                      float /*seedEnergy*/);
+                      float /*seedEnergy*/) const;
 
     // number of cells in eta
     Gaudi::Property<int> m_nCellsInEta {this, "NCellsInEta"};
diff --git a/Reconstruction/tauRecTools/src/TauShotVariableHelpers.cxx b/Reconstruction/tauRecTools/src/TauShotVariableHelpers.cxx
index f19902846e3..3b2ef8c1dc4 100644
--- a/Reconstruction/tauRecTools/src/TauShotVariableHelpers.cxx
+++ b/Reconstruction/tauRecTools/src/TauShotVariableHelpers.cxx
@@ -144,7 +144,7 @@ namespace TauShotVariableHelpers {
     }
 
 
-    float mean_eta(vector<vector<const CaloCell*> > shotCells, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float mean_eta(vector<vector<const CaloCell*> > shotCells, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         float sumEta=0.;
         float sumWeight=0.;
         vector<vector<const CaloCell*> >::iterator itrPhi = shotCells.begin();
@@ -160,7 +160,7 @@ namespace TauShotVariableHelpers {
         return sumEta/sumWeight;
     }
 
-    float mean_pt(vector<vector<const CaloCell*> > shotCells, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float mean_pt(vector<vector<const CaloCell*> > shotCells, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         float sumPt=0.;
         int nCells = 0;
         vector<vector<const CaloCell*> >::iterator itrPhi = shotCells.begin();
@@ -176,7 +176,7 @@ namespace TauShotVariableHelpers {
         return sumPt/nCells;
     }
 
-    float ptWindow(vector<vector<const CaloCell*> > shotCells, int windowSize, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float ptWindow(vector<vector<const CaloCell*> > shotCells, int windowSize, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         // window size should be odd and noti be larger than eta window of shotCells
         int nCells_eta = shotCells.at(0).size();
         int seedIndex = nCells_eta/2;
@@ -191,7 +191,7 @@ namespace TauShotVariableHelpers {
         return ptWindow;
     }
 
-    float ws5(vector<vector<const CaloCell*> > shotCells, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float ws5(vector<vector<const CaloCell*> > shotCells, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         int nCells_eta = shotCells.at(0).size();
         int seedIndex = nCells_eta/2;
         float sumWeight=0.;
@@ -208,7 +208,7 @@ namespace TauShotVariableHelpers {
         return sqrt( sumDev2 / sumWeight );
     }
 
-    float sdevEta_WRTmean(vector<vector<const CaloCell*> > shotCells, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float sdevEta_WRTmean(vector<vector<const CaloCell*> > shotCells, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         float mean = mean_eta(shotCells, caloWeightTool); 
         float sumWeight=0.;
         float sumDev2=0.;
@@ -225,7 +225,7 @@ namespace TauShotVariableHelpers {
         return sqrt( sumDev2 / sumWeight );
     }
 
-    float sdevEta_WRTmode(vector<vector<const CaloCell*> > shotCells, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float sdevEta_WRTmode(vector<vector<const CaloCell*> > shotCells, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         int nCells_eta = shotCells.at(0).size();
         int seedIndex = nCells_eta/2;
         float mode = shotCells.at(0).at(seedIndex)->eta();
@@ -244,7 +244,7 @@ namespace TauShotVariableHelpers {
         return sqrt( sumDev2 / sumWeight );
     }
 
-    float sdevPt(vector<vector<const CaloCell*> > shotCells, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float sdevPt(vector<vector<const CaloCell*> > shotCells, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         float mean = mean_pt(shotCells, caloWeightTool);
         float sumWeight=0.;
         float sumDev2=0.;
@@ -261,7 +261,7 @@ namespace TauShotVariableHelpers {
         return sqrt(sumDev2)/sumWeight;
     }
 
-    float deltaPt12_min(vector<vector<const CaloCell*> > shotCells, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float deltaPt12_min(vector<vector<const CaloCell*> > shotCells, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         int nCells_eta = shotCells.at(0).size();
         int seedIndex = nCells_eta/2;
         bool haveLeft  = false;
@@ -293,7 +293,7 @@ namespace TauShotVariableHelpers {
     }
 
 
-    float Fside(vector<vector<const CaloCell*> > shotCells, int largerWindow, int smallerWindow, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float Fside(vector<vector<const CaloCell*> > shotCells, int largerWindow, int smallerWindow, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         // window sizes should be odd and windows should be not larger than eta window of shotCells
         int nCells_eta = shotCells.at(0).size();
         int seedIndex = nCells_eta/2;
@@ -314,7 +314,7 @@ namespace TauShotVariableHelpers {
         return (pt_largerWindow-pt_smallerWindow)/pt_smallerWindow;
     }
 
-    float fracSide(vector<vector<const CaloCell*> > shotCells, int largerWindow, int smallerWindow, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float fracSide(vector<vector<const CaloCell*> > shotCells, int largerWindow, int smallerWindow, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         // window sizes should be odd and windows should be not larger than eta window of shotCells
         int nCells_eta = shotCells.at(0).size();
         int seedIndex = nCells_eta/2;
@@ -335,7 +335,7 @@ namespace TauShotVariableHelpers {
         return (pt_largerWindow-pt_smallerWindow)/pt_largerWindow;
     }
 
-    float ptWindowFrac(vector<vector<const CaloCell*> > shotCells, int largerWindow, int smallerWindow, ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
+    float ptWindowFrac(vector<vector<const CaloCell*> > shotCells, int largerWindow, int smallerWindow, const ToolHandle<IHadronicCalibrationTool>& caloWeightTool){
         // window sizes should be odd and windows should be not larger than eta window of shotCells
         int nCells_eta = shotCells.at(0).size();
         int seedIndex = nCells_eta/2;
diff --git a/Reconstruction/tauRecTools/src/TauShotVariableHelpers.h b/Reconstruction/tauRecTools/src/TauShotVariableHelpers.h
index 3b4919ed12e..fdc21ce85d0 100644
--- a/Reconstruction/tauRecTools/src/TauShotVariableHelpers.h
+++ b/Reconstruction/tauRecTools/src/TauShotVariableHelpers.h
@@ -25,42 +25,42 @@ namespace TauShotVariableHelpers {
 
     /** @brief mean eta, used by other functions */
     float mean_eta(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
-                   ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+                   const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief mean pt, used by other functions */ 
     float mean_pt(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
-                  ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+                  const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief pt in windows */
     float ptWindow(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
                    int /*windowSize*/, 
-                   ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+                   const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief ws5 variable (egamma) */
     float ws5(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
-                          ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+	      const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief standard deviation in eta WRT mean */
     float sdevEta_WRTmean(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
-                          ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+                          const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief standard deviation in eta WRT mode */
     float sdevEta_WRTmode(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
-                          ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+                          const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief normalized standard deviation in pt */
     float sdevPt(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
-                             ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+		 const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief pT diff b/w lead and sub-lead cell */
     float deltaPt12_min(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
-                        ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+                        const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief Fside variable (egamma) */
     float Fside(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
                 int /*largerWindow*/, 
                 int /*smallerWindow*/, 
-                ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+                const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 
     /** @brief similar than Fside but in unit of eta instead of number of cells */
     float fracSide(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
@@ -72,7 +72,7 @@ namespace TauShotVariableHelpers {
     float ptWindowFrac(std::vector<std::vector<const CaloCell*> > /*shotCells*/, 
                        int /*largerWindow*/, 
                        int /*smallerWindow*/, 
-                       ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
+                       const ToolHandle<IHadronicCalibrationTool>& /*caloWeightTool*/);
 }
 
 #endif // TAUSHOTVARIABLEHELPERS_H
diff --git a/Reconstruction/tauRecTools/tauRecTools/ITauToolBase.h b/Reconstruction/tauRecTools/tauRecTools/ITauToolBase.h
index 7eaf8a88137..d5f277423d6 100644
--- a/Reconstruction/tauRecTools/tauRecTools/ITauToolBase.h
+++ b/Reconstruction/tauRecTools/tauRecTools/ITauToolBase.h
@@ -54,9 +54,9 @@ class ITauToolBase : virtual public asg::IAsgTool
   virtual StatusCode executeTrackFinder(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackContainer, const xAOD::TrackParticleContainer* trackContainer = nullptr) const = 0;
   virtual StatusCode executeTrackClassifier(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackContainer) const = 0;
   virtual StatusCode executeRNNTrackClassifier(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackContainer) = 0;
-  virtual StatusCode executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& shotClusterContainer, xAOD::PFOContainer& PFOContainer ) = 0;
+  virtual StatusCode executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& shotClusterContainer, xAOD::PFOContainer& PFOContainer ) const = 0;
   virtual StatusCode executePi0ClusterCreator(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer, 
-					      xAOD::PFOContainer& hadronicPFOContainer, 
+  					      xAOD::PFOContainer& hadronicPFOContainer, 
 					      xAOD::CaloClusterContainer& caloClusterContainer, 
 					      const xAOD::CaloClusterContainer& pCaloClusterContainer ) = 0;
   virtual StatusCode executeVertexVariables(xAOD::TauJet& pTau, xAOD::VertexContainer& vertexContainer ) const = 0;  
diff --git a/Reconstruction/tauRecTools/tauRecTools/TauRecToolBase.h b/Reconstruction/tauRecTools/tauRecTools/TauRecToolBase.h
index 1498f49d9f2..855de21662e 100644
--- a/Reconstruction/tauRecTools/tauRecTools/TauRecToolBase.h
+++ b/Reconstruction/tauRecTools/tauRecTools/TauRecToolBase.h
@@ -51,7 +51,7 @@ class TauRecToolBase : public asg::AsgTool, virtual public ITauToolBase {
   virtual StatusCode executeTrackFinder(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackContainer, const xAOD::TrackParticleContainer* trackContainer = nullptr) const override;
   virtual StatusCode executeTrackClassifier(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackContainer) const override;
   virtual StatusCode executeRNNTrackClassifier(xAOD::TauJet& pTau, xAOD::TauTrackContainer& tauTrackContainer) override;
-  virtual StatusCode executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& shotClusterContainer, xAOD::PFOContainer& PFOContainer ) override;
+  virtual StatusCode executeShotFinder(xAOD::TauJet& pTau, xAOD::CaloClusterContainer& shotClusterContainer, xAOD::PFOContainer& PFOContainer ) const override;
   virtual StatusCode executePi0ClusterCreator(xAOD::TauJet& pTau, xAOD::PFOContainer& neutralPFOContainer, 
 					      xAOD::PFOContainer& hadronicPFOContainer, 
 					      xAOD::CaloClusterContainer& caloClusterContainer, 
-- 
GitLab